Tutorials > Program model > Web services > Create a WebSphere Commerce service module (SOI) > Creating the Get TutorialStore service

< Previous | Next >


Implement 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.

The following diagram illustrates the major components that we will be modifying in this section of the tutorial and how they interact with one another during the process flow of a Get request:


Procedure

  1. Update the GetTutorialStoreCmdImpl.java class to handle Get requests:

    1. Open the SOITutorialStore-Server/ejbModule/com.mycompany.commerce.soitutorialstore.facade.server.commands/GetTutorialStoreCmdImpl.java class. This is the BOD command for the Get service.

    2. The method, performExpression(), is the callback method from the service controller upon receiving a Get service request.

      1. Search for the following snippet:

        // Run the compose command for each EJB retrieved by the Fetch command.
        //java.util.Iterator itr = fetchCmd.getTutorialStores().iterator();
        

      2. Replace the proceeding while loop with the following snippet:

        // Import StoreDataBean
        import com.ibm.commerce.common.beans.StoreDataBean;
        
        // 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();
        }
        

      3. Save the changes and close the file.

  2. Import the remaining SOITutorialStore-Server code:

    1. Right-click the com.mycompany.commerce.soitutorialstore.facade.server.commands package.

    2. Select Import > File System and click Next.

    3. Browse to the temporary location where you unzipped TutorialStore.zip.

    4. 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.

      FetchAllTutorialStoresCmdImpl.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.

    5. Click Finish. Click Yes to All to overwrite any existing files.

  3. Organize the imports for the SOITutorialStore-Server project:

    1. Open the Java perspective in WebSphere Commerce Developer.

    2. Right-click the SOITutorialStore-Server\EJBModule folder and select Source.

    3. Select Organize Imports.

    4. Save the file.

  4. Register the Get, Fetch, and Compose commands by running the following SQL statements:

    1. delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.GetTutorialStoreCmd';

    2. delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreCmd+MyCompany_All';

    3. delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreCmd+MyCompany_Details';

    4. delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.ComposeTutorialStoreCmd+MyCompany_Summary';

    5. delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.FetchTutorialStoreCmd+/TutorialStore';

    6. delete from cmdreg where STOREENT_ID = 0 and INTERFACENAME = 'com.mycompany.commerce.soitutorialstore.facade.server.commands.FetchTutorialStoreCmd+/TutorialStore/TutorialStoreIdentifier[(UniqueID=)]';

    7. 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');

    8. 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');

    9. 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');

    10. 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');

    11. 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');

    12. 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');

< Previous | Next >


+

Search Tips   |   Advanced Search