diff options
7 files changed, 31 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..00a7233 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +target/ +.classpath +.project +.settings + diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java index 492a701..0de6318 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java @@ -41,7 +41,7 @@ public class DefaultExtensionFinder implements ExtensionFinder { @Override public <T> List<ExtensionWrapper<T>> find(Class<T> type) { - log.debug("Find extensions for " + type); + log.debug("Find extensions for {}", type); List<ExtensionWrapper<T>> result = new ArrayList<ExtensionWrapper<T>>(); getIndices(); // System.out.println("indices = "+ indices); @@ -49,11 +49,11 @@ public class DefaultExtensionFinder implements ExtensionFinder { try { AnnotatedElement element = item.element(); Class<?> extensionType = (Class<?>) element; - log.debug("Checking extension type " + extensionType); + log.debug("Checking extension type {}", extensionType); if (type.isAssignableFrom(extensionType)) { Object instance = item.instance(); if (instance != null) { - log.debug("Added extension " + extensionType); + log.debug("Added extension {}", extensionType); result.add(new ExtensionWrapper<T>(type.cast(instance), item.annotation().ordinal())); } } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java index 20aba2d..186ead9 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java @@ -117,11 +117,11 @@ public class DefaultPluginManager implements PluginManager { try { // create a list with plugin identifiers that should be only accepted by this manager (whitelist from plugins/enabled.txt file) enabledPlugins = FileUtils.readLines(new File(pluginsDirectory, "enabled.txt"), true); - log.info("Enabled plugins: " + enabledPlugins); + log.info("Enabled plugins: {}", enabledPlugins); // create a list with plugin identifiers that should not be accepted by this manager (blacklist from plugins/disabled.txt file) disabledPlugins = FileUtils.readLines(new File(pluginsDirectory, "disabled.txt"), true); - log.info("Disabled plugins: " + disabledPlugins); + log.info("Disabled plugins: {}", disabledPlugins); } catch (IOException e) { log.error(e.getMessage(), e); } @@ -160,7 +160,7 @@ public class DefaultPluginManager implements PluginManager { public void startPlugins() { for (PluginWrapper pluginWrapper : resolvedPlugins) { try { - log.info("Start plugin '" + pluginWrapper.getDescriptor().getPluginId() + "'"); + log.info("Start plugin '{}'", pluginWrapper.getDescriptor().getPluginId()); pluginWrapper.getPlugin().start(); pluginWrapper.setPluginState(PluginState.STARTED); startedPlugins.add(pluginWrapper); @@ -179,7 +179,7 @@ public class DefaultPluginManager implements PluginManager { Collections.reverse(startedPlugins); for (PluginWrapper pluginWrapper : startedPlugins) { try { - log.info("Stop plugin '" + pluginWrapper.getDescriptor().getPluginId() + "'"); + log.info("Stop plugin '{}'", pluginWrapper.getDescriptor().getPluginId()); pluginWrapper.getPlugin().stop(); pluginWrapper.setPluginState(PluginState.STOPPED); } catch (PluginException e) { @@ -195,7 +195,7 @@ public class DefaultPluginManager implements PluginManager { public void loadPlugins() { // check for plugins directory if (!pluginsDirectory.exists() || !pluginsDirectory.isDirectory()) { - log.error("No '" + pluginsDirectory + "' directory"); + log.error("No '{}' directory", pluginsDirectory); return; } @@ -284,28 +284,28 @@ public class DefaultPluginManager implements PluginManager { } // retrieves the plugin descriptor - log.debug("Find plugin descriptor '" + pluginPath + "'"); + log.debug("Find plugin descriptor '{}'", pluginPath); PluginDescriptor pluginDescriptor = pluginDescriptorFinder.find(pluginDirectory); log.debug("Descriptor " + pluginDescriptor); String pluginClassName = pluginDescriptor.getPluginClass(); - log.debug("Class '" + pluginClassName + "'" + " for plugin '" + pluginPath + "'"); + log.debug("Class '{}' for plugin '{}'", pluginClassName, pluginPath); // test for disabled plugin if (isPluginDisabled(pluginDescriptor.getPluginId())) { - log.info("Plugin '" + pluginPath + "' is disabled"); + log.info("Plugin '{}' is disabled", pluginPath); return; } // load plugin - log.debug("Loading plugin '" + pluginPath + "'"); + log.debug("Loading plugin '{}'", pluginPath); PluginLoader pluginLoader = new PluginLoader(this, pluginDescriptor, pluginDirectory); pluginLoader.load(); - log.debug("Loaded plugin '" + pluginPath + "'"); + log.debug("Loaded plugin '{}'", pluginPath); // create the plugin wrapper - log.debug("Creating wrapper for plugin '" + pluginPath + "'"); + log.debug("Creating wrapper for plugin '{}'", pluginPath); PluginWrapper pluginWrapper = new PluginWrapper(pluginDescriptor, pluginPath, pluginLoader.getPluginClassLoader()); - log.debug("Created wrapper '" + pluginWrapper + "' for plugin '" + pluginPath + "'"); + log.debug("Created wrapper '{}' for plugin '{}'", pluginWrapper, pluginPath); String pluginId = pluginDescriptor.getPluginId(); @@ -347,7 +347,7 @@ public class DefaultPluginManager implements PluginManager { File pluginDirectory = new File(pluginsDirectory, pluginName); // check if exists directory or the '.zip' file is "newer" than directory if (!pluginDirectory.exists() || (pluginArchiveDate > pluginDirectory.lastModified())) { - log.debug("Expand plugin archive '" + pluginArchiveFile + "' in '" + pluginDirectory + "'"); + log.debug("Expand plugin archive '{}' in '{}'", pluginArchiveFile, pluginDirectory); // create directorie for plugin pluginDirectory.mkdirs(); @@ -369,7 +369,7 @@ public class DefaultPluginManager implements PluginManager { for (PluginWrapper pluginWrapper : resolvedPlugins) { unresolvedPlugins.remove(pluginWrapper); compoundClassLoader.addLoader(pluginWrapper.getPluginClassLoader()); - log.info("Plugin '" + pluginWrapper.getDescriptor().getPluginId() + "' resolved"); + log.info("Plugin '{}' resolved", pluginWrapper.getDescriptor().getPluginId()); } } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java index 8611fef..a64aef5 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java @@ -51,14 +51,14 @@ class DependencyResolver { } } - log.debug("Graph: " + graph); + log.debug("Graph: {}", graph); List<String> pluginsId = graph.reverseTopologicalSort(); if (pluginsId == null) { throw new CyclicDependencyException("Cyclic dependences !!!" + graph.toString()); } - log.debug("Plugins order: " + pluginsId); + log.debug("Plugins order: {}", pluginsId); List<PluginWrapper> sortedPlugins = new ArrayList<PluginWrapper>(); for (String pluginId : pluginsId) { sortedPlugins.add(getPlugin(pluginId)); diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginLoader.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginLoader.java index 78603f4..1ad4245 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginLoader.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginLoader.java @@ -58,7 +58,7 @@ class PluginLoader { libDirectory = new File(pluginRepository, "lib"); ClassLoader parent = getClass().getClassLoader(); pluginClassLoader = new PluginClassLoader(pluginManager, pluginDescriptor, parent); - log.debug("Created class loader " + pluginClassLoader); + log.debug("Created class loader {}", pluginClassLoader); } public File getPluginRepository() { @@ -100,11 +100,11 @@ class PluginLoader { classesDirectory = classesDirectory.getAbsoluteFile(); if (classesDirectory.exists() && classesDirectory.isDirectory()) { - log.debug("Found '" + classesDirectory.getPath() + "' directory"); + log.debug("Found '{}' directory", classesDirectory.getPath()); try { pluginClassLoader.addURL(classesDirectory.toURI().toURL()); - log.debug("Added '" + classesDirectory + "' to the class loader path"); + log.debug("Added '{}' to the class loader path", classesDirectory); } catch (MalformedURLException e) { e.printStackTrace(); log.error(e.getMessage(), e); @@ -128,7 +128,7 @@ class PluginLoader { File jarFile = new File(libDirectory, jar); try { pluginClassLoader.addURL(jarFile.toURI().toURL()); - log.debug("Added '" + jarFile + "' to the class loader path"); + log.debug("Added '{}' to the class loader path", jarFile); } catch (MalformedURLException e) { e.printStackTrace(); log.error(e.getMessage(), e); diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/ExtensionFilter.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/ExtensionFilter.java index 22b999f..e5561b6 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/ExtensionFilter.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/ExtensionFilter.java @@ -34,6 +34,7 @@ public class ExtensionFilter implements FilenameFilter { return file.getName().toUpperCase().endsWith(extension.toUpperCase()); } + @Override public boolean accept(File dir, String name) { return accept(new File(dir, name)); } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/Unzip.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/Unzip.java index e3f3ed3..74d60d5 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/Unzip.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/Unzip.java @@ -61,7 +61,7 @@ public class Unzip { } public void extract() throws IOException { - log.debug("Extract content of " + source + " to " + destination); + log.debug("Extract content of '{}' to '{}'", source, destination); // delete destination file if exists removeDirectory(destination); @@ -91,7 +91,7 @@ public class Unzip { fos.close(); } } catch (FileNotFoundException e) { - log.error("File '" + zipEntry.getName() + "' not found"); + log.error("File '{}' not found", zipEntry.getName()); } } |