aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDecebal Suiu <decebal.suiu@gmail.com>2014-04-12 22:11:34 +0300
committerDecebal Suiu <decebal.suiu@gmail.com>2014-04-12 22:11:34 +0300
commitb5589a7d0ba12a13130c2f62578ad0d88dd5eb7a (patch)
tree68c9f37ba78b152073e03ba155bbce22e08a0838
parentf9be0a48ceb61395453c263b32958eb5a2190040 (diff)
parent2bc87639f97236312a1f8e5a895f6af76cd37612 (diff)
downloadpf4j-b5589a7d0ba12a13130c2f62578ad0d88dd5eb7a.tar.gz
pf4j-b5589a7d0ba12a13130c2f62578ad0d88dd5eb7a.zip
Merge pull request #13 from gitblit/description
Add an optional description to the manifest
-rw-r--r--pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java37
-rw-r--r--pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java22
2 files changed, 39 insertions, 20 deletions
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java
index fd82793..2de42f5 100644
--- a/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java
+++ b/pf4j/src/main/java/ro/fortsoft/pf4j/ManifestPluginDescriptorFinder.java
@@ -1,11 +1,11 @@
/*
* Copyright 2012 Decebal Suiu
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with
* the License. You may obtain a copy of the License in the LICENSE file, or 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.
@@ -32,9 +32,9 @@ import ro.fortsoft.pf4j.util.StringUtils;
public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder {
private static final Logger log = LoggerFactory.getLogger(ManifestPluginDescriptorFinder.class);
-
+
private PluginClasspath pluginClasspath;
-
+
public ManifestPluginDescriptorFinder(PluginClasspath pluginClasspath) {
this.pluginClasspath = pluginClasspath;
}
@@ -53,9 +53,9 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder {
try {
input = new FileInputStream(manifestFile);
} catch (FileNotFoundException e) {
- // not happening
+ // not happening
}
-
+
Manifest manifest = null;
try {
manifest = new Manifest(input);
@@ -67,10 +67,10 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder {
} catch (IOException e) {
throw new PluginException(e.getMessage(), e);
}
- }
-
+ }
+
PluginDescriptor pluginDescriptor = new PluginDescriptor();
-
+
// TODO validate !!!
Attributes attrs = manifest.getMainAttributes();
String id = attrs.getValue("Plugin-Id");
@@ -78,25 +78,32 @@ public class ManifestPluginDescriptorFinder implements PluginDescriptorFinder {
throw new PluginException("Plugin-Id cannot be empty");
}
pluginDescriptor.setPluginId(id);
-
+
+ String description = attrs.getValue("Plugin-Description");
+ if (StringUtils.isEmpty(description)) {
+ pluginDescriptor.setPluginDescription("");
+ } else {
+ pluginDescriptor.setPluginDescription(description);
+ }
+
String clazz = attrs.getValue("Plugin-Class");
if (StringUtils.isEmpty(clazz)) {
throw new PluginException("Plugin-Class cannot be empty");
}
pluginDescriptor.setPluginClass(clazz);
-
+
String version = attrs.getValue("Plugin-Version");
if (StringUtils.isEmpty(version)) {
throw new PluginException("Plugin-Version cannot be empty");
}
pluginDescriptor.setPluginVersion(PluginVersion.createVersion(version));
-
+
String provider = attrs.getValue("Plugin-Provider");
- pluginDescriptor.setProvider(provider);
+ pluginDescriptor.setProvider(provider);
String dependencies = attrs.getValue("Plugin-Dependencies");
pluginDescriptor.setDependencies(dependencies);
return pluginDescriptor;
}
-
+
}
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java
index 546f003..cb91f7d 100644
--- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java
+++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java
@@ -1,11 +1,11 @@
/*
* Copyright 2012 Decebal Suiu
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with
* the License. You may obtain a copy of the License in the LICENSE file, or 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.
@@ -25,6 +25,7 @@ import java.util.List;
public class PluginDescriptor {
private String pluginId;
+ private String pluginDescription;
private String pluginClass;
private PluginVersion version;
private String provider;
@@ -42,6 +43,13 @@ public class PluginDescriptor {
}
/**
+ * Returns the description of this plugin.
+ */
+ public String getPluginDescription() {
+ return pluginDescription;
+ }
+
+ /**
* Returns the name of the class that implements Plugin interface.
*/
public String getPluginClass() {
@@ -82,6 +90,10 @@ public class PluginDescriptor {
this.pluginId = pluginId;
}
+ void setPluginDescription(String pluginDescription) {
+ this.pluginDescription = pluginDescription;
+ }
+
void setPluginClass(String pluginClassName) {
this.pluginClass = pluginClassName;
}
@@ -93,7 +105,7 @@ public class PluginDescriptor {
void setProvider(String provider) {
this.provider = provider;
}
-
+
void setDependencies(String dependencies) {
if (dependencies != null) {
dependencies = dependencies.trim();
@@ -101,7 +113,7 @@ public class PluginDescriptor {
this.dependencies = Collections.emptyList();
} else {
this.dependencies = new ArrayList<PluginDependency>();
- String[] tokens = dependencies.split(",");
+ String[] tokens = dependencies.split(",");
for (String dependency : tokens) {
dependency = dependency.trim();
if (!dependency.isEmpty()) {