You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2006/10/06 02:23:35 UTC

svn commit: r453435 - in /incubator/tuscany/java/sca/kernel/core/src: main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java

Author: rfeng
Date: Thu Oct  5 17:23:34 2006
New Revision: 453435

URL: http://svn.apache.org/viewvc?view=rev&rev=453435
Log:
HeuristicPojoProcessor should check the "setter" (vois setA(X x)) pattern for reference and property detections.

Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java?view=diff&rev=453435&r1=453434&r2=453435
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessor.java Thu Oct  5 17:23:34 2006
@@ -118,7 +118,9 @@
         // heuristically determine the properties references
         // make a first pass through all public methods with one param
         for (Method method : methods) {
-            if (method.getParameterTypes().length != 1 || !Modifier.isPublic(method.getModifiers())) {
+            if (method.getParameterTypes().length != 1 || !Modifier.isPublic(method.getModifiers())
+                || !method.getName().startsWith("set")
+                || method.getReturnType() != void.class) {
                 continue;
             }
             if (!isInServiceInterface(method, services)) {
@@ -137,7 +139,9 @@
         }
         // second pass for protected methods with one param
         for (Method method : methods) {
-            if (method.getParameterTypes().length != 1 || !Modifier.isProtected(method.getModifiers())) {
+            if (method.getParameterTypes().length != 1 || !Modifier.isProtected(method.getModifiers())
+                || !method.getName().startsWith("set")
+                || method.getReturnType() != void.class) {
                 continue;
             }
             Class<?> param = method.getParameterTypes()[0];
@@ -478,13 +482,17 @@
                     Class<?>[] interfaceParamTypes = interfaceMethod.getParameterTypes();
                     Class<?>[] methodParamTypes = method.getParameterTypes();
                     if (interfaceParamTypes.length == methodParamTypes.length) {
-                        for (int i = 0; i < methodParamTypes.length; i++) {
-                            Class<?> param = methodParamTypes[i];
-                            if (!param.equals(interfaceParamTypes[i])) {
-                                break;
-                            }
-                            if (i == methodParamTypes.length - 1) {
-                                found = true;
+                        if (interfaceParamTypes.length == 0) {
+                            found = true;
+                        } else {
+                            for (int i = 0; i < methodParamTypes.length; i++) {
+                                Class<?> param = methodParamTypes[i];
+                                if (!param.equals(interfaceParamTypes[i])) {
+                                    break;
+                                }
+                                if (i == methodParamTypes.length - 1) {
+                                    found = true;
+                                }
                             }
                         }
                     }

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java?view=diff&rev=453435&r1=453434&r2=453435
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java Thu Oct  5 17:23:34 2006
@@ -220,10 +220,14 @@
 
         public void setString1(String val) {
         }
+
     }
 
     private interface HeuristicServiceInterface {
         void fooOperation(String ref);
+        void setInvalid1(); // No parameter
+        void setInvalid2(String str, int i); // More than one parameter
+        String setInvalid3(String str); // return should be void
     }
 
     public static class ServiceImpl implements PropertyInterface, RefInterface, HeuristicServiceInterface {
@@ -246,6 +250,15 @@
 
         public void fooOperation(String ref) {
 
+        }
+        public void setInvalid1() {
+        }
+
+        public void setInvalid2(String str, int i) {
+        }
+
+        public String setInvalid3(String str) {
+            return null;
         }
 
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org