Annotation-based programming is an extensible mechanism for generating
application artifacts, packaging the application, and readying the
application for execution. Annotation-based programming offers a set
of tags and a processing mechanism that allow you to embed additional
metadata in your Java™ source
code. Your application then uses this additional metadata to derive
the artifacts required to execute the application in a J2EE environment.
Goal of annotation-based programming
The goal of annotation-based programming is to minimize the number
of artifacts that you have to create and maintain, thereby simplifying
the development process.
For example, consider a stateless session EJB. With annotation-based
programming, you simply create a single Java source
file containing the bean implementation logic, and a few tags indicating
that you want to deploy this class as an EJB and indicating which
methods should be made public on the interface of the EJB. Using this
single artifact, WebSphere® Rapid
Deployment can create:
- the home and remote interface classes
- a stateless session implementation wrapper class
- the EJB deployment descriptor (ejb-jar.xml)
- the WebSphere-specific binding data
- all the remaining artifacts required to produce a compliant J2EE
application
All you have to deal with is a single Java artifact. Session EJB sample code:
/**
* @ejb.interface-method view-type=remote
*/
public String hello(String name)
{
return "Hello: " + name;
}
where @ejb.interface-method view-type=remote is
an example of an annotation tag.
Annotation Tags
Annotations are Javadoc-style comments that you embed within the Java source file. You can include
annotations in the package, class, field, or method declarations.
In addition, the tag syntax of XDoclet is supported. For more information,
see XDoclet.
Annotation tags map directly to known J2EE artifacts and deployment
descriptor elements, including tags for the following artifact types
and generation targets:
- EJBs
- Servlets
- Java classes
- Web services
Note:
The XDoclet Documentation included in this IBM® product is used with permission
and is covered under the following copyright attribution statement:
Copyright (c) 2000-2004, XDoclet Team. All rights reserved.