diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2014-06-11 13:30:30 +0300 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2014-06-11 13:30:30 +0300 |
commit | e58e71a0980e8a87d51903006c7a7cba6f317135 (patch) | |
tree | 54fd1bae7c857277ded67fab03bce2f37147d41b /demo | |
parent | f508484004b0d71bd146eadd0cb1f7de1db43952 (diff) | |
download | pf4j-e58e71a0980e8a87d51903006c7a7cba6f317135.tar.gz pf4j-e58e71a0980e8a87d51903006c7a7cba6f317135.zip |
load extensions from classpath; before this commit only plugins can declare extensions
Diffstat (limited to 'demo')
-rw-r--r-- | demo/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java | 9 | ||||
-rw-r--r-- | demo/app/src/main/java/ro/fortsoft/pf4j/demo/WhazzupGreeting.java | 29 | ||||
-rw-r--r-- | demo/app/src/main/resources/log4j.properties | 1 |
3 files changed, 38 insertions, 1 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 453e2c2..2619531 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 @@ -52,12 +52,19 @@ 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 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);
+ extensionClassNames = pluginManager.getExtensionClassNames(pluginId);
for (String extension : extensionClassNames) {
System.out.println(" " + extension);
}
diff --git a/demo/app/src/main/java/ro/fortsoft/pf4j/demo/WhazzupGreeting.java b/demo/app/src/main/java/ro/fortsoft/pf4j/demo/WhazzupGreeting.java new file mode 100644 index 0000000..9cf7e35 --- /dev/null +++ b/demo/app/src/main/java/ro/fortsoft/pf4j/demo/WhazzupGreeting.java @@ -0,0 +1,29 @@ +/* + * Copyright 2014 Decebal Suiu + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with + * the License. You may obtain a copy of the License in the LICENSE file, or at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package ro.fortsoft.pf4j.demo; + +import ro.fortsoft.pf4j.Extension; +import ro.fortsoft.pf4j.demo.api.Greeting; + +/** + * @author Decebal Suiu + */ +@Extension +public class WhazzupGreeting implements Greeting { + + @Override + public String getGreeting() { + return "Whazzup"; + } + +} diff --git a/demo/app/src/main/resources/log4j.properties b/demo/app/src/main/resources/log4j.properties index 066d5e5..16ce034 100644 --- a/demo/app/src/main/resources/log4j.properties +++ b/demo/app/src/main/resources/log4j.properties @@ -4,6 +4,7 @@ log4j.rootLogger=DEBUG, Console # PF4J log # log4j.logger.ro.fortsoft.pf4j=DEBUG, Console +log4j.logger.ro.fortsoft.pf4j.PluginClassLoader=WARN, Console log4j.additivity.ro.fortsoft.pf4j=false # |