Browse Source

Add getExtensionFactory in PluginManager interface

pull/346/head
Decebal Suiu 9 years ago
parent
commit
0dd5e53dff
  1. 6
      pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java
  2. 7
      pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java
  3. 2
      pf4j/src/main/java/ro/fortsoft/pf4j/PluginManager.java

6
pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java

@ -43,12 +43,10 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe
private static final Logger log = LoggerFactory.getLogger(DefaultExtensionFinder.class);
protected PluginManager pluginManager;
protected ExtensionFactory extensionFactory;
protected volatile Map<String, Set<String>> entries; // cache by pluginId
public DefaultExtensionFinder(PluginManager pluginManager, ExtensionFactory extensionFactory) {
public DefaultExtensionFinder(PluginManager pluginManager) {
this.pluginManager = pluginManager;
this.extensionFactory = extensionFactory;
}
@Override
@ -93,7 +91,7 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe
descriptor.setExtensionClass(extensionClass);
ExtensionWrapper extensionWrapper = new ExtensionWrapper<>(descriptor);
extensionWrapper.setExtensionFactory(extensionFactory);
extensionWrapper.setExtensionFactory(pluginManager.getExtensionFactory());
result.add(extensionWrapper);
log.debug("Added extension '{}' with ordinal {}", className, extension.ordinal());
} else {

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

@ -566,6 +566,11 @@ public class DefaultPluginManager implements PluginManager {
return extensionFinder.findClassNames(pluginId);
}
@Override
public ExtensionFactory getExtensionFactory() {
return extensionFactory;
}
@Override
public RuntimeMode getRuntimeMode() {
if (runtimeMode == null) {
@ -631,7 +636,7 @@ public class DefaultPluginManager implements PluginManager {
* Add the possibility to override the ExtensionFinder.
*/
protected ExtensionFinder createExtensionFinder() {
DefaultExtensionFinder extensionFinder = new DefaultExtensionFinder(this, extensionFactory);
DefaultExtensionFinder extensionFinder = new DefaultExtensionFinder(this);
addPluginStateListener(extensionFinder);
return extensionFinder;

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

@ -136,6 +136,8 @@ public interface PluginManager {
public Set<String> getExtensionClassNames(String pluginId);
public ExtensionFactory getExtensionFactory();
/**
* The runtime mode. Must currently be either DEVELOPMENT or DEPLOYMENT.
*/

Loading…
Cancel
Save