Sample Command Source Code Package README

IBM(R) WebSphere(R) Commerce Professional Edition, Version 5.4


Contents


Package contents

This package contains the following components:

Unzip the package to a temporary directory, for example, D:\temp.


Sample commands for which source code is provided

Source code is provided for the following commands:

From the com.ibm.commerce.samples.catalog.commands package:

From the com.ibm.commerce.samples.fulfillment.commands package:

From the com.ibm.commerce.samples.inventory.commands package:

From the com.ibm.commerce.samples.membergroup.commands package:

From the com.ibm.commerce.samples.messaging.commands package:

From the com.ibm.commerce.samples.negotiation.commands package:

From the com.ibm.commerce.samples.order.calculation package:

From the com.ibm.commerce.samples.order.commands package:

From the com.ibm.commerce.samples.orderitems.commands package:

From the com.ibm.commerce.samples.payment.commands package:

From the com.ibm.commerce.samples.price.commands package:

From the com.ibm.commerce.samples.returns.commands package:

From the com.ibm.commerce.samples.tools.campaigns package:

From the com.ibm.commerce.samples.tools.promotions package:

From the com.ibm.commerce.samples.usermanagement.commands package:


Viewing the sample command sequence diagrams

To view a sample command sequence diagram, do the following:

  1. In the directory where you have unzipped this package, go to the HTML directory.
  2. Open index.html in a web browser.
  3. Expand WebSphere Commerce Version 5.4 Sequence Diagrams.
  4. Double-click the name of the command for which you want to view the sequence diagram.

Importing the sample command source code into your workspace

To import the command source code into the VisualAge for Java workspace, do the following:

  1. Open VisualAge for Java (Start > Programs > IBM VisualAge for Java for Windows V4.0 > IBM VisualAge for Java).
  2. From the File menu, select Import.
  3. Select Repository and click Next.
  4. Select Local repository and in the Repository name field, enter the full qualified path for the Pro54Sample.dat file.   For example, enter D:\temp\Pro54Sample.dat
  5. Select Projects, then click Details.
  6. Select the IBM WCS Sample Commands project and click OK.
  7. Ensure that Add most recent project edition to workspace is enabled.
  8. Click Finish.

Using source code

The source code for the commands is packaged into uniquely named packages that use the following naming convention:
com.ibm.commerce.samples.component_name.commands

This packaging convention permits you to import the code into your workspace without conflicting with the original versions of the commands. These commands are to be used for reference only. When you need to modify the source code, you should copy the required command into a project and package of your own.

For example, if you must modify the source code of the ResolveSkuCmdImpl task command, do the following:

  1. Create a new project in which you will store your customized code, by doing the following:
    1. From the Selected menu, select Add Project.
    2. Enter a name for your project (for example, My Customized Commands) and click Finish.
  2. Create a new package in which you will store your customized command, by doing the following:
    1. Right-click your new project (for example, My Customized Commands) and select Add > Package.
    2. In the Create a new package named field, enter an appropriate name for your package.  com.mycompany.catalog.mycommands is an example of a package name.
    3. Click Finish.
  3. Move the sample command source code into your project, by doing the following:
    1. Expand the IBM WCS Sample Commands project.
    2. Expand the package that contains the task command you wish to modify.  In this case, expand com.ibm.commerce.samples.catalog.commands.
    3. Right-click the task command you wish to modify (the ResolveSkuCmdImpl class, in this case) and select Reorganize > Move.
      Note:
      When you copy GetContractUnitPriceCmdImpl, you also need to copy its dependent .class files:
          CalculateContractPricesCmd
          ItemPriceInfo
          QualifyingOfferInfo
          SelectContractPricesCmd

      When you copy AutoApproveReturnItemCmdImpl or DetermineReturnCreditVehicleCmdImpl, you also need to copy their dependent .class files:
          Misc
          MiscContract
          StateChange
          StateMachine
    4. In the Pattern field, enter the name of the package that you created in step 2b.  For example, enter com.mycompany.catalog.mycommands and click OK.
    5. When a confirmation window opens, click OK.
  4. Open your own project and modify the command that you have just moved to your own package.

Once you have modified the command, you must update the WebSphere Commerce command registry to associate your new implementation class with the existing interface for the command.

In the case of the ResolveSkuCmdImpl task command, the original entry in the CMDREG table appears as follows:

Interface Classname
com.ibm.commerce.catalog.ResolveSkuCmd com.ibm.commerce.catalog.ResolveSkuCmdImpl

Note that only columns relevant to this example are displayed.

To continue with the preceding example of modifying the ResolveSkuCmdImpl class, the entry in the CMDREG would then need to be changed to the following:

Interface Classname
com.ibm.commerce.catalog.ResolveSkuCmd com.mycompany.catalog.mycommands.ResolveSkuCmdImpl

Note that if you change the command registry while the servlet engine in VisualAge for Java's WebSphere Test Environment is running, you must refresh the cache before you can test the new command. You can either stop and restart the servlet engine or run the RefreshRegistry command to perform this refresh. For more information on the RefreshRegistry command, refer to the WebSphere Commerce online help.

After you have tested your new command, you must create a JAR file containing the new logic and deploy the command to a target WebSphere Commerce Server. 

For further details about commands, refer to Chapter 6 of the Programmer’s Guide. For more information about deployment, refer to Chapter 7 and Appendix B of the Programmer’s Guide.


Base commands

One of the commands for which source code is provided is a base command. This command is:

AuditBaseCmdImpl

This base command is included in the com.ibm.commerce.samples.usermanagement.commands package.  This is the base command for the following task commands:

The base command source code is provided for reference only.  Viewing the source code will help you to understand how the commands that extend from them work.   When modifiying business logic related to user management or fulfillment functions, modifications should be made to a copy of the task commands that extend the base commands.    As such, sequence diagrams are not provided for the base commands.

Packaging customized code

Be sure to package all of your customized command and data bean code in project that is separate from the IBM WebSphere Commerce Server project. This will make it easier to transition to future repositories of WebSphere Commerce code.


Where to find more information

For more information related to WebSphere Commerce and WebSphere Commerce Studio, refer to the following Web sites:


Trademarks and service Marks

The following are trademarks of International Business Machines Corporation in the United States and other countries or both:

IBM
VisualAge
WebSphere

Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc.

Other company, product and service names may be the trademarks or service marks of others.

**************************************************************************

** © COPYRIGHT INTERNATIONAL BUSINESS MACHINES CORPORATION 2000, 2002

** ALL RIGHTS RESERVED.

**************************************************************************

Note to US Government Users -- Documentation related to restricted rights -- Use, duplication, or disclosure is subject to restriction set forth in GSA ADP Schedule Contract with IBM Corp.

End of README File