aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Context Object Pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Context Object Pattern" Watch "Context Object Pattern" New topic
Author

Context Object Pattern

Aravind Ram
Greenhorn

Joined: Mar 06, 2008
Posts: 22
Hi all,

I've understood the J2ee patterns except Context Object Pattern.

Can somebody explain the Context Object Pattern, like its purpose ,how it is used and in what scenario it is used with an example if possible.

Thanks in advance !!
Aravind Ram
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Where did you see a Context Object Pattern


SCJP, SCJD, SCWCD, SCBCD
Lann Lu
Ranch Hand

Joined: May 31, 2008
Posts: 45
Please google it, there are plenty of resources talking about this pattern, It is explained there much better than me. :-)

http://www.cs.wustl.edu/~schmidt/PDF/Context-Object-Pattern.pdf
http://www.corej2eepatterns.com/Patterns2ndEd/ContextObject.htm

Cheers,
Tao
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Thanks Tao
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
In short it decouples software components from protocol-specific API.

For example, Web MVC framework such as Spring MVC, it creates domain object from ServletRequest, so we can have software components that work with domain object, that improves reuseability (can be used outside a web container) and testability (can be tested without a web container).


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Sorin Alexandru
Greenhorn

Joined: Nov 30, 2008
Posts: 28
Context Object wraps protocol specific information, such as HTTP and hides that from its clients. So it decouples the clients from the protocol-specific functionality.
A typical usage is:
- a FrontController creates a RequestContext object which wraps the HttpServletRequest
- the FrontController passes the RequestContext object to the ApplicationController
- now the ApplicationController is totally unaware of HTTP, so it works at a higher level of abstraction, e.g.: requestContext.getSomeParameter()
- the ApplicationController might pass the RequestContext object further, to a Command object (implementing the Service to Worker pattern)
- etc.
Aravind Ram
Greenhorn

Joined: Mar 06, 2008
Posts: 22
Thanks Sorin ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Context Object Pattern
 
Similar Threads
what is config object ?
Inversion of control
POJO class + Singleton
Connection pooling design pattern
J2EE Context Object design pattern