开发者

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 AP开发者_StackOverflow中文版I 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.


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.


Both fragments and annotations are metadata of the application. Thus metadata-complete applies for both annotation processing and processing of fragments. If the metadata-complete is set for web.xml, both the annotation processing and fragments processing are disabled.

But, the metadata-complete can also be set to web-fragments.xml. So, one can do selective processing of annotations and fragments.

Enabling metadata-complete on web.xml and disabling on web-fragments.xml will process fragments but disables the annotation processing of classes under web-fragments.xml

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