Tutorials > Program model > Web services > Create a new WebSphere Commerce BOD service module

< Previous | Next >


Generate the TutorialStore service module projects

The Java Emitter Template (JET) is an Eclipse-enabled template engine for generating applications based on model-driven architecture transformations. WebSphere Commerce uses a JET plug-in for creating WebSphere Commerce service modules from a simple XML file. By describing the service module in a specialized XML syntax, the service modules can be generated. This allows you to start directly with the service module implementation without having to spend hours with the setup and configuration of a service module.

In this step, you are going to use the Java Emitter Template (JET) to generate the base code for your TutorialStore component. A significant amount of Java code is related to the processing of WebSphere Commerce nouns and can be abstracted and generated. This allows you to focus on implementing the code specific to each component, for example the component's nouns and the noun's business logic. In the diagram below, you can see how generating these Rational Application Developer projects fits into the overall customization process:


Procedure

  1. Start WebSphere Commerce Developer.

  2. Open the J2EE perspective.

  3. Create the application definition file to create the base code for the TutorialStore service module.

    1. Create the service module input file.

      1. Right-click on the WebSphereCommerceServerExtensionsLogic project and select New > Folder.

      2. Enter ServiceModuleDefinition as the folder name. This creates a single location to store all service module input files.

      3. Right-click the ServiceModuleDefinition folder and select New > File.

      4. Enter BODTutorialStore.xml as the filename and click Finish.

    2. Paste the following application definition into the file:

      <_pattern:commerceComponent xmlns:_pattern="http://www.ibm.com/xmlns/prod/commerce/foundation/pattern" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/pattern ../../WC/xml/config/xsd/wc-component-patten.xsd " 
      name="BODTutorialStore" packagenameprefix="com.mycompany.commerce" company="MyCompany" 
      namespace="http://www.mycompany.com/xmlns/prod/commerce/9/bodtutorialstore" nlsprefix="myco" type="BOD"> 
      <_pattern:noun name="TutorialStore" get="true" process="true" change="true" sync="false"/> 
      
      </_pattern:commerceComponent>
      

      The definition indicates the name of the noun (TutorialStore) and the verbs that are enabled for the pattern (Get, Process, and Change, but not Sync). This file determines the assets and code to be generated for you.

    3. Save the file.

  4. Right-click BODTutorialStore.xml and select Run As > Input for Jet Transformation.

  5. In the Transformation section:

    1. Select the following ID:

      • com.ibm.commerce.toolkit.internal.pattern.componentprojects

    2. Click OK.

  6. The pattern is applied. Verify that the following projects are created, by switching to the Navigator view:

    • BODTutorialStore-Client

    • BODTutorialStore-DataObjects

    • BODTutorialStore-Server

    • BODTutorialStore-UnitTests

    • BODTutorialStoreServicesHTTPInterface

    • BODTutorialStoreServicesJMSInterface

  7. Update the build dependencies for the service module:

    This is necessary as build dependencies are managed using the Java EE Module dependencies instead of the project classpath. This requires projects to be added to a J2EE application.

    1. Add the service module to the WebSphere Commerce application.

      1. Expand WC > WebSphereCommerceServer deployment descriptor > Modules and select Modify

      2. Select the Java EE Module Dependencies tab, if it is not selected by default.

      3. Under the JAR/Module list, select the following items:

        • BODTutorialStore-Server

        • BODTutorialStoreServicesHTTPInterface

        • BODTutorialStore-Client

        • BODTutorialStore-DataObjects

      4. Save the deployment descriptor (press Ctrl + S).

    2. Right-click the BODTutorialStore-Server project and select Properties.

    3. Select Java EE Module Dependencies.

    4. Select the following:

      • Enablement-RelationshipManagementData.jar from the WC project.

      • Enablement-RelationshipManagementLogic.jar from the WC project.

      • BODTutorialStore-Client from the BODTutorialStore project.

      • BODTutorialStore-DataObjects from the BODTutorialStore project.

    5. Click OK.

Build errors will show up in the projects at this stage because the TutorialStore data objects have not yet been generated from the TutorialStore noun. Continue the tutorial to generate these objects and resolve the build errors.


Lesson checkpoint

In this step, you used the Java Emitter Template (JET) to generate the base code for the TutorialStore component.

The following assets were generated:

Your next task is to generate the data objects required for implementing the logical data model of the TutorialStore noun, which is defined in the TutorialStore.xsd file.

< Previous | Next >


+

Search Tips   |   Advanced Search