Implementing the component facade
In this step, you implement the code logic in the component facade for handling the GetTutorialStore requests, in addition to implementing the code for generating ShowTutorialStore responses.
Procedure
- Update the GetTutorialStoreCmdImpl.java class to handle
Get requests:
- In the Enterprise Explorer view, expand SOITutorialStore-Server/ejbModule/com.mycompany.commerce.soitutorialstore.facade.server.commands/GetTutorialStoreCmdImpl.java
- Open the GetTutorialStoreCmdImpl class
for editing. This is the BOD command for the Get service.
- Add the following code to the beginning of GetTutorialStoreCmdImpl.java
to import com.ibm.commerce.common.beans.StoreDataBean.
// Import StoreDataBean import com.ibm.commerce.common.beans.StoreDataBean;
- Add the following code to the beginning of GetTutorialStoreCmdImpl.java
to import com.ibm.commerce.common.beans.StoreDataBean.
- The method, performExpression(), is the callback method
from the service controller upon receiving a Get service request.
- Search for the following snippet:
// Run the compose command for each EJB retrieved by the Fetch command. //java.util.Iterator itr = fetchCmd.getTutorialStores().iterator();
- Replace the code snippet and the following
while
loop with the following snippet:// Run the compose command for each EJB retrieved by the Fetch command. java.util.Iterator itr = fetchCmd.getNouns().iterator(); while (itr.hasNext()) { // Set the bean on the compose command and run the command. StoreDataBean aStoreDataBean = (StoreDataBean) itr.next(); composeCmd.setTutorialStoreDataBean(aStoreDataBean); composeCmd.setSearchExpression(new SearchExpression(getTutorialStoreType.getDataArea().getGet(), SOITutorialStoreFacadeConstants.COMPONENT_NAME)); composeCmd.execute(); showTutorialStore.getDataArea().getTutorialStore().addAll(composeCmd.getTutorialStores()); composeCmd.reset(); }
- Save your changes and close the file.
- Search for the following snippet:
- 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:
- ComposeTutorialStoreAllCmdImpl.java
- Task command to retrieve all information about a TutorialStore.
- ComposeTutorialStoreBaseCmdImpl.java
- Base compose class containing common methods.
- ComposeTutorialStoreCmd.java
- Interface for the compose task command.
- ComposeTutorialStoreDetailsCmdImpl.java
- Task command to retrieve detail information about a TutorialStore.
- ComposeTutorialStoreSummaryCmdImpl.java
- Task command to retrieve summary information about a TutorialStore.
- FetchAllTutorialStoreCmdImpl.java
- Task command to retrieve a store data bean for each store on the server.
- FetchTutorialStoreByIdCmdImpl.java
- Task command to retrieve a store data bean for the specified store ID.
- Click Finish. Click Yes to All to overwrite any existing files.
- Right-click the
- 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.
- Register the Get, Fetch, and Compose commands by running
the following SQL statements:
delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.GetTutorialStoreCmd'; delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreCmd+MyCompany_All'; delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreCmd+MyCompany_Details'; delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreCmd+MyCompany_Summary'; delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.FetchTutorialStoreCmd+/TutorialStore'; delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.FetchTutorialStoreCmd+/TutorialStore/TutorialStoreIdentifier[(UniqueID=)]'; insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME, TARGET) VALUES (0, 'com.mycompany.commerce.soitutorialstore.facade.server.commands.GetTutorialStoreCmd', 'com.mycompany.commerce.soitutorialstore.facade.server.commands.GetTutorialStoreCmdImpl', 'Local'); insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME, TARGET) VALUES (0, 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreCmd+MyCompany_All', 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreAllCmdImpl', 'Local'); insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME, TARGET) VALUES (0, 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreCmd+MyCompany_Summary', 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreSummaryCmdImpl', 'Local'); insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME, TARGET) VALUES (0, 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreCmd+MyCompany_Details', 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreDetailsCmdImpl', 'Local'); insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME, TARGET) VALUES (0, 'com.mycompany.commerce.soitutorialstore.facade.server.commands.FetchTutorialStoreCmd+/TutorialStore', 'com.mycompany.commerce.soitutorialstore.facade.server.commands.FetchAllTutorialStoreCmdImpl', 'Local'); insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME, TARGET) VALUES (0, 'com.mycompany.commerce.soitutorialstore.facade.server.commands.FetchTutorialStoreCmd+/TutorialStore/TutorialStoreIdentifier[(UniqueID=)]', 'com.mycompany.commerce.soitutorialstore.facade.server.commands.FetchTutorialStoreByIdCmdImpl', 'Local');