diff --git a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java index 574bd8986b921432d8767112f109162ae7f1f75e..163d9fd67e02af183a9aa23a41318581ee06fed5 100644 --- a/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java +++ b/src/fr/inrialpes/exmo/align/service/AServProtocolManager.java @@ -75,12 +75,11 @@ import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import java.lang.ClassNotFoundException; +import java.lang.NoClassDefFoundError; import java.lang.InstantiationException; import java.lang.NoSuchMethodException; import java.lang.IllegalAccessException; import java.lang.NullPointerException; -import java.lang.UnsatisfiedLinkError; -import java.lang.ExceptionInInitializerError; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; @@ -163,11 +162,11 @@ public class AServProtocolManager implements Service { serverId = "http://"+prop.getProperty("host")+":"+prop.getProperty("http"); alignmentCache = new SQLCache( connection ); alignmentCache.init( prop, serverId ); - renderers = implementations( "org.semanticweb.owl.align.AlignmentVisitor" ); - methods = implementations( "org.semanticweb.owl.align.AlignmentProcess" ); - methods.remove("fr.inrialpes.exmo.align.impl.DistanceAlignment"); // this one is generic, but not abstract - services = implementations( "fr.inrialpes.exmo.align.service.AlignmentServiceProfile" ); - evaluators = implementations( "org.semanticweb.owl.align.Evaluator" ); + renderers = implementations( AlignmentVisitor.class ); + methods = implementations( AlignmentProcess.class ); + methods.remove( "fr.inrialpes.exmo.align.impl.DistanceAlignment" ); // this one is generic, but not abstract + services = implementations( AlignmentServiceProfile.class ); + evaluators = implementations( Evaluator.class ); } public void close() { @@ -1308,43 +1307,18 @@ public class AServProtocolManager implements Service { * Remedied (for the moment by improving the visited cache) * This may also benefit by first filling the visited by the path of the * libraries we know. - * - * May be replaced by org.reflections (see reflectiveImplementations) - * JE: Was unable to set it properly *********************************************************************/ - /* - public Set<Class<?>> reflectiveImplementations( String interfaceName ) { - Set<Class<?>> classes = null; - try { - Class toclass = Class.forName( interfaceName ); - //Reflections reflections = new Reflections("com.mycompany"); - Reflections reflections = new Reflections( new ConfigurationBuilder() ); - //Set<Class<? extends MyInterface>> - classes = reflections.getSubTypesOf(toclass); - } catch (ClassNotFoundException ex) { - logger.debug( "IGNORED Class {} not found!", interfaceName ); - } - return classes; - }*/ - /** * Display all the classes inheriting or implementing a given * interface in the currently loaded packages. - * @param interfaceName the name of the interface to implement + * @param toclass the interface to implement */ - public Set<String> implementations( String interfaceName ) { - Set<String> list = new HashSet<String>(); - try { - Class<?> toclass = Class.forName(interfaceName); - implementations( toclass, list ); - } catch (ClassNotFoundException ex) { - logger.debug( "IGNORED Class {} not found!", interfaceName ); - } - return list; + public Set<String> implementations( Class<?> toclass ) { + return implementations( toclass, new HashSet<String>() ); } - public void implementations( Class<?> tosubclass, Set<String> list ){ + public Set<String> implementations( Class<?> tosubclass, Set<String> list ) { Set<String> visited = new HashSet<String>(); //visited.add(); String classPath = System.getProperty("java.class.path","."); @@ -1422,6 +1396,7 @@ public class AServProtocolManager implements Service { classPath = ""; } } + return list; } public void exploreJar( Set<String> list, Set<String> visited, Class<?> tosubclass, JarFile jar ) { @@ -1483,8 +1458,8 @@ public class AServProtocolManager implements Service { public boolean implementsInterface( String classname, Class<?> tosubclass ) { try { - // JE2015: I guess that this was here because we used to instantiate the classes? // This is a little crazy but at least save PermGem + // Because Class.forName is actually allocating PermGem // These are our largest libraries, but others may be to ban // Hope that they do not implement any of our interfaces if ( classname.startsWith( "org.apache.lucene" ) @@ -1505,16 +1480,14 @@ public class AServProtocolManager implements Service { ) return false; Class<?> cl = Class.forName(classname); int mod = cl.getModifiers(); - // It is possible to suppress here abstract classes by: if ( !Modifier.isAbstract( mod ) && !Modifier.isInterface( mod ) && tosubclass.isAssignableFrom( cl ) ) return true; // Not one of our classes - } catch ( ExceptionInInitializerError eiie ) { - } catch ( NoClassDefFoundError ncdex ) { + } catch ( NoClassDefFoundError ncdferr ) { + //logger.trace(" NCDF ******** {}", classname); } catch ( ClassNotFoundException cnfex ) { - } catch ( UnsatisfiedLinkError ule ) { - //logger.trace(" ******** {}", classname); + //logger.trace(" CNF ******** {}", classname); } return false; }