A bean’s client interfaces can be local

We’ve looked at only the Remote client interfaces for a bean so far, but as of EJB 2.0, session and entity beans can expose a local client view. In other words, client interfaces that do not extend java.rmi.Remote.

What does this mean? That the home object and EJB object are not Remote objects! They’re running in the same JVM as the client and the bean. In the entity bean CMR chapter, we’ll look at why local interfaces were added to the spec. For now, think of them as a very special case.

Remote client view

image with no caption

Local client view

image with no caption

The local interfaces do NOT extend java.rmi.Remote (and our naming convention is not required... but you need SOMETHING to distinguish it from your Remote interfaces)

Brain Power

The Remote interfaces EJBHome and EJBObject have more methods than the local interfaces EJBLocalHome and EJBLocalObject. Flip back through this chapter and look at the methods for EJBHome and EJBObject, and try to work out which methods in those Remote interfaces might be inappropriate or not needed in the local interfaces.

Think about the implications of having the interfaces local to the client...

REMOTE client view

image with no caption

LOCAL client view

The client still can’t ...

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.