Summary
Resource injection through annotations is one of the main ease-of-use features in Java EE 5. Ryan Lubke's recent Sun Developer Network article summarizes what parts of Java EE 5 can be configured through annotation-based resource injection, and provides guidelines for the use of such annotations.
Advertisement
Among Java EE 5's usability improvements is the extensive use of annotations as a means to specifying resource dependencies of an enterprise component. While XML-based configurations are still supported, annotations are now the preferred means of declaring dependencies. Indeed, the question of when to use annotations and when to prefer XML-based configuration was a subject of Artima's recent interview with EJB 3 chief architect Linda DeMichiel, Refactoring the EJB APIs: A Conversation with Linda DeMichiel, Part I.
In his recent Sun Developer Network article, Web Tier to Go With Java EE 5: A Look at Resource Injection, Ryan Lubke provides a nice summary of EE 5 annotations. For contrast, he first shows how dependency was specified before annotations were introduced, and then presents an example of the dramatic code reduction when declaring that same dependency with an annotation. The article includes a table of a complete reference to EE 5 annotations as well.
There is no question that annotations are a simplifying mechanism for resource injection. By the same token, however, annotations can be used to streamline and factor out other repetitive tasks as well. What other roles do you see annotations play in your projects? Do you create custom annotations to simplify common coding tasks in your own apps?