Skip to content

Latest commit

 

History

History
105 lines (83 loc) · 4.1 KB

README-source.adoc

File metadata and controls

105 lines (83 loc) · 4.1 KB

ejb-remote: Remote EJB Client Example

The ejb-remote quickstart uses EJB and JNDI to demonstrate how to access an EJB, deployed to {productName}, from a remote Java client application.

What is it?

The ejb-remote quickstart shows how to access an EJB from a remote Java client application. It demonstrates the use of EJB and JNDI in {productNameFull}.

There are two components to this example:

  1. A server side component:

    The server component is comprised of a stateful EJB and a stateless EJB. It provides both an EJB JAR that is deployed to the server and a JAR file containing the remote business interfaces required by the remote client application.

  2. A remote client application that accesses the server component.

    The remote client application depends on the remote business interfaces from the server component. This application looks up the stateless and stateful beans via JNDI and invokes a number of methods on them.

Building and running the quickstart application with a {productName} server distribution

Investigate the Console Output

When the client application is run by the EJBRemoteIT tests, it performs the following steps:

  1. Obtains a stateless session bean instance.

  2. Sends method invocations to the stateless bean to add two numbers, and then displays the result.

  3. Sends a second invocation to the stateless bean subtract two numbers, and then displays the result.

  4. Obtains a stateful session bean instance.

  5. Sends several method invocations to the stateful bean to increment a field in the bean, displaying the result each time.

  6. Sends several method invocations to the stateful bean to decrement a field in the bean, displaying the result each time.

The following output is displayed in the terminal window:

Obtained a remote stateless calculator for invocation
Adding 204 and 340 via the remote stateless calculator deployed on the server
Remote calculator returned sum = 544
Subtracting 2332 from 3434 via the remote stateless calculator deployed on the server
Remote calculator returned difference = 1102
Obtained a remote stateful counter for invocation
Counter will now be incremented 5 times
Incrementing counter
Count after increment is 1
Incrementing counter
Count after increment is 2
Incrementing counter
Count after increment is 3
Incrementing counter
Count after increment is 4
Incrementing counter
Count after increment is 5
Counter will now be decremented 5 times
Decrementing counter
Count after decrement is 4
Decrementing counter
Count after decrement is 3
Decrementing counter
Count after decrement is 2
Decrementing counter
Count after decrement is 1
Decrementing counter
Count after decrement is 0

Logging statements have been removed from this output here to make it clearer.