There appears to be a feature that web[-fragment].xml file can contain such elements as <post-construct> and <pre-destroy>, and they are treated as equivalents to @PostConstruct and @PreDestroy annotations being present on the classes mentioned in them. This feature is 1. mentioned in the Java EE 6 Platform Specification, chapter "EE.5.2.5 Annotations and Injection" [1] 2. mentioned in chapter "8.2.3 Assembling the descriptor from web.xml, webfragment.xml and annotations", see points "k." and "l." on page 81 (103/230) of servlet-3_0-mrel-spec.pdf [1] javaee_platform-6_0-fr-spec.pdf http://jcp.org/aboutJava/communityprocess/final/jsr316/index.html An example can be found in Jetty wiki: http://wiki.eclipse.org/Jetty/Feature/Annotations#Lifecycle_callbacks:_PostConstruct_PreDestroy Searching by the tag names, I do not see any code in the current trunk that processes those XML elements.
Hi, I'm going to work on this. Regards Violeta
Could you provide a progress update please. This is (currently) the only remaining issue that needs fixing before the 7.0.35 tag.
I'm preparing the test cases just now. I'll be ready till end of the day is that OK?
That sounds great. Thanks.
Created attachment 29840 [details] Patch proposal + tests Hi, Please find attached a patch proposal and tests. Important notes to the implementation: 1. Only one method per given event is allowed per class. 2. As per javaee_6.xsd if 'lifefycle-callback-class' element is not specified then the component that contains definitions for post-construct or pre-destroy should be used. For web applications we can specify this functionality only per web application and not per web component so in the implementation if the class is not specified then IllegalArgumentException will be thrown. 3. If method for a given event is specified in deployment descriptor and with annotation - the definition in the descriptor will be used. 4. If there are definitions in web.xml and in web-fragment.xml then web-fragment.xml will be ignored. 5. If there are no definitions in the web.xml and we have definitions in web fragments then they will be merged. However if there are conflicts - more than one method per given event per class - the merge operation will not succeed. 6. If the method specified in the deployment descriptor cannot be found in the class then IllegalArgumentException will be thrown. I'm looking forward to your comment. Regards Violeta
Many thanks for the patch. That was a much bigger job than I realised. I have applied the patch to trunk with just a few minor tweaks: - fixed various IDE / Checkstyle warnings (Java 7 <>, whitespace etc) - removed unnecessary use of this (just a style thing) - removed syncs from new maps in StandardContext (deployment is always single threaded for an app) - renamed a test class for consistency - correct a few indents - Used Tomcat.enableNaming() rather than system property I'll back-port to 7.0.x shortly.
Fixed in 7.0.x and will be included in 7.0.35 onwards. Thanks again for the patch.