4.2. Music Stateless Session Bean

Because read-only access is all we need with the Music Collection database, it makes sense to perform this task with a session bean. And because we do not need to keep track of client-specific data, a stateless session bean will suffice. Let's examine the code for the Music EJB now.

Home Interface

Listing 4.1 is the home interface (MusicHome) for the Music EJB. Since this is a stateless session bean, we need only a single create() method with no arguments. Note that this method returns the remote interface object, Music.

Listing 4.1. MusicHome.java
 // MusicHome.java import java.io.Serializable; import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.EJBHome; public interface MusicHome ...

Get Enterprise JavaBeans™ Component Architecture: Designing and Coding Enterprise Applications 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.