©


Core J2EE Pattern Catalog

© CoreJ2EEPatterns
All Rights Reserved.

Last Updated:
January 29, 2006 8:54 PM

 

In Association with Amazon.com


Context Object

See Core J2EE Patterns, 2nd Edition for full description of this pattern and its strategies.

Problem

You want to avoid using protocol-specific system information outside of its relevant context.

Forces

  • You have components and services that need access to system information.
  • You want to decouple application components and services from the protocol specifics of system information.
  • You want to expose only the relevant APIs within a context.

Solution

Use a Context Object to encapsulate state in a protocol-independent way to be shared throughout your application.

Class Diagram

Sequence Diagram

Strategies

  • Request Context Strategies
    • Request Context Map Strategy
    • Request Context POJO Strategy
    • Request Context Validation Strategy
  • Configuration Context Strategies
    • JSTL Configuration Strategy
    • Security Context Strategy
  • General Context Object Strategies
    • Context Object Factory Strategy
    • Context Object Auto-Population Strategy

Consequences

  • Improves reusability and maintainability
  • Improves testability
  • Reduces constraints on evolution of interfaces
  • Reduces performance

Related Patterns

  • Intercepting Filter
    An Intercepting Filter can use a ContextFactory to create a Context Object during web request handling.
  • Front Controller
    A Front Controller can use a ContextFactory to create a Context Object during web request handling
  • Application Controller
    An Application Controller can use a ContextFactory to create a Context Object during web request handling
  • Transfer Object
    A Transfer Object is used specifically to transfer state across remote tiers to reduce network communication, while a Context Object is used to hide implementation details, improving reuse and maintainability.
Contact Us © CoreJ2EEPatterns.com. All Rights Reserved. Terms of use