Browse Source

minor fixes

pull/33/head
Stix 10 years ago
parent
commit
8ee33ea455
  1. 1
      demo_gradle/.gitignore
  2. 4
      demo_gradle/app/build.gradle
  3. 25
      demo_gradle/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java
  4. 6
      demo_gradle/plugins/plugin1/src/main/java/ro/fortsoft/pf4j/demo/welcome/WelcomePlugin.java
  5. 3
      demo_gradle/settings.gradle

1
demo_gradle/.gitignore vendored

@ -1 +1,2 @@
build
.gradle

4
demo_gradle/app/build.gradle

@ -1,3 +1,7 @@
apply plugin:'application'
mainClassName = 'ro.fortsoft.pf4j.demo.Boot'
dependencies {
compile project(':api')
compile 'ro.fortsoft.pf4j:pf4j:0.4'

25
demo_gradle/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java

@ -15,7 +15,7 @@ package ro.fortsoft.pf4j.demo;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import ro.fortsoft.pf4j.DefaultPluginManager;
import ro.fortsoft.pf4j.PluginManager;
@ -45,6 +45,9 @@ public class Boot {
// start (active/resolved) the plugins
pluginManager.startPlugins();
System.out.println("Plugindirectory: ");
System.out.println("\t" + System.getProperty("pf4j.pluginsDir", "plugins") + "\n");
// retrieves the extensions for Greeting extension point
List<Greeting> greetings = pluginManager.getExtensions(Greeting.class);
System.out.println(String.format("Found %d extensions for extension point '%s'", greetings.size(), Greeting.class.getName()));
@ -52,22 +55,22 @@ public class Boot {
System.out.println(">>> " + greeting.getGreeting());
}
// print extensions from classpath (non plugin)
System.out.println(String.format("Extensions added by classpath:"));
Set<String> extensionClassNames = pluginManager.getExtensionClassNames(null);
for (String extension : extensionClassNames) {
System.out.println(" " + extension);
}
// // print extensions from classpath (non plugin)
// System.out.println(String.format("Extensions added by classpath:"));
// Set<String> extensionClassNames = pluginManager.getExtensionClassNames(null);
// for (String extension : extensionClassNames) {
// System.out.println(" " + extension);
// }
// 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));
extensionClassNames = pluginManager.getExtensionClassNames(pluginId);
for (String extension : extensionClassNames) {
System.out.println(" " + extension);
}
// extensionClassNames = pluginManager.getExtensionClassNames(pluginId);
// for (String extension : extensionClassNames) {
// System.out.println(" " + extension);
// }
}
// stop the plugins

6
demo_gradle/plugins/plugin1/src/main/java/ro/fortsoft/pf4j/demo/welcome/WelcomePlugin.java

@ -12,12 +12,11 @@
*/
package ro.fortsoft.pf4j.demo.welcome;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import ro.fortsoft.pf4j.Extension;
import ro.fortsoft.pf4j.Plugin;
import ro.fortsoft.pf4j.PluginWrapper;
import ro.fortsoft.pf4j.RuntimeMode;
import ro.fortsoft.pf4j.demo.api.Greeting;
/**
@ -32,11 +31,8 @@ public class WelcomePlugin extends Plugin {
@Override
public void start() {
System.out.println("WelcomePlugin.start()");
// for testing the development mode
if (RuntimeMode.DEVELOPMENT.equals(wrapper.getRuntimeMode())) {
System.out.println(StringUtils.upperCase("WelcomePlugin"));
}
}
@Override
public void stop() {

3
demo_gradle/settings.gradle

@ -1,3 +1,4 @@
include 'api'
include 'app'
include 'plugins'
include 'plugins/plugin1'
include 'plugins/plugin2'
Loading…
Cancel
Save