geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r790607 - /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
Date Thu, 02 Jul 2009 14:52:06 GMT
Author: gnodet
Date: Thu Jul  2 14:52:06 2009
New Revision: 790607

URL: http://svn.apache.org/viewvc?rev=790607&view=rev
Log:
Make additional tests on the interfaces implemented by the service

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java

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=790607&r1=790606&r2=790607&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
Thu Jul  2 14:52:06 2009
@@ -257,6 +257,7 @@
             }
         }
         Object service = this.service;
+        // We need the real service ...
         if (bundle != null) {
             if (service instanceof ServiceFactory) {
                 service = ((ServiceFactory) service).getService(bundle, registration);
@@ -268,20 +269,31 @@
                 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);
-                }
-            }
+            validateClasses(service);
+        // We're not really interested in the service, but perform some sanity checks nonetheless
+        } else {
+             if (!(service instanceof ServiceFactory)) {
+                 // Check if the service actually implement all the requested interfaces
+                 validateClasses(service);
+             }
         }
         return service;
     }
 
+    private void validateClasses(Object service) {
+        // 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);
+            }
+        }
+    }
+
     public synchronized Object getService(Bundle bundle, ServiceRegistration registration)
{
         return internalGetService(bundle, registration);
     }



Mime
View raw message