} 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;
}
}
- // 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);
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.pf4j.asm;
import org.objectweb.asm.ClassReader;
* @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;
}
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;
}
}
+
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.pf4j.asm;
import org.objectweb.asm.AnnotationVisitor;
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;
* @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) {
@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);
}
return super.visitArray(name);
}
+
};
}
+
}