]> source.dussan.org Git - pf4j.git/commitdiff
remove commons-lang dependency
authorDecebal Suiu <decebal.suiu@gmail.com>
Tue, 13 Nov 2012 09:38:31 +0000 (11:38 +0200)
committerDecebal Suiu <decebal.suiu@gmail.com>
Tue, 13 Nov 2012 09:38:31 +0000 (11:38 +0200)
demo/app/pom.xml
pf4j/pom.xml
pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginDescriptorFinder.java
pf4j/src/main/java/ro/fortsoft/pf4j/PluginDescriptor.java
pf4j/src/main/java/ro/fortsoft/pf4j/PluginWrapper.java

index be35260315ee1d96e8249c8f52918e55f5e416e8..18383a276086e4e261eb137f962e901274554941 100644 (file)
             <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>
index 301ea44f3e97434aa9ca666103e228d2ad29e1eb..7bace35a68d809120f7252ec9f55d159bce0e1cd 100644 (file)
   </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>
index fa86e2ea641090de34bb3b44727061cd03d288ab..3cb6712ffc59fdfbfedc5a6fa4d81a5a497e7e7b 100644 (file)
@@ -19,8 +19,6 @@ import java.io.IOException;
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
-import org.apache.commons.lang.StringUtils;
-
 /**
  * Read the plugin descriptor from the manifest file.
  *
@@ -62,19 +60,19 @@ public class DefaultPluginDescriptorFinder implements PluginDescriptorFinder {
         // 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));
@@ -87,4 +85,7 @@ public class DefaultPluginDescriptorFinder implements PluginDescriptorFinder {
                return pluginDescriptor;
        }
     
+       private boolean isEmpty(String value) {
+               return (value != null) && !value.isEmpty();
+       }
 }
index a666b7a1b6175e85a0e04a4c512b9bb9ff31b9cd..aba2fac71f319f9f5ef8f8e83c901bf63841315d 100644 (file)
@@ -17,10 +17,6 @@ import java.util.Arrays;
 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.
@@ -86,17 +82,14 @@ public class PluginDescriptor {
     }
 
     @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;
     }
 
@@ -115,7 +108,7 @@ public class PluginDescriptor {
     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));
                }
index b3a5a01b321ce902c64db6ff971d1bb439027e11..c960ec1db47371e104c2f5b9ced7b6886000b7ca 100644 (file)
@@ -15,11 +15,6 @@ package ro.fortsoft.pf4j;
 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.
  *
@@ -41,7 +36,6 @@ public class PluginWrapper {
                try {
                        plugin = createPluginInstance();
                } catch (Exception e) {
-                       // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
@@ -92,31 +86,42 @@ public class PluginWrapper {
         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 + "]";
+       }
 
 }