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
- Review the ProcessTutorialStoreCmdImpl.java
class for handling Process requests:
- Open the SOITutorialStore-Server/ejbModule/com.mycompany.commerce.soitutorialstore.facade.server.commands/ProcessTutorialStoreCmdImpl.java class. This is the BOD command for the Process service.
- The method, performAction(), is the callback method from the service controller upon receiving a Process service request.
- Import the remaining SOITutorialStore-Server
code:
- Right-click the
com.mycompany.commerce.soitutorialstore.facade.server.commands
package. - Select Import > General > File System and click Next.
- Browse to the temporary location where you unzipped TutorialStore.zip.
- 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.
- Click Finish. Click Yes to All to overwrite any existing files.
- Right-click the
- Update the SOITutorialStore-Server build
path:
- Right-click the SOITutorialStore-Server project and select Properties.
- Select Java Build Path.
- Click the Projects tab; Click Add.
- Select the WebSphereCommerceServerExtensionsData project to add to the build path to resolve the compilation error.
- Update the SOITutorialStore-Server
Java EE module
dependencies:
- Right-click the SOITutorialStore-Server project and select Properties.
- Select Java EE Module Dependencies.
- Select the SOITutorialStore-Client.jar and SOITutorialStore-DataObject.jar projects and click OK.
- Organize the imports for the SOITutorialStore-Server
project:
- Open the Java perspective in WebSphere Commerce Developer.
- Expand SOITutorialStore-Server; right-click the EJBModule folder.
- Select Source > Organize Imports.
- Prepare the SOITutorialStore-Server project
for deployment:
- Open the Java perspective in WebSphere Commerce Developer.
- Delete any file that does not begin with SOI in the com.mycompany.commerce.soitutorialstore.facade.server package before executing Prepare for Deployment.
- Right-click the SOITutorialStore-Server project and select Java EE > Prepare for Deployment.
- 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');
- Configure message mapping to link the Process Open
and
Close actions to the WebSphere Commerce StoreOpenCmd and StoreCloseCmd
commands:
- Open the WC_eardir/xml/messaging/component-services/component-services-user-template.xml file.
- 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>
- Save your changes and close the file.