How to pass my application-specific context to EJB methods?

Discussions

EJB programming & troubleshooting: How to pass my application-specific context to EJB methods?

  1. Hello,

    We have developed an application that consists of a significant amount of web-tier code (mostly in HTTP servlets) and EJB-tier code (all stateless session beans).

    I would like to be able to pass some context from the web tier (HTTP servlets) to the EJB tier (stateless session EJB methods). Some of the things I would like to store in this context would be:
    * my user object (a Java object that represents application-specific access rights of the currently logged in user)
    * viewing locale
    * viewing timezone
    Etc.

    The trick is to do it *** TRANSPARENTLY ***, that is without having to modify the signature of the stateless session EJB method that requires this call context information.

    I know that the EJB container already sets up a session context, from which one can find out certain things, such as the name of the user on whose behalf the method is being executed. If I could somehow add some stuff (see above) to this context that would solve my issue.

    Alternatively, I could always create some sort of CallerContext object in which I would store the bits described above, and pass it to each EJB method that needs it. But I do not like this idea, since it would require that I modify the signatures of all EJB methods that need this information.

    Please, any suggestions are welcome.
    Thanks
    Greg
  2. see this thread:

    https://www.theserverside.com/discussion/thread.jsp?thread_id=13056
  3. Noone seems to be following the thread 13056, so I will post my follow-up question here:

    Re: discussion on how IBM implements this via their WorkArea object:

    My guess is the JNDI key involves some IBM-specific session ID that is passed from the webtier to the EJB tier so that both know about it and therefore can get to the right JNDI entry.

    If that is the case, I don't see how one can simulate the WorkArea concept without having the support from the app server vendor.

    Also,

    does anyone know whether a facility like "WorkArea" is available for Weblogic Server?

    Thanks
    Greg