Results 1 to 5 of 5

Thread: JNDI BeanFactory lookup

  1. #1

    Default JNDI BeanFactory lookup

    I have a web application in context A needs access to some APIs provided by a web application in context B. I'm going to create a set of interfaces to define the APIs that application A can access.

    This library of interfaces will also include factories. My current idea is the factories have a utlity that will do a lookup via JNDI for a BeanFactory and then the factories will use the BeanFactory to create instances of the interfaces. The BeanFactory would be configured and implementations of the interfaces provided by the application in context B.

    This will keep any spring code out of the application in context A that depend only on the factories and interfaces API and allow for the actual application in context B to be swapped out more easily.

    I looked at using the JndiBeanFactoryLocator for the factories to find the bean factory but I don't know how to setup a bean factory to be accesable via jndi. Any pointers will be much appreciated.

    -Eric Dalquist

  2. #2
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    Binding a beanfactory in the JNDI tree is not recommended. You're basically violating the spec by doing so; each and every object in the JNDI tree should be serializable.

    We've done this in the past and have our internal class to do this, extending the ApplicationContext to add Serializalbe to it.

    I think the better option would be to make your beans in context B remotely accessible by using HttpInvokers, Hessian, Burlab or RMI. Spring provides excellent support for all four of those and it'll be completely transparant to your application (have a look at the reference manual for more info on remoting).

  3. #3
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Alef,

    What if Contexts A and B use the same JVM. Is Spring Remoting sweetable for such case?
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  4. #4

    Default

    They will both be in the same JVM. The main issue with the contexts is classloaders. Since, in tomcat at least, the each context has it's own classloader. The point of the interfaces is to put them in a shared lib folder to work around the classloader problem. The interfaces factories would use JNDI to find the implementation of the interfaces provided by some application in the JVM. The idea then is that the common interfaces won't have any knowledge of the actual implementation.

  5. #5
    Join Date
    Aug 2004
    Location
    Hawaii, US
    Posts
    225

    Default

    While I agree with Alef that it's not a great idea to bind a beanfactory into JNDI, we have one reason why we need to do this.

    We need to access some shared services from all webapps. Usually, the HttpInvoker would be perfect for this. But, we also need to maintain the thread context (and its authentication information) throughout the entire call. Accessing remote services, even if they are in the same application server, would lose this caller identity.

    There are a few services that a full blown J2EE server might provide, like authentication information propogation that we just don't have in Tomcat. By binding the BeanFactory into JNDI (which wasn't easy on Tomcat, let me tell you) we can access a shared singleton of the service from all webapps and within the same thread.

    Now, if maybe Acegi Security Plugin would include a Tomcat authentication identity Valve and then propogate this information across HttpInvoker calls, we might be on to something.

Similar Threads

  1. Replies: 7
    Last Post: Aug 29th, 2011, 05:01 AM
  2. Replies: 4
    Last Post: Jan 17th, 2007, 01:01 AM
  3. JNDI DataSource lookup outside of JBoss
    By cpmcda01 in forum Data
    Replies: 4
    Last Post: Jun 15th, 2005, 03:56 PM
  4. Replies: 2
    Last Post: Jun 8th, 2005, 01:26 AM
  5. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 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
  •