Java Reference
In-Depth Information
The home interface for BoardFacade
Since we have a session bean, the home interface is extremely simple, having
only the create method:
package com.bitterjava.bbs.ejb;
public interface BoardFacadeHome extends javax.ejb.EJBHome {
com.bitterjava.bbs.ejb.BoardFacade create()
throws javax.ejb.CreateException, java.rmi.RemoteException;
}
The bean class for BoardFacade
This class has the implementation of the two previous interfaces. We'll see this
facade interact with all three of the EJB s. We simply have to pass requests
straight through the facade to the EJB interface.
Let's look at some of the method implementations in our facade solution.
I've chosen a representative set of the implementation but left off some of the
similar implementations and much of the exception management for brevity.
For the full implementation, go to http: // www.bitterjava.com.
package com.bitterjava.bbs.ejb;
import java.rmi.RemoteException;
import java.security.Identity;
import java.util.Properties;
import javax.ejb.*;
public class BoardFacadeBean implements SessionBean {
private javax.ejb.SessionContext mySessionCtx = null;
final static long serialVersionUID = 3206093459760846163L;
private static BoardHome boardHome = null;
private static DiscussionHome discussionHome = null;
private static PostHome postHome = null;
We use these three instance variables as convenient placeholders for our home
interfaces, where we have our finders and the life cycle methods. We expose
several of them within our interface.
public java.util.Vector addPostToDiscussion(String boardName,
int discussionID,
Post post)
throws RemoteException, FinderException, CreateException {
Discussion discussion = getDiscussionHome().findByPrimaryKey(
new DiscussionKey(boardName, discussionID));
discussion.addPost(post.getAuthor(),
post.getDate(),
post.getSubject(),
Search WWH ::




Custom Search