EJB Query Language

   

Home Interface Business Methods

EJB 1.1 allowed the declaration of create and finder methods for an entity bean in its home interface and business methods in its remote interface. Because static methods aren't allowed in an EJB, this meant that a business method could only be executed by invoking it on a particular entity object through its remote interface. Business methods related to a bean class but independent of a particular entity instance were best implemented as session bean methods that acted on the entities involved.

EJB 2.0 allows you to implement business methods within a bean class that are independent of a particular entity object. This still doesn't involve declaring static methods in the component interface though. Instead, you declare these methods, known as home methods, in the home interface. The container executes a home method by selecting an available instance of the entity class from the pool and invoking the method on that instance. The method isn't allowed to reference the attributes of the instance used to invoke it. In fact, the container never activates the instance, so it's never associated with a particular entity object.

A home method is allowed to locate instances of its associated entity class using finder method calls. It can then access those entities using the methods exposed by the component interface just like any other client would. These methods are useful if you want to perform an operation on all instances of an entity or some particular subset of them. Instead of declaring a session bean method to do this, you can now keep that logic within the bean class when it's appropriate.

For more information on exposing business methods through the home interface, see "Declaring the Home Interface," p. 130 .



Special Edition Using Enterprise JavaBeans 2.0
Special Edition Using Enterprise JavaBeans 2.0
ISBN: 0789725673
EAN: 2147483647
Year: 2000
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net