Accessing Application Context in standalone client, EJB and Servlet
I'd like to write code which works whether the client is running standalone, in an EJB or a Servlet. But my problem is that in each of the 3 scenarios the way we access the Application Context is different.
I can get hold of the Application Context via WebApplicationContextUtils.getRequiredWebApplicati onContext from a servlet.
I can get hold of the Application Context via ??? (sorry can't remember how!) from an EJB.
I assume a standalone client would have to implement ApplicationContextAware and set the context via a call to setApplicationContext().
I need a handle to the Application Context to pull out JMS destination info.
My question is, given the approaches differ whether I am in container or not, is there any way to write code which hides these differences?