Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using interface for both component and bean

 
Geert Krekelberg
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just started reading the Head First EJB book. Sorry if this question already has been asked, but I couldn't find it here.

The design on page 86 (and the brainpower question on page 22) suggest the use of a common interface for both the component interface and the bean.

But the methods in the component interface must throw the RemoteException, where the methods in the bean should not.

How can a single interface be used here?

Geert.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Geert,

Welcome to Javaranch, a friendly place for Java greenhorns

Please refer to this discussion which handles the same topic.
 
Joe Nguyen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just extend from the common interface that contains business methods, not the component interface.

interface CommonIF{
public void verify();
}

public class CreditCardBean extends SessionBean implements CommonIF{

}

public interface CreditCard implements EJBObject, CommonIF{

}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic