Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Sample of a Stateless Session Bean in EJB 3.0

...

Calculator.java: A stateless session bean that implements a simple java interface instead of an EJB component interface like EJBObject, EJBLocalObject or java.rmi.Remote. By annotating this class as a @Stateless session there is no need for a deployment descriptor to describe it separately. This class implements both a local and remote business interface, namely CalculatorLocal and CalculatorRemote.

...

...

CalculatorLocal.java: Since this is a local business interface, it is optional that the coder marks this class with a @Local annotation. A business interface which is not annotated with @Local or @Remote is assumed to be Local.

...

...

CalculatorRemote.java: Since this is a remote business interface, it must be annotated with the @Remote annotation.

...

CalculatorServlet.java: This is a servlet to process the form on the jsp page. It uses the stateless session bean Calculator to do some computation and returns the result. Note that CalculatorLocal is being annotated with the @EJB annotation. The ejb container will route every request to different bean instances. Note: a stateful session bean must be declared at the type level, whereas a stateless session bean may be declared at any level.

...

...

Deployment Plans

The structure of the deployable should look like the following:

...

application.xml: The JAR file is referenced to provide the functionality of this deployable. The WAR file is referenced in order to show the usage of this deployable through a web based interface. The context-root is set to be /calculator-stateless so that the URL for this application will be http://<hostname>:<port>/calculator-stateless.

...

...

geronimo-application.xml: Information about the project (e.g. module's unique identification, any dependencies) is described inside the <environment> tag. In this case, there are no dependencies so there is nothing to be listed. However, it is a good idea to give this module some sort of unique identification, so that it can later be referenced by some other deployable application.

...

Installation instructions

  1. Checkout the source code of this sample from SVN:

    svn checkout http://svn.apache.org/repos/asf/geronimo/samples/trunk/samples/calculator-stateless-pojo

  2. Build the source code by executing mvn install site command. That will create calculator-stateless-ear-2.0-SNAPSHOT.ear file in the current directory.
  3. Go to the $geronimo_home/bin directory and start the geronimo server.
  4. Deploy the calculator-stateless-ear-2.0-SNAPSHOT.ear file using the console by clicking on this link. The userid/password for the console is system/manager. Or to deploy using the command line, use the following command

    deploy --user system --password manager deploy <path to the ear file>

  5. Click on this url http://localhost:8080/calculator-stateless. Read the documentation there.
    info

    Once you go the sample application, click on the "source" tab in the top right hand corner to see the source code. Click on the "javadoc" tab to see the javadocs.