Java Reference
In-Depth Information
8.2.3
Creating the home interface
The home interface, shown in listing 8.2, supports methods related to a class
that aren't contained in the bean class. Creating ( B ), finding ( C ), and
removing are all handled by the home interface. These life cycle methods help
the container manage the bean. In our case, we have no reason to remove a
board once it is created, so there's no remove interface.
Listing 8.2
The home interface to our Board bean
package com.bitterjava.bbs.ejb;
public interface BoardHome extends javax.ejb.EJBHome {
com.bitterjava.bbs.ejb.Board create(java.lang.String argName)
throws javax.ejb.CreateException, java.rmi.RemoteException;
B
Creator method for Board
com.bitterjava.bbs.ejb.Board findByPrimaryKey(BoardKey key)
throws java.rmi.RemoteException, javax.ejb.FinderException;
}
c
Finder (by
primary key)
We will have two more home interfaces, for discussions and posts . First, the
Discussion home:
package com.bitterjava.bbs.ejb;
public interface DiscussionHome extends javax.ejb.EJBHome {
com.bitterjava.bbs.ejb.Discussion create(
java.lang.String argBoardName,
int argDiscussionID)
throws javax.ejb.CreateException, java.rmi.RemoteException;
Enumeration findAllForBoard(String boardName)
throws java.rmi.RemoteException, javax.ejb.FinderException;
com.bitterjava.bbs.ejb.Discussion findByPrimaryKey(DiscussionKey key)
throws java.rmi.RemoteException, javax.ejb.FinderException;
}
This interface also has another finder. We'll need to find all of the discussions
on a given board. We've chosen to put this function in the home interface for
discussions , since it returns an enumeration of discussions . We have one
more home interface, for posts . It is straightforward:
package com.bitterjava.bbs.ejb;
Search WWH ::




Custom Search