Results 1 to 6 of 6

Thread: Looking up beanfactory

  1. #1

    Default Looking up beanfactory

    Hi
    I am new to spring so this might be trivial, but I can't figure out how to get this working.
    I have some business logic running on a application server (Jboss) where i uses spring as my bean manager. I have created a XmlBeanFactory, and bound it to jndi in the server. When i shall use the bean factory I first lookup the beanfactory from jndi and the lookup the bean (factory.getBean("mybean")). Is this the right way to do it?

    Furthermore I will have to use some of the same beans in my frontend (servlets). I works fine creating it own beanfactory with the listener org.springframework.web.context.ContextLoaderListe ner. But I can't find a way to get the 2 beanfactorys to see eachother, looking backend/business beans up from the frontend. How could i do this?
    Thougt abot making the backend/business factory parrent to the servlets factory but how?

    Hope I just missing something obvious but what?

    Thanks in advantage
    /Kasper

  2. #2

    Default AplicationContext

    Hi
    I have a application running in my j2ee server using a XmlBeanFactory. I want my frontend applications (servlets to access the same beanfactory) How can I combine a servlets beanfactory with my already existing XmlBeanFactory
    Can i somehow set the servlets parent BeanFactory to my XmlbeanFactory?

    I could really need a hint, about how to achieve this functionality, or if i am doing something conceptual wrong?

  3. #3
    Join Date
    Aug 2004
    Location
    u.s.a
    Posts
    399

    Default

    Did you look in the ejb support section here? Like:

    http://forum.springframework.org/showthread.php?t=9831


    afaik, the ejb "example" in cvs is the only example thats available for how to do something like what you ask. If there are others, I'd like to see them myself, I'm having ejb load and classpath issues with contexts.
    Last edited by robyn; May 14th, 2006 at 09:49 AM.

  4. #4
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    The ejbtest integration test sample in the CVS tree shows how you can use the ContextSingletonBeanFactoryLocator in order to share an appcontext as both the parent of the web appcontext, and to be used directly from EJBs...

    http://cvs.sourceforge.net/viewcvs.p...btest/#dirlist
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  5. #5

    Default Jndi or jmx lookup of ApplicationContext

    Thanks for the answers.
    I am not using any EJB's but I tried to use the FileSystemXmlApplicationContext instead of the XmlBeanFactory, and now i can use this as parent context;
    I then registered this factory to jboss jndi and looked it up again in the webaplication where it is used as parent context for the webapp.

    So for now I am happy and all seams to work fine
    Just a little curious about the jndi lookup of the ApplicationContext. Saw someone waring about this method(classcast problem), but is there any other way to use the same beanfactory in many different applications running in the same application server?
    As I see the JMX work in spring 1.2 will make the jndi lookup unnecessary, am I right?

    /Kasper

  6. #6
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Generally different apps running the same app server are not supposed to see each other (according to the spec) with only j2ee authentication information potentially being shared, so the only mechanisms you can use to share data across them are things like JNDI or taking advantage of the classloader hierarchy that may exist in the appserver and putting some things in a shared parent classloader.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. BeanFactory, FactoryBean and &
    By cherrick in forum Architecture
    Replies: 1
    Last Post: Aug 23rd, 2005, 07:42 PM
  2. Simple BeanFactory
    By strbuf in forum Container
    Replies: 1
    Last Post: May 20th, 2005, 06:11 PM
  3. JNDI BeanFactory lookup
    By edalquist in forum Container
    Replies: 4
    Last Post: Dec 16th, 2004, 02:18 PM
  4. Root of BeanFactory hierarchy
    By wangdongzjk in forum Data
    Replies: 3
    Last Post: Nov 28th, 2004, 10:33 PM
  5. Replies: 2
    Last Post: Aug 27th, 2004, 01:41 AM

Posting Permissions

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