Before going on, let s first establish some conventions. (Apache web server)
Sunday, September 30th, 2007Before going on, let s first establish some conventions. When we speak about an enterprise bean as a whole, its component interfaces, bean class, and so forth, we will call it by its common business name, followed by the word bean. For example, an enterprise bean that is developed to model a cabin on a ship will be called the Cabin EJB. Notice that we didn t use a constant width font for Cabin. We do this because we are referring to all the parts of the bean (the component interfaces, bean class, etc.) as a whole, not just one particular part like the remote interface or bean class. The term enterprise bean denotes any kind of bean including entity, session, or message-driven beans. Similarly, entity bean denotes a entity type enterprise bean; session bean a session type enterprise bean; and message-driven bean a message-driven type enterprise bean. It s popular to use the acronym EJB for enterprise bean, a style adopted in this book to distinguish an enterprise bean as a whole from its component parts. We will also use suffixes to distinguish between local component interfaces and remote component interfaces. When we are talking about the remote interface of the Cabin EJB we will use combine the common business name with the word Remote. For example, the remote interface for the Cabin EJB is called the CabinRemote interface. In EJB 2.0, the local component interface of the Cabin EJB would be the CabinLocal interface. The home interfaces follow the convention by adding the word Home to the mix. The remote and local home interfaces for the Cabin EJB would be CabinHomeRemote and CabinHomeLocal respectively. The bean class is always the common business name followed by the word Bean. For example, the Cabin EJB s bean class would be named CabinBean. The remote interface Having introduced the machinery, let s look at how to build an entity or stateful enterprise bean with remote component interfaces. In this section, we will examine the Cabin EJB, an entity bean that models a cabin on a cruise ship. Let s start with its remote interface. We ll define the remote interface for a Cabin bean using the interface called CabinRemote, which defines business methods for working with cabins. All remote-interface types extend the javax.ejb.EJBObject interface. import java.rmi.RemoteException; public interface CabinRemote extends javax.ejb.EJBObject { public String getName() throws RemoteException; public void setName(String str) throws RemoteException; public int getDeckLevel() throws RemoteException; public void setDeckLevel(int level) throws RemoteException; } These are methods for naming the cabin and methods for setting the cabin s deck level; you can probably imagine lots of other methods that you d need, but this is enough to get started. All of these methods declare that they throw Copyright (c) 2001 O’Reilly & Associates
We strive to offer the highest quality service while maintaining a cheap and discount price structure. For your company, ecommerce, or personal web hosting needs, we offer the best solution.Trust us and please check quality web hosting services.