Java Reference
In-Depth Information
@Stateless
@Remote(TheatreInfo.class)
public class TheatreInfoBean implements
TheatreInfo {
@EJB TheatreBox box;
@Override
public String printSeatList() {
ArrayList<Seat> seats= box.getSeatList();
StringBuffer sb = new StringBuffer();
for (Seat seat: seats) {
sb.append(seat );
sb.append("\n");
}
return sb;
}
}
Since we are planning to invoke this EJB from a remote client, we have provided a
remote interface for it with the @Remote(TheatreInfo.class) annotation.
Next, have a look at the @EJB TheatreBox box that can be used to safely inject
an EJB into your class without the need of your manually performing a JNDI lookup.
This practice can be used to increase the portability of your application between dif-
ferent application servers where different JNDI rules might exist.
The remote interface of your bean will be as simple as this:
public interface TheatreInfo {
public String printSeatList();
}
Search WWH ::




Custom Search