152 Patterns: Implementing Self-Service in an SOA Environment
򐂰 Promotes the ability to drop common information on multiple pages, such as
displaying the current weather information and current stock price on all the
pages of the Web application.
A disadvantage of formatter beans is that some of the display page functionality
that is best expressed in a JSP is now moved into Java code.
7.2.5 Command bean design pattern
The business logic part of a Web application must address a wide range of
potential requirements, including transactional integrity, application data access,
workflow support, and integration of new and legacy applications. To achieve
this, business logic components may use various protocols, including JDBC,
JNDI, IIOP, RMI, Web services, JCA, JMS, and so on to communicate with
enterprise applications, enterprise data sources, and external applications. The
Model is not only responsible for implementing the business logic, but also for
hiding the details of the data and application access protocols. To simplify the
implementation of the Model, we can implement one business logic bean per
task. We call such beans
command beans.
Command beans can be defined as JavaBeans that provide a standard way to
invoke business logic. The following are the key characteristics of command
beans:
򐂰 Each command bean corresponds to a single business logic task, such as a
query or an update task.
򐂰 All command beans inherit from a single command interface. In essence, they
implement the command interface.
򐂰 The inherited command bean defines business domain-specific properties
such as account numbers.
򐂰 Command execution results are stored as properties of a command bean.
Therefore, command beans also act as result beans.
򐂰 Commands have a simple, uniform usage pattern:
a. Create an instance of the command bean.
b. Initialize the bean by setting its properties.
c. Cause the bean to execute its action by calling one of its methods.
d. Access the results of command execution by inspecting its properties.
e. Discard the command object.
򐂰 Commands can be serialized.
Figure 7-5 on page 153 shows how such a command bean interacts with the
other components of the Web application.

Get Patterns: Implementing Self-Service in an SOA Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.