Welcome!

IBM Cloud Authors: Zakia Bouachraoui, Elizabeth White, Yeshim Deniz, Pat Romanski, Liz McMillan

Related Topics: IBM Cloud

IBM Cloud: Article

WebSphere Commerce Design Pattern

Writing applications that adhere to the WebSphere Commerce framework

The IBM WebSphere Commerce product is a platform for developing and deploying value-chain solutions from a consumer-centric online sales channel to a completely integrated, multitiered demand chain. A variety of design patterns were used to develop the WebSphere Commerce framework. By understanding and using these high-level design patterns, you can write WebSphere Commerce applications that adhere to the WebSphere Commerce framework. Furthermore, these patterns will help you to customize the out-of-the-box capabilities of WebSphere Commerce.

WebSphere Commerce design patterns fall into two main categories: 1) the command design patterns and 2) the display design patterns. In the first category are the Controller Command pattern, Task Command pattern, and Data Bean Command pattern. In the second category are the Smart Data Bean pattern and Command Data Bean pattern.

In this two-part article, I’ll discuss the design patterns in terms of the template described in the book Design Patterns – Elements of Reusable Object-Oriented Software by Erich Gamma et al. This template lends a uniform structure to the design patterns, making them easier to learn, compare, and use. In the first part, I’ll cover the controller command and task command. In the second part, to be published in the July issue (Volume 4, Issue 7), I’ll cover Data Bean command and Display pattern.

Controller Command
Intent: Decouple the implementation of the business process logic from the caller to provide the ability to have different implementations of business processes depending on the type of WebSphere Commerce store and to provide the ability to verify if the client is authorized to execute the process.

Motivation: In commerce applications, it’s necessary to have different implementations of a business process to accommodate various types of users and WebSphere Commerce stores. Furthermore, a business process can be configured by assembling a number of low-level business tasks.

For example, the logon process can vary depending on the user who tries to log on and the store to which the user logs on. As commerce application designers, we may not know how the logon business process and the user’s relationship with the store will change over time. So there’s a need to decouple the implementation of the business process from the caller.

The Controller Command pattern lets the caller make a request to an unspecified implementation of a business process by passing in the command name, store details, user details, and other properties required by the process. This pattern controls the business tasks (see Task Command pattern) that will be executed according to the properties that are passed into it. The key to this pattern is the Controller Command interface and the CommandFactory class. The Controller Command interface defines the interfaces that are to be implemented by the business process implementers. The CommandFactory class follows a typical Factory pattern to determine the appropriate business process implementation based on the command issued by the caller and the WebSphere Commerce store.

In the logon example, when a user issues the logon command, the CommandFactory class will instantiate the appropriate logon business process implementation based on the store. In Figure 1, the CommandFactory class instantiates StoreALogonCtrlCmdImpl or StoreBLogonCtrlCmdImpl depending on the store the user is trying to log on to. Once the right business process is instantiated, the controller (WebController) executes the process by calling the command’s execute method.



Applicability: Use this pattern when you want to do one of the following tasks:
  • Build your commerce system by assembling low-level business tasks (see Task Command Pattern) and your business process may change over time or new business tasks may be added.
  • Dynamically change the business process based on the type of WebSphere Commerce store.

Structure:


Participants:
ControllerCommand: A Java interface that declares the methods for the following tasks: to execute a business process, check for access control, set input properties that will be used by business tasks, and set the response properties that may be used by the client when a business process is completed. WebSphere Commerce Server provides this interface.

ControllerCmdImpl: Provides the default implementation for the methods declared in the ControllerCommand interface. WebSphere Commerce Server provides this class.

AControllerCommand: A Java interface that declares the additional methods required by a particular business process. It also provides the name of the default implementation class that implements the methods that are defined by this interface and the business process logic. CommandFactory instantiates the default class if it fails to find an appropriate implementation class in the command registry. For more details about the command registry, see the WebSphere Commerce Developers’ Guide.

AControllerCmdImpl: Provides the implementation for the methods declared in AControllerCommand and the implementation for the business process. Controls the business processes by calling appropriate business tasks based on data passed by the caller.

CommandFactory: Instantiates the appropriate implementation of the ATaskCommand based on store type. The appropriate implementation class is defined in the command registry. The CommandFactory class will instantiate the default implementation defined in the ATaskCommand if there’s no implementation class defined in the command registry.

WebController: Uses CommandFactory to create the appropriate implementation of AControllerCommand and triggers the implementation class to execute the business process.

Client: Requests the operation of a particular command.

More Stories By Bhadri Madapusi

Bhadri Madapusi is a software developer working in the IBM Toronto Lab's Electronic Commerce Division. He earned his MSc in information systems from BITS, India, and his MSc in computer science from Queens University, Canada. Bhadri's interests include software modeling, design patterns, and data management.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
Moroccanoil®, the global leader in oil-infused beauty, is thrilled to announce the NEW Moroccanoil Color Depositing Masks, a collection of dual-benefit hair masks that deposit pure pigments while providing the treatment benefits of a deep conditioning mask. The collection consists of seven curated shades for commitment-free, beautifully-colored hair that looks and feels healthy.
The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
The textured-hair category is inarguably the hottest in the haircare space today. This has been driven by the proliferation of founder brands started by curly and coily consumers and savvy consumers who increasingly want products specifically for their texture type. This trend is underscored by the latest insights from NaturallyCurly's 2018 TextureTrends report, released today. According to the 2018 TextureTrends Report, more than 80 percent of women with curly and coily hair say they purcha...
We all love the many benefits of natural plant oils, used as a deap treatment before shampooing, at home or at the beach, but is there an all-in-one solution for everyday intensive nutrition and modern styling?I am passionate about the benefits of natural extracts with tried-and-tested results, which I have used to develop my own brand (lemon for its acid ph, wheat germ for its fortifying action…). I wanted a product which combined caring and styling effects, and which could be used after shampo...
The platform combines the strengths of Singtel's extensive, intelligent network capabilities with Microsoft's cloud expertise to create a unique solution that sets new standards for IoT applications," said Mr Diomedes Kastanis, Head of IoT at Singtel. "Our solution provides speed, transparency and flexibility, paving the way for a more pervasive use of IoT to accelerate enterprises' digitalisation efforts. AI-powered intelligent connectivity over Microsoft Azure will be the fastest connected pat...
There are many examples of disruption in consumer space – Uber disrupting the cab industry, Airbnb disrupting the hospitality industry and so on; but have you wondered who is disrupting support and operations? AISERA helps make businesses and customers successful by offering consumer-like user experience for support and operations. We have built the world’s first AI-driven IT / HR / Cloud / Customer Support and Operations solution.
Codete accelerates their clients growth through technological expertise and experience. Codite team works with organizations to meet the challenges that digitalization presents. Their clients include digital start-ups as well as established enterprises in the IT industry. To stay competitive in a highly innovative IT industry, strong R&D departments and bold spin-off initiatives is a must. Codete Data Science and Software Architects teams help corporate clients to stay up to date with the mod...
At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
Druva is the global leader in Cloud Data Protection and Management, delivering the industry's first data management-as-a-service solution that aggregates data from endpoints, servers and cloud applications and leverages the public cloud to offer a single pane of glass to enable data protection, governance and intelligence-dramatically increasing the availability and visibility of business critical information, while reducing the risk, cost and complexity of managing and protecting it. Druva's...
BMC has unmatched experience in IT management, supporting 92 of the Forbes Global 100, and earning recognition as an ITSM Gartner Magic Quadrant Leader for five years running. Our solutions offer speed, agility, and efficiency to tackle business challenges in the areas of service management, automation, operations, and the mainframe.