You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gn...@apache.org on 2009/07/06 21:07:58 UTC

svn commit: r791570 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container: AbstractServiceReferenceRecipe.java ReferenceListRecipe.java ReferenceRecipe.java

Author: gnodet
Date: Mon Jul  6 19:07:57 2009
New Revision: 791570

URL: http://svn.apache.org/viewvc?rev=791570&view=rev
Log:
Fix references with no interface specified

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java?rev=791570&r1=791569&r2=791570&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java Mon Jul  6 19:07:57 2009
@@ -30,6 +30,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Arrays;
 import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -185,7 +186,13 @@
             if (listenersRecipe != null) {
                 listeners = (List<Listener>) listenersRecipe.create();
                 for (Listener listener : listeners) {
-                    listener.init(loadAllClasses(Collections.singletonList(metadata.getInterface())));
+                    List<Class> cl = new ArrayList<Class>();
+                    if (metadata.getInterface() != null) {
+                        cl.addAll(loadAllClasses(Collections.singletonList(metadata.getInterface())));
+                    } else {
+                        cl.add(Object.class);
+                    }
+                    listener.init(cl);
                 }
             } else {
                 listeners = Collections.emptyList();
@@ -221,7 +228,11 @@
 
 
     protected Object createProxy(final Callable<Object> dispatcher, Iterable<String> interfaces) throws Exception {
-        return getProxyFactory().createProxy(proxyClassLoader, toClassArray(loadAllClasses(interfaces)), dispatcher);
+        if (!interfaces.iterator().hasNext()) {
+            return new Object();
+        } else {
+            return getProxyFactory().createProxy(proxyClassLoader, toClassArray(loadAllClasses(interfaces)), dispatcher);
+        }
     }
 
     protected synchronized ProxyFactory getProxyFactory() throws ClassNotFoundException {
@@ -458,12 +469,9 @@
             members.add(flt);
         }
         // Handle interfaces
-        Set<String> interfaces = new HashSet<String>();
-        interfaces.add(metadata.getInterface());
-        if (!interfaces.isEmpty()) {
-            for (String itf : interfaces) {
-                members.add("(" + Constants.OBJECTCLASS + "=" + itf + ")");
-            }
+        String interfaceName = metadata.getInterface();
+        if (interfaceName != null && interfaceName.length() > 0) {
+            members.add("(" + Constants.OBJECTCLASS + "=" + interfaceName + ")");
         }
         // Handle component name
         String componentName = metadata.getComponentName();
@@ -474,6 +482,9 @@
         if (members.isEmpty()) {
             throw new IllegalStateException("No constraints were specified on the service reference");
         }
+        if (members.size() == 1) {
+            return members.get(0);
+        }
         StringBuilder sb = new StringBuilder("(&");
         for (String member : members) {
             sb.append(member);

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java?rev=791570&r1=791569&r2=791570&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java Mon Jul  6 19:07:57 2009
@@ -119,7 +119,10 @@
                     }
                 } else {
                     dispatcher = new ServiceDispatcher(reference);
-                    List<String> interfaces = Collections.singletonList(metadata.getInterface());
+                    List<String> interfaces = new ArrayList<String>();
+                    if (metadata.getInterface() != null) {
+                        interfaces.add(metadata.getInterface());
+                    }
                     if (metadata instanceof ExtendedReferenceListMetadata) {
                         boolean greedy = (((ExtendedReferenceListMetadata) metadata).getProxyMethod() & ExtendedReferenceListMetadata.PROXY_METHOD_GREEDY) != 0;
                         if (greedy) {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java?rev=791570&r1=791569&r2=791570&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java Mon Jul  6 19:07:57 2009
@@ -20,6 +20,7 @@
 
 import java.util.Collections;
 import java.util.List;
+import java.util.ArrayList;
 import java.util.concurrent.Callable;
 
 import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
@@ -74,7 +75,11 @@
                 }
             }
             // Create the proxy
-            proxy = createProxy(new ServiceDispatcher(), Collections.singletonList(this.metadata.getInterface()));
+            List<String> interfaces = new ArrayList<String>();
+            if (this.metadata.getInterface() != null) {
+                interfaces.add(this.metadata.getInterface());
+            }
+            proxy = createProxy(new ServiceDispatcher(), interfaces);
 
             // Add partially created proxy to the context
             ServiceProxyWrapper wrapper = new ServiceProxyWrapper();