Creating a Stateless Session Bean
Now you can move on to actually creating your first EJB. To begin, create a new subdirectory called ejb in your com/bfg source hierarchy. You're going to move the logic that computes sales tax into a bean called Cart. Start by writing the remote interface (see Listing 17.1), which extends EJBObject. There's not much to it really—it just declares the calling parameters for the computeTax call and specifies that it throws RemoteException, as all EJB beans must.
By convention, if a bean implements a functionality called Foo, the remote interface is called Foo, the home interface is called FooHome, and the enterprise bean is called FooBean.
Listing 17.1. Cart.java
package com.bfg.ejb.cart; import javax.ejb.EJBObject; ... |
Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.