<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
</dependencies>
</project>
</scm>
<dependencies>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- </dependency>
-
<dependency>
<groupId>net.java.sezpoz</groupId>
<artifactId>sezpoz</artifactId>
import java.util.jar.Attributes;
import java.util.jar.Manifest;
-import org.apache.commons.lang.StringUtils;
-
/**
* Read the plugin descriptor from the manifest file.
*
// TODO validate !!!
Attributes attrs = manifest.getMainAttributes();
String id = attrs.getValue("Plugin-Id");
- if (StringUtils.isEmpty(id)) {
+ if (isEmpty(id)) {
throw new PluginException("Plugin-Id cannot be empty");
}
pluginDescriptor.setPluginId(id);
String clazz = attrs.getValue("Plugin-Class");
- if (StringUtils.isEmpty(clazz)) {
+ if (isEmpty(clazz)) {
throw new PluginException("Plugin-Class cannot be empty");
}
pluginDescriptor.setPluginClass(clazz);
String version = attrs.getValue("Plugin-Version");
- if (StringUtils.isEmpty(version)) {
+ if (isEmpty(version)) {
throw new PluginException("Plugin-Version cannot be empty");
}
pluginDescriptor.setPluginVersion(PluginVersion.createVersion(version));
return pluginDescriptor;
}
+ private boolean isEmpty(String value) {
+ return (value != null) && !value.isEmpty();
+ }
}
import java.util.Collections;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
/**
* A plugin descriptor contains information about a plug-in obtained
* from the manifest (META-INF) file.
}
@Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
- .append("pluginId", pluginId)
- .append("pluginClass", pluginClass)
- .append("version", version)
- .append("provider", provider)
- .append("dependencies", dependencies)
- .toString();
- }
+ public String toString() {
+ return "PluginDescriptor [pluginId=" + pluginId + ", pluginClass="
+ + pluginClass + ", version=" + version + ", provider="
+ + provider + ", dependencies=" + dependencies
+ + ", pluginClassLoader=" + pluginClassLoader + "]";
+ }
- void setPluginId(String pluginId) {
+ void setPluginId(String pluginId) {
this.pluginId = pluginId;
}
void setDependencies(String dependencies) {
if (dependencies != null) {
this.dependencies = new ArrayList<PluginDependency>();
- List<String> tokens = Arrays.asList(StringUtils.split(dependencies, ','));
+ List<String> tokens = Arrays.asList(dependencies.split(","));
for (String dependency : tokens) {
this.dependencies.add(new PluginDependency(dependency));
}
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
/**
* A wrapper over plugin instance.
*
try {
plugin = createPluginInstance();
} catch (Exception e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
return plugin;
}
- @Override
+
+ @Override
public int hashCode() {
- return new HashCodeBuilder().append(descriptor.getPluginId())
- .toHashCode();
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + descriptor.getPluginId().hashCode();
+
+ return result;
}
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof PluginWrapper)) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
return false;
}
- PluginWrapper wrapper = (PluginWrapper) obj;
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ PluginWrapper other = (PluginWrapper) obj;
+ if (!descriptor.getPluginId().equals(other.descriptor.getPluginId())) {
+ return false;
+ }
- return new EqualsBuilder().append(descriptor.getPluginId(), wrapper.getDescriptor().getPluginId())
- .isEquals();
+ return true;
}
@Override
- public String toString() {
- return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
- .append("descriptor", descriptor)
- .append("pluginPath", pluginPath)
- .append("plugin", plugin)
- .toString();
- }
+ public String toString() {
+ return "PluginWrapper [descriptor=" + descriptor + ", pluginPath="
+ + pluginPath + "]";
+ }
}