geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick McGuire <rick...@gmail.com>
Subject 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
Date Mon, 27 Jul 2009 14:16:44 GMT
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 <gnodet@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 <gawor@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
>>
>>
>>
>>
>>     
>
>
>
>   


Mime
View raw message