From: Decebal Suiu Date: Fri, 11 Jan 2019 20:21:26 +0000 (+0200) Subject: Formatting X-Git-Tag: release-2.6.0~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8feda969a0a0224127479ea350ab4fd34ccfa3f1;p=pf4j.git Formatting --- 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 plugins = new ArrayList<>(); List 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); } + }; } + }