Java 5 added a new syntax element: the annotation. An annotation
is a piece of descriptive data (metadata) about a class, field, or method.
It is somewhat like a comment, except that individual annotations are predefined,
reusable, and can have effects on either the compilation process or the
use of the class once compiled. If you have used an IDE like Eclipse or NetBeans,
you may have seen the
@Override annotation on editor-supplied template code.
This particular annotation tells the compiler that the method that immediately
follows is meant to override a base class method (or a method required by
an interface). If it does not (because perhaps you spelled the name incorrectly,
or got the parameter list wrong), then a compiler error is issued.
Annotations provide Java with a means to achieve, at least to some extent, Aspect-Oriented Programming, or AOP. AOP recognizes cross-cutting concerns, that is, aspects of an element that cut across classes that might not be related by inheritance or implementation of an interface.
is a Java web service. While servlets usually extend a Java EE base class
(and will always implement the
Servlet interface), there is
no specified base class or interface for a web service. Instead, configuration
information informs the web server that a specific class is intended to
be used as a web service, and the server takes steps to make that happen.
Prior to annotations, that information was supplied solely by XML configuration
files. With Java EE 5, annotations were provided with which a class could
be internally marked as a web service.