Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable annotation processing, but enable web-fragments feature in servlet api 3.0 (Tomcat7)

I am giving a try on Tomcat 7.0 and Servlet API 3.0.

I had an application for Servlet API 2.5. So I edited web.xml to configure it for Servlet API 3.0. After the change the start time of Tomcat increased by 14 seconds.

So I set <web-app metadata-complete="true" ... and the start time of Tomcat got back to normal, because tomcat does not scan every class for annotations. This is good, but web-fragment.xml feature is also disabled by this.

I wonder if it possible to disable annotation scanning of Tomcat, but to enable processing of web-fragment.xml.

like image 314
Igor Mukhin Avatar asked Jan 19 '11 09:01

Igor Mukhin


1 Answers

Consider using 'absolute-ordering' element in your web.xml. Servlet API 3.0 Final Spec describes it's usage in section 8.2.2 "Ordering of web.xml and web-fragment.xml".

You can specify the exact web-fragments to be processed, disable annotations processing of classes in web-fragment's jar ('metadata-complete' in the web-fragment from the list) and of course exclude other jars from processing by this kind of web-fragment inclusion.

like image 191
bad_habit Avatar answered Sep 30 '22 17:09

bad_habit