Announcement Announcement Module
Collapse
No announcement yet.
Accessing the ApplicationContext from a non-spring bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accessing the ApplicationContext from a non-spring bean

    Hi all, I'm a newbie so it might be that I haven't found the solution to my problem as provided by Spring.

    I need to access a DAO I created using HibernateTemplate from a JAAS Callback Class that is not managed by the spring container... How can I get a reference to the ApplicationContext?

    One option is to add a property to the Callback class to hold the DAO, however I cannot change the code that creates and execute the instance of the class...

    I have thought of the following alternatives:
    * Lookup the application context using something like jndi.
    * Have a ApplicationContext Factory (Initializing it on server startup)

    What would your suggestions be?

    Best Regards,

    Jose M. Selman

  • #2
    I think those options are pretty much it. Other ways of creating Application contexts tend to require Spring to be injected in way that requires code or configuration change (like a Servlet listener, or using the Spring EJB classes.)

    Comment


    • #3
      Inside a web container, if you start Spring using the contextListener you can access it from the ServletContext.

      Comment

      Working...
      X