IMHO the finder methods in EJB 1.1 should have their own elements in the
DTD . Obviously, the syntax for describing the operation of finders is
implementation specific -- maybe this will change with EJB 2.0 -- but it
would still be helpful if an element existed that allowed finder methods
to be described by the bean provider. I would recommend the following
definition which is limited to identifying the method and providing a
description.
<!ELEMENT ejb-finder-method (description?, method-name, method-params?)>
the entity element would change to include the ejb-finder-method element
as shown below:
<!ELEMENT entity (description?, display-name?, small-icon?,
large-icon?, ejb-name, home, remote, ejb-class,
persistence-type, prim-key-class, reentrant,
cmp-field*, primkey-field?, env-entry*,
ejb-ref*, security-role-ref*, resource-ref*, ejb-finder-method*)>
Below is an example of an XML descriptor (modified from the spec):
<entity>
<description>
The EmployeeRecord entity bean encapsulates access
to the employee records.The deployer will use
container-managed persistence to integrate the
entity bean with the back-end system managing
the employee records.
</description>
<ejb-name>EmployeeRecord</ejb-name>
<home>com.wombat.empl.EmployeeRecordHome</home>
<remote>com.wombat.empl.EmployeeRecord</remote>
<ejb-class>com.wombat.empl.EmployeeRecordBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>com.wombat.empl.EmployeeID</prim-key-class>
<reentrant>True</reentrant>
<ejb-finder-method>
<description>This finder should locate all employees with
the exact zip code including box numbers if used</description>
<method-name>findByZipCode</method-name>
</ejb-finder-method>
</ejb-finder-method>
<description>This finder should locate all employees by
their last Name in ascending order</descrption>
<method-name>findByName</method-name>
<method-param>java.lang.String</method-param>
</ejb-finder-method>
<ejb-finder-method>
<description>This finder should locate all employees ordered
by last Name ascending then first Name assending</description>
<method-name>findByName</method-name>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</ejb-finder-method>
</entity>
At the very least, this type of element makes it much simpler for the
deployer and deployer tools to locate the descriptions of finders when
deploying the bean. As the specification currently stands descriptions
of finders are to be placed in the description field of the entity
element (EJB 1.1 B.4). While the ejb-finder-method element provides
only descriptive information this is very important because the finder's
description is the only information that the bean provider has as a
contract with the deployer. This is why it should be elevated to a DTD
element: to solidify that contract. In the future as a syntax is
developed to describe the query operations of a finer method additional
elements can be added to the ejb-finder-method element to support it.
Richard
--
Richard Monson-Haefel
Author of Enterprise JavaBeans
Published by O'Reilly & Associates
( http://www.monson-haefel.com )
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".