ESB

Generating Code for the Defined Microservices

Generating Source Code

To generate the source code for the component defined, use the generate command as follows:

  • Windows

    1. Browse to %TEMPLATE_ENGINE% 

    2. Run templates-console.bat; a command prompt opens in directory pointed to %TEMPLATE_ENGINE%.

    3. Run the following command specifying the destination directory:

      generate.bat -dest c:\development\CustomServices
      

      GenerateCode.png
      Figure 1: Run templates-console.bat

      Run generate.bat without any arguments to see the help.


  • Linux

    1. Browse to %TEMPLATE_ENGINE% in Linux console

    2. Run the following command specifying the destination directory:

      generate.sh -dest c:\development\CustomServices
      


      usage

      run [-language <name>] [-setting <name>] -dest <directory>

      • -dest <directory> target directory where source files are Generated (same directory given while launching wizard)

      • -language <name>language (c, cpp, csharp, java, jca) in which source files are generated (default is java)

      • -setting <name> name of setting directory in etc folder


      • Run generate.sh without any arguments to see the help

        • Executing generate.sh command generates the sources under src directory specified in the directory specified against –dest argument. It also creates necessary files to build and deploy the components. Below are the common files that are created irrespective of language:

          • build.properties

          • build.xml

          • common.xml


Refer the Characteristics and Design Choices section for an overview of Synchronous and Asynchronous components. This section enables decision making of the best suited design.

Code for Asynchronous (EDBC) Component

To generate code for asynchronous component, use generate command. Though, by default, it assumes that the code is generated for the asynchronous component, to specify particularly  that the code generated should be for asynchronous component, use –language option with value java

generate.bat -dest C:\development\CustomServices\EDBC\SampleEDBC -language java

The generated component code has the structure as shown in figure below; it shows the description/purpose of each file generated.

worddav61ab4b30c16af6dbee46ff7be1e9d7a9.png
Figure 2: Structure of asynchronous component

Code for Synchronous (BC) Component

To generate code for synchronous component, use generate command specifying the language using –language option followed by the value representing the language as shown in the below example.

generate.bat -dest C:\development\CustomServices\EDBC\SampleEDBC -language jca

The generated component code has the structure as shown in figure below.

worddav26a7e81a7e4f08fb606752ffaf4b6691.png
Figure 3: Structure of synchronous component

Code for C Component

To generate code for C component, use generate command specifying the language using -language option followed by the value representing the language, that is, 'c'.

generate.bat/sh -dest C:\development\CustomServices\C\SampleC -language c


Figure below shows the structure of the code generated for an asynchronous component defined in C.

worddav55274b36c499804eedb23f5507824423.png
Figure 4: Structure of C component

Code for C++ component

To generate code for C++ component, use generate command specifying the language using -language option followed by the value representing the language, that is, 'cpp'.

generate.bat/sh -dest C:\development\CustomServices\cpp\SampleCpp -language cpp

Figure below shows the structure of the code generated for an asynchronous component defined in C++.

worddav09fb7b34bcb8f9d36cc39f55869a67d7.png
Figure 5: Structure of C++ component

Code for C# Component

To generate code for C# component, use generate command specifying the language using -language option followed by the value representing the language, that is, 'csharp'.

generate.bat/sh -dest C:\development\CustomServices\CSharp\CSSample -language csharp

worddav5011870429baaf2f3aa2f14ba91d3387.png
Figure 6: Structure of C# component