From 2aeb77b8c8e6023651d1fc7b9ef31736b855cafa Mon Sep 17 00:00:00 2001 From: Decebal Suiu Date: Thu, 11 Oct 2012 13:29:43 +0300 Subject: first commit --- demo/app/src/main/assembly/assembly.xml | 32 +++++++++++++ demo/app/src/main/java/org/pf4j/demo/Boot.java | 63 ++++++++++++++++++++++++++ demo/app/src/main/resources/log4j.properties | 10 ++++ demo/app/src/main/resources/logging.properties | 8 ++++ 4 files changed, 113 insertions(+) create mode 100644 demo/app/src/main/assembly/assembly.xml create mode 100644 demo/app/src/main/java/org/pf4j/demo/Boot.java create mode 100644 demo/app/src/main/resources/log4j.properties create mode 100644 demo/app/src/main/resources/logging.properties (limited to 'demo/app/src') diff --git a/demo/app/src/main/assembly/assembly.xml b/demo/app/src/main/assembly/assembly.xml new file mode 100644 index 0000000..1d9e8e4 --- /dev/null +++ b/demo/app/src/main/assembly/assembly.xml @@ -0,0 +1,32 @@ + + + plugin + + dir + + false + + + false + lib + + *:jar:* + + + + + + ${project.build.directory} + + + *.jar + + + + + diff --git a/demo/app/src/main/java/org/pf4j/demo/Boot.java b/demo/app/src/main/java/org/pf4j/demo/Boot.java new file mode 100644 index 0000000..b34af53 --- /dev/null +++ b/demo/app/src/main/java/org/pf4j/demo/Boot.java @@ -0,0 +1,63 @@ +/* + * Copyright 2012 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 org.pf4j.demo; + +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.pf4j.DefaultPluginManager; +import org.pf4j.ExtensionWrapper; +import org.pf4j.PluginManager; +import org.pf4j.demo.api.Greeting; + +/** + * A boot class that start the demo. + * + * @author Decebal Suiu + */ +public class Boot { + + public static void main(String[] args) { + // print logo + printLogo(); + + // load and start (active/resolved) plugins + final PluginManager pluginManager = new DefaultPluginManager(); + pluginManager.loadPlugins(); + pluginManager.startPlugins(); + + List> greetings = pluginManager.getExtensions(Greeting.class); + for (ExtensionWrapper greeting : greetings) { + System.out.println(">>> " + greeting.getInstance().getGreeting()); + } + + pluginManager.stopPlugins(); + /* + Runtime.getRuntime().addShutdownHook(new Thread() { + + @Override + public void run() { + pluginManager.stopPlugins(); + } + + }); + */ + } + + private static void printLogo() { + System.out.println(StringUtils.repeat("#", 40)); + System.out.println(StringUtils.center("PF4J-DEMO", 40)); + System.out.println(StringUtils.repeat("#", 40)); + } + +} diff --git a/demo/app/src/main/resources/log4j.properties b/demo/app/src/main/resources/log4j.properties new file mode 100644 index 0000000..b3e5aa8 --- /dev/null +++ b/demo/app/src/main/resources/log4j.properties @@ -0,0 +1,10 @@ +log4j.rootLogger=DEBUG,Console + +log4j.appender.Console=org.apache.log4j.ConsoleAppender +log4j.appender.Console.layout=org.apache.log4j.PatternLayout +log4j.appender.Console.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n + +log4j.logger.org.apache.wicket=INFO +log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO +log4j.logger.org.apache.wicket.version=INFO +log4j.logger.org.apache.wicket.RequestCycle=INFO diff --git a/demo/app/src/main/resources/logging.properties b/demo/app/src/main/resources/logging.properties new file mode 100644 index 0000000..6fe7cef --- /dev/null +++ b/demo/app/src/main/resources/logging.properties @@ -0,0 +1,8 @@ +#handlers = java.util.logging.ConsoleHandler +handlers = org.slf4j.bridge.SLF4JBridgeHandler + +# Set the default logging level for the root logger +.level = ALL + +# Set the default formatter for new ConsoleHandler instances +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter -- cgit v1.2.3