Implementing the component facade

In this step, you implement the code logic in the component facade for handling the ProcessTutorialStore requests, in addition to implementing the code for generating AcknowledgeTutorialStore responses.

Procedure

  1. Review the ProcessTutorialStoreCmdImpl.java class for handling Process requests:
    1. Open the SOITutorialStore-Server/ejbModule/com.mycompany.commerce.soitutorialstore.facade.server.commands/ProcessTutorialStoreCmdImpl.java class. This is the BOD command for the Process service.
    2. The method, performAction(), is the callback method from the service controller upon receiving a Process service request.
  2. Import the remaining SOITutorialStore-Server code:
    1. Right-click the com.mycompany.commerce.soitutorialstore.facade.server.commands package.
    2. Select Import > General > File System and click Next.
    3. Browse to the temporary location where you unzipped TutorialStore.zip.
    4. Select the following files:
      AcknowledgeTutorialStoreBuildCmdImpl.java
      Command to build the Acknowledge BOD after a process action.
      AcknowledgeTutorialStoreBuildErrorCmdImpl.java
      Command to build the Acknowledge BOD error response if the process action fails.
      AcknowledgeTutorialStoreBaseCmdImpl.java
      Base acknowledge class containing common methods.
    5. Click Finish. Click Yes to All to overwrite any existing files.
  3. Update the SOITutorialStore-Server build path:
    1. Right-click the SOITutorialStore-Server project and select Properties.
    2. Select Java Build Path.
    3. Click the Projects tab; Click Add.
    4. Select the WebSphereCommerceServerExtensionsData project to add to the build path to resolve the compilation error.
  4. Update the SOITutorialStore-Server Java EE module dependencies:
    1. Right-click the SOITutorialStore-Server project and select Properties.
    2. Select Java EE Module Dependencies.
    3. Select the SOITutorialStore-Client.jar and SOITutorialStore-DataObject.jar projects and click OK.
  5. Organize the imports for the SOITutorialStore-Server project:
    1. Open the Java perspective in WebSphere Commerce Developer.
    2. Expand SOITutorialStore-Server; right-click the EJBModule folder.
    3. Select Source > Organize Imports.
  6. Prepare the SOITutorialStore-Server project for deployment:
    1. Open the Java perspective in WebSphere Commerce Developer.
    2. Delete any file that does not begin with SOI in the com.mycompany.commerce.soitutorialstore.facade.server package before executing Prepare for Deployment.
    3. Right-click the SOITutorialStore-Server project and select Java EE > Prepare for Deployment.
  7. Register the Process command by running the following SQL statements.
    delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ProcessTutorialStoreCmd';
    
    insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME, TARGET) VALUES (0, 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ProcessTutorialStoreCmd', 'com.ibm.commerce.foundation.server.command.soi.MessageMappingCmdImpl', 'Local');
  8. Configure message mapping to link the Process Open and Close actions to the WebSphere Commerce StoreOpenCmd and StoreCloseCmd commands:
    1. Open the WC_eardir/xml/messaging/component-services/component-services-user-template.xml file.
    2. Paste the following code within the <ECTemplate> tag:
      
      <!-- TutorialStore -->
      <TemplateDocument>
      <DocumentType version="*">ProcessTutorialStore</DocumentType>
      <StartElement>ProcessTutorialStore</StartElement>
      <TemplateTagName>ProcessTutorialStoreMap</TemplateTagName>
      <CommandMapping>
      <Command CommandName="com.ibm.commerce.store.commands.StoreOpenCmd" Condition='actionCode="Open" AND actionExpression="/TutorialStore"'>
      <Constant Field="URL">NoURL</Constant>
      <Constant FieldInfo='CONTROL' Field='responseCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildCmdImpl</Constant>
      <Constant FieldInfo='CONTROL' Field='errorCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildErrorCmdImpl</Constant>
      </Command>
      <Command CommandName="com.ibm.commerce.store.commands.StoreCloseCmd" Condition='actionCode="Close" AND actionExpression="/TutorialStore"'>
      <Constant Field="URL">NoURL</Constant> 
      <Constant FieldInfo='CONTROL' Field='responseCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildCmdImpl</Constant>
      <Constant FieldInfo='CONTROL' Field='errorCommand'>com.mycompany.commerce.soitutorialstore.facade.server.commands.AcknowledgeTutorialStoreBuildErrorCmdImpl</Constant>
      </Command> 
      </CommandMapping>
      </TemplateDocument>
      
      <TemplateTag name="ProcessTutorialStoreMap">
      <Tag XPath="ApplicationArea/BusinessContext/ContextData" XPathType="USERDATA"/>
      <Tag XPath="DataArea/Process/ActionCriteria/ActionExpression@actionCode" Field="actionCode" FieldInfo="COMMAND"/>
      <Tag XPath="DataArea/Process/ActionCriteria/ActionExpression" Field="actionExpression" FieldInfo="COMMAND"/>
      <Tag XPath="DataArea/TutorialStore/StoreIdentifier/UniqueID" Field="targetStoreId"/>
      </TemplateTag>
      
    3. Save your changes and close the file.