Hi all

Most of the time we are assuming that all EJBs are deployed on the same machine.
Assume that I have three EJBs

  1. MySession
  2. MyEntity1
  3. MyEntity2

The EJB MySession references the other two EJBs, MyEntity1 and MyEntity2. So, I
have <ejb-ref> entries in ejb-jar.xml to refer to the target EJBs. I also use
the standard code to refer these entity EJBs.

     // Obtain the default initial JNDI context.
     Context initCtx = new InitialContext();
     // Look up the home interface of the MyEntity1Home
     // enterprise bean in the environment.
     Object result = initCtx.lookup("java:comp/env/ejb/MyEntity1");
     // Convert the result to the proper type.
     MyEntity1Home home = (MyEntity1Home)
       PortableRemoteObject.narrow(result, MyEntity1Home.class);

Suppose all three EJBs are deployed on three different machines, this code will
not work! So, I have to use the InitialContext(Hashtable) version of the
constructor to pass the provider url.

     Hashtable env = new Hashtable();
     env.put(Context.PROVIDER_URL,  "appserver_url");
     ...

And I do not want to hard code the 'appserver_url' in my code. I should give a
chance for the Application Assember and Deployer to change the URL because they
will know where the EJBs are actually insalled. So, the bean code should be
changed to get the URL from bean's environment context

     <env-entry>
       <env-entry-name>MyEntity1URL</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>appserver_url</env-entry-value>
     </env-entry>

For each EJB referenced, there should be a separate env entry, to make the
solution really flexible. The actual bean code becomes bloated because of all
these extra work.

Is there any other easier way to solve this problem?

TIA.
--
shiv
[EMAIL PROTECTED]



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to