Results 1 to 4 of 4

Thread: inject bean defined in a different applicationContext as singleton

  1. #1
    Join Date
    Sep 2006
    Posts
    19

    Question 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. #2
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    There are various ways of doing this. How does your service.xml context get loaded?
    --Jing Xue

  3. #3
    Join Date
    Sep 2006
    Posts
    19

    Default

    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.

  4. #4
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    Quote 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.
    --Jing Xue

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •