Author: markt
Date: Tue Jul 30 12:29:58 2013
New Revision: 1508413
URL: http://svn.apache.org/r1508413
Log:
Ensure container JARs are processed for @HandlesTypes matches
Modified:
tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1508413&r1=1508412&r2=1508413&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Tue Jul 30
12:29:58 2013
@@ -1128,7 +1128,8 @@ public class ContextConfig implements Li
}
if (!webXml.isMetadataComplete() || typeInitializerMap.size() > 0) {
- // Step 4. Process /WEB-INF/classes for annotations
+ // Step 4. Process /WEB-INF/classes for annotations and
+ // @HandlesTypes matches
if (ok) {
WebResource[] webResources =
context.getResources().listResources("/WEB-INF/classes");
@@ -1139,8 +1140,10 @@ public class ContextConfig implements Li
}
}
- // Step 5. Process JARs for annotations - only need to process
- // those fragments we are going to use
+ // Step 5. Process JARs for annotations for annotations and
+ // @HandlesTypes matches - only need to process those fragments we
+ // are going to use (remember orderedFragments includes any
+ // container fragments)
if (ok) {
processAnnotations(
orderedFragments, webXml.isMetadataComplete());
@@ -1860,20 +1863,24 @@ public class ContextConfig implements Li
protected void processAnnotations(Set<WebXml> fragments,
boolean handlesTypesOnly) {
for(WebXml fragment : fragments) {
- if (fragment.getWebappJar()) {
- // Only web application JARs should be scanned for deployment
- // annotations
- WebXml annotations = new WebXml();
- // no impact on distributable
- annotations.setDistributable(true);
- URL url = fragment.getURL();
- processAnnotationsUrl(url, annotations,
- (handlesTypesOnly || fragment.isMetadataComplete()));
- Set<WebXml> set = new HashSet<>();
- set.add(annotations);
- // Merge annotations into fragment - fragment takes priority
- fragment.merge(set);
- }
+ // Only need to scan for @HandlesTypes matches if any of the
+ // following are true:
+ // - it has already been determined only @HandlesTypes is required
+ // (e.g. main web.xml has metadata-complete="true"
+ // - this fragment is for a container JAR (Servlet 3.1 section 8.1)
+ // - this fragment has metadata-complete="true"
+ boolean htOnly = handlesTypesOnly || !fragment.getWebappJar() ||
+ fragment.isMetadataComplete();
+
+ WebXml annotations = new WebXml();
+ // no impact on distributable
+ annotations.setDistributable(true);
+ URL url = fragment.getURL();
+ processAnnotationsUrl(url, annotations, htOnly);
+ Set<WebXml> set = new HashSet<>();
+ set.add(annotations);
+ // Merge annotations into fragment - fragment takes priority
+ fragment.merge(set);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]