Author: dblevins
Date: Tue Jan 26 21:51:07 2010
New Revision: 903438
URL: http://svn.apache.org/viewvc?rev=903438&view=rev
Log:
A potential optimization for those who use the default include/exclude
settings. Attempts to skip all the regex flitering when it won't be needed
anyway.
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java?rev=903438&r1=903437&r2=903438&view=diff
==============================================================================
---
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
(original)
+++
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentsResolver.java
Tue Jan 26 21:51:07 2010
@@ -180,7 +180,9 @@
urlSet =
urlSet.excludePaths(System.getProperty("sun.boot.class.path", ""));
urlSet = urlSet.exclude(".*/JavaVM.framework/.*");
- urlSet = applyBuiltinExcludes(urlSet);
+ if (shouldFilter(include, exclude, requireDescriptors)) {
+ urlSet = applyBuiltinExcludes(urlSet);
+ }
UrlSet prefiltered = urlSet;
urlSet = urlSet.exclude(exclude);
@@ -263,6 +265,33 @@
}
+ /**
+ * The regular expressions involved in filtering can be costly
+ * In the normal case we will not scan anyway, so if not
+ * no point in optimizing the list of urls in the classpath
+ *
+ * @param include
+ * @param exclude
+ * @param requireDescriptors
+ * @return
+ */
+ private static boolean shouldFilter(String include, String exclude,
Set<RequireDescriptors> requireDescriptors) {
+ boolean includeNothing = include.equals("");
+ boolean excludeEverything = exclude.equals(".*");
+
+ // If we are going to eliminate the entire classpath from
+ // scanning anyway, no sense in taking the time to do it
+ // bit by bit. Return false
+ if (includeNothing && excludeEverything) return false;
+
+ // If we are forcably requiring descriptors for all possible file
types
+ // then there is also no scanning and no point in filtering the
+ // classpath down bit by bit. Return false
+ if (requireDescriptors.size() == RequireDescriptors.values().length)
return false;
+
+ return true;
+ }
+
private static UrlSet applyBuiltinExcludes(UrlSet urlSet) throws
MalformedURLException {
urlSet = urlSet.exclude(".*/activation(-[\\d.]+)?.jar(!/)?");
urlSet =
urlSet.exclude(".*/activeio-core(-[\\d.]+)?(-incubator)?.jar(!/)?");