Brief description on the 4 interfaces applicable to EJBs (Remote, Local, Home, LocalHome): when to use them and the differences between them?

Sean Owen

The Remote and Home interfaces have somewhat misleading names, because both interfaces are used by the EJB client, which may be on a "remote" machine.

You will need to use both when working with EJBs. In very general terms, the Home interface has methods that relate to all EJBs of a certain class as a whole. For example, you will find the create() methods in the Home interface, which create new beans. You'll also see the find() methods, in the case of entity beans, which return handles on certain beans.

The Remote interface has the methods that relate to a particular bean instance. This is usually where all the business methods go. For example, the Remote interface for an entity bean will have all of the "getFoo()", "getBar()" methods that return properties of a particular bean.

In some sense Home interface methods are analagous to the constructor and static methods of a regular Java class, and Remote interface methods are like instance methods of a regular Java class.

The Local and LocalHome interfaces are entirely analagous, but are used to more efficiently access EJBs that are deployed in the same container.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact