From 746ac803b843d3ef92005539f4116d4c8bcd7f0e Mon Sep 17 00:00:00 2001 From: Decebal Suiu Date: Mon, 7 Apr 2014 01:02:29 +0300 Subject: a first version related to enable-disable plugin --- .../src/main/java/ro/fortsoft/pf4j/demo/Boot.java | 34 +++++++++++++--------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'demo/app/src/main') 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 8dde182..548ef4f 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 @@ -1,11 +1,11 @@ /* * 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. @@ -26,24 +26,30 @@ import ro.fortsoft.pf4j.demo.api.Greeting; * @author Decebal Suiu */ public class Boot { - + public static void main(String[] args) { // print logo printLogo(); - + // create the plugin manager final PluginManager pluginManager = new DefaultPluginManager(); - - // load and start (active/resolved) the plugins + + // load the plugins pluginManager.loadPlugins(); + + // enable a disabled plugin + pluginManager.enablePlugin("welcome-plugin"); + + // start (active/resolved) the plugins pluginManager.startPlugins(); - - // retrieves the extensions for Greeting extension point + + // retrieves the extensions for Greeting extension point List greetings = pluginManager.getExtensions(Greeting.class); + System.out.println(String.format("### Found %d extensions for the extension point '%s'", greetings.size(), Greeting.class.getName())); for (Greeting greeting : greetings) { System.out.println(">>> " + greeting.getGreeting()); } - + // stop the plugins pluginManager.stopPlugins(); /* @@ -53,15 +59,15 @@ public class Boot { 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)); + System.out.println(StringUtils.repeat("#", 40)); } - + } -- cgit v1.2.3