HI Sameera,

 

I think Equinox' behavior is correct here. If you have a mandatory
service reference that is not valid anymore, the referring component has
to be deactivated even if the policy is dynamic.

 

>But my requirement is that the service should be registered before the
component is activated.

>in that case I have to put cardinality as "1..1" right?

I guess your question is related to the lazy activation of components.
This is the default unless you declare the component itself "immediate".
The meaning is: Unless no one wants to use your service, the component
(the implementing Java class) will not be instantiated.

 

Best regards,

 

Kai

 

From: equinox-dev-boun...@eclipse.org
[mailto:equinox-dev-boun...@eclipse.org] On Behalf Of Sameera Jayasoma
Sent: Montag, 4. Mai 2009 04:59
To: Equinox development mailing list
Subject: Re: [equinox-dev] policy="dynamic" in Declarative Services.

 

Hi,

On Mon, May 4, 2009 at 8:23 AM, BlueDavy Lin <blued...@gmail.com> wrote:

if u want to the component isn't deactivated,u should set the bound
service cardinality to "0..1"


 
Thanks for the quick reply. But my requirement is that the service
should be registered before the component is activated. in that case I
have to put cardinality as "1..1" right?

Thanks
Sameera

        
        
        2009/5/4 Sameera Jayasoma <sameera.madus...@gmail.com>:

        > Hi devs,
        >
        > Even though I have used the value "dynamic" for the "policy"
attribute in
        > the "reference" element, the component is deactivated once the
bound service
        > is unregistered. Here is the component.xml I am using.
        >
        > <components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0";>
        >     <scr:component enabled="true"
name="carbon.core.dscomponent">
        >         <implementation
        > class="org.wso2.carbon.core.internal.CarbonCoreDSComponent"/>
        >         <property name="service.pid"
value="carbon.core.dscomponent"/>
        >         <reference name="registry.service"
        >
interface="org.wso2.carbon.registry.core.service.RegistryService"
        > cardinality="1..1" policy="dynamic" bind="setRegistryService"
        > unbind="unsetRegistryService"/>
        >     </scr:component>
        > </components>
        >
        > Here is the component implementation class.
        >
        > public class CarbonCoreDSComponent{
        >
        >     private static Log log =
LogFactory.getLog(CarbonCoreDSComponent.class);
        >     private BundleContext bundleContext;
        >
        >     protected void activate(ComponentContext ctxt) {
        >         log.info("******* Carbon Core bundle is activated
******* ");
        >     }
        >
        >     protected void deactivate(ComponentContext ctxt) {
        >         log.info("******* Carbon Core bundle is deactivated
******* ");
        >     }
        >
        >     protected void setRegistryService(RegistryService
registryService) {
        >         System.out.println("--------------------Set Registry
Service");
        >     }
        >
        >     protected void unsetRegistryService(RegistryService
registryService) {
        >         System.out.println("--------------------Unset Registry
        > Service");
        >     }
        > }
        >
        > When I stop the bundle which registers the
        > "org.wso2.carbon.registry.core.service.RegistryService",
following out put
        > is generated.
        >
        > ******* Carbon Core bundle is deactivated *******
        > {org.wso2.carbon.core.internal.CarbonCoreDSComponent}
        > --------------------Unset Registry Service
        >
        > This mean carbon.core bundle is deactivated right?
        >
        > Expected behavior: When the RegisterService is unregisterd,
only the unbind
        > method should be called. But here first the bundle is
deactivated and then
        > the unbind method is called.
        >
        > Any solution would be greatly appreciated.
        >
        > Thanks
        > --
        > Sameera Jayasoma
        > WSO2 Inc.
        > Oxygenating the Web Service Platform.
        > http://wso2.org/
        >
        > blog: http://tech.jayasoma.org
        >

        > _______________________________________________
        > equinox-dev mailing list
        > equinox-dev@eclipse.org
        > https://dev.eclipse.org/mailman/listinfo/equinox-dev
        >
        >
        
        
        
        --
        =============================
        |     BlueDavy                                      |
        |     OSGi China User Group Director    |
        |     http://china.osgiusers.org               |
        |     http://blog.bluedavy.cn                   |
        =============================
        _______________________________________________
        equinox-dev mailing list
        equinox-dev@eclipse.org
        https://dev.eclipse.org/mailman/listinfo/equinox-dev




-- 
Sameera Jayasoma
Software Engineer
WSO2 Inc.
Oxygenating the Web Service Platform.
http://wso2.org/

blog: http://tech.jayasoma.org

_______________________________________________
equinox-dev mailing list
equinox-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/equinox-dev

Reply via email to