*/
public class DefaultExtensionFinder implements ExtensionFinder {
- private static final Logger LOG = LoggerFactory.getLogger(DefaultExtensionFinder.class);
+ private static final Logger log = LoggerFactory.getLogger(DefaultExtensionFinder.class);
private volatile List<IndexItem<Extension, Object>> indices;
private ClassLoader classLoader;
@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);
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()));
}
}
} catch (InstantiationException e) {
- LOG.error(e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
}
*/
public class DefaultPluginManager implements PluginManager {
- private static final Logger LOG = LoggerFactory.getLogger(DefaultPluginManager.class);
+ private static final Logger log = LoggerFactory.getLogger(DefaultPluginManager.class);
/**
* The plugins repository.
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);
} catch (PluginException e) {
- LOG.error(e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
}
}
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) {
- LOG.error(e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
}
}
public void loadPlugins() {
// check for plugins directory
if (!pluginsDirectory.exists() || !pluginsDirectory.isDirectory()) {
- LOG.error("No '" + pluginsDirectory + "' directory");
+ log.error("No '" + pluginsDirectory + "' directory");
return;
}
try {
expandPluginArchive(zipFile);
} catch (IOException e) {
- LOG.error(e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
}
try {
loadPlugin(directory);
} catch (PluginException e) {
- LOG.error(e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
}
// check for no plugins
if (directories.length == 0) {
- LOG.info("No plugins");
+ log.info("No plugins");
return;
}
try {
resolvePlugins();
} catch (PluginException e) {
- LOG.error(e.getMessage(), e);
+ log.error(e.getMessage(), e);
}
}
}
// 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);
+ log.debug("Descriptor " + pluginDescriptor);
String pluginClassName = pluginDescriptor.getPluginClass();
- LOG.debug("Class '" + pluginClassName + "'" + " for plugin '" + pluginPath + "'");
+ log.debug("Class '" + pluginClassName + "'" + " for plugin '" + pluginPath + "'");
// 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 '" + pluginWrapper + "' for plugin '" + pluginPath + "'");
String pluginId = pluginDescriptor.getPluginId();
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 '" + pluginArchiveFile + "' in '" + pluginDirectory + "'");
// create directorie for plugin
pluginDirectory.mkdirs();
for (PluginWrapper pluginWrapper : resolvedPlugins) {
unresolvedPlugins.remove(pluginWrapper);
compoundClassLoader.addLoader(pluginWrapper.getPluginClassLoader());
- LOG.info("Plugin '" + pluginWrapper.getDescriptor().getPluginId() + "' resolved");
+ log.info("Plugin '" + pluginWrapper.getDescriptor().getPluginId() + "' resolved");
}
}
*/
class PluginLoader {
- private static final Logger LOG = LoggerFactory.getLogger(PluginLoader.class);
+ private static final Logger log = LoggerFactory.getLogger(PluginLoader.class);
/*
* The plugin repository.
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() {
classesDirectory = classesDirectory.getAbsoluteFile();
if (classesDirectory.exists() && classesDirectory.isDirectory()) {
- LOG.debug("Found '" + classesDirectory.getPath() + "' directory");
+ log.debug("Found '" + classesDirectory.getPath() + "' directory");
try {
pluginClassLoader.addURL(classesDirectory.toURI().toURL());
- LOG.debug("Added '" + classesDirectory + "' to the class loader path");
+ log.debug("Added '" + classesDirectory + "' to the class loader path");
} catch (MalformedURLException e) {
e.printStackTrace();
- LOG.error(e.getMessage(), e);
+ log.error(e.getMessage(), e);
return false;
}
}
File jarFile = new File(libDirectory, jar);
try {
pluginClassLoader.addURL(jarFile.toURI().toURL());
- LOG.debug("Added '" + jarFile + "' to the class loader path");
+ log.debug("Added '" + jarFile + "' to the class loader path");
} catch (MalformedURLException e) {
e.printStackTrace();
- LOG.error(e.getMessage(), e);
+ log.error(e.getMessage(), e);
return false;
}
}