Tutorials > Program model > Web services > Create a new WebSphere Commerce BOD service module
Implement the business logic layer
This lesson provides a quick review of the Get, Change and Process design patterns, as you implement the business logic layer using the BOD command framework.
The business logic layer contains the Get, Change, and Process commands used in this tutorial.
To save time, you can import these commands directly from the provided tutorial code. The following description of the design patterns describes how the commands you are importing fit into the BOD command framework.
The design pattern for Get services is the basic design pattern to be used for retrieving and displaying information from Web services. This pattern uses the following requests and responses:
- The Get request provides the search criteria used to retrieve the business objects along with paging options for paged requests. The search criteria is represented as a XPath expression.
- The Show response includes the business objects that match the search criteria.
The Get Noun Controller extracts the search information from the request, performs an access control check on the request Access Profile, and delegates to two types of task commands:
- A Fetch command that pulls the data for the requested business objects from the persistence layer and transforms it into the OAGIS logical structure. The default Fetch task implementation will use the Business Object Mediator to retrieve data and convert it to its logical representation. A custom fetch implementation is only needed if the command needs to implement any business logic. In the case of this tutorial, the default Fetch implementation generated by the Java Emitter Template (JET) is sufficient, and no commands need to be imported.
- An optional InsertMoreData command that is used to augment the objects retrieved by the fetch, for example to add computed values or aggregate with content from an alternate data source. This tutorial does not implement an InsertMoreData command.
The BOD Change processing pattern is used to create, update, or delete a business object. The Change processing pattern uses the following requests and responses:
- A Change request notifies the server to change business objects managed by that server. The request contains a Change verb identifying the actions to perform and nouns containing a unique identifier and the attributes to change.
- The Respond response includes the shell of the processed business object containing at a minimum the unique identifier for the new or changed business object.
The Change Noun Controller performs initial validation, for example whether the noun to change exists, an access control check, and then delegates to the following two types of task commands:
- A series of Change Noun Part task commands that are responsible for performing the business logic CUD (Create, Update, and Delete) for a section of the noun. The intent of dividing a noun into separate changeable parts is to simplify the implementation and maintenance of code. Simple nouns may have one changeable part and one Change Noun Part task command while complex nouns may have many changeable parts and many Change Noun Part tasks. In this tutorial, you import ChangeTutorialStoreDescriptionCmdImpl.java, which is a Change Noun Part command.
- An optional series of PostChangeNounPart task command that contain postrequisite business logic that needs to be run after a noun or part of the noun has been changed. This tutorial does not implement a PostChangeNounPart task command.
The BOD Process processing pattern is used to perform business logic and CUD operations on a business object. The Process pattern is a simplified version of the Change pattern and differs by acting upon an entire noun, where a Change action can affect only a section of a noun. The Process pattern uses the following request and response messages:
- A Process request is used to submit a new business object, cancel an existing business object, or invoke processing logic against an existing business object.
- The Acknowledge response includes the shell of the processed business object, containing at a minimum the unique identifier for the new or changed business object.
In this tutorial lesson, you implement two process commands, ProcessTutorialStoreOpenActionCmd and ProcessTutorialStoreCloseActionCmd.
The following diagram shows the business logic assets in the overall customization process:
To import the business logic layer commands:
Procedure
- Import the ChangeStoreDescription command to perform the change store description request.
- Right-click the BODTutorialStore-Server/ejbModule/com.mycompany.commerce.bodtutorialstore.facade.server.commands package.
- Select Import.
- Browse to the location where you unzipped TutorialStore.zip.
- Select ChangeTutorialStoreDescriptionCmdImpl.java
- Import the ProcessTutorialStoreCloseAction command to close a store:
- Right-click the BODTutorialStore-Server/ejbModule/com.mycompany.commerce.bodtutorialstore.facade.server.commands package.
- Select Import.
- Browse to the location where you unzipped TutorialStore.zip.
- Select ProcessTutorialStoreCloseActionCmdImpl.java.
- Import the ProcessTutorialStoreOpenAction command to open a store:
- Right-click the BODTutorialStore-Server/ejbModule/com.mycompany.commerce.bodtutorialstore.facade.server.commands package.
- Select Import.
- Browse to the location where you unzipped TutorialStore.zip.
- Select ProcessTutorialStoreOpenActionCmdImpl.java.
- Organize the imports for the BODTutorialStore-Server project:
- Open the Java perspective in WebSphere Commerce Developer.
- Right-click the BODTutorialStore-Server\EJBModule folder and select Source.
- Select Organize Imports.
- Save the file.
- Register the new commands in the CMDREG table by running the following SQL statements:
- insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME,TARGET) VALUES (0, 'com.mycompany.commerce.bodtutorialstore.facade.server.commands.FetchTutorialStoreCmd', 'com.mycompany.commerce.bodtutorialstore.facade.server.commands.FetchTutorialStoreCmdImpl', 'Local');
- insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME,TARGET) VALUES (0, 'com.mycompany.commerce.bodtutorialstore.facade.server.commands.GetTutorialStoreCmd', 'com.mycompany.commerce.bodtutorialstore.facade.server.commands.GetTutorialStoreCmdImpl', 'Local');
- insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME,TARGET) VALUES (0,'com.mycompany.commerce.bodtutorialstore.facade.server.commands.ChangeTutorialStoreCmd','com.mycompany.commerce.bodtutorialstore.facade.server.commands.ChangeTutorialStoreCmdImpl' , 'Local');
- insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME,TARGET) VALUES (0,'com.mycompany.commerce.bodtutorialstore.facade.server.commands.ChangeTutorialStorePartActionCmd+/TutorialStore[]/StoreDescription','com.mycompany.commerce.bodtutorialstore.facade.server.commands.ChangeTutorialStoreDescriptionCmdImpl' , 'Local');
- insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME,TARGET) VALUES (0,'com.mycompany.commerce.bodtutorialstore.facade.server.commands.ProcessTutorialStoreCmd','com.mycompany.commerce.bodtutorialstore.facade.server.commands.ProcessTutorialStoreCmdImpl' , 'Local');
- insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME,TARGET) VALUES (0,'com.mycompany.commerce.bodtutorialstore.facade.server.commands.ProcessTutorialStoreActionCmd+Open','com.mycompany.commerce.bodtutorialstore.facade.server.commands.ProcessTutorialStoreOpenActionCmdImpl' , 'Local');
- insert into cmdreg (STOREENT_ID, INTERFACENAME, CLASSNAME,TARGET) VALUES (0,'com.mycompany.commerce.bodtutorialstore.facade.server.commands.ProcessTutorialStoreActionCmd+Close','com.mycompany.commerce.bodtutorialstore.facade.server.commands.ProcessTutorialStoreCloseActionCmdImpl' , 'Local');
To run the SQL statements
- Start the WebSphere Commerce test server.
- Open the following URL: http://localhost/webapp/wcs/admin/servlet/db.jsp