Ajs 3 a
- 1. Behavioral and J2EE Design Patterns
Pre-assessment Questions
1. Which structural design pattern separates the interface with its
implementation?
a) Adapter
b) Bridge
c) Composite
d) Decorator
3. Which behavioral design pattern encapsulates a request as an object
and enables the queuing and logging of requests?
a) Template Method
b) Visitor
c) Strategy
d) Command
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 1 of 54
- 2. Behavioral and J2EE Design Patterns
Pre-assessment Questions
1. Which statement defines a structural design pattern?
a) Represents the composition of classes and objects.
b) Defines the state, behavior, and communication among the
objects.
c) Provides separation between the sender and receiver of a request
by introducing a number of objects between them.
d) Provides a way to dynamically select the instantiation of an object
and to return a clone of a prototypical object.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 2 of 54
- 3. Behavioral and J2EE Design Patterns
Pre-assessment Questions
1. Consider the statements:
Statement A: Facade design pattern provides a unified interface to a
collection of interfaces in a subsystem.
Statement B: Facade pattern enables you to extend functionality of an
object and dynamically provides additional responsibilities to an object.
Identify the correct option.
a) Statement A is true and statement B is false
b) Statement A is false and statement B is true
c) Both, statements A and B, are true
d) Both, statements A and B, are false
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 3 of 54
- 4. Behavioral and J2EE Design Patterns
Pre-assessment Questions
2. Which design pattern composes objects into tree structures?
a) Flyweight
b) Composite
c) Adaptor
d) Proxy
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 4 of 54
- 5. Behavioral and J2EE Design Patterns
Solutions to Pre-assessment
Questions
1. b. Bridge
2. d. Command
3. a. Represents the composition of classes and objects.
4. a. Statement A is true and statement B is false
5. b. Composite
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 5 of 54
- 6. Behavioral and J2EE Design Patterns
Objectives
In this lesson you will learn to:
• Use Behavioral design patterns
• Identify J2EE design Patterns
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 6 of 54
- 7. Behavioral and J2EE Design Patterns
Behavioral Design Patterns
• The behavioral design pattern defines the state, behavior, and communication
among the objects.
• The various behavioral design patterns are Chain of Responsibility, Command,
Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template
Method, and Visitor.
• All these patterns are concerned with how an object behaves.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 7 of 54
- 8. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Interpreter Pattern
• The Interpreter design pattern is used to interpret the grammar of a given
language.
• The advantages of using Interpreter design pattern are:
• Makes it easy to change and extend the grammar.
• Makes it simple to implement the grammar.
• The participants of Interpreter design pattern are:
• Context: Contains global information.
• Client: Invokes methods on the Interpreter.
• AbstractExpression abstract class : Declares abstract operations
implemented by TerminalExpression class.
• TerminalExpresssion class : Implements an operation to interpret
a language for terminal symbols in the grammar. For example, ‘X’ in
roman is a terminal symbol that represents “10”.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 8 of 54
- 9. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Interpreter Pattern (Contd.)
• Class diagram of Interpreter design pattern
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 9 of 54
- 10. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Iterator Pattern
• The Iterator design pattern allows you to access elements of a certain data
structure in a sequential manner, without knowing the internal
representation of the content.
• The advantages of using Iterator design pattern are:
• Provides different ways to iterate through a data structure.
• Simplifies the retrieval of data from a collection.
• The participants of Iterator design pattern are:
• Aggregate abstract class: Defines an interface to create an
Iterator object.
• ConcreteAggregate class: Creates and returns an instance of
ConcreteIterator object.
• Iterator abstract class: Defines an interface for accessing elements
of a data structure.
• ConcreteIterator class: Implements the Iterator operation.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 10 of 54
- 11. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Iterator Pattern (Contd.)
• Class diagram of Iterator design pattern
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 11 of 54
- 12. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Mediator Pattern
• The Mediator design pattern defines an object, which is responsible for
coordinating and controlling the change in state between objects of a
group.
• The advantages of using Mediator design pattern are:
• Provides loose coupling among the objects of a group.
• Centralizes the logic to manage interaction between the objects of a
group.
• Enables the objects of a group to avoid the logic required to
communicate with each other.
• The participants of Mediator design pattern are:
• Mediator abstract class: Defines an interface for communication
with other objects.
• Colleague abstract class: An object that communicates with other
objects using the Mediator.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 12 of 54
- 13. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Mediator Pattern (Contd.)
• The participants of Mediator design pattern are (Contd.):
• ConcreteMediator class : Implements Mediator behavior in order to
provide communication between colleague objects.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 13 of 54
- 14. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Mediator Pattern (Contd.)
• Class diagram of Mediator design pattern
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 14 of 54
- 15. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Memento Pattern
• The Memento design pattern provides serialization of an object, so that
the state of the object at various stages during the execution of a program
can be saved.
• The advantages of using the Memento design pattern are:
• Restores the state of an object.
• Conserves the encapsulation limitations of an object.
• The participants of Memento design pattern are:
• Originator class: Creates a Memento object by saving its current
internal state.
• Memento class: Stores the internal state of an Originator object.
• Caretaker class : Maintains an object’s saved internal state.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 15 of 54
- 16. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Memento Pattern (Contd.)
• Class diagram of Memento design pattern
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 16 of 54
- 17. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Observer Pattern
• The Observer design pattern defines one to many relationships between
subject and observer objects.
• The advantages of using Observer design pattern are:
• Provides support for publisher to subscriber type communication.
• Provides decoupling between subject and observer in order to
reuse them independently.
• The participants of Observer design pattern are:
• Subject abstract class: Provides an interface using which
observers can keep track of its implementation object.
• Observer abstract class: An object that updates itself according to
the changes in subject.
• ConcreteSubject class: Notifies its observers when its state
changes.
• ConcreteObserver class: Keeps its state consistent with the
subject’s state.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 17 of 54
- 18. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Observer Pattern (Contd.)
• Class diagram of Observer design pattern
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 18 of 54
- 19. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• State Pattern
• The State design pattern enables an object to change its behavior when
the state of the object changes.
• The advantage of using State design pattern is that the transition of
state is made explicit.
• The participants of State design pattern are:
• Context class: Maintains an instance that defines the current
state of a ConcreteState class.
• State class: Encapsulates the behavior associated with a specific
state of context by defining an interface.
• ConcreteState1 class: Implements the behavior defined in the
State object.
• ConcreteState2 class: Implements the behavior defined in the
State object.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 19 of 54
- 20. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• State Pattern (Contd.)
• Class diagram of State design pattern
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 20 of 54
- 21. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Strategy Pattern
• The Strategy design pattern encapsulates the functionality of the
subclasses of a common superclass.
• The advantages of using Strategy design pattern are:
• Providing an alternative to subclassing.
• Enabling you to add new behavior without making changes in the
application.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 21 of 54
- 22. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Strategy Pattern (Contd.)
• The participants of Strategy design pattern are:
• Context class: Keeps a reference to a Strategy object.
• Strategy abstract class: Declares a strategy interface that is
common to all algorithms, which support the interface.
• ConcreteStrategy1 class: Implements the algorithm that is
defined in the Strategy object.
• ConcreteStrategy2 class: Implements the algorithm that is
defined in the Strategy object.
• ConcreteStrategy3 class: Implements the algorithm that is
defined in the Strategy object.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 22 of 54
- 23. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Strategy Pattern (Contd.)
• Class diagram of Strategy design pattern
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 23 of 54
- 24. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Template Method Pattern
• The Template Method design pattern defines the skeleton of a method
deferring the implementation to the subclasses.
• The advantages of using the Template Method design pattern are:
• Allows code reusability.
• Allows you to define the structure of an algorithm and force the
subclass to provide the implementation.
• The participants of Template Method design pattern are:
• Abstract Class: Declares abstract operations that are implemented
by Concrete classes.
• Concrete Class: Implements the abstract operations to provide
subclass specific functionality.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 24 of 54
- 25. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Template Method Pattern (Contd.)
• Class diagram of Template Method design pattern
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 25 of 54
- 26. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Visitor Pattern
• The Visitor design pattern defines an operation, which is executed on
the elements of other classes.
• The advantages of using the Visitor design pattern are:
• Separates the related operations from the unrelated operations.
• Enables you to add new operations.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 26 of 54
- 27. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Visitor Pattern (Contd.)
• The participants of Visitor design pattern are:
• Visitor abstract class: Declares the methods that are
implemented by ConcreteVisitor1 and ConcreteVisitor2
classes.
• ConcreteVisitor1 class: Implements all the operations declared
by the Visitor class.
• ConcreteVisitor2 class: Implements all the operations declared
by the Visitor class.
• ObjectStructure class: Provides a higher-level interface allowing
the visitor to visit its elements.
• Element abstract class: Defines an operation to accept the
Visitor object.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 27 of 54
- 28. Behavioral and J2EE Design Patterns
Behavioral Design Patterns (Contd.)
• Visitor Pattern (Contd.)
• Class diagram of Visitor design pattern
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 28 of 54
- 29. Behavioral and J2EE Design Patterns
Demonstration-Identifying Behavioral
Design Patterns
• Problem Statement
• In an online shopping portal, the sales manager frequently
announces various schemes and discounts. The sales manager
segregates the information of different kind of customers on the
basis of age group, income group, location, and gender. The
sales manager is also responsible for enabling and disabling the
schemes and discounts. The shopping portal always provides
special discount to its privileged customers. While shopping, the
customer can stop shopping at any instance of time. Later on,
the customer can restart shopping from the point he has left
shopping. Identify the behavioral design pattern that can be
applied on the given scenario.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 29 of 54
- 30. Behavioral and J2EE Design Patterns
Demonstration-Identifying Behavioral
Design Patterns (Contd.)
• Solution
• To solve the preceding problem, perform the following tasks:
1. Identify the Chain of Responsibility design pattern.
2. Identify the Command design pattern.
3. Identify the Interpreter design pattern.
4. Identify the State design pattern.
5. Identify the Mediator design pattern.
6. Identify the Memento design pattern.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 30 of 54
- 31. Behavioral and J2EE Design Patterns
J2EE Design Patterns
• A pattern is defined as a recurring problem and its solution in context to
share the knowledge among different users.
• Context is defined as an environment in which a problem occurs.
• A problem is defined as a query that needs to be explored and answered in a
given environment .
• Solution is defined as a response to the query that resolves the problem.
• A J2EE pattern is defined as a group of J2EE-based problems and its
solutions.
• The J2EE design patterns are categorized into different tiers that build up an
enterprise application:
• Presentation tier
• Business tier
• Integration tier
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 31 of 54
- 32. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Presentation Tier
• A presentation tier contains the logic that is required for presenting the
information to an end user.
• The major role of the presentation tier is to intercept the client
requests, restrict the access to business services, and send the
response back to clients.
• The various patterns available in the presentation tier are:
• Intercepting Filter
• Front Controller
• Context Object
• Application Controller
• View Helper
• Composite View
• Service to Worker
• Dispatcher View
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 32 of 54
- 33. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Intercepting Filter Pattern
• The Intercepting Filter design pattern is used to preprocess and post
process a client request.
• The advantages of using the Intercepting Filter design pattern are:
• Centralizes control for managing processing across various client
requests.
• Provides reusability by adding or removing the pluggable
interceptors from an existing code and using them for creating
different presentations.
• This design pattern creates pluggable filters to process these
preprocessing and post processing services.
• The servlet filters for Hypertext Transfer Protocol (HTTP) requests or
responses and message handlers for Simple Object Access Protocol
(SOAP) requests or responses are the examples that implement the
Intercepting Filter design pattern.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 33 of 54
- 34. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Front Controller Pattern
• The Front Controller design pattern manages the client requests using a
centralized controller.
• The advantages of using the Front Controller design pattern are:
• Centralizes control for managing control logic across multiple
requests.
• Provides reusability by transferring the code that needs to be
common among applications to a controller and allowing the
access to the code.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 34 of 54
- 35. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Context Object Pattern
• The Context Object design pattern encapsulates the data in a context
object.
• The advantages of using the Context Object design pattern are:
• Improving the process of testing by eliminating the protocol-
specific code that binds a Web server or an application server with
a container.
• Providing reusability of application components among various
clients by eliminating the protocol-specific data types.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 35 of 54
- 36. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Application Controller Pattern
• The Application Controller design pattern integrates and modularizes
action management and view management along with a front controller.
• The advantages of using the Application Controller design pattern are:
• Providing reusability and modularity by categorizing the code into
action management and view management.
• Reducing the coupling between the code that enables the rules to
be modified without modifying the code.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 36 of 54
- 37. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• View Helper Pattern
• The View Helper design pattern enables a view to perform tasks that
are not related with the presentation of the view.
• Programming logic is responsible for formatting and presenting the
output.
• The advantages of using the View Helper design pattern are:
• Developing modularity in an application by detaching HTML from
the processing logic, such as business logic and control logic.
• Reducing the need of incorporating implementation details in code
by separating the HTML code from the processing logic.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 37 of 54
- 38. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Composite View Pattern
• A view represents the information to clients.
• An atomic portion of a composite whole is known as a subview or a view
segment.
• A composite view is composed of multiple views.
• The Composite View design pattern creates a flexible presentation that
enables personalization and customization of views by grouping
together sub views.
• The advantages of using the Composite View design pattern are:
• Providing modularity and reusability by dividing a template into
various subviews and reusing them.
• Incorporating role-based and policy-based controls, such as user
role or security policy in an application.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 38 of 54
- 39. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Service to Worker Pattern
• The Service to Worker design pattern consists of a combination of front
controller, view helper, and dispatcher components.
• The advantages of using the Service to Worker design pattern are:
• Providing reusability by incorporating the request-handling logic
within a view.
• Improving maintainability by making the changes at a centralized
location.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 39 of 54
- 40. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Dispatcher View Pattern
• The Dispatcher View design pattern is similar to the Service to Worker
design pattern and consists of a combination of front controller, view
helper, and dispatcher components.
• The advantages of using the Dispatcher View design pattern are:
• Providing support for standard and custom libraries that enable
you to use data access tags, transformers, and view adapters.
• Improving reusability by separating the processing logic from the
view that reduces the need of implementation in code.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 40 of 54
- 41. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Business Tier
• The business tier provides various business services, such as business
data and business logic required by an application client in an enterprise
application.
• The various patterns available in the business tier are:
• Business Delegate
• Service Locator
• Session Facade
• Application Service
• Business Object
• Composite Entity
• Transfer Object
• Transfer Object Assembler
• Value List Handler
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 41 of 54
- 42. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Business Delegate Pattern
• The Business Delegate design pattern extracts and hides the details
required in implementing business services at client-side.
• A business service encapsulates the business logic and business state.
• The advantages of using the Business Delegate design pattern are:
• Reducing coupling by hiding the details of the business services,
such as naming and lookup mechanisms.
• Improving the performance of request services by caching the data
for presentation tier.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 42 of 54
- 43. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Service Locator Pattern
• The Service Locator design pattern is used by the Business Delegate
design pattern to trace the business services.
• The Service Locator design pattern locates the business services by
hiding the implementation details of the business services components.
• The advantages of using Service Locator design pattern are:
• Improving the network performance by eliminating the need of
creating and locating an object.
• Providing a centralized control and improving the performance of
the system through caching.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 43 of 54
- 44. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Session Facade Pattern
• The Session Facade design pattern is used when a client wants to
retrieve data from the server.
• This design pattern provides a remote reference layer, which exposes
the required interfaces to be used by the clients.
• The advantages of using the Session Facade design pattern are:
• Centralizing security management by managing security policies at
the client-end.
• Improving flexibility by introducing a layer between clients and
business tier to provide remote services to multiple clients.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 44 of 54
- 45. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Application Service Pattern
• The Application Service design pattern provides a uniform service layer
that implements business logic by hiding the complexity of business
services.
• The advantages of using the Application Service design pattern are:
• Avoiding the duplication of code by introducing a reusable business
logic layer.
• Improving the reusability of business logic by creating a set of
components that you can reuse across various use case
implementations. A use case implementation determines the
operations that a system performs.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 45 of 54
- 46. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Business Object Pattern
• The Business Object design pattern preserves the business data and
implements actions that are common to an enterprise application.
• The basic role of a business object is to represent the state and
behavior of information associated with business.
• The advantages of using the Business Object design pattern are:
• Providing a centralized and modular approach to multi-tier
components by implementing the rules and behavior of business
logic as separate components.
• Improving the maintainability of system by providing the
reusability and centralization of code.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 46 of 54
- 47. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Transfer Object Pattern
• The Transfer Object design pattern is used to carry multiple data
elements required by a request or a response in a single structure
across a tier.
• A transfer object is passed by value to a client and all the operations
are performed on duplicate copies of the transfer object.
• The advantages of using the Transfer Object design pattern are:
• Transmitting data of multiple clients over the network using a
single method call thereby reducing the network traffic.
• Reducing the duplication of code between an entity and its transfer
object.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 47 of 54
- 48. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Transfer Object Assembler Pattern
• The Transfer Object Assembler design pattern is used to create complex
transfer objects from session beans and entity beans.
• This design pattern is used to retrieve transfer objects from the
business components.
• The advantages of using the Transfer Object Assembler design pattern
are:
• Reducing the coupling between the clients and the application
model.
• Improving the client performance by creating the model without
using any client resources.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 48 of 54
- 49. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Value List Handler Pattern
• The Value List Handler design pattern accesses the persistent data
store, such as RDBMS at request time to provide a set of dynamically
created transfer objects.
• The advantages of using the Value List Handler design pattern are:
• Improving the network performance by sending only the required
result set instead of sending the whole result set that increases
unnecessary network traffic. A result set represents the results
obtained while executing a query.
• Improving the transaction management by caching the results on
the server side.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 49 of 54
- 50. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Integration Tier
• The integration tier communicates with the external resources, such as
data stores and applications.
• When a business object needs data or services that exist in the resource
tier, the business tier integrates with the integration tier to perform
these services.
• A resource tier contains the business data and the required services.
• The integration tier uses JDBC and J2EE connector technologies to work
with the resource tier.
• The various patterns available in the integration tier are:
• Data Access Object
• Service Activator
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 50 of 54
- 51. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Data Access Object Pattern
• The Data Access Object design pattern provides transparent access to
the persistent store in order to retrieve and store data.
• This design pattern contains a data access object, which does not cache
the result of executing a query that a client can need at a later stage.
• The advantages of using the Data Access Object design pattern are:
• Reducing complexity of data access client code by encapsulating
the code required interacting with the persistent storage.
• Enabling an application to easily migrate to a different database
implementation.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 51 of 54
- 52. Behavioral and J2EE Design Patterns
J2EE Design Patterns (Contd.)
• Service Activator Pattern
• The Service Activator design pattern enables you to receive messages
and perform asynchronous processing with EJB components, such as
session beans.
• The advantages of using the Service Activator design pattern are:
• Integrating JMS into enterprise applications to provide
asynchronous processing capabilities for any business-tier
component.
• Providing a standalone JMS listener that can run without using a
container.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 52 of 54
- 53. Behavioral and J2EE Design Patterns
Summary
In this lesson, you learned:
• The behavioral design pattern, defines the state, behavior, and
communication among the objects.
• The various behavioral design patterns are Chain of Responsibility,
Command, Interpreter, Iterator, Mediator, Memento, Observer, State,
Strategy, Template Method, and Visitor.
• The behavioral design patterns are concerned with how an object
behaves.
• A J2EE pattern is defined as a group of J2EE-based problems and its
solutions. The J2EE patterns are categorized into different tiers that
build up an application:
• Presentation tier
• Business tier
• Integration tier
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 53 of 54
- 54. Behavioral and J2EE Design Patterns
Summary (Contd.)
• The various presentation tier design patterns are Intercepting Filter, Front
Controller, Context Object, Application Controller, View Helper, Composite
View, Service to Worker, and Dispatcher View.
• The business tier provides various business services, such as business data
and business logic required by an application client in an enterprise
application.
• The various business tier design patterns are Business Delegate, Service
Locator, Session Facade, Application Service, Business Object, Transfer
Object, Transfer Object Assembler, and Value List Handler.
• The various integration tier design patterns are Data Access Object and
Service Activator.
©NIIT Architecting J2EE Solutions Lesson 3A / Slide 54 of 54