Discussions

EJB programming & troubleshooting: Access to Session Context

  1. Access to Session Context (1 messages)

    In our application we want to be able to access the Session Context from classes other than the Session Bean itself. Specifically, we will have our business logic in separate classes, which will be called by the session beans; as well as Data Access Objects, which will be called by the business classes. Both will need access to the context from time to time.

    We would rather not pass the context into all business classes and data object just for the few times we may need it. Is there a way to access the context without a reference to the session?

    Assuming the answer is no, we will be creating a singleton which has a map of contexts. The context will be added when the session bean's business method is called, and removed when it finishes. The key would be the current thread. What problems might I run into with this system?
  2. Access to Session Context[ Go to top ]

    I think in this scenario, the session context will be passed by refence rather than value...unless the helper classes are EJBs again... so passing the sessioncontext would be cheaper than using a singlton-lookup approach.