You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2009/07/24 20:42:35 UTC

svn commit: r797601 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint: ExtendedBlueprintContainer.java container/BlueprintContainerImpl.java container/ServiceRecipe.java

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;
     }



Re: svn commit: r797601 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint: ExtendedBlueprintContainer.java container/BlueprintContainerImpl.java container/ServiceRecipe.java

Posted by Rick McGuire <ri...@gmail.com>.
Guillaume Nodet wrote:
> For more informations, see section 121.6.10 and 121.6.11 of the OSGi
> compendium spec, but there is a clear different between the service
> being enabled or not and the lazy / eager activation.
>   

The lifecycle diagram in section 121.3 and sections 121.3.8 and 121.3.9 
are bit clearer as to the order of events and what's expected. 

Rick

> 2009/7/27 Guillaume Nodet <gn...@gmail.com>:
>   
>> Lazy activation of services does not mean that the service is not registered, but simply that the service object is not eagerly created.
>> Else, the service will never be registered in the OSGi registry.
>> Could you please revert this commit ?
>>
>> 2009/7/24 gawor <ga...@apache.org>:
>>     
>>> 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;
>>>     }
>>>
>>>
>>>
>>>       
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com
>>
>>
>>
>>
>>     
>
>
>
>   


Re: svn commit: r797601 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint: ExtendedBlueprintContainer.java container/BlueprintContainerImpl.java container/ServiceRecipe.java

Posted by Jarek Gawor <jg...@gmail.com>.
I reverted all those changes. My understanding of how this was
supposed to work was incorrect.

Jarek

On Mon, Jul 27, 2009 at 9:52 AM, Guillaume Nodet<gn...@gmail.com> wrote:
> I've made a quick revert at rev 798132, but a cleaner one is needed.
>
> 2009/7/27 Guillaume Nodet <gn...@gmail.com>:
>> For more informations, see section 121.6.10 and 121.6.11 of the OSGi
>> compendium spec, but there is a clear different between the service
>> being enabled or not and the lazy / eager activation.
>>
>> 2009/7/27 Guillaume Nodet <gn...@gmail.com>:
>>> Lazy activation of services does not mean that the service is not registered, but simply that the service object is not eagerly created.
>>> Else, the service will never be registered in the OSGi registry.
>>> Could you please revert this commit ?
>>>
>>> 2009/7/24 gawor <ga...@apache.org>:
>>>> 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;
>>>>     }
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Guillaume Nodet
>>> ------------------------
>>> Blog: http://gnodet.blogspot.com/
>>> ------------------------
>>> Open Source SOA
>>> http://fusesource.com
>>>
>>>
>>>
>>>
>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>

Re: svn commit: r797601 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint: ExtendedBlueprintContainer.java container/BlueprintContainerImpl.java container/ServiceRecipe.java

Posted by Guillaume Nodet <gn...@gmail.com>.
I've made a quick revert at rev 798132, but a cleaner one is needed.

2009/7/27 Guillaume Nodet <gn...@gmail.com>:
> For more informations, see section 121.6.10 and 121.6.11 of the OSGi
> compendium spec, but there is a clear different between the service
> being enabled or not and the lazy / eager activation.
>
> 2009/7/27 Guillaume Nodet <gn...@gmail.com>:
>> Lazy activation of services does not mean that the service is not registered, but simply that the service object is not eagerly created.
>> Else, the service will never be registered in the OSGi registry.
>> Could you please revert this commit ?
>>
>> 2009/7/24 gawor <ga...@apache.org>:
>>> 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;
>>>     }
>>>
>>>
>>>
>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com
>>
>>
>>
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: svn commit: r797601 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint: ExtendedBlueprintContainer.java container/BlueprintContainerImpl.java container/ServiceRecipe.java

Posted by Guillaume Nodet <gn...@gmail.com>.
For more informations, see section 121.6.10 and 121.6.11 of the OSGi
compendium spec, but there is a clear different between the service
being enabled or not and the lazy / eager activation.

2009/7/27 Guillaume Nodet <gn...@gmail.com>:
> Lazy activation of services does not mean that the service is not registered, but simply that the service object is not eagerly created.
> Else, the service will never be registered in the OSGi registry.
> Could you please revert this commit ?
>
> 2009/7/24 gawor <ga...@apache.org>:
>> 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;
>>     }
>>
>>
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>
>
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: svn commit: r797601 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint: ExtendedBlueprintContainer.java container/BlueprintContainerImpl.java container/ServiceRecipe.java

Posted by Guillaume Nodet <gn...@gmail.com>.
Lazy activation of services does not mean that the service is not
registered, but simply that the service object is not eagerly created.
Else, the service will never be registered in the OSGi registry.
Could you please revert this commit ?

2009/7/24 gawor <ga...@apache.org>:
> 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;
>     }
>
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com