Java Reference
In-Depth Information
public interface PostHome extends javax.ejb.EJBHome {
Post create(java.lang.String argBoardName,
int argPostId,
int argDiscussionID)
throws javax.ejb.CreateException, java.rmi.RemoteException;
public Enumeration findAllForDiscussion(String boardName,
int discussionID)
throws java.rmi.RemoteException, javax.ejb.FinderException;
Post findByPrimaryKey(PostKey key)
throws java.rmi.RemoteException, javax.ejb.FinderException;
Once again, we have two finders: one to find by primary key, and one to find
all posts on a discussion. Now that we've defined the interfaces, we should
examine the bean classes that will handle our implementation.
Implementing the bean class
In the bean classes, we'll implement the methods that make up our BBS . Since
the container handles most management details for us, we'll work primarily
with methods that make up the primary functions of a BBS .
The bean class for Board
Listing 8.3 shows the implementation for Board . The bean class implements
the methods defined in the remote interface.
Listing 8.3
The implementation for Board
package com.bitterjava.bbs.ejb;
import java.rmi.RemoteException;
import java.util.Properties;
import javax.ejb.*;
EntityBean ,
one of four
possible types
public class BoardBean implements EntityBeean {
private javax.ejb.EntityContext entityContext = null;
private String name;
private java.util.Vector discussions;
private DiscussionHome discussionHome = null;
final static long serialVersionUID = 3206093459760846163L;
C Adds a discussion
to a board
public int addDiscussion(String discussionName)
throws RemoteException, CreateException {
int nextID = 0;
for (int i = 0; i < discussions.size(); i++) {
Discussion discussion = (Discussion)discussions.elementAt(i);
int discussionID = discussion.getDiscussionID();
Search WWH ::

Custom Search