Felix Meschberger wrote:
Hi Guido,

[...]
Point is that the Declarative Services implementation
is providing the configuration to the component as part of the
properties of the ComponentContext the component receives in the
activate and deactivate method.

So, given that the runtime is providing the configuration, there is no
need for the component to register as a ManagedService.

[...]
Hi Felix and Jeremias, thanks for your precious tips.

I'm writing how I solved my issue here, in case someone else
might have my doubts in the future.

From the compendium specs, section 112.2:
"If an activated component configuration’s configuration properties change,
SCR must deactivate the component configuration and then attempt to
reactivate the component configuration using the new configuration information."

So the next question is:
"How do I programatically alter a component configuration's configuration property, so that the
'activate' method of the component will be invoked?"

On section 112.6 of the compendium specs, there's written:
"Each component configuration is associated with a set of component properties.
The component properties are specified in the following places [...]:
[...]
2 Properties retrieved from the OSGi Configuration Admin service with a
Configuration object that has a PID equal to the name of the component.
[...]
The precedence behavior allows certain default values to be specified in the
component description while allowing properties to be replaced and
extended by:
• A configuration in Configuration Admin"


So I've come up with this snippet of code:

String COMPONENT_NAME = "<@name value in the 'component' element of the component descriptor>"; Configuration config = this.confAdminService.getConfiguration(COMPONENT_NAME);
Dictionary serviceProperties = config.getProperties();
if (serviceProperties == null) {
serviceProperties = new Hashtable();
serviceProperties.put(Constants.SERVICE_PID, COMPONENT_NAME);
}
serviceProperties.put("prop1", prop1_new_value);
serviceProperties.put("prop2", prop2_new_value);
config.update(serviceProperties);

Prop1 and Prop2 have default values specified in the component
descriptor.

Seems to be working...

Thanks again
--
Logo
Guido Spadotto
Soluta.net, Italy
http://www.soluta.net


The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to