geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r797601 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint: ExtendedBlueprintContainer.java container/BlueprintContainerImpl.java container/ServiceRecipe.java
Date Fri, 24 Jul 2009 18:42:35 GMT
Author: gawor
Date: Fri Jul 24 18:42:34 2009
New Revision: 797601

URL: http://svn.apache.org/viewvc?rev=797601&view=rev
Log:
services can also have eager or lazy activation

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedBlueprintContainer.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
    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/ExtendedBlueprintContainer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedBlueprintContainer.java?rev=797601&r1=797600&r2=797601&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedBlueprintContainer.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ExtendedBlueprintContainer.java
Fri Jul 24 18:42:34 2009
@@ -20,6 +20,7 @@
 import java.util.Dictionary;
 import java.util.List;
 
+import org.apache.geronimo.blueprint.container.ServiceRecipe;
 import org.apache.geronimo.blueprint.di.Repository;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -59,4 +60,6 @@
     
     AccessControlContext getAccessControlContext();
         
+    boolean isServiceEnabled(ServiceRecipe service);
+    
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java?rev=797601&r1=797600&r2=797601&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
Fri Jul 24 18:42:34 2009
@@ -592,6 +592,20 @@
         }
     }
 
+    public boolean isServiceEnabled(ServiceRecipe r) {
+        List<SatisfiableRecipe> dependencies = getSatisfiableDependenciesMap().get(r.getName());
+        boolean enabled = true;
+        if (dependencies != null) {
+            for (SatisfiableRecipe recipe : dependencies) {
+                if (!recipe.isSatisfied()) {
+                    enabled = false;
+                    break;
+                }
+            }
+        }
+        return enabled;
+    }
+
     private void instantiateEagerComponents() {
         List<String> components = new ArrayList<String>();
         for (String name : componentDefinitionRegistry.getComponentDefinitionNames()) {
@@ -619,16 +633,16 @@
         services = repository.getAllRecipes(ServiceRecipe.class);
         for (ServiceRecipe r : services) {
             List<SatisfiableRecipe> dependencies = getSatisfiableDependenciesMap().get(r.getName());
-            boolean satisfied = true;
+            boolean enabled = true;
             if (dependencies != null) {
                 for (SatisfiableRecipe recipe : dependencies) {
                     if (!recipe.isSatisfied()) {
-                        satisfied = false;
+                        enabled = false;
                         break;
                     }
                 }
             }
-            if (satisfied) {
+            if (r.isEager() && enabled) {
                 r.register();
             }
         }

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=797601&r1=797600&r2=797601&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
Fri Jul 24 18:42:34 2009
@@ -94,6 +94,10 @@
         this.prototypeService = isPrototypeService(metadata.getServiceComponent());
     }
 
+    public boolean isEager() {
+        return (metadata.getActivation() == ComponentMetadata.ACTIVATION_EAGER);
+    }
+    
     public Recipe getServiceRecipe() {
         return serviceRecipe;
     }
@@ -127,6 +131,9 @@
         }
         ServiceRegistrationProxy proxy = new ServiceRegistrationProxy();
         addObject(proxy, true);
+        if (blueprintContainer.isServiceEnabled(this)) {
+            register();
+        }
         internalGetService(null, null); // null bundle means we don't want to retrieve the
actual service when used with a ServiceFactory
         return proxy;
     }



Mime
View raw message