Преглед изворни кода

WebServiceMethod - szkic obsługi parametrów
CrossHashMap - #size zwraca rzeczywistą ilość elementów

Ranides Atterwim пре 13 година
родитељ
комит
df1f4beb1d

+ 11 - 0
src/main/java/net/ranides/assira/collection/map/CrossHashMap.java

@@ -8,6 +8,7 @@
 package net.ranides.assira.collection.map;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map.Entry;
 
@@ -80,5 +81,15 @@ public class CrossHashMap<KX, KY, V> extends HashMap<KX, HashMap<KY,V>> implemen
         return result;
     }
 
+    @Override
+    public int size() {
+        int sum = 0;
+        for(HashMap<KY,V> row : values()) {
+            sum += row.size();
+        }
+        return sum;
+    }
+
+    
 
 }

+ 20 - 15
src/main/java/net/ranides/assira/reflection/WebServiceMethod.java

@@ -14,6 +14,7 @@ import java.util.*;
 import javax.jws.WebMethod;
 import javax.jws.WebParam;
 import javax.jws.WebResult;
+import net.ranides.assira.asm.MethodInspector;
 import net.ranides.assira.collection.ArrayUtils;
 import net.ranides.assira.text.Strings;
 
@@ -27,7 +28,8 @@ public class WebServiceMethod  {
     private final WebMethod info;
     private final String result;
 
-    private final Map<String, Class<?>> params = new LinkedHashMap<String, Class<?>>();
+    private final Map<String, GenericClass> params = new LinkedHashMap<String, GenericClass>();
+    private final Map<String, String> webParams = new LinkedHashMap<String, String>();
 
     WebServiceMethod(Method method) {
         this.method = method;
@@ -40,15 +42,18 @@ public class WebServiceMethod  {
         WebResult iresult = method.getAnnotation(WebResult.class);
         this.result = (null==iresult) ? null : iresult.name();
         
-        Annotation[][] metaParams  = method.getParameterAnnotations();
-        Class<?>[] typeParams = method.getParameterTypes();
-
-        for (int i = 0, n=typeParams.length; i < n; i++) {
-            WebParam paramInfo = ArrayUtils.first(metaParams[i], WebParam.class);
+        Annotation[][] paramInfos  = method.getParameterAnnotations();
+        Class<?>[] paramTypes = method.getParameterTypes();
+        
+        int index = 0;
+        for(Variable param : MethodInspector.getArguments(method)) {
+            params.put(param.name(), param.type());
+            WebParam paramInfo = ArrayUtils.first(paramInfos[index], WebParam.class);
             if (null == paramInfo) {
-                throw new IncompleteAnnotationException(WebParam.class, method.getDeclaringClass().getCanonicalName() + "." + method.getName() );
+                webParams.put(param.name(), param.type().asText());
+            } else {
+                webParams.put(paramInfo.name(), param.type().asText());
             }
-            params.put(paramInfo.name(), typeParams[i]);
         }
     }
     
@@ -72,12 +77,12 @@ public class WebServiceMethod  {
         return Strings.orne(result, method.getReturnType().getSimpleName());
     }
 
-//    public Map<String, String> getParamsMap() {
-//        return Collections.unmodifiableMap(params);
-//    }
-//
-//    public List< Entry<String,String> > getParamsList() {
-//        return new LinkedList< Entry<String,String> >( params.entrySet() );
-//    }
+    public Map<String, GenericClass> getParamTypes() {
+        return Collections.unmodifiableMap(params);
+    }
+    
+    public Map<String, String> getParams() {
+        return Collections.unmodifiableMap(webParams);
+    }
 
 }