Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Jury2015-11-13 22:44:08 +0000
committerAndy Jury2015-11-13 22:46:13 +0000
commit60acab55cc8743097db98770a8d897d6d1bbd562 (patch)
tree1530e7f94fa60d896dbe25266f690e274c66f29c
parent6e622ec7ac95d13b9f29a0eac0db596dfb10bc00 (diff)
downloadorg.eclipse.osee-60acab55cc8743097db98770a8d897d6d1bbd562.tar.gz
org.eclipse.osee-60acab55cc8743097db98770a8d897d6d1bbd562.tar.xz
org.eclipse.osee-60acab55cc8743097db98770a8d897d6d1bbd562.zip
feature[ats_ATS258705]: Make class loading more robust and efficient.
-rw-r--r--plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/OseeURLClassLoader.java32
1 files changed, 31 insertions, 1 deletions
diff --git a/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/OseeURLClassLoader.java b/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/OseeURLClassLoader.java
index a79f2217623..785f3e272a9 100644
--- a/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/OseeURLClassLoader.java
+++ b/plugins/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/OseeURLClassLoader.java
@@ -13,6 +13,9 @@ package org.eclipse.osee.ote.core;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLStreamHandlerFactory;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.plugin.core.util.ExportClassLoader;
/**
* @author Andrew M. Finkbeiner
@@ -20,27 +23,54 @@ import java.net.URLStreamHandlerFactory;
public class OseeURLClassLoader extends URLClassLoader {
private final String name;
+ private final ExportClassLoader exportClassLoader;
public OseeURLClassLoader(String name, URL[] urls, ClassLoader parent) {
super(urls, parent);
this.name = name;
GCHelper.getGCHelper().addRefWatch(this);
-
+ exportClassLoader = ExportClassLoader.getInstance();
+
}
public OseeURLClassLoader(String name, URL[] urls) {
super(urls);
GCHelper.getGCHelper().addRefWatch(this);
this.name = name;
+ exportClassLoader = ExportClassLoader.getInstance();
}
public OseeURLClassLoader(String name, URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) {
super(urls, parent, factory);
GCHelper.getGCHelper().addRefWatch(this);
this.name = name;
+ exportClassLoader = ExportClassLoader.getInstance();
}
@Override
+ public Class<?> loadClass(String clazz) throws ClassNotFoundException{
+ try {
+ return exportClassLoader.loadClass(clazz);
+ } catch (Exception ex2) {
+ int timesTriedToLoad = 0;
+ while(timesTriedToLoad < 10){
+ try {
+ return super.loadClass(clazz);
+ } catch (ClassNotFoundException ex) {
+ System.out.println("Retrying to load from OseeURLClassLoader for class = "+ clazz);
+ timesTriedToLoad++; //Try to load again
+ try {
+ Thread.sleep(1);
+ } catch (InterruptedException ex1) {
+ OseeLog.log(OseeURLClassLoader.class, Level.SEVERE, ex1.toString(), ex1);
+ }
+ }
+ }
+ throw new ClassNotFoundException("Class = " + clazz);
+ }
+ }
+
+ @Override
public String toString() {
return this.getClass().getName() + " [ " + name + " ] ";
}

Back to the top