Presented by developerWorks, your source for great tutorials
ibm.com/developerWorks
XDoclet and EJB: ejb.bean
The
ejb.bean
allows you to specify the type of the bean. The first bean I will cover
will be an CMP 2.0 entity bean. You will need to specify that it is a CMP bean, that is
uses
cmp version
2.x, give it a schema name, and specify its primary key (if it is not
using a complex primary key), and the primary key type. Here is the Xdoclet tags for
ejbs as demonstrated with the Dept bean:
/**...
* @ejb.bean
*
type="CMP"
*
cmp version="2.x"
*
name="DeptBean"
*
schema="Dept"
*
local jndi name="DeptBean"
*
view type="local"
*
primkey field="id"
*
*
* @ejb.pk
class="java.lang.Integer"
*
*/
public abstract class DeptBean implements EntityBean {
Notice that the primary key class is specified with the tags class attribute. The names
are very close to what you would expect them to be. It is fairly intuitive as the
corresponding meta data matches that which you would find for the
ejb jar.xml
file.
What may not be obvious is the
view type
parameter. The
view type
parameter
specifies if this is going to be a local bean, a remote bean or both. The above XDoclet
tags would generate the following elements in the EJB deployment descriptor
(
ejb jar.xml
):
This entity bean represents a Department of Employees.
DeptBean
...
ejb.DeptBean
Container
java.lang.Integer
False
2.x
Dept
Enhance J2EE component reuse with XDoclets
Page 29 of 49
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved