The Enterprise Server supports and is compliant with the Sun Microsystems Enterprise JavaBeans (EJB) architecture as defined by the Enterprise JavaBeans Specification, v3.1, also known as JSR 318.
The main changes in the Enterprise JavaBeans Specification, v3.1 that impact enterprise beans in the Enterprise Server environment are as follows:
An EJB component need not implement any interface as long as it contains one of the component defining annotations or the XML equivalent. Essentially, the local business interface is optional. For example, the following is a simple no-interface bean:
@Stateless public class HelloBean { public String sayHello(String msg) { return "Hello " + msg; } }
Even though the bean doesn't implement any interface, the client can still inject (or look up) a reference to the session bean. The client still has to perform a JNDI lookup or inject a reference of the bean. More specifically, it cannot use the new operator to construct the bean.
@EJB HelloBean h; ... h.sayHello("bob");
EJB classes can be packaged inside WAR files. These classes must reside under WEB-INF/classes. For example, the structure of a hello.war file might look like this:
index.jsp META-INF/ MANIFEST.MF WEB-INF/ web.xml classes/ com/ sun/ v3/ demo/ HelloEJB.class HelloServlet.class
For more information about web applications, see Chapter 7, Developing Web Applications.