geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r790148 - in /geronimo/sandbox/blueprint/blueprint-core/src: main/java/org/apache/geronimo/blueprint/container/ test/resources/
Date Wed, 01 Jul 2009 12:50:06 GMT
Author: gnodet
Date: Wed Jul  1 12:50:06 2009
New Revision: 790148

URL: http://svn.apache.org/viewvc?rev=790148&view=rev
Log:
Fix reference-listeners, fix the listener target validation test, make sure the service target
implements the required interfaces

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/BlueprintRepository.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceListener.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml

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=790148&r1=790147&r2=790148&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
Wed Jul  1 12:50:06 2009
@@ -419,7 +419,7 @@
             for (Method method : objectPropMethods) {
                 if (props == null) {
                     props = new HashMap<String, Object>();
-                    if (reference == null) {
+                    if (reference != null) {
                         for (String name : reference.getPropertyKeys()) {
                             props.put(name, reference.getProperty(name));
                         }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintRepository.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintRepository.java?rev=790148&r1=790147&r2=790148&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintRepository.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintRepository.java
Wed Jul  1 12:50:06 2009
@@ -227,30 +227,36 @@
                     throw new ComponentDefinitionException("The target for a <service>
element must not be <reference-list> element");
                 }
                 CollectionRecipe listeners = ((ServiceRecipe) recipe).getListenersRecipe();
-                for (Recipe l : listeners.getDependencies()) {
-                    if (l instanceof RefRecipe) {
-                        l = getRecipe(((RefRecipe) l).getIdRef());
-                    }
-                    if (l instanceof ServiceRecipe) {
-                        throw new ComponentDefinitionException("The target for a <registration-listener>
element must not be <service> element");
-                    }
-                    if (l instanceof ReferenceListRecipe) {
-                        throw new ComponentDefinitionException("The target for a <registration-listener>
element must not be <reference-list> element");
+                for (Recipe lr : listeners.getDependencies()) {
+                    // The listener recipe is a bean recipe with the listener being set in
a property
+                    for (Recipe l : lr.getDependencies()) {
+                        if (l instanceof RefRecipe) {
+                            l = getRecipe(((RefRecipe) l).getIdRef());
+                        }
+                        if (l instanceof ServiceRecipe) {
+                            throw new ComponentDefinitionException("The target for a <registration-listener>
element must not be <service> element");
+                        }
+                        if (l instanceof ReferenceListRecipe) {
+                            throw new ComponentDefinitionException("The target for a <registration-listener>
element must not be <reference-list> element");
+                        }
                     }
                 }
             }
             // Check references
             if (recipe instanceof AbstractServiceReferenceRecipe) {
                 CollectionRecipe listeners = ((AbstractServiceReferenceRecipe) recipe).getListenersRecipe();
-                for (Recipe l : listeners.getDependencies()) {
-                    if (l instanceof RefRecipe) {
-                        l = getRecipe(((RefRecipe) l).getIdRef());
-                    }
-                    if (l instanceof ServiceRecipe) {
-                        throw new ComponentDefinitionException("The target for a <reference-listener>
element must not be <service> element");
-                    }
-                    if (l instanceof ReferenceListRecipe) {
-                        throw new ComponentDefinitionException("The target for a <reference-listener>
element must not be <reference-list> element");
+                for (Recipe lr : listeners.getDependencies()) {
+                    // The listener recipe is a bean recipe with the listener being set in
a property
+                    for (Recipe l : lr.getDependencies()) {
+                        if (l instanceof RefRecipe) {
+                            l = getRecipe(((RefRecipe) l).getIdRef());
+                        }
+                        if (l instanceof ServiceRecipe) {
+                            throw new ComponentDefinitionException("The target for a <reference-listener>
element must not be <service> element");
+                        }
+                        if (l instanceof ReferenceListRecipe) {
+                            throw new ComponentDefinitionException("The target for a <reference-listener>
element must not be <reference-list> element");
+                        }
                     }
                 }
             }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceListener.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceListener.java?rev=790148&r1=790147&r2=790148&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceListener.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceListener.java
Wed Jul  1 12:50:06 2009
@@ -55,6 +55,7 @@
     }
 
     public void unregister(Object service, Map properties) {
+        init(service);
         invokeMethod(unregisterMethods, service, properties);
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java?rev=790148&r1=790147&r2=790148&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
Wed Jul  1 12:50:06 2009
@@ -266,6 +266,17 @@
         if (service == null) {
             throw new IllegalStateException("service is null");
         }
+        // Check if the service actually implement all the requested interfaces
+        if (metadata.getAutoExport() == ServiceMetadata.AUTO_EXPORT_DISABLED) {
+            Set<String> allClasses = new HashSet<String>();
+            ReflectionUtils.getSuperClasses(allClasses, service.getClass());
+            ReflectionUtils.getImplementedInterfaces(allClasses, service.getClass());
+            Set<String> classes = getClasses();
+            classes.removeAll(allClasses);
+            if (!classes.isEmpty()) {
+                throw new ComponentDefinitionException("The service implementation does not
implement the required interfaces: " + classes);
+            }
+        }
         return service;
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml?rev=790148&r1=790147&r2=790148&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml Wed Jul 
1 12:50:06 2009
@@ -7,8 +7,8 @@
                 <property name="bundle" ref="blueprintBundleContext" />
             </bean>
     </type-converters>
-    
-    <service id="service1" ref="pojoB" interface="foo">
+
+    <service id="service1" ref="pojoB" interface="org.apache.geronimo.blueprint.pojos.PojoB">
         <service-properties>
             <entry key="key1" value="value1"/>
             <entry key="key2" value="value2"/>



Mime
View raw message