aboutsummaryrefslogtreecommitdiffstats
path: root/demo
diff options
context:
space:
mode:
Diffstat (limited to 'demo')
-rw-r--r--demo/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/demo/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java b/demo/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java
index 548ef4f..453e2c2 100644
--- a/demo/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java
+++ b/demo/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java
@@ -13,11 +13,13 @@
package ro.fortsoft.pf4j.demo;
import java.util.List;
+import java.util.Set;
import org.apache.commons.lang.StringUtils;
import ro.fortsoft.pf4j.DefaultPluginManager;
import ro.fortsoft.pf4j.PluginManager;
+import ro.fortsoft.pf4j.PluginWrapper;
import ro.fortsoft.pf4j.demo.api.Greeting;
/**
@@ -28,26 +30,37 @@ import ro.fortsoft.pf4j.demo.api.Greeting;
public class Boot {
public static void main(String[] args) {
- // print logo
- printLogo();
+ // print logo
+ printLogo();
- // create the plugin manager
+ // create the plugin manager
final PluginManager pluginManager = new DefaultPluginManager();
// load the plugins
pluginManager.loadPlugins();
// enable a disabled plugin
- pluginManager.enablePlugin("welcome-plugin");
+// pluginManager.enablePlugin("welcome-plugin");
// start (active/resolved) the plugins
pluginManager.startPlugins();
// retrieves the extensions for Greeting extension point
List<Greeting> greetings = pluginManager.getExtensions(Greeting.class);
- System.out.println(String.format("### Found %d extensions for the extension point '%s'", greetings.size(), Greeting.class.getName()));
+ System.out.println(String.format("Found %d extensions for extension point '%s'", greetings.size(), Greeting.class.getName()));
for (Greeting greeting : greetings) {
- System.out.println(">>> " + greeting.getGreeting());
+ System.out.println(">>> " + greeting.getGreeting());
+ }
+
+ // print extensions for each started plugin
+ List<PluginWrapper> startedPlugins = pluginManager.getStartedPlugins();
+ for (PluginWrapper plugin : startedPlugins) {
+ String pluginId = plugin.getDescriptor().getPluginId();
+ System.out.println(String.format("Extensions added by plugin '%s':", pluginId));
+ Set<String> extensionClassNames = pluginManager.getExtensionClassNames(pluginId);
+ for (String extension : extensionClassNames) {
+ System.out.println(" " + extension);
+ }
}
// stop the plugins