Announcement Announcement Module
Collapse
No announcement yet.
inject bean defined in a different applicationContext as singleton Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • inject bean defined in a different applicationContext as singleton

    Hi!

    i have two application contexts 1) app.xml of a web application and 2) service.xml of a non-web application. the latter provides beans that implement a session pool of a legacy application. This pool should be used as a singleton by all applications that run in the appserver. is there a possibility to inject this service bean defined in service.xml as a singleton into a bean defined in the app.xml? would this be somhow possible with a SingletonBeanFactoryLocator? If yes, how?

    Thanks!

  • #2
    There are various ways of doing this. How does your service.xml context get loaded?

    Comment


    • #3
      yeah, that's a good question. i do not know how to do this. i have my classes, and i have related objects wired with spring. i test the whole thing with:

      Code:
      AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("service.xml");
      but how can i load it when the appserver is started? and then place it into the JNDI tree? And then access it? i don't know.

      Comment


      • #4
        Originally posted by iliad View Post
        but how can i load it when the appserver is started? and then place it into the JNDI tree? And then access it? i don't know.
        How to load a server-wide module when the app server starts is vendor specific, I guess. But once you have put the bean into JNDI, all you need to do is implement a FactoryBean to get it and inject it into other beans.

        Comment

        Working...
        X