The Component interface

In EJB, the business interface is called the component interface. This is where you expose your business methods to the client. The main difference between an RMI interface and a remote component interface is that with EJB you extend javax.ejb.EJBObject instead of java.rmi.Remote.

Key points:

  1. Any interface with java.rmi.Remote in its inheritance tree is a Remote interface.

  2. The EJBObject interface extends Remote, so EJBObject is a Remote interface.

  3. Your remote component interface must extend the EJBObject interface.

    (You can have a local component interface, and the rules are different, but we’ll look at that in the chapter on Client View.)

  4. You expose your business methods to the client through the component interface.

  5. The EJBObject interface adds additional methods for the client to use. (We’ll see those later.)

image with no caption

Whoever implements the BookCart interface must implement all the methods from both BookCart and EJBObject. The EJBObject interface adds the methods that all EJB clients might need.

How the bean class fits in

image with no caption

The bean developer must make sure that the bean class has methods that match the methods in the component interface, exactly as if the bean class DID implement the component interface.

Note

You REALLY have to know the interfaces!

The exam expects you to know exactly ...

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.