J2EE Design Pattern : Presentation Tier Patterns : Context Object Design Pattern
Context Object Design Pattern? |
Context Object avoid using protocol specific system information outside of its relevant context.
Context
An application typically uses system information, such as request, configuration, and security data, throughout the lifecycle of a request and response. Aspects of this system information are accessed based on their relevance to a certain processing context.
Problem
When application-specific components and services are exposed to system information that is outside their context, flexibility and reusability of these components are reduced.
Solution
Use a Context Object to encapsulate state in a protocol -independent way to be shared throughout your application.
Encapsulating system data in a Context Object allows it to be shared with other parts of the application without coupling the application to a specific protocol.
Context Object Class Diagram
Participants and Responsibilities
Client
It creates an object with ProtocolInterface.
ProtocolInterface
It is an object that exposes protocol or tier-specific details.
ContextFactory
A ContextFactory creates a protocol- and tier-independent ContextObject.
ContextObject
ContextObject is a generic object used to share domain-neutral state throughout an application.
Example for Context Object |
Recent Comments