Java Reference
In-Depth Information
Building the remote interface
As we explained earlier, the board is a collection point for discussions around a
single topic, denoted by the board name. Listing 8.1 shows the remote inter-
face to our Board bean.
Listing 8.1
The remote interface to our Board bean
Remote interfaces
always extend
package com.bitterjava.bbs.ejb;
public interface Board extends javax.ejb.EJBObject {
int addDiscussion(java.lang.String threadName)
throws javax.ejb.CreateException, java.rmi.RemoteException;
A method
String getName() throws java.rmi.RemoteException;
Accessor for the name attribute o
com.bitterjava.bbs.ejb.Discussion getDiscussion(int discussionID)
throws java.rmi.RemoteException;
java.util.Collection getDiscussions()
throws java.rmi.RemoteException;
void removeDiscussion(com.bitterjava.bbs.ejb.Discussion discussion)
throws java.rmi.RemoteException, javax.ejb.RemoveException;
For a distributed persistent object, the interface is remarkably simple. We
aren't forced to deal with the complexities—the container in our application
server masks all of those complexities from us. Here we can see the power of
the EJB architecture.
Next, we'll look at two additional remote interfaces, for discussions and posts.
The remote interface for Discussion
The Discussion interface is used to provide a collection point for a discussion,
or a collection of posts. We have the methods that you'd expect: add, remove,
and get a post. We also have attributes for the name and a collection of posts,
wrapped with accessor methods:
package com.bitterjava.bbs.ejb;
public interface Discussion extends javax.ejb.EJBObject {
int addPost(String author,
Date date,
String subject,
String text)
throws javax.ejb.CreateException,
Search WWH ::

Custom Search