190 CHAPTER 10 PLUGGABLE ANNOTATION PROCESSING UPDATES
190 CHAPTER 10 PLUGGABLE ANNOTATION PROCESSING UPDATES Generated: Used to flag autogenerated source. Usage would include the value of the source generator: @Generated(”net.zukowski.revealed.FooGenerator”) InjectionComplete: Used to flag methods to be called after insertion into the container. PostConstruct: Used to flag initialization methods to be called after construction. PreDestroy: Used to flag methods that release resources upon finalization of class usage such as when removed from an EJB container. For instance, if PostConstruct got a database connection, then PreDestroy would probably close it. private DataSource aDB; private Connection connection; @Resource private void setADB(DataSource ds) { aDB = ds; } @PostConstruct private void initialize() { connection = aDB.getConnection(); } @PreDestroy private void cleanup() { connection.close(); } Resource: Used to declare a reference to a resource. The name specified would be the JNDI name of the resource. For instance, to look up the JNDI resource named fooDB, use the following: @Resource(name=”fooDB”) private DataSource aDB; Resources: Used to block multiple Resource declarations together. @Resources ({ @Resource(name=”fooDB” type=javax.sql.DataSource), @Resource(name=”fooMQ” type=javax.jms.ConnectionFactory) })
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Java Web Hosting services