Welcome to CrossContext

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.

Implementation

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.

Simple web application usage

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 :

  • add CrossContext JAR to WEB-INF/lib, or to shared libraries directory of the Application Server,
  • specify CrossContextManagerFilter mapping in web.xml
  • * RDBMS or EJB context storage implementations are planned for for the next release

    What elese can it do?

    • Share the same request, session or application context across multiple tiers (if considered necessary).
    • Share a global context between different web applications deployed on the same Servlet container.
    • Introduce stateful behavior to Web Services.
    • etc..

    Get CorssContext

    CrossContext 1.0 : Download

    Help and Feedback

    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.