Servlet 2.5 Annotations and Resource Injections
The http://jcp.org/en/jsr/detail?id=154 adds the ability to inject JNDI resources into fields and methods of servlets, filters and listeners, and also to perform certain callbacks at various points in the lifecycle of a web application.
JNDI resources and the lifecycle callbacks can be specified entirely within the web.xml file. Here is a small example of the injection of a DataSource resource:
This example shows that the resource named
java:comp/env/jdbc/mydatasource will be injected by Jetty into the the field named
myDatasource or the method named
setMyDatasource(javax.sql.DataSource) in the instance of the class
com.acme.JNDITest before it goes into service.
PAGE UNDER CONSTRUCTION.