Hi,
Your code looks perfectly right to me. The problem is, that you assume,
that the SCR is creating Configuration instances. This is not the case.
What happens here is, that when ComponentWithConf is activated, a
ManagedService is registered on behalf of the ComponentWithConf. If the
Configuration Admin Service is active and has a configuration, it is
sent to the ComponentWithConf. Otherwise no configuration is sent. What
the ComponentWithConf will receive in its activate method is actually
the default configuration properties as per the descriptor file created
from the @scr.* tags.
When the ManagementComponent is started, it just also asks the
ConfigurationAdmin for configurations. There are none at the moment, so
there is nothing to print.
Only if you have a management agent actually creating a Configuration
object through the ConfigurationAdmin, will the ManagementComponent see
the configuration and the ComponentWithConf reveive the configuration.
FYI: You might want to have a look at the Management Console we use over
in the Apache Sling project. This provides you with pretty much
something, you might be interested in. (And you might also be interested
that there are in fact plans to move this over here to the Felix
project).
Regards
Felix
Am Freitag, den 25.04.2008, 16:02 +0200 schrieb Martin Testrot:
> Hi,
>
>
>
> I would like to implement a management bundle which displays the
> properties defined by other bundles/SCR components.
>
>
>
> To try this approach I wrote a simple bundle with one component and a
> simple property as follows:
>
>
>
> /*
>
> * @scr.component
>
> *
>
> * @scr.service
>
> */
>
> public class ComponentWithConf implements EmptyService{
>
>
>
> /** scr.property value="defaultvalue"*/
>
> private static final String MYPROP = "myprop";
>
>
>
> ...
>
> }
>
>
>
> The Management Bundle looks like this:
>
>
>
> /*
>
> * @scr.component
>
> */
>
> public class ManagementComponent {
>
>
>
> /**
>
> * @scr.reference
>
> */
>
> private ConfigurationAdmin mConfigurationAdmin;
>
>
>
> proteced void activate (ComponentContext pContext){
>
> Configuration[] lConfigurations =
> mConfigurationAdmin.listConfigurations(null);
>
> if (lConfigurations.length() == 0)
> System.out.println ("No conf found!");
>
> }
>
> }
>
>
>
> The problem is, that I don't see any configurations from my
> ManagementComponent. The above activate - method always prints "No conf
> found!" on the console.
>
>
>
> Am I missing something? Is this a bug?
>
>
>
> Thanks for help,
>
>
>
> Martin
>
>
>
> P.S.: I'm using
>
> org.apache.felix.configadmin 1.0.1
>
> org.apache.felix.scr 1.0.0
>
> maven-bundle-plugin 1.2.0
>
> maven-scr-plugin 1.0.3
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]