Java Reference
In-Depth Information
• Informing the compiler about detecting errors and generating or suppressing
warnings. The @Deprecated annotation is used to inform the compiler about
a deprecated feature, on detecting which the compiler generates a warning.
The @Override annotation informs the compiler about an overridden
element. If the element is not overridden properly, the compiler generates an
error. The @SuppressWarnings annotation is used to inform the compiler to
suppress specific warnings.
• Runtime processing of annotations by annotating the annotations with the @
Retention ( RetentionPolicy.RUNTIME ) annotation.
EJB 3.0 specification has introduced some metadata annotations for annotating EJB
3.0 applications. EJB 3.0 metadata annotations have reduced the number of classes
and interfaces a developer is required to implement. Also, the metadata annotations
have eliminated the requirement for an EJB deployment descriptor. Three types
of metadata annotations are used in EJB 3.0: EJB 3.0 annotations, object/relational
mapping annotations, and annotations for resource injection and security. Though
annotations follow a different semantic than Java code, they help in reducing code
lines and—in the case of EJB—increase cross-platform portability. The EJB 3.0
annotations are defined in the javax.ejb package. For example, the @Stateless
annotation specifies that an EJB is a Stateless Session Bean:
import javax.ejb.Stateless;
@Stateless
public class HelloBean implements Hello {
public void hello() {
System.out.println("Hello EJB 3.0!");
}
}
For all the new EJB 3.0, annotations, refer to the EJB 3.0 specification document
EJBCore (ejb-3_0-fr-spec-ejbcore.pdf). Persistence annotations are defined in the
javax.ejb.persistence package. For example, the @Entity annotation specifies
that the EJB is an Entity Bean:
import javax.persistence.*;
@Entity
@Table(name = "Catalog")
public class Catalog implements Serializable {
private long id;
@Id
public long getId() {
 
Search WWH ::




Custom Search