Browse Source

make PluginManager available in Plugin via PluginWrapper

pull/346/head
Decebal Suiu 9 years ago
parent
commit
c7d6a98d99
  1. 2
      pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java
  2. 11
      pf4j/src/main/java/ro/fortsoft/pf4j/PluginWrapper.java

2
pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java

@ -780,7 +780,7 @@ public class DefaultPluginManager implements PluginManager {
// create the plugin wrapper
log.debug("Creating wrapper for plugin '{}'", pluginPath);
PluginWrapper pluginWrapper = new PluginWrapper(pluginDescriptor, pluginPath, pluginClassLoader);
PluginWrapper pluginWrapper = new PluginWrapper(this, pluginDescriptor, pluginPath, pluginClassLoader);
pluginWrapper.setPluginFactory(pluginFactory);
pluginWrapper.setRuntimeMode(getRuntimeMode());

11
pf4j/src/main/java/ro/fortsoft/pf4j/PluginWrapper.java

@ -19,6 +19,7 @@ package ro.fortsoft.pf4j;
*/
public class PluginWrapper {
PluginManager pluginManager;
PluginDescriptor descriptor;
String pluginPath;
PluginClassLoader pluginClassLoader;
@ -27,7 +28,8 @@ public class PluginWrapper {
RuntimeMode runtimeMode;
Plugin plugin; // cache
public PluginWrapper(PluginDescriptor descriptor, String pluginPath, PluginClassLoader pluginClassLoader) {
public PluginWrapper(PluginManager pluginManager, PluginDescriptor descriptor, String pluginPath, PluginClassLoader pluginClassLoader) {
this.pluginManager = pluginManager;
this.descriptor = descriptor;
this.pluginPath = pluginPath;
this.pluginClassLoader = pluginClassLoader;
@ -35,6 +37,13 @@ public class PluginWrapper {
pluginState = PluginState.CREATED;
}
/**
* Returns the plugin manager.
*/
public PluginManager getPluginManager() {
return pluginManager;
}
/**
* Returns the plugin descriptor.
*/

Loading…
Cancel
Save