</license>
</licenses>
-
<properties>
<plugin.id>welcome-plugin</plugin.id>
<plugin.class>ro.fortsoft.pf4j.demo.welcome.WelcomePlugin</plugin.class>
*/
private List<PluginWrapper> disabledPlugins;
+ /**
+ * A list with started plugins.
+ */
+ private List<PluginWrapper> startedPlugins;
+
private UberClassLoader uberClassLoader;
/**
*/
public DefaultPluginManager(File pluginsDirectory) {
this.pluginsDirectory = pluginsDirectory;
+
plugins = new HashMap<String, PluginWrapper>();
pluginClassLoaders = new HashMap<String, PluginClassLoader>();
pathToIdMap = new HashMap<String, String>();
unresolvedPlugins = new ArrayList<PluginWrapper>();
resolvedPlugins = new ArrayList<PluginWrapper>();
disabledPlugins = new ArrayList<PluginWrapper>();
+ startedPlugins = new ArrayList<PluginWrapper>();
pluginDescriptorFinder = new DefaultPluginDescriptorFinder();
uberClassLoader = new UberClassLoader();
extensionFinder = new DefaultExtensionFinder(uberClassLoader);
+
+ System.setProperty("pf4j.pluginsDir", pluginsDirectory.getAbsolutePath());
}
/**
return disabledPlugins;
}
+ public List<PluginWrapper> getStartedPlugins() {
+ return startedPlugins;
+ }
+
/**
* Start all active plugins.
*/
try {
LOG.info("Start plugin '" + pluginWrapper.getDescriptor().getPluginId() + "'");
pluginWrapper.getPlugin().start();
+ startedPlugins.add(pluginWrapper);
} catch (PluginException e) {
LOG.error(e.getMessage(), e);
}
/**
* Wrapper of the plugin.
*/
- PluginWrapper wrapper;
+ protected PluginWrapper wrapper;
/**
* Constructor to be used by plugin manager for plugin instantiation.
*
* @author Decebal Suiu
*/
-class PluginClassLoader extends URLClassLoader {
+public class PluginClassLoader extends URLClassLoader {
private static final String JAVA_PACKAGE_PREFIX = "java.";
private static final String JAVAX_PACKAGE_PREFIX = "javax.";
*
* @author Decebal Suiu
*/
-class PluginDescriptor {
+public class PluginDescriptor {
private String pluginId;
private String pluginClass;
*/
public List<PluginWrapper> getPlugins();
+ /**
+ * Retrieves all resolved plugins (with resolved dependency).
+ */
+ public List<PluginWrapper> getResolvedPlugins();
+
+ /**
+ * Retrieves all unresolved plugins (with unresolved dependency).
+ */
+ public List<PluginWrapper> getUnresolvedPlugins();
+
+ /**
+ * Retrieves all started plugins.
+ */
+ public List<PluginWrapper> getStartedPlugins();
+
/**
* Load plugins.
*/
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
}
@Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(descriptor.getPluginId())
+ .toHashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof PluginWrapper)) {
+ return false;
+ }
+
+ PluginWrapper wrapper = (PluginWrapper) obj;
+
+ return new EqualsBuilder().append(descriptor.getPluginId(), wrapper.getDescriptor().getPluginId())
+ .isEquals();
+ }
+
+ @Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("descriptor", descriptor)