Author: slaws
Date: Thu May 22 14:08:20 2008
New Revision: 659259

URL: http://svn.apache.org/viewvc?rev=659259&view=rev
Log:
TUSCANY-2311. Set multiple callback members at once if they share a common 
callback type. Thanks for the patch Vamsi. 

Modified:
    
incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java
    
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
    
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
    
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
    
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
    
incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java
    
incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/context/OSGiPropertyInjector.java
    
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java

Modified: 
incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java?rev=659259&r1=659258&r2=659259&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaImplementationImpl.java
 Thu May 22 14:08:20 2008
@@ -22,6 +22,7 @@
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -50,7 +51,7 @@
     private final Map<String, JavaResourceImpl> resources = new 
HashMap<String, JavaResourceImpl>();
     private final Map<String, JavaElementImpl> propertyMembers = new 
HashMap<String, JavaElementImpl>();
     private final Map<String, JavaElementImpl> referenceMembers = new 
HashMap<String, JavaElementImpl>();
-    private final Map<String, JavaElementImpl> callbackMembers = new 
HashMap<String, JavaElementImpl>();
+    private final Map<String, Collection<JavaElementImpl>> callbackMembers = 
new HashMap<String, Collection<JavaElementImpl>>();
     private List<Member> conversationIDMember = new ArrayList<Member>();
     private boolean eagerInit;
     private boolean allowsPassByReference;
@@ -128,7 +129,7 @@
         this.eagerInit = eagerInit;
     }
 
-    public Map<String, JavaElementImpl> getCallbackMembers() {
+    public Map<String, Collection<JavaElementImpl>> getCallbackMembers() {
         return callbackMembers;
     }
 

Modified: 
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java?rev=659259&r1=659258&r2=659259&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
 Thu May 22 14:08:20 2008
@@ -26,6 +26,7 @@
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -153,7 +154,7 @@
                 }
             }
 
