From: Decebal Suiu Date: Mon, 19 Mar 2018 18:21:35 +0000 (+0200) Subject: Resolve #199 X-Git-Tag: release-2.3.0~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9b6d4a3efb31351cb45d1187edba796e03bcec16;p=pf4j.git Resolve #199 --- diff --git a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java index 99aff8c..57f1c86 100644 --- a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java +++ b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java @@ -887,10 +887,6 @@ public abstract class AbstractPluginManager implements PluginManager { throw new PluginException("Field 'id' cannot be empty"); } - if (StringUtils.isNullOrEmpty(descriptor.getPluginClass())) { - throw new PluginException("Field 'class' cannot be empty"); - } - if (descriptor.getVersion() == null) { throw new PluginException("Field 'version' cannot be empty"); } diff --git a/pf4j/src/main/java/org/pf4j/DefaultPluginDescriptor.java b/pf4j/src/main/java/org/pf4j/DefaultPluginDescriptor.java index 61a7d2a..4d81a8d 100644 --- a/pf4j/src/main/java/org/pf4j/DefaultPluginDescriptor.java +++ b/pf4j/src/main/java/org/pf4j/DefaultPluginDescriptor.java @@ -26,7 +26,7 @@ public class DefaultPluginDescriptor implements PluginDescriptor { private String pluginId; private String pluginDescription; - private String pluginClass; + private String pluginClass = Plugin.class.getName(); private String version; private String requires = "*"; // SemVer format private String provider; @@ -37,15 +37,6 @@ public class DefaultPluginDescriptor implements PluginDescriptor { dependencies = new ArrayList<>(); } - /** - * @param pluginId - * @param pluginDescription - * @param pluginClass - * @param version - * @param requires - * @param provider - * @param license - */ public DefaultPluginDescriptor(String pluginId, String pluginDescription, String pluginClass, String version, String requires, String provider, String license) { this(); this.pluginId = pluginId; diff --git a/pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java b/pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java index e2f26c9..d6ef17f 100644 --- a/pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java +++ b/pf4j/src/main/java/org/pf4j/ManifestPluginDescriptorFinder.java @@ -103,7 +103,9 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder { } String clazz = attributes.getValue("Plugin-Class"); - pluginDescriptor.setPluginClass(clazz); + if (StringUtils.isNotNullOrEmpty(clazz)) { + pluginDescriptor.setPluginClass(clazz); + } String version = attributes.getValue("Plugin-Version"); if (StringUtils.isNotNullOrEmpty(version)) { diff --git a/pf4j/src/main/java/org/pf4j/Plugin.java b/pf4j/src/main/java/org/pf4j/Plugin.java index 1972664..cfaa343 100644 --- a/pf4j/src/main/java/org/pf4j/Plugin.java +++ b/pf4j/src/main/java/org/pf4j/Plugin.java @@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory; * * @author Decebal Suiu */ -public abstract class Plugin { +public class Plugin { /** * Makes logging service available for descending classes. diff --git a/pf4j/src/main/java/org/pf4j/PropertiesPluginDescriptorFinder.java b/pf4j/src/main/java/org/pf4j/PropertiesPluginDescriptorFinder.java index 80026b9..cedb4aa 100644 --- a/pf4j/src/main/java/org/pf4j/PropertiesPluginDescriptorFinder.java +++ b/pf4j/src/main/java/org/pf4j/PropertiesPluginDescriptorFinder.java @@ -109,7 +109,9 @@ public class PropertiesPluginDescriptorFinder implements PluginDescriptorFinder } String clazz = properties.getProperty("plugin.class"); - pluginDescriptor.setPluginClass(clazz); + if (StringUtils.isNotNullOrEmpty(clazz)) { + pluginDescriptor.setPluginClass(clazz); + } String version = properties.getProperty("plugin.version"); if (StringUtils.isNotNullOrEmpty(version)) {