From 86a38894c252308188c65892d65ca558df666225 Mon Sep 17 00:00:00 2001 From: =?utf8?q?M=C3=A1rio=20Franco?= Date: Fri, 5 Jun 2015 15:21:32 +0100 Subject: [PATCH] Editor config style applied --- demo/api/pom.xml | 6 +- .../ro/fortsoft/pf4j/demo/api/Greeting.java | 6 +- demo/app/src/main/assembly/assembly.xml | 2 +- .../main/java/ro/fortsoft/pf4j/demo/Boot.java | 186 +++++----- demo/plugins/disabled.txt | 2 +- demo/plugins/enabled.txt | 2 +- demo/plugins/plugin1/pom.xml | 12 +- .../plugin1/src/main/assembly/assembly.xml | 2 +- .../pf4j/demo/welcome/WelcomePlugin.java | 6 +- demo/plugins/plugin2/pom.xml | 10 +- .../plugin2/src/main/assembly/assembly.xml | 2 +- .../fortsoft/pf4j/demo/hello/HelloPlugin.java | 6 +- demo/plugins/pom.xml | 8 +- demo/pom.xml | 2 +- .../ro/fortsoft/pf4j/demo/api/Greeting.java | 6 +- .../main/java/ro/fortsoft/pf4j/demo/Boot.java | 192 +++++----- demo_gradle/plugins/disabled.txt | 2 +- demo_gradle/plugins/enabled.txt | 2 +- .../fortsoft/pf4j/demo/hello/HelloPlugin.java | 6 +- .../pf4j/CompoundPluginRepository.java | 2 +- .../pf4j/CyclicDependencyException.java | 8 +- .../pf4j/DefaultPluginDescriptorFinder.java | 12 +- .../pf4j/DefaultPluginRepository.java | 2 +- .../pf4j/DefaultPluginStatusProvider.java | 2 +- .../ro/fortsoft/pf4j/DependencyResolver.java | 8 +- .../pf4j/DevelopmentPluginClasspath.java | 12 +- .../main/java/ro/fortsoft/pf4j/Extension.java | 8 +- .../java/ro/fortsoft/pf4j/ExtensionPoint.java | 6 +- .../ro/fortsoft/pf4j/ExtensionWrapper.java | 2 +- .../ro/fortsoft/pf4j/ExtensionsIndexer.java | 36 +- .../main/java/ro/fortsoft/pf4j/Plugin.java | 6 +- .../fortsoft/pf4j/PluginDescriptorFinder.java | 10 +- .../ro/fortsoft/pf4j/PluginException.java | 6 +- .../pf4j/PluginNotFoundException.java | 10 +- .../ro/fortsoft/pf4j/PluginRepository.java | 2 +- .../fortsoft/pf4j/PluginStatusProvider.java | 2 +- .../java/ro/fortsoft/pf4j/RuntimeMode.java | 24 +- .../ro/fortsoft/pf4j/util/AndFileFilter.java | 6 +- .../ro/fortsoft/pf4j/util/DirectedGraph.java | 342 +++++++++--------- .../pf4j/util/DirectoryFileFilter.java | 8 +- .../pf4j/util/ExtensionFileFilter.java | 8 +- .../ro/fortsoft/pf4j/util/HiddenFilter.java | 8 +- .../ro/fortsoft/pf4j/util/JarFileFilter.java | 6 +- .../ro/fortsoft/pf4j/util/NotFileFilter.java | 6 +- .../ro/fortsoft/pf4j/util/StringUtils.java | 6 +- .../java/ro/fortsoft/pf4j/util/Unzip.java | 6 +- .../ro/fortsoft/pf4j/util/ZipFileFilter.java | 6 +- 47 files changed, 510 insertions(+), 510 deletions(-) diff --git a/demo/api/pom.xml b/demo/api/pom.xml index 9d748b9..b379fbe 100644 --- a/demo/api/pom.xml +++ b/demo/api/pom.xml @@ -1,6 +1,6 @@ - + ro.fortsoft.pf4j.demo pf4j-demo-parent @@ -23,7 +23,7 @@ - + ro.fortsoft.pf4j @@ -32,5 +32,5 @@ provided - + diff --git a/demo/api/src/main/java/ro/fortsoft/pf4j/demo/api/Greeting.java b/demo/api/src/main/java/ro/fortsoft/pf4j/demo/api/Greeting.java index 9a700c2..ddf3538 100644 --- a/demo/api/src/main/java/ro/fortsoft/pf4j/demo/api/Greeting.java +++ b/demo/api/src/main/java/ro/fortsoft/pf4j/demo/api/Greeting.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. diff --git a/demo/app/src/main/assembly/assembly.xml b/demo/app/src/main/assembly/assembly.xml index ef8515d..77c66b4 100644 --- a/demo/app/src/main/assembly/assembly.xml +++ b/demo/app/src/main/assembly/assembly.xml @@ -1,6 +1,6 @@ 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 2619531..4ba1422 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,93 +1,93 @@ -/* - * 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 ro.fortsoft.pf4j.demo; - -import java.util.List; -import java.util.Set; - -import org.apache.commons.lang.StringUtils; - -import ro.fortsoft.pf4j.DefaultPluginManager; -import ro.fortsoft.pf4j.PluginManager; -import ro.fortsoft.pf4j.PluginWrapper; -import ro.fortsoft.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(); - - // create the plugin manager - final PluginManager pluginManager = new DefaultPluginManager(); - - // 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 - List greetings = pluginManager.getExtensions(Greeting.class); - System.out.println(String.format("Found %d extensions for extension point '%s'", greetings.size(), Greeting.class.getName())); - for (Greeting greeting : greetings) { - 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)); - extensionClassNames = pluginManager.getExtensionClassNames(pluginId); - for (String extension : extensionClassNames) { - System.out.println(" " + extension); - } - } - - // stop the plugins - 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)); - } - -} +/* + * 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 ro.fortsoft.pf4j.demo; + +import java.util.List; +import java.util.Set; + +import org.apache.commons.lang.StringUtils; + +import ro.fortsoft.pf4j.DefaultPluginManager; +import ro.fortsoft.pf4j.PluginManager; +import ro.fortsoft.pf4j.PluginWrapper; +import ro.fortsoft.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(); + + // create the plugin manager + final PluginManager pluginManager = new DefaultPluginManager(); + + // 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 + List greetings = pluginManager.getExtensions(Greeting.class); + System.out.println(String.format("Found %d extensions for extension point '%s'", greetings.size(), Greeting.class.getName())); + for (Greeting greeting : greetings) { + 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)); + extensionClassNames = pluginManager.getExtensionClassNames(pluginId); + for (String extension : extensionClassNames) { + System.out.println(" " + extension); + } + } + + // stop the plugins + 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/plugins/disabled.txt b/demo/plugins/disabled.txt index fcaef50..45f1801 100644 --- a/demo/plugins/disabled.txt +++ b/demo/plugins/disabled.txt @@ -3,4 +3,4 @@ # - add one plugin id on each line # - put this file in plugins folder ######################################## -#welcome-plugin \ No newline at end of file +#welcome-plugin diff --git a/demo/plugins/enabled.txt b/demo/plugins/enabled.txt index 5594017..3d76b2f 100644 --- a/demo/plugins/enabled.txt +++ b/demo/plugins/enabled.txt @@ -3,4 +3,4 @@ # - add one plugin id on each line # - put this file in plugins folder ######################################## -#welcome-plugin \ No newline at end of file +#welcome-plugin diff --git a/demo/plugins/plugin1/pom.xml b/demo/plugins/plugin1/pom.xml index 10e16f7..844d217 100644 --- a/demo/plugins/plugin1/pom.xml +++ b/demo/plugins/plugin1/pom.xml @@ -1,6 +1,6 @@ - + ro.fortsoft.pf4j.demo pf4j-demo-plugins @@ -19,7 +19,7 @@ 0.0.1 Decebal Suiu - + @@ -43,7 +43,7 @@ --> - + org.apache.maven.plugins maven-antrun-plugin @@ -63,7 +63,7 @@ - + maven-assembly-plugin 2.3 @@ -110,7 +110,7 @@ - + @@ -119,5 +119,5 @@ 2.6 - + diff --git a/demo/plugins/plugin1/src/main/assembly/assembly.xml b/demo/plugins/plugin1/src/main/assembly/assembly.xml index 3fdc464..ce2e92c 100644 --- a/demo/plugins/plugin1/src/main/assembly/assembly.xml +++ b/demo/plugins/plugin1/src/main/assembly/assembly.xml @@ -1,6 +1,6 @@ diff --git a/demo/plugins/plugin1/src/main/java/ro/fortsoft/pf4j/demo/welcome/WelcomePlugin.java b/demo/plugins/plugin1/src/main/java/ro/fortsoft/pf4j/demo/welcome/WelcomePlugin.java index 1c35259..6021fbf 100644 --- a/demo/plugins/plugin1/src/main/java/ro/fortsoft/pf4j/demo/welcome/WelcomePlugin.java +++ b/demo/plugins/plugin1/src/main/java/ro/fortsoft/pf4j/demo/welcome/WelcomePlugin.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. diff --git a/demo/plugins/plugin2/pom.xml b/demo/plugins/plugin2/pom.xml index c2e5413..7852d4f 100644 --- a/demo/plugins/plugin2/pom.xml +++ b/demo/plugins/plugin2/pom.xml @@ -1,6 +1,6 @@ - + ro.fortsoft.pf4j.demo pf4j-demo-plugins @@ -19,7 +19,7 @@ 0.0.1 Decebal Suiu - + @@ -43,7 +43,7 @@ --> - + org.apache.maven.plugins maven-antrun-plugin @@ -63,7 +63,7 @@ - + maven-assembly-plugin 2.3 @@ -110,6 +110,6 @@ - + diff --git a/demo/plugins/plugin2/src/main/assembly/assembly.xml b/demo/plugins/plugin2/src/main/assembly/assembly.xml index 5cefe0d..4eacbe3 100644 --- a/demo/plugins/plugin2/src/main/assembly/assembly.xml +++ b/demo/plugins/plugin2/src/main/assembly/assembly.xml @@ -1,6 +1,6 @@ diff --git a/demo/plugins/plugin2/src/main/java/ro/fortsoft/pf4j/demo/hello/HelloPlugin.java b/demo/plugins/plugin2/src/main/java/ro/fortsoft/pf4j/demo/hello/HelloPlugin.java index 7072e3d..4502126 100644 --- a/demo/plugins/plugin2/src/main/java/ro/fortsoft/pf4j/demo/hello/HelloPlugin.java +++ b/demo/plugins/plugin2/src/main/java/ro/fortsoft/pf4j/demo/hello/HelloPlugin.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. diff --git a/demo/plugins/pom.xml b/demo/plugins/pom.xml index 3f717c3..3044f1d 100644 --- a/demo/plugins/pom.xml +++ b/demo/plugins/pom.xml @@ -1,6 +1,6 @@ - + ro.fortsoft.pf4j.demo pf4j-demo-parent @@ -27,7 +27,7 @@ src/main/resources - + maven-dependency-plugin @@ -93,7 +93,7 @@ pf4j ${project.version} provided - + ro.fortsoft.pf4j.demo @@ -102,5 +102,5 @@ provided - + diff --git a/demo/pom.xml b/demo/pom.xml index fe55184..087e22f 100644 --- a/demo/pom.xml +++ b/demo/pom.xml @@ -1,6 +1,6 @@ - + ro.fortsoft.pf4j pf4j-parent diff --git a/demo_gradle/api/src/main/java/ro/fortsoft/pf4j/demo/api/Greeting.java b/demo_gradle/api/src/main/java/ro/fortsoft/pf4j/demo/api/Greeting.java index 9a700c2..ddf3538 100644 --- a/demo_gradle/api/src/main/java/ro/fortsoft/pf4j/demo/api/Greeting.java +++ b/demo_gradle/api/src/main/java/ro/fortsoft/pf4j/demo/api/Greeting.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. diff --git a/demo_gradle/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java b/demo_gradle/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java index 503e7c0..8c7d8e1 100644 --- a/demo_gradle/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java +++ b/demo_gradle/app/src/main/java/ro/fortsoft/pf4j/demo/Boot.java @@ -1,96 +1,96 @@ -/* - * 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 ro.fortsoft.pf4j.demo; - -import java.util.List; -import java.util.Set; - -import org.apache.commons.lang3.StringUtils; - -import ro.fortsoft.pf4j.DefaultPluginManager; -import ro.fortsoft.pf4j.PluginManager; -import ro.fortsoft.pf4j.PluginWrapper; -import ro.fortsoft.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(); - - // create the plugin manager - final PluginManager pluginManager = new DefaultPluginManager(); - - // load the plugins - pluginManager.loadPlugins(); - - // enable a disabled plugin -// pluginManager.enablePlugin("welcome-plugin"); - - // start (active/resolved) the plugins - pluginManager.startPlugins(); - - System.out.println("Plugindirectory: "); - System.out.println("\t" + System.getProperty("pf4j.pluginsDir", "plugins") + "\n"); - - // retrieves the extensions for Greeting extension point - List greetings = pluginManager.getExtensions(Greeting.class); - System.out.println(String.format("Found %d extensions for extension point '%s'", greetings.size(), Greeting.class.getName())); - for (Greeting greeting : greetings) { - 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)); - // extensionClassNames = pluginManager.getExtensionClassNames(pluginId); - // for (String extension : extensionClassNames) { - // System.out.println(" " + extension); - // } - } - - // stop the plugins - 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)); - } - -} +/* + * 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 ro.fortsoft.pf4j.demo; + +import java.util.List; +import java.util.Set; + +import org.apache.commons.lang3.StringUtils; + +import ro.fortsoft.pf4j.DefaultPluginManager; +import ro.fortsoft.pf4j.PluginManager; +import ro.fortsoft.pf4j.PluginWrapper; +import ro.fortsoft.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(); + + // create the plugin manager + final PluginManager pluginManager = new DefaultPluginManager(); + + // load the plugins + pluginManager.loadPlugins(); + + // enable a disabled plugin +// pluginManager.enablePlugin("welcome-plugin"); + + // start (active/resolved) the plugins + pluginManager.startPlugins(); + + System.out.println("Plugindirectory: "); + System.out.println("\t" + System.getProperty("pf4j.pluginsDir", "plugins") + "\n"); + + // retrieves the extensions for Greeting extension point + List greetings = pluginManager.getExtensions(Greeting.class); + System.out.println(String.format("Found %d extensions for extension point '%s'", greetings.size(), Greeting.class.getName())); + for (Greeting greeting : greetings) { + 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)); + // extensionClassNames = pluginManager.getExtensionClassNames(pluginId); + // for (String extension : extensionClassNames) { + // System.out.println(" " + extension); + // } + } + + // stop the plugins + 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_gradle/plugins/disabled.txt b/demo_gradle/plugins/disabled.txt index fcaef50..45f1801 100644 --- a/demo_gradle/plugins/disabled.txt +++ b/demo_gradle/plugins/disabled.txt @@ -3,4 +3,4 @@ # - add one plugin id on each line # - put this file in plugins folder ######################################## -#welcome-plugin \ No newline at end of file +#welcome-plugin diff --git a/demo_gradle/plugins/enabled.txt b/demo_gradle/plugins/enabled.txt index 5594017..3d76b2f 100644 --- a/demo_gradle/plugins/enabled.txt +++ b/demo_gradle/plugins/enabled.txt @@ -3,4 +3,4 @@ # - add one plugin id on each line # - put this file in plugins folder ######################################## -#welcome-plugin \ No newline at end of file +#welcome-plugin diff --git a/demo_gradle/plugins/plugin2/src/main/java/ro/fortsoft/pf4j/demo/hello/HelloPlugin.java b/demo_gradle/plugins/plugin2/src/main/java/ro/fortsoft/pf4j/demo/hello/HelloPlugin.java index 7072e3d..4502126 100644 --- a/demo_gradle/plugins/plugin2/src/main/java/ro/fortsoft/pf4j/demo/hello/HelloPlugin.java +++ b/demo_gradle/plugins/plugin2/src/main/java/ro/fortsoft/pf4j/demo/hello/HelloPlugin.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. diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/CompoundPluginRepository.java b/pf4j/src/main/java/ro/fortsoft/pf4j/CompoundPluginRepository.java index 28c5d80..60d6163 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/CompoundPluginRepository.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/CompoundPluginRepository.java @@ -18,7 +18,7 @@ import java.util.List; /** * @author Decebal Suiu - * @author Mário Franco + * @author Mário Franco */ public class CompoundPluginRepository implements PluginRepository { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/CyclicDependencyException.java b/pf4j/src/main/java/ro/fortsoft/pf4j/CyclicDependencyException.java index 483665c..17aeddf 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/CyclicDependencyException.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/CyclicDependencyException.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. @@ -14,7 +14,7 @@ package ro.fortsoft.pf4j; /** * CyclicDependencyException will be thrown if a cyclic dependency is detected. - * + * * @author Decebal Suiu */ class CyclicDependencyException extends PluginException { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginDescriptorFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginDescriptorFinder.java index 144fc6e..d347d8d 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginDescriptorFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginDescriptorFinder.java @@ -1,11 +1,11 @@ /* * Copyright 2013 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. @@ -13,9 +13,9 @@ package ro.fortsoft.pf4j; /** - * The default implementation for PluginDescriptorFinder. + * The default implementation for PluginDescriptorFinder. * Now, this class it's a "link" to {@link ro.fortsoft.pf4j.ManifestPluginDescriptorFinder}. - * + * * @author Decebal Suiu */ public class DefaultPluginDescriptorFinder extends ManifestPluginDescriptorFinder { @@ -23,5 +23,5 @@ public class DefaultPluginDescriptorFinder extends ManifestPluginDescriptorFinde public DefaultPluginDescriptorFinder(PluginClasspath pluginClasspath) { super(pluginClasspath); } - + } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginRepository.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginRepository.java index 15f6ca3..b882050 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginRepository.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginRepository.java @@ -22,7 +22,7 @@ import java.util.List; /** * @author Decebal Suiu - * @author Mário Franco + * @author Mário Franco */ public class DefaultPluginRepository implements PluginRepository { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginStatusProvider.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginStatusProvider.java index 84d09cc..7554aaa 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginStatusProvider.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginStatusProvider.java @@ -24,7 +24,7 @@ import ro.fortsoft.pf4j.util.FileUtils; * The default implementation for PluginStatusProvider. * * @author Decebal Suiu - * @author Mário Franco + * @author Mário Franco */ public class DefaultPluginStatusProvider implements PluginStatusProvider { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java index a64aef5..885928b 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DependencyResolver.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,7 +26,7 @@ import ro.fortsoft.pf4j.util.DirectedGraph; class DependencyResolver { private static final Logger log = LoggerFactory.getLogger(DependencyResolver.class); - + private List plugins; public DependencyResolver(List plugins) { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DevelopmentPluginClasspath.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DevelopmentPluginClasspath.java index e14722c..e4d21a0 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DevelopmentPluginClasspath.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DevelopmentPluginClasspath.java @@ -1,11 +1,11 @@ /* * Copyright 2013 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. @@ -14,14 +14,14 @@ package ro.fortsoft.pf4j; /** * Overwrite classes directories to "target/classes" and lib directories to "target/lib". - * + * * @author Decebal Suiu */ public class DevelopmentPluginClasspath extends PluginClasspath { private static final String DEVELOPMENT_CLASSES_DIRECTORY = "target/classes"; private static final String DEVELOPMENT_LIB_DIRECTORY = "target/lib"; - + public DevelopmentPluginClasspath() { super(); } @@ -32,5 +32,5 @@ public class DevelopmentPluginClasspath extends PluginClasspath { libDirectories.add(DEVELOPMENT_LIB_DIRECTORY); } - + } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/Extension.java b/pf4j/src/main/java/ro/fortsoft/pf4j/Extension.java index f2c01bd..f30d123 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/Extension.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/Extension.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. @@ -28,5 +28,5 @@ import java.lang.annotation.Target; public @interface Extension { int ordinal() default 0; - + } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionPoint.java b/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionPoint.java index 8d94847..11be4bd 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionPoint.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionPoint.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. diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionWrapper.java b/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionWrapper.java index d6ac74d..747c991 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionWrapper.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionWrapper.java @@ -52,4 +52,4 @@ public class ExtensionWrapper implements Comparable> { this.extensionFactory = extensionFactory; } -} \ No newline at end of file +} diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionsIndexer.java b/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionsIndexer.java index c4a8f40..eec6c95 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionsIndexer.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/ExtensionsIndexer.java @@ -1,11 +1,11 @@ /* * Copyright 2013 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. @@ -37,9 +37,9 @@ import javax.tools.StandardLocation; public class ExtensionsIndexer extends AbstractProcessor { public static final String EXTENSIONS_RESOURCE = "META-INF/extensions.idx"; - + private List extensions = new ArrayList(); - + @Override public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); @@ -49,16 +49,16 @@ public class ExtensionsIndexer extends AbstractProcessor { public Set getSupportedAnnotationTypes() { Set annotationTypes = new HashSet(); annotationTypes.add(Extension.class.getName()); - + return annotationTypes; } - + @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { return false; } - + for (Element element : roundEnv.getElementsAnnotatedWith(Extension.class)) { if (!(element instanceof TypeElement)) { continue; @@ -69,7 +69,7 @@ public class ExtensionsIndexer extends AbstractProcessor { processingEnv.getMessager().printMessage(Kind.NOTE, message); extensions.add(typeElement); } - + /* if (!roundEnv.processingOver()) { return false; @@ -77,17 +77,17 @@ public class ExtensionsIndexer extends AbstractProcessor { */ write(); - + return false; // return true; // no further processing of this annotation type } - + private void write() { Set entries = new HashSet(); for (TypeElement typeElement : extensions) { entries.add(processingEnv.getElementUtils().getBinaryName(typeElement).toString()); } - + read(entries); // read old entries write(entries); // write entries } @@ -107,7 +107,7 @@ public class ExtensionsIndexer extends AbstractProcessor { processingEnv.getMessager().printMessage(Kind.ERROR, e.toString()); } } - + private void read(Set entries) { try { FileObject file = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", EXTENSIONS_RESOURCE); @@ -119,17 +119,17 @@ public class ExtensionsIndexer extends AbstractProcessor { // java6 does not support reading old index files } } - + public static void readIndex(Reader reader, Set entries) throws IOException { BufferedReader bufferedReader = new BufferedReader(reader); - + String line; while ((line = bufferedReader.readLine()) != null) { entries.add(line); } - + reader.close(); } - + } - \ No newline at end of file + diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/Plugin.java b/pf4j/src/main/java/ro/fortsoft/pf4j/Plugin.java index 80221ac..8cfdb2d 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/Plugin.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/Plugin.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. diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptorFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptorFinder.java index 44b0846..f6c82d0 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptorFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptorFinder.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. @@ -18,11 +18,11 @@ import java.io.File; * Find a plugin descriptor in a directory (plugin repository). * You can find in manifest file @see DefaultPluginDescriptorFinder, * xml file, properties file, java services (with ServiceLoader), etc. - * + * * @author Decebal Suiu */ public interface PluginDescriptorFinder { public PluginDescriptor find(File pluginRepository) throws PluginException; - + } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginException.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginException.java index e048c1f..1b4f2a4 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginException.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginException.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. diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginNotFoundException.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginNotFoundException.java index 67658f3..21eff10 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginNotFoundException.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginNotFoundException.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. @@ -18,12 +18,12 @@ package ro.fortsoft.pf4j; class PluginNotFoundException extends PluginException { private static final long serialVersionUID = 1L; - + private String pluginId; public PluginNotFoundException(String pluginId) { super("Plugin '" + pluginId + "' not found."); - + this.pluginId = pluginId; } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginRepository.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginRepository.java index dcdcc42..797fdd0 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginRepository.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginRepository.java @@ -19,7 +19,7 @@ import java.util.List; * Directory whose contents are .zip files used as plugins. * * @author Decebal Suiu - * @author Mário Franco + * @author Mário Franco */ public interface PluginRepository { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginStatusProvider.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginStatusProvider.java index 33c7b6f..9c95328 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginStatusProvider.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginStatusProvider.java @@ -14,7 +14,7 @@ package ro.fortsoft.pf4j; /** * @author Decebal Suiu - * @author Mário Franco + * @author Mário Franco */ public interface PluginStatusProvider { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/RuntimeMode.java b/pf4j/src/main/java/ro/fortsoft/pf4j/RuntimeMode.java index 0e7cd3a..fa57b2a 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/RuntimeMode.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/RuntimeMode.java @@ -1,11 +1,11 @@ /* * Copyright 2013 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. @@ -20,20 +20,20 @@ import java.util.NoSuchElementException; * @author Decebal Suiu */ public enum RuntimeMode { - + DEVELOPMENT("development"), // development - DEPLOYMENT("deployment"); // deployment + DEPLOYMENT("deployment"); // deployment private final String name; - + private static final Map map = new HashMap(); - + static { for (RuntimeMode mode : RuntimeMode.values()) { map.put(mode.name, mode); } } - + private RuntimeMode(final String name) { this.name = name; } @@ -42,14 +42,14 @@ public enum RuntimeMode { public String toString() { return name; } - + public static RuntimeMode byName(String name) { if (map.containsKey(name)) { return map.get(name); } - throw new NoSuchElementException("Cannot found PF4J runtime mode with name '" + name + + throw new NoSuchElementException("Cannot found PF4J runtime mode with name '" + name + "'. Must be 'development' or 'deployment'."); } - -} \ No newline at end of file + +} diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/AndFileFilter.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/AndFileFilter.java index b50e852..b06c1d9 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/AndFileFilter.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/AndFileFilter.java @@ -1,11 +1,11 @@ /* * Copyright 2013 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. diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectedGraph.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectedGraph.java index 5c1f446..06d8986 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectedGraph.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectedGraph.java @@ -1,171 +1,171 @@ -/* - * 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 ro.fortsoft.pf4j.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Stack; - -/** - * @author Decebal Suiu - */ -public class DirectedGraph { - - /** - * The implementation here is basically an adjacency list, but instead - * of an array of lists, a Map is used to map each vertex to its list of - * adjacent vertices. - */ - private Map> neighbors = new HashMap>(); - - /** - * Add a vertex to the graph. Nothing happens if vertex is already in graph. - */ - public void addVertex(V vertex) { - if (neighbors.containsKey(vertex)) { - return; - } - neighbors.put(vertex, new ArrayList()); - } - - /** - * True if graph contains vertex. - */ - public boolean containsVertex(V vertex) { - return neighbors.containsKey(vertex); - } - - /** - * Add an edge to the graph; if either vertex does not exist, it's added. - * This implementation allows the creation of multi-edges and self-loops. - */ - public void addEdge(V from, V to) { - this.addVertex(from); - this.addVertex(to); - neighbors.get(from).add(to); - } - - /** - * Remove an edge from the graph. Nothing happens if no such edge. - * @throws IllegalArgumentException if either vertex doesn't exist. - */ - public void remove(V from, V to) { - if (!(this.containsVertex(from) && this.containsVertex(to))) { - throw new IllegalArgumentException("Nonexistent vertex"); - } - neighbors.get(from).remove(to); - } - - /** - * Report (as a Map) the out-degree of each vertex. - */ - public Map outDegree() { - Map result = new HashMap(); - for (V vertex : neighbors.keySet()) { - result.put(vertex, neighbors.get(vertex).size()); - } - - return result; - } - - /** - * Report (as a Map) the in-degree of each vertex. - */ - public Map inDegree() { - Map result = new HashMap(); - for (V vertex : neighbors.keySet()) { - result.put(vertex, 0); // all in-degrees are 0 - } - for (V from : neighbors.keySet()) { - for (V to : neighbors.get(from)) { - result.put(to, result.get(to) + 1); // increment in-degree - } - } - - return result; - } - - /** - * Report (as a List) the topological sort of the vertices; null for no such sort. - */ - public List topologicalSort() { - Map degree = inDegree(); - - // determine all vertices with zero in-degree - Stack zeroVertices = new Stack(); // stack as good as any here - for (V v : degree.keySet()) { - if (degree.get(v) == 0) { - zeroVertices.push(v); - } - } - - // determine the topological order - List result = new ArrayList(); - while (!zeroVertices.isEmpty()) { - V vertex = zeroVertices.pop(); // choose a vertex with zero in-degree - result.add(vertex); // vertex 'v' is next in topological order - // "remove" vertex 'v' by updating its neighbors - for (V neighbor : neighbors.get(vertex)) { - degree.put(neighbor, degree.get(neighbor) - 1); - // remember any vertices that now have zero in-degree - if (degree.get(neighbor) == 0) { - zeroVertices.push(neighbor); - } - } - } - - // check that we have used the entire graph (if not, there was a cycle) - if (result.size() != neighbors.size()) { - return null; - } - - return result; - } - - /** - * Report (as a List) the reverse topological sort of the vertices; null for no such sort. - */ - public List reverseTopologicalSort() { - List list = topologicalSort(); - if (list == null) { - return null; - } - Collections.reverse(list); - - return list; - } - - /** - * True if graph is a dag (directed acyclic graph). - */ - public boolean isDag () { - return topologicalSort() != null; - } - - /** - * String representation of graph. - */ - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - for (V vertex : neighbors.keySet()) { - sb.append("\n " + vertex + " -> " + neighbors.get(vertex)); - } - - return sb.toString(); - } - -} +/* + * 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 ro.fortsoft.pf4j.util; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Stack; + +/** + * @author Decebal Suiu + */ +public class DirectedGraph { + + /** + * The implementation here is basically an adjacency list, but instead + * of an array of lists, a Map is used to map each vertex to its list of + * adjacent vertices. + */ + private Map> neighbors = new HashMap>(); + + /** + * Add a vertex to the graph. Nothing happens if vertex is already in graph. + */ + public void addVertex(V vertex) { + if (neighbors.containsKey(vertex)) { + return; + } + neighbors.put(vertex, new ArrayList()); + } + + /** + * True if graph contains vertex. + */ + public boolean containsVertex(V vertex) { + return neighbors.containsKey(vertex); + } + + /** + * Add an edge to the graph; if either vertex does not exist, it's added. + * This implementation allows the creation of multi-edges and self-loops. + */ + public void addEdge(V from, V to) { + this.addVertex(from); + this.addVertex(to); + neighbors.get(from).add(to); + } + + /** + * Remove an edge from the graph. Nothing happens if no such edge. + * @throws IllegalArgumentException if either vertex doesn't exist. + */ + public void remove(V from, V to) { + if (!(this.containsVertex(from) && this.containsVertex(to))) { + throw new IllegalArgumentException("Nonexistent vertex"); + } + neighbors.get(from).remove(to); + } + + /** + * Report (as a Map) the out-degree of each vertex. + */ + public Map outDegree() { + Map result = new HashMap(); + for (V vertex : neighbors.keySet()) { + result.put(vertex, neighbors.get(vertex).size()); + } + + return result; + } + + /** + * Report (as a Map) the in-degree of each vertex. + */ + public Map inDegree() { + Map result = new HashMap(); + for (V vertex : neighbors.keySet()) { + result.put(vertex, 0); // all in-degrees are 0 + } + for (V from : neighbors.keySet()) { + for (V to : neighbors.get(from)) { + result.put(to, result.get(to) + 1); // increment in-degree + } + } + + return result; + } + + /** + * Report (as a List) the topological sort of the vertices; null for no such sort. + */ + public List topologicalSort() { + Map degree = inDegree(); + + // determine all vertices with zero in-degree + Stack zeroVertices = new Stack(); // stack as good as any here + for (V v : degree.keySet()) { + if (degree.get(v) == 0) { + zeroVertices.push(v); + } + } + + // determine the topological order + List result = new ArrayList(); + while (!zeroVertices.isEmpty()) { + V vertex = zeroVertices.pop(); // choose a vertex with zero in-degree + result.add(vertex); // vertex 'v' is next in topological order + // "remove" vertex 'v' by updating its neighbors + for (V neighbor : neighbors.get(vertex)) { + degree.put(neighbor, degree.get(neighbor) - 1); + // remember any vertices that now have zero in-degree + if (degree.get(neighbor) == 0) { + zeroVertices.push(neighbor); + } + } + } + + // check that we have used the entire graph (if not, there was a cycle) + if (result.size() != neighbors.size()) { + return null; + } + + return result; + } + + /** + * Report (as a List) the reverse topological sort of the vertices; null for no such sort. + */ + public List reverseTopologicalSort() { + List list = topologicalSort(); + if (list == null) { + return null; + } + Collections.reverse(list); + + return list; + } + + /** + * True if graph is a dag (directed acyclic graph). + */ + public boolean isDag () { + return topologicalSort() != null; + } + + /** + * String representation of graph. + */ + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + for (V vertex : neighbors.keySet()) { + sb.append("\n " + vertex + " -> " + neighbors.get(vertex)); + } + + return sb.toString(); + } + +} diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectoryFileFilter.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectoryFileFilter.java index 3877222..e73fd3b 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectoryFileFilter.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/DirectoryFileFilter.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. @@ -17,7 +17,7 @@ import java.io.FileFilter; /** * Filter accepts files that are directories. - * + * * @author Decebal Suiu */ public class DirectoryFileFilter implements FileFilter { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/ExtensionFileFilter.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/ExtensionFileFilter.java index 03ed0b7..d1e17bc 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/ExtensionFileFilter.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/ExtensionFileFilter.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. @@ -17,7 +17,7 @@ import java.io.FileFilter; /** * Filter accepts any file ending in extension. The case of the filename is ignored. - * + * * @author Decebal Suiu */ public class ExtensionFileFilter implements FileFilter { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/HiddenFilter.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/HiddenFilter.java index eed53f1..cfd2355 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/HiddenFilter.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/HiddenFilter.java @@ -1,11 +1,11 @@ /* * Copyright 2013 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. @@ -17,7 +17,7 @@ import java.io.FileFilter; /** * Filter that only accepts hidden files. - * + * * @author decebal.suiu */ public class HiddenFilter implements FileFilter { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/JarFileFilter.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/JarFileFilter.java index 5c1f0ca..24fc12e 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/JarFileFilter.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/JarFileFilter.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. diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/NotFileFilter.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/NotFileFilter.java index 68ff3e0..83f8dd0 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/NotFileFilter.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/NotFileFilter.java @@ -1,11 +1,11 @@ /* * Copyright 2013 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. diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/StringUtils.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/StringUtils.java index 1938c27..94cd640 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/StringUtils.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/StringUtils.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. diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/Unzip.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/Unzip.java index 74d60d5..d00d3ac 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/Unzip.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/Unzip.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. diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/ZipFileFilter.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/ZipFileFilter.java index 9743fb6..bae9265 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/ZipFileFilter.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/ZipFileFilter.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. -- 2.39.5