Counter Stateful Session Bean Example has been created by filippo diotalevi (Jan 09, 2007).

Content:

Overview

An error occurred: http://svn.apache.org/repos/asf/incubator/openejb/trunk/openejb3/examples/counter-stateful-pojo/README.txt. The system administrator has been notified.

The Code

In this example we develop a simple counter stateful session EJB.

Local business interface
@Local annotation

Note that it's not mandatory to annotate local business interfaces with the @Local annotation. If a business interface doesn't have any annotation, it's assumed to be local by the ejb container.


Remote business interface


Bean

Writing a unit test for the example

Writing an unit test for the stateful session EJB is quite simple. We need just to write a setup method to create and initialize the InitialContext, and then write our test methods

setUp


Note the "openejb.deployments.classpath.include" parameter, which tells the ejb container to search for EJBs in the classpath, and specifies in which java packages they are to be located.

Test the local business interface


Test the remote business interface


Running

Running the example is fairly simple, just run:

$ cd counter-stateful-pojo
$ mvn clean install

Which should create output like the following.

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
[surefire] Running org.apache.openejb.examples.counter.CounterImplTest
log4j:WARN No appenders could be found for logger (OpenEJB).
log4j:WARN Please initialize the log4j system properly.
Apache OpenEJB 3.0-incubating-SNAPSHOT    build: 20070105-12:45
http://incubator.apache.org/openejb
OpenEJB ready.
[surefire] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 1.943 sec
[INFO] [jar:jar]
[INFO] Building jar: openejb3/examples/counter-stateful-pojo/target/simple-counter-statefuls-1.0-SNAPSHOT.jar
[INFO] [install:install]
[INFO] Installing openejb3/examples/counter-stateful-pojo/target/simple-counter-statefuls-1.0-SNAPSHOT.jar to /.m2/repository/org/apache/openejb/simple-counter-statefuls/1.0-SNAPSHOT/simple-counter-statefuls-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------

Reply via email to