diff --git a/pom.xml b/pom.xml index ad25fb811ab455b20fe850e5eae254970fc9387c..76e717425cfff25a091f16452534674c1db93154 100755 --- a/pom.xml +++ b/pom.xml @@ -30,10 +30,10 @@ </repositories> <dependencies> <dependency> - <groupId>org.reflections</groupId> - <artifactId>reflections</artifactId> - <version>0.10.2</version> - </dependency> + <groupId>io.github.classgraph</groupId> + <artifactId>classgraph</artifactId> + <version>4.8.162</version> + </dependency> <dependency> <groupId>com.thetransactioncompany</groupId> <artifactId>cors-filter</artifactId> diff --git a/src/main/java/no/nibio/vips/model/factory/ModelFactory.java b/src/main/java/no/nibio/vips/model/factory/ModelFactory.java index ae55f7001c7e7e0117bdaa4a9c7f5cb6951e6b6b..9f293054d7ca0cbd6b3a97a78851e9f82f454e7d 100755 --- a/src/main/java/no/nibio/vips/model/factory/ModelFactory.java +++ b/src/main/java/no/nibio/vips/model/factory/ModelFactory.java @@ -19,7 +19,9 @@ package no.nibio.vips.model.factory; -import java.lang.reflect.Constructor; +import io.github.classgraph.ClassGraph; +import io.github.classgraph.ClassInfo; +import io.github.classgraph.ScanResult; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.HashSet; @@ -27,7 +29,6 @@ import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import org.reflections.Reflections; import no.nibio.vips.model.Model; /** @@ -130,13 +131,28 @@ public class ModelFactory { * for each TLD not found. Use application container's config to suppress * this in log files. */ - Reflections reflections; + Set<Class<? extends Model>> subTypes = new HashSet(); - for(String topDomain: defaultTopDomains) + + /*for(String topDomain: defaultTopDomains) { reflections = new Reflections(topDomain); subTypes.addAll(reflections.getSubTypesOf(Model.class)); - } + }*/ + + try (ScanResult scanResult = // Assign scanResult in try-with-resources + new ClassGraph() // Create a new ClassGraph instance + .verbose() // If you want to enable logging to stderr + .enableClassInfo() // Scan classes, methods, fields, annotations + //.acceptPackages("com.xyz") // Scan com.xyz and subpackages + .scan()) { // Perform the scan and return a ScanResult + + //ClassInfoList classInfoList = + for(ClassInfo cInfo:scanResult.getClassesImplementing(Model.class)) + { + subTypes.add(cInfo.loadClass(Model.class)); + } + /** * Iterates and instantiates one object for each class @@ -165,6 +181,7 @@ public class ModelFactory { Logger.getLogger(ModelFactory.class.getName()).log(Level.SEVERE, null, ex); } } + } } /** diff --git a/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index 0afc3426ce1471cf541ae6ce865dc2b4c6711a36..0d8a4e7d4cfd034496218dcac00a9110bf1c63cf 100755 --- a/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -20,15 +20,8 @@ along with VIPSCore. If not, see <http://www.nibio.no/licenses/>. <jboss-deployment-structure> <deployment> <dependencies> - <module name="no.nibio.vips.modelcontainer"/> - <module name="org.graalvm"/> - <module name="no.nibio.vips.VIPSCommon" export="true"/> - <module name="com.fasterxml.jackson.core.jackson-core" /> - <module name="com.fasterxml.jackson.core.jackson-databind" /> - <module name="com.fasterxml.jackson.core.jackson-annotations" /> + </dependencies> - <exclusions> - <module name="org.jboss.resteasy.resteasy-json-binding-provider"/> - </exclusions> + </deployment> </jboss-deployment-structure>