diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2014-04-07 01:02:29 +0300 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2014-04-07 01:02:29 +0300 |
commit | 746ac803b843d3ef92005539f4116d4c8bcd7f0e (patch) | |
tree | 1a15be1e84efd79d21a1f9070582875f25ae6c02 /demo/app/src | |
parent | 1da96c7ddefeebbd5f7f1820637d4480a9bb4d82 (diff) | |
download | pf4j-746ac803b843d3ef92005539f4116d4c8bcd7f0e.tar.gz pf4j-746ac803b843d3ef92005539f4116d4c8bcd7f0e.zip |
a first version related to enable-disable plugin
Diffstat (limited to 'demo/app/src')
-rw-r--r-- | demo/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java | 34 |
1 files changed, 20 insertions, 14 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 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<Greeting> 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));
}
-
+
}
|