aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demo/app/src/main/java/org/pf4j/demo/Boot.java11
-rw-r--r--pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java12
-rw-r--r--pf4j/src/main/java/org/pf4j/DefaultPluginManager.java4
-rw-r--r--pf4j/src/main/java/org/pf4j/JarPluginManager.java69
-rw-r--r--pf4j/src/main/java/org/pf4j/JarPluginRepository.java31
5 files changed, 47 insertions, 80 deletions
diff --git a/demo/app/src/main/java/org/pf4j/demo/Boot.java b/demo/app/src/main/java/org/pf4j/demo/Boot.java
index 76145a4..ba5396e 100644
--- a/demo/app/src/main/java/org/pf4j/demo/Boot.java
+++ b/demo/app/src/main/java/org/pf4j/demo/Boot.java
@@ -15,16 +15,14 @@
*/
package org.pf4j.demo;
-import java.util.List;
-import java.util.Set;
-
import org.apache.commons.lang.StringUtils;
-
+import org.pf4j.DefaultPluginManager;
import org.pf4j.PluginManager;
import org.pf4j.PluginWrapper;
import org.pf4j.demo.api.Greeting;
-import org.pf4j.DefaultPluginManager;
-import org.pf4j.JarPluginManager;
+
+import java.util.List;
+import java.util.Set;
/**
* A boot class that start the demo.
@@ -39,7 +37,6 @@ public class Boot {
// create the plugin manager
final PluginManager pluginManager = new DefaultPluginManager();
-// final PluginManager pluginManager = new JarPluginManager();
// load the plugins
pluginManager.loadPlugins();
diff --git a/pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java b/pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java
index 105929c..2bc1257 100644
--- a/pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java
+++ b/pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java
@@ -25,10 +25,16 @@ import java.util.List;
*/
public class CompoundPluginRepository implements PluginRepository {
- private final PluginRepository[] repositories;
+ private List<PluginRepository> repositories = new ArrayList<>();
- public CompoundPluginRepository(PluginRepository... repositories) {
- this.repositories = repositories;
+ public CompoundPluginRepository add(PluginRepository repository) {
+ if (repository == null) {
+ throw new IllegalArgumentException("null not allowed");
+ }
+
+ repositories.add(repository);
+
+ return this;
}
@Override
diff --git a/pf4j/src/main/java/org/pf4j/DefaultPluginManager.java b/pf4j/src/main/java/org/pf4j/DefaultPluginManager.java
index 1010bcf..660950f 100644
--- a/pf4j/src/main/java/org/pf4j/DefaultPluginManager.java
+++ b/pf4j/src/main/java/org/pf4j/DefaultPluginManager.java
@@ -83,7 +83,9 @@ public class DefaultPluginManager extends AbstractPluginManager {
@Override
protected PluginRepository createPluginRepository() {
- return new DefaultPluginRepository(getPluginsRoot(), isDevelopment());
+ return new CompoundPluginRepository()
+ .add(new DefaultPluginRepository(getPluginsRoot(), isDevelopment()))
+ .add(new JarPluginRepository(getPluginsRoot()));
}
@Override
diff --git a/pf4j/src/main/java/org/pf4j/JarPluginManager.java b/pf4j/src/main/java/org/pf4j/JarPluginManager.java
deleted file mode 100644
index 9e66df8..0000000
--- a/pf4j/src/main/java/org/pf4j/JarPluginManager.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2016 Decebal Suiu
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License 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;
-
-import org.pf4j.util.AndFileFilter;
-import org.pf4j.util.DirectoryFileFilter;
-import org.pf4j.util.HiddenFilter;
-import org.pf4j.util.JarFileFilter;
-import org.pf4j.util.NameFileFilter;
-import org.pf4j.util.NotFileFilter;
-import org.pf4j.util.OrFileFilter;
-
-import java.io.FileFilter;
-import java.nio.file.Path;
-
-/**
- * It's a {@link PluginManager} that loads plugin from a jar file.
- * Actually, a plugin is a fat jar, a jar which contains classes from all the libraries,
- * on which your project depends and, of course, the classes of current project.
- *
- * @author Decebal Suiu
- */
-public class JarPluginManager extends DefaultPluginManager {
-
- @Override
- protected PluginRepository createPluginRepository() {
- return new JarPluginRepository(getPluginsRoot(), isDevelopment());
- }
-
- class JarPluginRepository extends BasePluginRepository {
-
- public JarPluginRepository(Path pluginsRoot, boolean development) {
- super(pluginsRoot);
-
- if (development) {
- AndFileFilter pluginsFilter = new AndFileFilter(new DirectoryFileFilter());
- pluginsFilter.addFileFilter(new NotFileFilter(createHiddenPluginFilter(development)));
- setFilter(pluginsFilter);
- } else {
- setFilter(new JarFileFilter());
- }
- }
-
- protected FileFilter createHiddenPluginFilter(boolean development) {
- OrFileFilter hiddenPluginFilter = new OrFileFilter(new HiddenFilter());
-
- if (development) {
- hiddenPluginFilter.addFileFilter(new NameFileFilter("target"));
- }
-
- return hiddenPluginFilter;
- }
-
- }
-
-}
diff --git a/pf4j/src/main/java/org/pf4j/JarPluginRepository.java b/pf4j/src/main/java/org/pf4j/JarPluginRepository.java
new file mode 100644
index 0000000..e98c286
--- /dev/null
+++ b/pf4j/src/main/java/org/pf4j/JarPluginRepository.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2016 Decebal Suiu
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License 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;
+
+import org.pf4j.util.JarFileFilter;
+
+import java.nio.file.Path;
+
+/**
+ * @author Decebal Suiu
+ */
+public class JarPluginRepository extends BasePluginRepository {
+
+ public JarPluginRepository(Path pluginsRoot) {
+ super(pluginsRoot, new JarFileFilter());
+ }
+
+}