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 2007/03/23 19:22:55 UTC

svn commit: r521848 - in /incubator/tuscany/java/sca/kernel: core/src/main/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessor.java spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java

Author: rfeng
Date: Fri Mar 23 11:22:54 2007
New Revision: 521848

URL: http://svn.apache.org/viewvc?view=rev&rev=521848
Log:
Fix AllowsPassByReferenceProcessor and add information to PojoComponentType

Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessor.java
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessor.java?view=diff&rev=521848&r1=521847&r2=521848
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessor.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessor.java Fri Mar 23 11:22:54 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.tuscany.core.implementation.processor;
 
+import java.lang.reflect.Method;
+
 import org.osoa.sca.annotations.AllowsPassByReference;
 
 import org.apache.tuscany.spi.deployer.DeploymentContext;
@@ -30,21 +32,24 @@
 
 /**
  * Processes {@link AllowsPassByReference} on an implementation
- *
+ * 
  * @version $Rev: 479093 $ $Date: 2006-11-25 12:34:41 +0530 (Sat, 25 Nov 2006) $
  */
 public class AllowsPassByReferenceProcessor extends ImplementationProcessorExtension {
 
     public <T> void visitClass(Class<T> clazz,
                                PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
-                               DeploymentContext context)
-        throws ProcessingException {
-        AllowsPassByReference annotation = clazz.getAnnotation(AllowsPassByReference.class);
-        if (annotation == null) {
-            return;
-        } else {
-            // TODO implement
-        }
+                               DeploymentContext context) throws ProcessingException {
+        type.setAllowsPassByReference(clazz.isAnnotationPresent(AllowsPassByReference.class));
+    }
 
+    @Override
+    public void visitMethod(Method method,
+                            PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+                            DeploymentContext context) throws ProcessingException {
+        boolean pbr = method.isAnnotationPresent(AllowsPassByReference.class);
+        if (pbr) {
+            type.getAllowsPassByReferenceMethods().add(method);
+        }
     }
 }

Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java?view=diff&rev=521848&r1=521847&r2=521848
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java Fri Mar 23 11:22:54 2007
@@ -20,7 +20,9 @@
 
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.tuscany.spi.model.ComponentType;
@@ -41,6 +43,9 @@
     private Method destroyMethod;
     private final Map<String, Resource> resources = new HashMap<String, Resource>();
     private Member conversationIDMember;
+    
+    private boolean allowsPassByReference;
+    private List<Method> allowsPassByReferenceMethods = new ArrayList<Method>();
 
     /**
      * Deprecated no-arg constructor, replaced with one that takes the POJO class.
@@ -144,5 +149,30 @@
 
     public void setConversationIDMember(Member conversationIDMember) {
         this.conversationIDMember = conversationIDMember;
+    }
+
+    /**
+     * @return the allowsPassByReference
+     */
+    public boolean isAllowsPassByReference() {
+        return allowsPassByReference;
+    }
+
+    /**
+     * @param allowsPassByReference the allowsPassByReference to set
+     */
+    public void setAllowsPassByReference(boolean allowsPassByReference) {
+        this.allowsPassByReference = allowsPassByReference;
+    }
+
+    /**
+     * @return the allowsPassByReferenceMethods
+     */
+    public List<Method> getAllowsPassByReferenceMethods() {
+        return allowsPassByReferenceMethods;
+    }
+    
+    public boolean isAllowsPassByReference(Method method) {
+        return allowsPassByReference || allowsPassByReferenceMethods.contains(method);
     }
 }



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