A simple stateless session bean

I base my example on the simple stateless example from OpenEJB, an
embeddable and lightweight EJB 3.0 implementation. I have based my code as
closely as possible to the original, for the sake of comparison.

The local interface

The local interface is fairly simple. There are no annotations needed, and is
easily written with a simple definterface.

Similar to the remote interface, the bean is annotated, this time with
#^{Stateless {}} for javax.ejb.Stateless. Otherwise, this type is
implemented just like any other using deftype.

And that is all there is to it. You can AOT compile the above forms, and you
will have a working stateless session bean you can drop into any EJB container.

Get the bean from GitHub

I have created ejb-annot, a simple Clojure project that implements the
above bean, along with some unit tests to show that the bean will work. It
uses an embedded OpenEJB instance as the bean container.

Note that it is ejb-test and not test. This is because OpenEJB seems to
have some issues when running from within the same JVM as Leiningen, due to
some class loading issues. Also, for OpenEJB to automatically discover the
bean, it needs to find an ejb-jar.xml in the same path as the class files.

Final thoughts

Annotations in Clojure are dead simple and will help make Clojure more Java EE
friendly. In fact it was an order of magnitude more difficult to get the tests
to run within Leiningen than it was to implement the bean and the tests.