On Wed, 23 Aug 2000 17:39:26 +0530, Shiv Kumar <[EMAIL PROTECTED]>
wrote:
>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!

Sure it will. If the Deployer has coupled the MyEntity1 link to the
other server it will 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?

You should choose an EJB container that lets you point EJB-references
(the "java:comp/env/ejb/.." thing) to beans in another server, from
another vendor, on another machine.

..aaand...(surprise surprise)..

<vendor>
jBoss supports EJB-references to any server from any vendor on any
machine. We do this by internally linking the java: namespace to
JNDI-names in other namespaces. This is resolved by the Deployer. So,
you could let "java:comp/env/ejb/MyBean" reference
"t3://somehost/someapp/MyBean".
</vendor>

regards,
  Rickard

--
Rickard �berg

Email: [EMAIL PROTECTED]
http://www.telkel.com
http://www.jboss.org
http://www.dreambean.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