jndi context

Discussions

EJB design: jndi context

  1. jndi context (1 messages)

    Hi,

    While refering another bean, we have to lookup its remote interface in jndi context. Normally we use following construct

    Context jndiContext = new InitialContext()
    Object objRef = jndiContext.lookup("<bean-jndi-name>")

    Here it is assumed that the referenced bean is deployed on the same server. But if we want to refer to a bean which is on a remote server, we have to provide the location of the that server while getting the jndi context. For this we have to hardcode the address of the other server in our bean. But this is a problematic situation. Can anybody suggest a better way to do this ? (for example using properties file)

    -Sujit Nene

    Threaded Messages (1)

  2. jndi context[ Go to top ]

    1) Don't use the JNDI name for one bean to look up another. Check out the ejb-ref tags in the deployment descriptor which allow you to decouple your code from what the deployer chooses to name the beans.

    2) If the bean is merely on another server in the same cluster, then don't do anything, let the server take care of load balancing issues for you, that's its job.

    3) If the bean is on another server, not in the same cluster, then simply include the relevant properties in the call to the construction of the InitialContext object, which will point you at the other server.

    Hope that helps

    Chz

    Tony