You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/01/09 08:35:58 UTC
svn commit: r1229044 - in
/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config:
ValidateModules.java rules/CheckClassLoading.java
Author: rmannibucau
Date: Mon Jan 9 07:35:58 2012
New Revision: 1229044
URL: http://svn.apache.org/viewvc?rev=1229044&view=rev
Log:
some more tweaking about classloading diagnostic
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ValidateModules.java
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckClassLoading.java
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ValidateModules.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ValidateModules.java?rev=1229044&r1=1229043&r2=1229044&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ValidateModules.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/ValidateModules.java Mon Jan 9 07:35:58 2012
@@ -24,10 +24,11 @@ import org.apache.openejb.config.rules.C
*/
// START SNIPPET : code
public class ValidateModules implements DynamicDeployer {
+ public static final String OPENEJB_CHECK_CLASSLOADER = "openejb.check.classloader";
public AppModule deploy(AppModule appModule) throws OpenEJBException {
final AppValidator validator;
- if (!Boolean.getBoolean("openejb.check.classloader")) {
+ if (!Boolean.getBoolean(OPENEJB_CHECK_CLASSLOADER)) {
validator = new AppValidator();
} else {
validator = new AppValidator(new CheckClassLoading());
Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckClassLoading.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckClassLoading.java?rev=1229044&r1=1229043&r2=1229044&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckClassLoading.java (original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/rules/CheckClassLoading.java Mon Jan 9 07:35:58 2012
@@ -42,6 +42,8 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class CheckClassLoading extends ValidationBase {
+ public static final String OPENEJB_CHECK_CLASSLOADER_VERBOSE = "openejb.check.classloader.verbose";
+
protected AppModule appModule;
@Override public void validate(AppModule appModule) {
@@ -57,17 +59,14 @@ public class CheckClassLoading extends V
}
private void check(final ClassLoader classLoader) {
- UrlSet set = null;
- UrlSet openejbSet = null;
+ UrlSet set;
+ UrlSet openejbSet;
try {
openejbSet = new UrlSet(OpenEJB.class.getClassLoader());
set = new UrlSet(classLoader);
set = set.exclude(openejbSet);
} catch (IOException e) {
warn(module.getModuleId() + " application", e.getMessage());
- }
- if (set == null || openejbSet == null) {
- warn(module.getModuleId() + " application", "was not able to compare application classloader and its parent");
return;
}
@@ -78,7 +77,7 @@ public class CheckClassLoading extends V
final Classes scl = new Classes(parentUrls.toArray(new URL[parentUrls.size()]));
final Collection<DiffItem> diffs = intersection(fcl, scl);
for (DiffItem diff : diffs) {
- warn(module.getModuleId() + " application", diff.toString());
+ warn(module.getModuleId() + " application", diff.toScreen());
}
}
@@ -111,7 +110,7 @@ public class CheckClassLoading extends V
for (URL archive : urls) {
try {
final File file = URLs.toFile(archive);
- List<String> files = JarUtil.listFiles(file, CLASS_EXTENSION);
+ final List<String> files = JarUtil.listFiles(file, CLASS_EXTENSION);
Collections.sort(files);
fileByArchive.put(file.getName(), files);
} catch (Exception e) {
@@ -185,16 +184,6 @@ public class CheckClassLoading extends V
}
}
- public static class ContainingItem extends DiffItem {
- public ContainingItem(Collection<String> inter, String dir1, String dir2) {
- super(inter, dir1, dir2);
- }
-
- @Override public String toString() {
- return "ContainingItem{" + getFile1() + " contains " + getFile2() + "}";
- }
- }
-
public static class DiffItem {
private Collection<String> files = new ArrayList<String>();
private String file1;
@@ -206,10 +195,6 @@ public class CheckClassLoading extends V
this.file2 = file2;
}
- public Collection<String> getFiles() {
- return files;
- }
-
public String getFile1() {
return file1;
}
@@ -218,12 +203,43 @@ public class CheckClassLoading extends V
return file2;
}
- @Override public String toString() {
- return "DiffItem{"
- + "both files " + file1 + '\''
- + " and " + file2 + '\''
- + "contains files=" + files
- + '}';
+ public String toScreen() {
+ final String str = "both files " + file1 + '\''
+ + " and " + file2 + '\'';
+ if (Boolean.getBoolean(OPENEJB_CHECK_CLASSLOADER_VERBOSE)) {
+ return str + "contains files=" + files;
+ }
+ return str;
+ }
+ }
+
+ public static class ContainingItem extends DiffItem {
+ public ContainingItem(Collection<String> inter, String dir1, String dir2) {
+ super(inter, dir1, dir2);
+ }
+
+ @Override public String toScreen() {
+ return getFile1() + " contains " + getFile2();
+ }
+ }
+
+ public static class IncludedItem extends DiffItem {
+ public IncludedItem(Collection<String> files, String file1, String file2) {
+ super(files, file1, file2);
+ }
+
+ @Override public String toScreen() {
+ return getFile1() + " is included inside " + getFile2();
+ }
+ }
+
+ public static class SameItem extends DiffItem {
+ public SameItem(Collection<String> files, String file1, String file2) {
+ super(files, file1, file2);
+ }
+
+ @Override public String toScreen() {
+ return getFile1() + " is the same than " + getFile2();
}
}
@@ -251,24 +267,4 @@ public class CheckClassLoading extends V
return index1 - index2;
}
}
-
- public static class IncludedItem extends DiffItem {
- public IncludedItem(Collection<String> files, String file1, String file2) {
- super(files, file1, file2);
- }
-
- @Override public String toString() {
- return "IncludedItem{" + getFile1() + " is included inside " + getFile2() + "}";
- }
- }
-
- public static class SameItem extends DiffItem {
- public SameItem(Collection<String> files, String file1, String file2) {
- super(files, file1, file2);
- }
-
- @Override public String toString() {
- return "SameItem{" + getFile1() + ", " + getFile2() + "}";
- }
- }
}