Generating the Project service module projects

The Java Emitter Template (JET) is an Eclipse-enabled template engine for generating applications based on model-driven architecture transformations. By defining an XML file that describes your module, the JET plug-in for Rational Application Developer (RAD) can generate the basic HCL Commerce service module code for you. Afterward, you can complete the module by completing your specific business logic to start directly with the service module implementation. You do not need to spend hours with the setup and configuration of a service module.

Before you begin

Ensure that you install the Java Emitter Template (JET) package. For more information, see Installing the Java Emitter Template (JET) package.

About this task

In this lesson, you use the Java Emitter Template (JET) provided to generate the base code for your Project service module. The Java code for an HCL Commerce service module is abstracted and generated. You can then focus on implementing the code specific to each service module, for example, the nouns and the business logic.

Procedure

  1. Start HCL Commerce Developer.
  2. In the Enterprise Explorer view, create the application definition file to create the base code for the TutorialStore service module.
    1. Create the service module input file.
      You can store this file in any location within you workspace. As an example, the following steps create this file within a new ServiceModuleDefinition directory in the WebSphereCommerceServerExtensionsLogic project.
      1. Right-click the WebSphereCommerceServerExtensionsLogic project. Select New > Folder.
      2. Enter ServiceModuleDefinition as the folder name. This step creates a single location to store all service module input files.
      3. Right-click ServiceModuleDefinition. Select New > File.
      4. Enter project.xml as the file name and click Finish.
    2. Paste the following application definition into the Source tab of project.xml:
      <?xml version="1.0" encoding="utf-8"?>
      
      <_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-pattern.xsd " 
          name="Project" packagenameprefix="com.mycompany.commerce" company="myCompany" namespace="http://www.mycompany.com/xmlns/prod/commerce/9/project" nlsprefix="myprj" type="BOD"> 
        <_pattern:noun name="Project" get="true" process="true" change="true" sync="false">
        </_pattern:noun>
      </_pattern:commerceComponent>
      Note: The definition indicates the name of the noun 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.
  3. Right-click project.xml. Select Run As > Run configurations.
  4. Double-click JET Transformation.
  5. In the Transformation section:
    1. Select the following ID:
      • com.ibm.commerce.toolkit.internal.pattern.componentprojects

      Select the com.ibm.commerce.toolkit.internal.pattern.componentprojects ID

    2. Click Apply. Then, click Run.
  6. The pattern is applied. In the Navigator view, verify that the following projects are created:
    Project-Client
    This project contains client-specific code that is used to build requests and handle responses from the Project Web service.
    Project-DataObjects
    This project holds the XSD file that defines the Project noun and the Service Data Objects generated from the Project and ProjectCollection nouns.
    Project-Server
    This project contains the server-side business logic for the Project and ProjectCollection nouns.
    Project-UnitTests
    This project contains ready built unit tests to verify the Project component.
    ProjectServicesHTTPInterface
    This project enables the Project-Server for web services over HTTP.
    ProjectServicesJMSInterface
    This project enables the Project-Server for web services over JMS.
    Note: Build errors occur in the projects at this stage because data objects are not yet generated. Continue the tutorial to generate these objects and resolve the build errors.
  7. Update the HCL Commerce project.
    When you run the JET pattern tool, the code that is generated by the tool configures your service module to remove WS binding. By updating the project, you can set local bindings for your new service module.
    1. Right-click the WC project. Select Refresh.
    2. Expand WC > xml > config > com.mycompany.commerce.project.
      • Rename wc-component-client.xml to wc-component-client-J2SEWebService-example.xml
      • Rename wc-component-client-local-example.xml to wc-component-client.xml
  8. Change the data source JNDI name:
    1. In the Enterprise Explorer view, expand Project-Server > ejModule > META-INF.
    2. Right-click ibm-ejb-jar-bnd.xmi; select Open.
    3. Verify that the following jndiName values are specified for the attribute <resRefBindings>:
      • DB2jdbc/HCL Commerce DB2 DataSource demo
      • Oraclejdbc/HCL Commerce Oracle DataSource demo

      If the JNDI name field is empty or incorrect, make the necessary changes for the wanted database.

  9. Update the build dependencies for the service module.
    Build dependencies are managed by using the Deployment Assembly instead of the project class path. After you generate your service module code, you need to add the following build dependencies to integrate your service module within the existing HCL Commerce application.
    1. Add the service module to the HCL Commerce application.
      1. Expand WC, right-click WebSphereCommerceServer. Select Open.
      2. Click the Design tab to view the Application Deployment Descriptor Editor.
      3. Within the Overview section, select Application (WebSphereCommerceServer). Then, click Add.
      4. Select Module. Then, click OK.
      5. Under Module, select Project-Server, then click Finish.
      6. Within the Overview section, select Application (WebSphereCommerceServer). Click Add.
      7. Select Module. Then, click OK.
      8. Under Module, select ProjectServicesHTTPInterface, then click Finish.
      9. Again within the Overview section, select Application (WebSphereCommerceServer).
      10. Under Actions, click Manage Utility JARs > Add. Select Project and click Next.
      11. Select Project-Client and Project-DataObjects. Click Finish > OK.
      12. Save the changes that are made in the Application Deployment Descriptor Editor.
    2. Right-click the Project-Server project. Select Properties.
    3. Select Deployment Assembley. Click Add.
    4. Select Java Build Path Entries. Click Next.
    5. Select the following JAR files and projects:
      • Foundation-Core.jar
      • Foundation-DataObjects.jar
      • Foundation-Extension.jar
      • Foundation-Server.jar
      • Enablement-BaseComponentsData.jar
      Note: It is safe to ignore any warnings that occur during this step.
    6. Click Finish > OK.

Results

In this lesson, you used the Java Emitter Template (JET) to generate the base code for the Project component. Your next task is to generate the data objects that are required to implement the logical data model of your Project noun. This noun is defined in the Project.xsd file.