You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by bu...@apache.org on 2012/01/20 22:16:04 UTC

svn commit: r802985 - /websites/staging/openejb/trunk/content/ejb-refs.html

Author: buildbot
Date: Fri Jan 20 21:16:04 2012
New Revision: 802985

Log:
Staging update by buildbot for openejb

Modified:
    websites/staging/openejb/trunk/content/ejb-refs.html

Modified: websites/staging/openejb/trunk/content/ejb-refs.html
==============================================================================
--- websites/staging/openejb/trunk/content/ejb-refs.html (original)
+++ websites/staging/openejb/trunk/content/ejb-refs.html Fri Jan 20 21:16:04 2012
@@ -163,20 +163,18 @@ xml.  The following would be added to th
     <session>
       <ejb-name>SquareBean</ejb-name>
       <ejb-ref>
-    <ejb-ref-name>com.foo.shapes.SquareBean/orangeRemote</ejb-ref-name>
-    <ejb-ref-type>Session</ejb-ref-type>
-    <remote>com.foo.colors.OrangeRemote</remote>
-    <ejb-link>colorsApp.jar#OrangeBean</ejb-link>
-    <injection-target>
-</code></pre>
-
-<p><injection-target-class>com.foo.shapes.SquareBean</injection-target-class>
-          <injection-target-name>orangeRemote</injection-target-name>
-        </injection-target>
-          </ejb-ref>
-        </session></p>
+        &lt;ejb-ref-name&gt;com.foo.shapes.SquareBean/orangeRemote&lt;/ejb-ref-name&gt;
+        &lt;ejb-ref-type&gt;Session&lt;/ejb-ref-type&gt;
+        &lt;remote&gt;com.foo.colors.OrangeRemote&lt;/remote&gt;
+        &lt;ejb-link&gt;colorsApp.jar#OrangeBean&lt;/ejb-link&gt;
+        &lt;injection-target&gt;
+          &lt;injection-target-class&gt;com.foo.shapes.SquareBean&lt;/injection-target-class&gt;
+          &lt;injection-target-name&gt;orangeRemote&lt;/injection-target-name&gt;
+        &lt;/injection-target&gt;
+      &lt;/ejb-ref&gt;
+    &lt;/session&gt;
 
-<pre><code>  &lt;/enterprise-beans&gt;
+  &lt;/enterprise-beans&gt;
 &lt;/ejb-jar&gt;
 </code></pre>
 
@@ -185,6 +183,45 @@ above example would still work as there 
 match the <ejb-ref-name> and no one will likely be looking up the EJB as
 it's injected.</p>
 
+<h1>Referencing a bean in another server</h1>
+
+<p>As of OpenEJB 4.0.0-beta-3, server to server references work.</p>
+
+<p>First we need to configure and name the InitialContext that will be used to satisfy the lookup to the other server.</p>
+
+<p>In this example we are calling our InitialContext <code>shoe</code> for fun.</p>
+
+<pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
+&lt;openejb&gt;
+
+  &lt;JndiProvider id="shoe"&gt;
+    java.naming.provider.url = ejbd://localhost:4201
+    java.naming.factory.initial = org.apache.openejb.client.RemoteInitialContextFactory
+  &lt;/JndiProvider&gt;
+
+&lt;/openejb&gt;
+</code></pre>
+
+<p>Declaring the <code>@EJB</code> reference is then done using a <code>mappedName</code>  that references the named <code>InitialContext</code></p>
+
+<pre><code>public class BlueBean implements BlueRemote {
+
+    @EJB(mappedName = "jndi:ext://shoe/OrangeBeanRemote")
+    private OrangeRemote orangeRemote;
+
+    public void hasOrangeRemote() {
+        Assert.assertNotNull("orangeRemote is null", orangeRemote);
+        assertEquals("olleh", orangeRemote.echo("hello"));
+    }
+}
+</code></pre>
+
+<p>Specifically, the <code>mappedName</code> syntax is as follows:</p>
+
+<ul>
+<li>jndi:ext://<code>&lt;contextId&gt;</code>/<code>&lt;jndiName&gt;</code></li>
+</ul>
+