aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDecebal Suiu <decebal.suiu@gmail.com>2019-01-11 22:21:26 +0200
committerDecebal Suiu <decebal.suiu@gmail.com>2019-01-11 22:21:26 +0200
commit8feda969a0a0224127479ea350ab4fd34ccfa3f1 (patch)
tree341cbe352022dadb297724db1e3a15372309c5e3
parent153c7b332627e3ea0b06d9d8a6d52b8373e6c2db (diff)
downloadpf4j-8feda969a0a0224127479ea350ab4fd34ccfa3f1.tar.gz
pf4j-8feda969a0a0224127479ea350ab4fd34ccfa3f1.zip
Formatting
-rw-r--r--pf4j/src/main/java/org/pf4j/DependencyResolver.java6
-rw-r--r--pf4j/src/main/java/org/pf4j/Extension.java1
-rw-r--r--pf4j/src/main/java/org/pf4j/PluginDependency.java3
-rw-r--r--pf4j/src/main/java/org/pf4j/asm/ExtensionInfo.java7
-rw-r--r--pf4j/src/main/java/org/pf4j/asm/ExtensionVisitor.java23
5 files changed, 23 insertions, 17 deletions
diff --git a/pf4j/src/main/java/org/pf4j/DependencyResolver.java b/pf4j/src/main/java/org/pf4j/DependencyResolver.java
index c528d63..6cc4e2e 100644
--- a/pf4j/src/main/java/org/pf4j/DependencyResolver.java
+++ b/pf4j/src/main/java/org/pf4j/DependencyResolver.java
@@ -145,8 +145,7 @@ public class DependencyResolver {
} else {
boolean edgeAdded = false;
for (PluginDependency dependency : dependencies) {
- // Don't register optional plugins in the dependency graph
- // to avoid automatic disabling of the plugin,
+ // Don't register optional plugins in the dependency graph to avoid automatic disabling of the plugin,
// if an optional dependency is missing.
if (!dependency.isOptional()) {
edgeAdded = true;
@@ -155,8 +154,7 @@ public class DependencyResolver {
}
}
- // Register the plugin without dependencies,
- // if all of its dependencies are optional.
+ // Register the plugin without dependencies, if all of its dependencies are optional.
if (!edgeAdded) {
dependenciesGraph.addVertex(pluginId);
dependentsGraph.addVertex(pluginId);
diff --git a/pf4j/src/main/java/org/pf4j/Extension.java b/pf4j/src/main/java/org/pf4j/Extension.java
index 43b749e..57a435c 100644
--- a/pf4j/src/main/java/org/pf4j/Extension.java
+++ b/pf4j/src/main/java/org/pf4j/Extension.java
@@ -59,4 +59,5 @@ public @interface Extension {
* @return plugin IDs, that have to be available in order to load this extension
*/
String[] plugins() default {};
+
}
diff --git a/pf4j/src/main/java/org/pf4j/PluginDependency.java b/pf4j/src/main/java/org/pf4j/PluginDependency.java
index 47e77e6..85d3c22 100644
--- a/pf4j/src/main/java/org/pf4j/PluginDependency.java
+++ b/pf4j/src/main/java/org/pf4j/PluginDependency.java
@@ -35,8 +35,7 @@ public class PluginDependency {
}
}
- // A dependency is considered as optional,
- // if the plugin id ends with a question mark.
+ // A dependency is considered as optional, if the plugin id ends with a question mark.
this.optional = this.pluginId.endsWith("?");
if (this.optional) {
this.pluginId = this.pluginId.substring(0, this.pluginId.length() - 1);
diff --git a/pf4j/src/main/java/org/pf4j/asm/ExtensionInfo.java b/pf4j/src/main/java/org/pf4j/asm/ExtensionInfo.java
index e81763d..d0acee1 100644
--- a/pf4j/src/main/java/org/pf4j/asm/ExtensionInfo.java
+++ b/pf4j/src/main/java/org/pf4j/asm/ExtensionInfo.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.pf4j.asm;
import org.objectweb.asm.ClassReader;
@@ -35,14 +34,16 @@ import java.util.List;
* @author Decebal Suiu
*/
public final class ExtensionInfo {
+
private static final Logger log = LoggerFactory.getLogger(ExtensionInfo.class);
+
private final String className;
+
int ordinal = 0;
List<String> plugins = new ArrayList<>();
List<String> points = new ArrayList<>();
private ExtensionInfo(String className) {
- super();
this.className = className;
}
@@ -93,10 +94,12 @@ public final class ExtensionInfo {
try (InputStream input = classLoader.getResourceAsStream(className.replace('.', '/') + ".class")) {
ExtensionInfo info = new ExtensionInfo(className);
new ClassReader(input).accept(new ExtensionVisitor(info), ClassReader.SKIP_DEBUG);
+
return info;
} catch (IOException e) {
log.error(e.getMessage(), e);
return null;
}
}
+
}
diff --git a/pf4j/src/main/java/org/pf4j/asm/ExtensionVisitor.java b/pf4j/src/main/java/org/pf4j/asm/ExtensionVisitor.java
index fa92c67..b2a17f5 100644
--- a/pf4j/src/main/java/org/pf4j/asm/ExtensionVisitor.java
+++ b/pf4j/src/main/java/org/pf4j/asm/ExtensionVisitor.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.pf4j.asm;
import org.objectweb.asm.AnnotationVisitor;
@@ -21,6 +20,8 @@ import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.pf4j.Extension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Arrays;
@@ -38,8 +39,11 @@ import java.util.Arrays;
* @author Decebal Suiu
*/
class ExtensionVisitor extends ClassVisitor {
- //private static final Logger log = LoggerFactory.getLogger(ExtensionVisitor.class);
+
+ private static final Logger log = LoggerFactory.getLogger(ExtensionVisitor.class);
+
private static final int ASM_VERSION = Opcodes.ASM7;
+
private final ExtensionInfo extensionInfo;
ExtensionVisitor(ExtensionInfo extensionInfo) {
@@ -63,24 +67,23 @@ class ExtensionVisitor extends ClassVisitor {
@Override
public void visit(String key, Object value) {
- //log.debug("Load annotation attribute {} = {} ({})", name, value, value.getClass().getName());
-
+ log.debug("Load annotation attribute {} = {} ({})", name, value, value.getClass().getName());
if ("ordinal".equals(name)) {
extensionInfo.ordinal = Integer.parseInt(value.toString());
} else if ("plugins".equals(name)) {
if (value instanceof String) {
- //log.debug("found plugin " + value);
+ log.debug("Found plugin {}", value);
extensionInfo.plugins.add((String) value);
} else if (value instanceof String[]) {
- //log.debug("found plugins " + Arrays.toString((String[]) value));
+ log.debug("Found plugins {}", Arrays.toString((String[]) value));
extensionInfo.plugins.addAll(Arrays.asList((String[]) value));
} else {
- //log.debug("found plugin " + value.toString());
+ log.debug("Found plugin {}", value.toString());
extensionInfo.plugins.add(value.toString());
}
- } else if ("points".equals(name)) {
+ } else {
String pointClassName = ((Type) value).getClassName();
- //log.debug("found point " + pointClassName);
+ log.debug("Found point " + pointClassName);
extensionInfo.points.add(pointClassName);
}
@@ -91,6 +94,8 @@ class ExtensionVisitor extends ClassVisitor {
return super.visitArray(name);
}
+
};
}
+
}