geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r806367 - /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
Date Thu, 20 Aug 2009 21:26:14 GMT
Author: gawor
Date: Thu Aug 20 21:26:12 2009
New Revision: 806367

URL: http://svn.apache.org/viewvc?rev=806367&view=rev
Log:
1) explicit dependencies must be created before the service is registered, and 2) service
object is only obtained once now

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=806367&r1=806366&r2=806367&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 Aug 20 21:26:12 2009
@@ -128,11 +128,6 @@
     }
 
     protected Object internalCreate() throws ComponentDefinitionException {
-        if (explicitDependencies != null) {
-            for (Recipe recipe : explicitDependencies) {
-                recipe.create();
-            }
-        }
         ServiceRegistrationProxy proxy = new ServiceRegistrationProxy();
         addPartialObject(proxy);
         internalGetService(null, null); // null bundle means we don't want to retrieve the
actual service when used with a ServiceFactory
@@ -145,6 +140,8 @@
 
     public void register() {
         if (registered.compareAndSet(false, true)) {
+            createExplicitDependencies();
+            
             Hashtable props = new Hashtable();
             if (properties == null) {
                 properties = (Map) createRecipe(propertiesRecipe);
@@ -185,7 +182,7 @@
             if (listeners != null) {
                 LOGGER.debug("Calling listeners for service unregistration");
                 for (ServiceListener listener : listeners) {
-                    listener.unregister(service instanceof ServiceFactory || !prototypeService
? service : null, registrationProperties);
+                    listener.unregister(service, registrationProperties);
                 }
             }
             if (reg != null) {
@@ -252,14 +249,12 @@
                         if (registered.get()) {
                             LOGGER.debug("Calling listeners for initial service registration");
                             for (ServiceListener listener : listeners) {
-                                listener.register(service instanceof ServiceFactory || !prototypeService
? service : null,
-                                                  registrationProperties);
+                                listener.register(service, registrationProperties);
                             }
                         } else {
                             LOGGER.debug("Calling listeners for initial service unregistration");
                             for (ServiceListener listener : listeners) {
-                                listener.unregister(service instanceof ServiceFactory ||
!prototypeService ? service : null,
-                                                    registrationProperties);
+                                listener.unregister(service, registrationProperties);
                             }
                         }
                     }
@@ -274,9 +269,6 @@
         if (bundle != null) {
             if (service instanceof ServiceFactory) {
                 service = ((ServiceFactory) service).getService(bundle, registration);
-            } else if (prototypeService && bundle != blueprintContainer.getBundleContext().getBundle())
{
-                service = createInstance();
-                LOGGER.debug("Created service instance for bundle: {} {}", bundle, service.hashCode());
             }
             if (service == null) {
                 throw new IllegalStateException("service is null");
@@ -315,6 +307,7 @@
         if (this.service instanceof ServiceFactory) {
             ((ServiceFactory) this.service).ungetService(bundle, registration, service);
         }
+        // TODO: need to check on this, if this should be called
         if (prototypeService) {
             destroyInstance(service);
             LOGGER.debug("Destroyed service instance for bundle: {}", bundle);
@@ -345,6 +338,14 @@
         return createRecipe(serviceRecipe);
     }
 
+    private void createExplicitDependencies() {
+        if (explicitDependencies != null) {
+            for (Recipe recipe : explicitDependencies) {
+                createRecipe(recipe);
+            }
+        }
+    }
+    
     private Object createRecipe(Recipe recipe) {
         String name = recipe.getName();
         Repository repo = blueprintContainer.getRepository();
@@ -353,7 +354,7 @@
         }
         return repo.create(name);
     }
-
+   
     private void destroyInstance(Object instance) {
         Recipe recipe = serviceRecipe;
         Repository objectRepository = blueprintContainer.getRepository();



Mime
View raw message