Browse Source

add args to logging code

pull/3/head
Decebal Suiu 11 years ago
parent
commit
3bd47b504a
  1. 5
      .gitignore
  2. 6
      pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java
  3. 28
      pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java
  4. 4
      pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java
  5. 8
      pf4j/src/main/java/ro/fortsoft/pf4j/PluginLoader.java
  6. 1
      pf4j/src/main/java/ro/fortsoft/pf4j/util/ExtensionFilter.java
  7. 4
      pf4j/src/main/java/ro/fortsoft/pf4j/util/Unzip.java

5
.gitignore vendored

@ -0,0 +1,5 @@
target/
.classpath
.project
.settings

6
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()));
}
}

28
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());
}
}

4
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));

8
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);

1
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));
}

4
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());
}
}

Loading…
Cancel
Save