From e58e71a0980e8a87d51903006c7a7cba6f317135 Mon Sep 17 00:00:00 2001 From: Decebal Suiu Date: Wed, 11 Jun 2014 13:30:30 +0300 Subject: load extensions from classpath; before this commit only plugins can declare extensions --- .../src/main/java/ro/fortsoft/pf4j/demo/Boot.java | 9 ++++++- .../ro/fortsoft/pf4j/demo/WhazzupGreeting.java | 29 ++++++++++++++++++++++ demo/app/src/main/resources/log4j.properties | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 demo/app/src/main/java/ro/fortsoft/pf4j/demo/WhazzupGreeting.java (limited to 'demo') 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 extensionClassNames = pluginManager.getExtensionClassNames(null); + for (String extension : extensionClassNames) { + System.out.println(" " + extension); + } + // print extensions for each started plugin List startedPlugins = pluginManager.getStartedPlugins(); for (PluginWrapper plugin : startedPlugins) { String pluginId = plugin.getDescriptor().getPluginId(); System.out.println(String.format("Extensions added by plugin '%s':", pluginId)); - Set 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 # -- cgit v1.2.3