-            for (Map.Entry<String, JavaElementImpl> entry : 
instanceFactoryProvider.getImplementation()
+            for (Map.Entry<String, Collection<JavaElementImpl>> entry : 
instanceFactoryProvider.getImplementation()
                 .getCallbackMembers().entrySet()) {
                 List<RuntimeWire> wires = callbackWires.get(entry.getKey());
                 if (wires == null) {
@@ -161,21 +162,22 @@
                     // component that has a callback
                     continue;
                 }
-                JavaElementImpl element = entry.getValue();
-                Class<?> businessInterface = element.getType();
-                ObjectFactory<?> factory = null;
-                if 
(CallableReference.class.isAssignableFrom(element.getType())) {
-                    businessInterface =
-                        
JavaIntrospectionHelper.getBusinessInterface(element.getType(), 
element.getGenericType());
-                    factory =
-                        new CallbackReferenceObjectFactory(businessInterface, 
proxyFactory, wires);
-                } else {
-                    factory = new CallbackWireObjectFactory(businessInterface, 
proxyFactory, wires);
-                }
-                if (!(element.getAnchor() instanceof Constructor)) {
-                    instanceFactoryProvider.getInjectionSites().add(element);
+                for(JavaElementImpl element : entry.getValue()) {
+                    Class<?> businessInterface = element.getType();
+                    ObjectFactory<?> factory = null;
+                    if 
(CallableReference.class.isAssignableFrom(element.getType())) {
+                        businessInterface =
+                            
JavaIntrospectionHelper.getBusinessInterface(element.getType(), 
element.getGenericType());
+                        factory =
+                            new 
CallbackReferenceObjectFactory(businessInterface, proxyFactory, wires);
+                    } else {
+                        factory = new 
CallbackWireObjectFactory(businessInterface, proxyFactory, wires);
+                    }
+                    if (!(element.getAnchor() instanceof Constructor)) {
+                        
instanceFactoryProvider.getInjectionSites().add(element);
+                    }
+                    instanceFactoryProvider.setObjectFactory(element, factory);
                 }
-                instanceFactoryProvider.setObjectFactory(element, factory);
             }
         }
         for (Reference ref : 
instanceFactoryProvider.getImplementation().getReferences()) {

Modified: 
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java?rev=659259&r1=659258&r2=659259&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
 Thu May 22 14:08:20 2008
@@ -22,6 +22,7 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
@@ -142,7 +143,7 @@
     /**
      * @return the callbacks
      */
-    Map<String, JavaElementImpl> getCallbackMembers();
+    Map<String, Collection<JavaElementImpl>> getCallbackMembers();
 
     /**
      * @return the properties

Modified: 
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java?rev=659259&r1=659258&r2=659259&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
 Thu May 22 14:08:20 2008
@@ -22,6 +22,7 @@
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -42,7 +43,7 @@
     private final Map<String, JavaResourceImpl> resources = new 
HashMap<String, JavaResourceImpl>();
     private final Map<String, JavaElementImpl> propertyMembers = new 
HashMap<String, JavaElementImpl>();
     private final Map<String, JavaElementImpl> referenceMembers = new 
HashMap<String, JavaElementImpl>();
-    private final Map<String, JavaElementImpl> callbackMembers = new 
HashMap<String, JavaElementImpl>();
+    private final Map<String, Collection<JavaElementImpl>> callbackMembers = 
new HashMap<String, Collection<JavaElementImpl>>();
     private List<Member> conversationIDMember = new ArrayList<Member>();
     private boolean eagerInit;
     private boolean allowsPassByReference;
@@ -120,7 +121,7 @@
         this.eagerInit = eagerInit;
     }
 
-    public Map<String, JavaElementImpl> getCallbackMembers() {
+    public Map<String, Collection<JavaElementImpl>> getCallbackMembers() {
         return callbackMembers;
     }
 

Modified: 
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java?rev=659259&r1=659258&r2=659259&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
 Thu May 22 14:08:20 2008
@@ -24,6 +24,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
+import java.util.ArrayList;
 import java.util.Set;
 import java.util.logging.Logger;
 
@@ -152,7 +153,10 @@
         if (callbackService == null) {
             throw new IllegalCallbackReferenceException("Callback type does 
not match a service callback interface: " + type.getName() );
         }
-        type.getCallbackMembers().put(baseType.getName(), element);
+        if(type.getCallbackMembers().get(baseType.getName()) == null) {
+            type.getCallbackMembers().put(baseType.getName(), new 
ArrayList<JavaElementImpl>());
+        }
+        type.getCallbackMembers().get(baseType.getName()).add(element);
     }
 
     public Service createService(Class<?> interfaze) throws 
InvalidInterfaceException {

Modified: 
incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java?rev=659259&r1=659258&r2=659259&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java
 Thu May 22 14:08:20 2008
@@ -56,7 +56,7 @@
         assertNotNull(service);
         Method method = FooImpl.class.getMethod("setCallback", 
FooCallback.class);
         processor.visitMethod(method, type);
-        assertEquals(method, 
type.getCallbackMembers().get(FooCallback.class.getName()).getAnchor());
+        assertEquals(method, 
type.getCallbackMembers().get(FooCallback.class.getName()).iterator().next().getAnchor());
     }
 
     public void testFieldCallbackInterface() throws Exception {
@@ -66,7 +66,7 @@
         assertNotNull(service);
         Field field = FooImpl.class.getDeclaredField("callback");
         processor.visitField(field, type);
-        assertEquals(field, 
type.getCallbackMembers().get(FooCallback.class.getName()).getAnchor());
+        assertEquals(field, 
type.getCallbackMembers().get(FooCallback.class.getName()).iterator().next().getAnchor());
     }
 
     public void testFieldCallbackInterface1() throws Exception {
@@ -76,7 +76,7 @@
         assertNotNull(service);
         Field field1 = FooImpl1.class.getDeclaredField("callbackRef");
         processor.visitField(field1, type);
-        assertEquals(field1, 
type.getCallbackMembers().get(FooCallback.class.getName()).getAnchor());
+        assertEquals(field1, 
type.getCallbackMembers().get(FooCallback.class.getName()).iterator().next().getAnchor());
         
     }
     

Modified: 
incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/context/OSGiPropertyInjector.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/context/OSGiPropertyInjector.java?rev=659259&r1=659258&r2=659259&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/context/OSGiPropertyInjector.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/context/OSGiPropertyInjector.java
 Thu May 22 14:08:20 2008
@@ -25,6 +25,7 @@
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
@@ -155,7 +156,7 @@
                 }
             }
 
-            for (Map.Entry<String, JavaElementImpl> entry : 
javaImpl.getCallbackMembers()
+            for (Map.Entry<String, Collection<JavaElementImpl>> entry : 
javaImpl.getCallbackMembers()
                 .entrySet()) {
                 List<RuntimeWire> wires = callbackWires.get(entry.getKey());
                 if (wires == null) {
@@ -163,12 +164,13 @@
                     // component that has a callback
                     continue;
                 }
-                JavaElementImpl element = entry.getValue();
-                ObjectFactory<?> factory = new 
CallbackWireObjectFactory(element.getType(), proxyFactory, wires);
-                if (!(element.getAnchor() instanceof Constructor)) {
-                    injectionSites.add(element);
+                for(JavaElementImpl element : entry.getValue()) {
+                    ObjectFactory<?> factory = new 
CallbackWireObjectFactory(element.getType(), proxyFactory, wires);
+                    if (!(element.getAnchor() instanceof Constructor)) {
+                        injectionSites.add(element);
+                    }
+                    factories.put(element, factory);
                 }
-                factories.put(element, factory);
             }
         }
         

Modified: 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java?rev=659259&r1=659258&r2=659259&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java
 (original)
+++ 
incubator/tuscany/java/sca/vtest/java-api/conversation/callback/src/test/java/org/apache/tuscany/sca/vtest/javaapi/conversation/callback/CallbackTestCase.java
 Thu May 22 14:08:20 2008
@@ -292,7 +292,6 @@
      * callback fields, then all of them will be set.
      */
     @Test
-    @Ignore("TUSCANY-2311")
     public void statefulMultiBidirectional() throws Exception {
         System.out.println("Setting up for multi-bidirectional interfaces 
tests");
         ServiceFinder.init("callback-multi.composite");


Reply via email to