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>
+ <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>
+ <injection-target-class>com.foo.shapes.SquareBean</injection-target-class>
+ <injection-target-name>orangeRemote</injection-target-name>
+ </injection-target>
+ </ejb-ref>
+ </session>
-<pre><code> </enterprise-beans>
+ </enterprise-beans>
</ejb-jar>
</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><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<openejb>
+
+ <JndiProvider id="shoe">
+ java.naming.provider.url = ejbd://localhost:4201
+ java.naming.factory.initial = org.apache.openejb.client.RemoteInitialContextFactory
+ </JndiProvider>
+
+</openejb>
+</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><contextId></code>/<code><jndiName></code></li>
+</ul>
+