You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Ian Boston <ie...@tfd.co.uk> on 2011/09/30 06:04:41 UTC

Enabling and Disabling components.

Hi,
Is if possible to enable and disable components, and have that
enable/disable persist over Sling/Felix restarts ?

I have 2 components. A is enabled, B is disabled in the serviceComponents.xml.
I want to ensure that A is disabled and B is enabled on the first
start of the container, and I would rather not unpack the bundle, edit
serviceComponents.xml and repack the bundle.

I am currently looking at fragment bundles but according to
scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
you cant re-configure part of a component, you can only provide a
complete replacement serviceComponent.xml file. (is that right ?)

Ian

Re: Enabling and Disabling components.

Posted by Ian Boston <ie...@tfd.co.uk>.
Felix,
Thank you, I'll give that a go.
Ian

On 30 September 2011 18:48, Felix Meschberger <fm...@adobe.com> wrote:
> Hi,
>
> No, initial enablement of components is coded in the component.xml and
> any changes through the ScrService API are purely transitional.
>
> What you can do, though, is leverage the R4.2 configuration policy: Set
> the policy to required and provide or don't provide configuration. As
> long as there is no configuration, the component is not activated (much
> like a required service reference). Once configuration becomes
> available, the component is activated..
>
> Regards
> Felix
>
> On 30.09.2011 06:04, Ian Boston wrote:
>> Hi,
>> Is if possible to enable and disable components, and have that
>> enable/disable persist over Sling/Felix restarts ?
>>
>> I have 2 components. A is enabled, B is disabled in the serviceComponents.xml.
>> I want to ensure that A is disabled and B is enabled on the first
>> start of the container, and I would rather not unpack the bundle, edit
>> serviceComponents.xml and repack the bundle.
>>
>> I am currently looking at fragment bundles but according to
>> scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
>> you cant re-configure part of a component, you can only provide a
>> complete replacement serviceComponent.xml file. (is that right ?)
>>
>> Ian
>>
>
>

Re: Enabling and Disabling components.

Posted by Felix Meschberger <fm...@adobe.com>.
Hi,

No, initial enablement of components is coded in the component.xml and
any changes through the ScrService API are purely transitional.

What you can do, though, is leverage the R4.2 configuration policy: Set
the policy to required and provide or don't provide configuration. As
long as there is no configuration, the component is not activated (much
like a required service reference). Once configuration becomes
available, the component is activated..

Regards
Felix

On 30.09.2011 06:04, Ian Boston wrote:
> Hi,
> Is if possible to enable and disable components, and have that
> enable/disable persist over Sling/Felix restarts ?
>
> I have 2 components. A is enabled, B is disabled in the serviceComponents.xml.
> I want to ensure that A is disabled and B is enabled on the first
> start of the container, and I would rather not unpack the bundle, edit
> serviceComponents.xml and repack the bundle.
>
> I am currently looking at fragment bundles but according to
> scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
> you cant re-configure part of a component, you can only provide a
> complete replacement serviceComponent.xml file. (is that right ?)
>
> Ian
>


Re: Enabling and Disabling components.

Posted by Ian Boston <ie...@tfd.co.uk>.
Justin,
Thanks, I had a feeling that was the case, and my 5 or 6 failed
attempts prove you right.
I feel some local refactoring coming.
Ian

On 30 September 2011 14:16, Justin Edelson <ju...@justinedelson.com> wrote:
> Ian-
> I don't think you can do this with a fragment bundle, but feel free to prove me wrong :)
>
> I've been thinking enablement/disablement of components should be a feature of the installer, but haven't had a chance to sketch out how it would work.
>
> In some cases, you can use the configuration policy of require to accomplish something similar, but that doesn't work if it isn't your component.
>
> Justin
>
> On Sep 29, 2011, at 9:04 PM, Ian Boston <ie...@tfd.co.uk> wrote:
>
>> Hi,
>> Is if possible to enable and disable components, and have that
>> enable/disable persist over Sling/Felix restarts ?
>>
>> I have 2 components. A is enabled, B is disabled in the serviceComponents.xml.
>> I want to ensure that A is disabled and B is enabled on the first
>> start of the container, and I would rather not unpack the bundle, edit
>> serviceComponents.xml and repack the bundle.
>>
>> I am currently looking at fragment bundles but according to
>> scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
>> you cant re-configure part of a component, you can only provide a
>> complete replacement serviceComponent.xml file. (is that right ?)
>>
>> Ian
>

Re: Enabling and Disabling components.

Posted by Justin Edelson <ju...@justinedelson.com>.
Ian-
I don't think you can do this with a fragment bundle, but feel free to prove me wrong :)

I've been thinking enablement/disablement of components should be a feature of the installer, but haven't had a chance to sketch out how it would work.

In some cases, you can use the configuration policy of require to accomplish something similar, but that doesn't work if it isn't your component.

Justin

On Sep 29, 2011, at 9:04 PM, Ian Boston <ie...@tfd.co.uk> wrote:

> Hi,
> Is if possible to enable and disable components, and have that
> enable/disable persist over Sling/Felix restarts ?
> 
> I have 2 components. A is enabled, B is disabled in the serviceComponents.xml.
> I want to ensure that A is disabled and B is enabled on the first
> start of the container, and I would rather not unpack the bundle, edit
> serviceComponents.xml and repack the bundle.
> 
> I am currently looking at fragment bundles but according to
> scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
> you cant re-configure part of a component, you can only provide a
> complete replacement serviceComponent.xml file. (is that right ?)
> 
> Ian