activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r883209 - in /activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util: IntrospectionSupport.java cli/CommonsCLISupport.java
Date Mon, 23 Nov 2009 01:52:03 GMT
Author: chirino
Date: Mon Nov 23 01:52:03 2009
New Revision: 883209

URL: http://svn.apache.org/viewvc?rev=883209&view=rev
Log:
better CommonsCLISupport

Modified:
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/IntrospectionSupport.java
    activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/cli/CommonsCLISupport.java

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/IntrospectionSupport.java?rev=883209&r1=883208&r2=883209&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/IntrospectionSupport.java
(original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/IntrospectionSupport.java
Mon Nov 23 01:52:03 2009
@@ -171,6 +171,15 @@
         return rc;
     }
 
+    public static Class<?> getPropertyType(Object target, String name) {
+        Class<?> clazz = target.getClass();
+        Method setter = findSetterMethod(clazz, name);
+        if (setter == null) {
+            return null;
+        }
+        return setter.getParameterTypes()[0];
+    }
+    
     public static boolean setProperty(Object target, String name, Object value) {
         try {
             Class<?> clazz = target.getClass();

Modified: activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/cli/CommonsCLISupport.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/cli/CommonsCLISupport.java?rev=883209&r1=883208&r2=883209&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/cli/CommonsCLISupport.java
(original)
+++ activemq/sandbox/activemq-apollo/activemq-util/src/main/java/org/apache/activemq/util/cli/CommonsCLISupport.java
Mon Nov 23 01:52:03 2009
@@ -1,5 +1,8 @@
 package org.apache.activemq.util.cli;
 
+import java.util.ArrayList;
+import java.util.HashSet;
+
 import org.apache.activemq.util.IntrospectionSupport;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
@@ -20,11 +23,16 @@
             
             String value = option.getValue();
             if( value!=null ) {
-                if( !IntrospectionSupport.setProperty(target, propName, option.getValues())
) {
-                    if( !IntrospectionSupport.setProperty(target, propName, option.getValuesList()))
{
-                        IntrospectionSupport.setProperty(target, propName, value);
-                    }
-                }                
+                Class<?> type = IntrospectionSupport.getPropertyType(target, propName);
+                if( type.isArray() ) {
+                    IntrospectionSupport.setProperty(target, propName, option.getValues());
+                } else if( type.isAssignableFrom(ArrayList.class) ) {
+                    IntrospectionSupport.setProperty(target, propName, new ArrayList(option.getValuesList())
);
+                } else if( type.isAssignableFrom(HashSet.class) ) {
+                    IntrospectionSupport.setProperty(target, propName, new HashSet(option.getValuesList())
);
+                } else {
+                    IntrospectionSupport.setProperty(target, propName, value);
+                }
             } else {
                 IntrospectionSupport.setProperty(target, propName, true);               
  
             }



Mime
View raw message