Java Reference
In-Depth Information
Adding a stateless bean
So, the first bean we will create is
com.packtpub.wflydevelopment.chapter3.boundary.TheatreInfo ,
which barely contains the logic to look up the list of theatre seats. In practice, this bean acts
as a facade for our singleton bean, as shown in the following code:
public class TheatreInfo implements TheatreInfoRemote {
private TheatreBox box;
public String printSeatList() {
final Collection<Seat> seats = box.getSeats();
final StringBuilder sb = new StringBuilder();
for (Seat seat : seats) {
return sb.toString();
Since we are planning to invoke this EJB from a remote client, we defined a remote inter-
face for it with the @Remote(TheatreInfoRemote.class) annotation.
Next, take a look at the @EJB TheatreBox box , which can be used to safely inject an
EJB into your class without the need of a manual JNDI lookup. This practice can be used to
increase the portability of your application between different application servers, where dif-
ferent JNDI rules might exist.
The remote interface of your bean will be as simple as the following code:
public interface TheatreInfoRemote {
String printSeatList();
Search WWH ::

Custom Search