
o develop even a simple J2EE application, developers must write lots of boilerplate code (as Enterprise JavaBeans, or EJB, in Java) and set up a myriad configuration files (as deployment descriptors in XML). Therefore, to become a J2EE developer, a programmer must be familiar with EJB and XML. For novices, these can represent a daunting learning curve.
Adding to its reputation of complexity, the current J2EE specification (1.4) was written a long while back using JDK 1.2, so it does not include the rich, ease-of-use features offered by later JDK versions, such as J2SE 5.0's generics and annotations support.
One of the main goals of the upcoming Java EE 5.0 release is to keep the power of J2EE, while making common development tasks simpler. To accomplish this, Java EE 5.0 aims to provide better default behavior and configuration by allowing most containers to get what they want from the application without using deployment descriptors. Java EE 5.0 puts annotations to great use for this purpose. Although developers don't need to know the implementation details (the containers do the bulk of the implementation work), these new features will make enterprise Java applications lighter and faster.
This article explores the new features J2EE developers can expect in Java EE 5.0. It takes a brief look at annotations first before delving into the others.
[Author Note: In case you haven't heard yet, the latest version of J2EE is called Java EE 5.0. Henceforth, new versions will be referred to as Java EE and J2EE will refer to earlier versions.]
Java Annotations
An annotation is a special kind of modifier that you can use anywhere you use other modifiers (such as
public
,
static
, or
final
). By convention, annotations precede other modifiers. They consist of an at sign (
@
) followed by an annotation type and a parenthesized list of element-value pairs. The values must be compile-time constants. In other words, Java itself provides a specific list of annotations.
Annotations do not directly affect program semantics, but they do affect the way tools and libraries treat programs, which can in turn affect the semantics of the running program. Annotations can be read from source files, class files, or reflectively at run time. Separating the definition from the enforcement and providing a way to introspect these constraints provides much more flexibility in the enforcement.
Most Java developers already are familiar with annotations. For example, all JavaDoc
tags and transient
tags are examples of annotations.