From b011f59c632a42c9d4b8abb239fd767a115e056d Mon Sep 17 00:00:00 2001 From: Decebal Suiu Date: Fri, 20 Dec 2019 22:48:46 +0200 Subject: Remove unneeded methods --- pf4j/src/main/java/org/pf4j/LegacyExtensionFinder.java | 16 +++++++--------- .../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 bucket = new HashSet<>(); try { - Enumeration urls = getClass().getClassLoader().getResources(getExtensionsResource()); + Enumeration 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 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 bucket = new HashSet<>(); try { - Enumeration urls = getClass().getClassLoader().getResources(getExtensionsResource()); + Enumeration 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 bucket = new HashSet<>(); try { - Enumeration urls = ((PluginClassLoader) plugin.getPluginClassLoader()).findResources(getExtensionsResource()); + Enumeration 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 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 readExtensions(Path extensionPath) throws IOException { final Set result = new HashSet<>(); Files.walkFileTree(extensionPath, Collections.emptySet(), 1, new SimpleFileVisitor() { -- cgit v1.2.3