EJBs: review

As a reminder, and Enterprise JavaBean has a minimum of three classes, the remote interface, the home interface, and the bean implementation. The remote interface is the class that exposes the methods of the EJB to the outside world. In the example, the remote interface is the class org.jboss.docs.interest.Interest. The home interface specifies how to create a bean that implements the remote interface. In this example, the home interface is org.jboss.docs.InterestHome. The bean implementation provides an implementation of the methods specified by the remote and home interfaces. In this example, the Bean class is org.jboss.docs.interest.InterestBean.

Of course, a Bean can include other classes, or even other packages, but the classes listed above are the minimum. The classes must be packaged into a JAR archive with a directory structure that reflects the hierarchy of packages. In the example, the classes are in the package org.jboss.docs.interest, so they need to be in the directory org/jboss/docs/interest/ which is what you will find in the examples distribution.

Before the jar archive with all the classes is created there must be a directory called META-INF to store the deployment descriptor (always called ejb-jar.xml) and -- optionally -- another XML file to tell the server about application specific server infomormation. With JBoss, this file must be called jboss.xml.

The jar file you created is then deployed on the JBoss server. On the client side you need a jndi.properties file that tells your client where to initially find the JNDI naming service. From this service the client will look up the Interest bean and get back the home interface of the bean. The home interface is used to get a remote interface of the bean. He can now use this remote interface to access the functions provided by the Enterprise Java Bean a.k.a EJB.