| <?xml version="1.0" encoding="utf-8"?> | |
| <!--Arbortext, Inc., 1988-2006, v.4002--> | |
| <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" | |
| "concept.dtd"> | |
| <concept id="cjavaee5" xml:lang="en-us"> | |
| <title outputclass="id_title"><tm tmclass="special" tmowner="Sun Microsystems, Inc." | |
| tmtype="tm" trademark="Java">Java</tm> EE 5 support for annotations</title> | |
| <shortdesc outputclass="id_shortdesc">The goal of <tm tmclass="special" tmowner="Sun Microsystems, Inc." | |
| tmtype="tm" trademark="Java">Java</tm> EE 5 platform development is to minimize | |
| the number of artifacts that you have to create and maintain, thereby simplifying | |
| the development process. <tm tmclass="special" tmowner="Sun Microsystems, Inc." | |
| tmtype="tm" trademark="Java">Java</tm> EE 5 supports the injection of annotations | |
| into your source code, so that you can embed resources, dependencies, services, | |
| and life-cycle notifications in your source code, without having to maintain | |
| these artifacts elsewhere.</shortdesc> | |
| <prolog><metadata> | |
| <keywords><indexterm>Java EE 5<indexterm>annotations</indexterm></indexterm> | |
| </keywords> | |
| </metadata></prolog> | |
| <conbody> | |
| <p>An annotation is a modifier or Metadata tag that provides additional data | |
| to <tm tmclass="special" tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="Java">Java</tm> classes, | |
| interfaces, constructors, methods, fields, parameters, and local variables. | |
| Annotations replace boilerplate code, common code that is required by certain | |
| applications. For example, an annotation can replace the paired interface | |
| and implementation required for a Web service. Annotations can also replace | |
| additional files that programs require, which are maintained separately. By | |
| using an annotation, this separate file is no longer required. For example, | |
| annotations can replace the need for a separately maintained deployment descriptor | |
| for <tm tmclass="special" tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="JavaBeans">JavaBeans</tm>. </p> | |
| <p>Annotations<ul> | |
| <li>Replace descriptors for most purposes</li> | |
| <li>Remove the need for marker interfaces (like java.rmi.Remote)</li> | |
| <li>Allow application settings to be visible in the component they affect</li> | |
| </ul></p> | |
| <p>Java EE 5 provides annotations for the following tasks, among others:<ul> | |
| <li>Developing Enterprise JavaBean applications</li> | |
| <li>Defining and using Web services</li> | |
| <li>Mapping Java technology classes to XML</li> | |
| <li>Mapping Java technology classes to databases</li> | |
| <li>Mapping methods to operations</li> | |
| <li>Specifying external dependencies</li> | |
| <li>Specirying deployment information, including security attributes</li> | |
| </ul></p> | |
| <p><tm tmclass="special" tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="Java">Java</tm> EE | |
| 5 defines a number of annotations that can be injected into your source code. | |
| To declare an annotation, you simply precede the keyword with an "at" sign | |
| (@). <codeblock> | |
| package com.ibm.counter; | |
| import javax.ejb.Stateless; | |
| @Stateless | |
| public class CounterBean { | |
| }</codeblock></p> | |
| <p>For more information about the categories of annotations that <tm tmclass="special" | |
| tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="Java">Java</tm> EE | |
| 5 supports, see <xref href="ctypesofanno.dita">Types of annotations</xref>.</p> | |
| </conbody> | |
| </concept> |