CrossContext is an independent abstraction of request, session, application and custom user contexts. It removes compile-time and run-time dependency of you code on any particular API, like Java Servlet API, thus increasing code portability and alows code reuse inside Web-tier, Swing rich client, or even EJBs or Web Services.
CrossContext supports multithreading key-based synchronization and timed locking.
* Distributed synchronization is planned for the next release.
CrossContext uses java.lang.ThreadLocal class to allow accessing to any context without having its reference, just as JNDI resource lookup. To access to HttpSession or HttpServlerResponse , its reference must be available inside the method, however, no external reference is needed to access to JNDI.
Similarly, once bind to the current thread, CrossContext is available from any method of any class as long as we stay inside the thread. Such feature is especially important for code evolution, especially if method signatures must stay intact for the reason of backward compatibility.
In addition, developer can create their own contexts with a custom scope.
For a web application, CrossContext is usually backed with HttpServletRequest, HttpSession and ServletContext implementations. However, you can choose another back-end. You might prefer to use RDBMS or EJB context storage to share the application context across multiple nodes in a cluster (as an alternative to HttpSession replication).
Use org.crosscontext.http.CrossContextManagerFilter to assign and release automatically contexts backed with HttpServletRequest, HttpSession and ServletContext.
Developer simply needs to :
* RDBMS or EJB context storage implementations are planned for for the next release
If you have any questions, propositions, suggestions or comments about CrossContext or this website, please feel free to post them to me shevit@users.sourceforge.com.