<document>
<header>
<product>resin-ee</product>
<resin-2.0>$ee/ejb-ref/corba.xtp</resin-2.0>
<title>CORBA/IIOP</title>
<description>
<p>
EJB 2.0 requires servers to implement CORBA/IIOP as a wire protocol.  So in
addition to the (preferred) usage of Burlap and Hessian as protocols, Resin-EE
makes CORBA/IIOP available.
</p>
</description>
</header>

  <body>
    <summary/>

<section title='Server Configuration'>

<p>The Resin CORBA server configuration is almost identical to the Burlap
or Hessian configuration.  The difference is that CORBA uses a dedicated 
port instead of a servlet to listen for CORBA requests.
Everything else is identical, including the <a config-tag="ejb-server"/>, so
beans do not need to be aware which wire protocol is used.</p>

<example title='resin.conf'>
&lt;server&gt;

 ...

 &lt;port port="2099"&gt;
   &lt;protocol resin:type="com.caucho.iiop.IiopProtocol"/&gt;
 &lt;/port&gt;

 ...

&lt;/server&gt;
</example>

<example title="webapps/appname/WEB-INF/web.xml">
&lt;web-app&gt;

  ...

  &lt;ejb-server config-directory="WEB-INF"/&gt;

  ...

&lt;/web-app&gt;

</example>

</section>

<section title='Client Example'>

<p>Clients will use JNDI to look up beans in the server.  The JNDI name
uses the same name as the bean's Burlap URL.  If the EJBServlet is at
http://localhost:8080/app/ejb, the IIOP server is localhost:2099, and
the bean name is "hello",
the JNDI path will be /localhost:2099/hello.</p>

<example title="CORBA client">
import javax.naming.*;

env.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
env.put("java.naming.provider.url", "iiop://localhost:2099/hello");
Context ejb = new InitialContext(env);
Object helloHomeObj = ctx.lookup("hello");
HelloHome helloHome = 
  (HelloHome) PortableRemoteObject.narrow(helloHomeObj, HelloHome.class);
</example>

<p>You can also use Resin's jndi features to configure the factory:</p>

<example title="corba jndi client configuration">
&lt;web-app&gt;

   ...

  &lt;jndi-link jndi-name='java:comp/env/ejb'
             factory='com.sun.jndi.cosnaming.CNCtxFactory'&gt;
    &lt;init-param java.naming.provider.url='http://localhost:2099/hello'/&gt;
  &lt;/jndi-link&gt;

</example>

<example title="corba jndi client code">
Context ejb = (Context) new InitialContext().lookup("java:comp/env/ejb");
Object helloHomeObj = ejb.lookup("hello");
HelloHome helloHome =
  (HelloHome) PortableRemoteObject.narrow(helloHomeObj, HelloHome.class);
</example>

</section>
</body>
</document>
