...
We're going to embed OpenEJB3 into a plain JUnit TestCase as a simple means of demonstrating the remote capabilities. We'll do the embedding in our test setUp method, then will make two test methods:
- one for invoking the bean's remote interface via the LocalInitialContextFactory which goes straight against the embedded container system
...
- one for invoking the bean's remote interface via the RemoteInitialContextFactory which connects to a Socket and communicates to the embedded container system over the ejbd protocol.
...
setUp
Wiki Markup |
---|
{snippet:id=setup|url=openejb3/examples/telephone-stateful/src/test/java/org/apache/openejb/examples/telephone/TelephoneTest.java|lang=java} |
LocalInitialContextFactory: making in-vm calls to a remote business interface
Wiki Markup |
---|
{snippet:id=localcontext|url=openejb3/examples/telephone-stateful/src/test/java/org/apache/openejb/examples/telephone/TelephoneTest.java|lang=java} |
RemoteInitialContextFactory: making networked calls to a remote business interface
This is the part you would want to do in apps that are running a different VM than the one in which the ejb container is embedded. These "client" VMs need only have the the openejb-client jar in their classpath and connect to OpenEJB via the RemoteInitialContextFactory like any other remote EJB client.
Wiki Markup |
---|
{snippet:id=remotecontext|url=openejb3/examples/telephone-stateful/src/test/java/org/apache/openejb/examples/telephone/TelephoneTest.java|lang=java} |
...