diff options
Diffstat (limited to 'pf4j/src/main/java/org')
-rw-r--r-- | pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java | 16 | ||||
-rw-r--r-- | pf4j/src/main/java/org/pf4j/ServiceProviderExtensionFinder.java | 16 |
2 files changed, 14 insertions, 18 deletions
diff --git a/pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java b/pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java index 7c7ce09..838b0bf 100644 --- a/pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java +++ b/pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java @@ -43,6 +43,8 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder { private static final Logger log = LoggerFactory.getLogger(LegacyExtensionFinder.class); + public static final String EXTENSIONS_RESOURCE = LegacyExtensionStorage.EXTENSIONS_RESOURCE; + public LegacyExtensionFinder(PluginManager pluginManager) { super(pluginManager); } @@ -54,11 +56,11 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder { Set<String> bucket = new HashSet<>(); try { - Enumeration<URL> urls = getClass().getClassLoader().getResources(getExtensionsResource()); + Enumeration<URL> urls = getClass().getClassLoader().getResources(EXTENSIONS_RESOURCE); if (urls.hasMoreElements()) { collectExtensions(urls, bucket); } else { - log.debug("Cannot find '{}'", getExtensionsResource()); + log.debug("Cannot find '{}'", EXTENSIONS_RESOURCE); } debugExtensions(bucket); @@ -83,11 +85,11 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder { Set<String> bucket = new HashSet<>(); try { - log.debug("Read '{}'", getExtensionsResource()); + log.debug("Read '{}'", EXTENSIONS_RESOURCE); ClassLoader pluginClassLoader = plugin.getPluginClassLoader(); - try (InputStream resourceStream = pluginClassLoader.getResourceAsStream(getExtensionsResource())) { + try (InputStream resourceStream = pluginClassLoader.getResourceAsStream(EXTENSIONS_RESOURCE)) { if (resourceStream == null) { - log.debug("Cannot find '{}'", getExtensionsResource()); + log.debug("Cannot find '{}'", EXTENSIONS_RESOURCE); } else { collectExtensions(resourceStream, bucket); } @@ -118,8 +120,4 @@ public class LegacyExtensionFinder extends AbstractExtensionFinder { } } - private static String getExtensionsResource() { - return LegacyExtensionStorage.EXTENSIONS_RESOURCE; - } - } diff --git a/pf4j/src/main/java/org/pf4j/ServiceProviderExtensionFinder.java b/pf4j/src/main/java/org/pf4j/ServiceProviderExtensionFinder.java index 48483fc..e20c467 100644 --- a/pf4j/src/main/java/org/pf4j/ServiceProviderExtensionFinder.java +++ b/pf4j/src/main/java/org/pf4j/ServiceProviderExtensionFinder.java @@ -51,6 +51,8 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder { private static final Logger log = LoggerFactory.getLogger(ServiceProviderExtensionFinder.class); + public static final String EXTENSIONS_RESOURCE = ServiceProviderExtensionStorage.EXTENSIONS_RESOURCE; + public ServiceProviderExtensionFinder(PluginManager pluginManager) { super(pluginManager); } @@ -62,11 +64,11 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder { final Set<String> bucket = new HashSet<>(); try { - Enumeration<URL> urls = getClass().getClassLoader().getResources(getExtensionsResource()); + Enumeration<URL> urls = getClass().getClassLoader().getResources(EXTENSIONS_RESOURCE); if (urls.hasMoreElements()) { collectExtensions(urls, bucket); } else { - log.debug("Cannot find '{}'", getExtensionsResource()); + log.debug("Cannot find '{}'", EXTENSIONS_RESOURCE); } debugExtensions(bucket); @@ -91,11 +93,11 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder { final Set<String> bucket = new HashSet<>(); try { - Enumeration<URL> urls = ((PluginClassLoader) plugin.getPluginClassLoader()).findResources(getExtensionsResource()); + Enumeration<URL> urls = ((PluginClassLoader) plugin.getPluginClassLoader()).findResources(EXTENSIONS_RESOURCE); if (urls.hasMoreElements()) { collectExtensions(urls, bucket); } else { - log.debug("Cannot find '{}'", getExtensionsResource()); + log.debug("Cannot find '{}'", EXTENSIONS_RESOURCE); } debugExtensions(bucket); @@ -120,7 +122,7 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder { private void collectExtensions(URL url, Set<String> bucket) throws URISyntaxException, IOException { Path extensionPath; if (url.toURI().getScheme().equals("jar")) { - extensionPath = FileUtils.getPath(url.toURI(), getExtensionsResource()); + extensionPath = FileUtils.getPath(url.toURI(), EXTENSIONS_RESOURCE); } else { extensionPath = Paths.get(url.toURI()); } @@ -128,10 +130,6 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder { bucket.addAll(readExtensions(extensionPath)); } - private static String getExtensionsResource() { - return ServiceProviderExtensionStorage.EXTENSIONS_RESOURCE; - } - private Set<String> readExtensions(Path extensionPath) throws IOException { final Set<String> result = new HashSet<>(); Files.walkFileTree(extensionPath, Collections.<FileVisitOption>emptySet(), 1, new SimpleFileVisitor<Path>() { |