Author: markt
Date: Thu Dec 6 15:05:38 2018
New Revision: 1848330
URL: http://svn.apache.org/viewvc?rev=1848330&view=rev
Log:
Refactor the code that performs class scanning during web application start to
make integration simpler for downstream users.
Patch provided by rmannibucau.
Modified:
tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
tomcat/trunk/webapps/docs/changelog.xml
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=1848330&r1=1848329&r2=1848330&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Thu Dec 6
15:05:38 2018
@@ -1132,36 +1132,8 @@ public class ContextConfig implements Li
}
if (!webXml.isMetadataComplete() || typeInitializerMap.size() > 0) {
- // Step 4. Process /WEB-INF/classes for annotations and
- // @HandlesTypes matches
- Map<String,JavaClassCacheEntry> javaClassCache = new HashMap<>();
-
- if (ok) {
- WebResource[] webResources =
-
context.getResources().listResources("/WEB-INF/classes");
-
- for (WebResource webResource : webResources) {
- // Skip the META-INF directory from any JARs that have been
- // expanded in to WEB-INF/classes (sometimes IDEs do this).
- if ("META-INF".equals(webResource.getName())) {
- continue;
- }
- processAnnotationsWebResource(webResource, webXml,
- webXml.isMetadataComplete(), javaClassCache);
- }
- }
-
- // Step 5. Process JARs 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(),
javaClassCache);
- }
-
- // Cache, if used, is no longer required so clear it
- javaClassCache.clear();
+ // Steps 4 & 5.
+ processClasses(webXml, orderedFragments);
}
if (!webXml.isMetadataComplete()) {
@@ -1237,6 +1209,40 @@ public class ContextConfig implements Li
}
+ protected void processClasses(WebXml webXml, Set<WebXml> orderedFragments)
{
+ // Step 4. Process /WEB-INF/classes for annotations and
+ // @HandlesTypes matches
+ Map<String, JavaClassCacheEntry> javaClassCache = new HashMap<>();
+
+ if (ok) {
+ WebResource[] webResources =
+ context.getResources().listResources("/WEB-INF/classes");
+
+ for (WebResource webResource : webResources) {
+ // Skip the META-INF directory from any JARs that have been
+ // expanded in to WEB-INF/classes (sometimes IDEs do this).
+ if ("META-INF".equals(webResource.getName())) {
+ continue;
+ }
+ processAnnotationsWebResource(webResource, webXml,
+ webXml.isMetadataComplete(), javaClassCache);
+ }
+ }
+
+ // Step 5. Process JARs 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(),
javaClassCache);
+ }
+
+ // Cache, if used, is no longer required so clear it
+ javaClassCache.clear();
+ }
+
+
private void configureContext(WebXml webxml) {
// As far as possible, process in alphabetical order so it is easy to
// check everything is present
@@ -2109,6 +2115,11 @@ public class ContextConfig implements Li
return;
}
+ processClass(fragment, clazz);
+ }
+
+
+ protected void processClass(WebXml fragment, JavaClass clazz) {
AnnotationEntry[] annotationsEntries = clazz.getAnnotationEntries();
if (annotationsEntries != null) {
String className = clazz.getClassName();
@@ -2127,6 +2138,7 @@ public class ContextConfig implements Li
}
}
+
/**
* For classes packaged with the web application, the class and each
* super class needs to be checked for a match with {@link HandlesTypes} or
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1848330&r1=1848329&r2=1848330&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Dec 6 15:05:38 2018
@@ -124,6 +124,11 @@
<code>x-forwarded-proto</code> header. Based on a patch provided by Tom
Groot. (markt)
</fix>
+ <scode>
+ <bug>62986</bug>: Refactor the code that performs class scanning during
+ web application start to make integration simpler for downstream users.
+ Patch provided by rmannibucau. (markt)
+ </scode>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]