You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by ismail berrada <is...@yahoo.fr> on 2015/06/03 23:13:50 UTC
Accessing bundle configuration
Hello all
I developed my own bundle and I would like to change configuration of publisher connectorI write the following code:
ServiceReference configurationAdminReference = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
if(configurationAdminReference != null) {
//LOGGER
ConfigurationAdmin confAdmin = (ConfigurationAdmin) bundleContext.getService(configurationAdminReference);
if(confAdmin != null) {
//LOGGER
Configuration configConnector = confAdmin.getConfiguration("com.eclipsesource.jaxrs.connector","inputstream:publisher-4.3.jar");
if(configConnector != null) {
//LOGGER
Dictionary<String,String> props = configConnector.getProperties();
if(props != null) {
properties.put("root","/");
//LOGGER
Enumeration<String> keys = props.keys();
if(keys != null) {
//LOGGER
while(keys.hasMoreElements()) {
String key = keys.nextElement();
//LOGGER
}
}
}else {
props = new Hashtable<String, String>();
properties.put("root","/");
}
configConnector.update(props);
}
}
}
But when I went to the configuration page in the web console I have seen the following error
Error: the PID "com.eclipsesource.jaxrs.connector" is bound to "file:/c:/Dev/Tools/Apache/Felix/bundle/mybundle-1.0.0.jar" but the actual managed service is registered from "inputstream:publisher-4.3.jar" bundle
Any idea of the root cause. It sounds like I don't have the permission to modify configuration of other bundles ?Right ? any way to do that ?
Regards
RE: Accessing bundle configuration
Posted by Ismail Berrada <is...@yahoo.fr>.
Hello Jan
Thanks for your answer
I have tried both solutions you suggested but the result is the same
-----Message d'origine-----
De : "Jan Willem Janssen" <ja...@luminis.eu>
Envoyé : 04/06/2015 07:11
À : "users@felix.apache.org" <us...@felix.apache.org>
Cc : "ismail berrada" <is...@yahoo.fr>
Objet : Re: Accessing bundle configuration
> On 03 Jun 2015, at 23:13, ismail berrada <is...@yahoo.fr> wrote:
>
> I developed my own bundle and I would like to change configuration of publisher connectorI write the following code:
> ServiceReference configurationAdminReference = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
> if(configurationAdminReference != null) {
> //LOGGER
> ConfigurationAdmin confAdmin = (ConfigurationAdmin) bundleContext.getService(configurationAdminReference);
> if(confAdmin != null) {
> //LOGGER
>
> Configuration configConnector = confAdmin.getConfiguration("com.eclipsesource.jaxrs.connector","inputstream:publisher-4.3.jar");
> //…
> configConnector.update(props);
> }
> }
> }
>
> But when I went to the configuration page in the web console I have seen the following error
> Error: the PID "com.eclipsesource.jaxrs.connector" is bound to "file:/c:/Dev/Tools/Apache/Felix/bundle/mybundle-1.0.0.jar" but the actual managed service is registered from "inputstream:publisher-4.3.jar" bundle
> Any idea of the root cause. It sounds like I don't have the permission to modify configuration of other bundles ?Right ? any way to do that ?
The 2nd argument you provide to confAdmin.getConfiguration denotes to what bundle this configuration
should be bound, in your case the “inputstream:publisher-4.3.jar”. WebConsole most probably doesn’t
know about that bundle-location, and tries to set the configuration without one causing the error.
Either you should use the same bundle-location in WebConsole (not sure that is possible), or do not
provide a bundle-location by supplying null as 2nd argument to confAdmin.getConfiguration implying
that the configuration can be bound to any bundle using the managed service PID.
Hope this helps,
--
Met vriendelijke groeten | Kind regards
Jan Willem Janssen | Software Architect
+31 631 765 814
My world is revolving around INAETICS and Amdatu
Luminis Technologies B.V.
Churchillplein 1
7314 BZ Apeldoorn
+31 88 586 46 00
http://www.luminis-technologies.com
http://www.luminis.eu
KvK (CoC) 09 16 28 93
BTW (VAT) NL8169.78.566.B.01
Re: Accessing bundle configuration
Posted by Jan Willem Janssen <ja...@luminis.eu>.
> On 03 Jun 2015, at 23:13, ismail berrada <is...@yahoo.fr> wrote:
>
> I developed my own bundle and I would like to change configuration of publisher connectorI write the following code:
> ServiceReference configurationAdminReference = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
> if(configurationAdminReference != null) {
> //LOGGER
> ConfigurationAdmin confAdmin = (ConfigurationAdmin) bundleContext.getService(configurationAdminReference);
> if(confAdmin != null) {
> //LOGGER
>
> Configuration configConnector = confAdmin.getConfiguration("com.eclipsesource.jaxrs.connector","inputstream:publisher-4.3.jar");
> //…
> configConnector.update(props);
> }
> }
> }
>
> But when I went to the configuration page in the web console I have seen the following error
> Error: the PID "com.eclipsesource.jaxrs.connector" is bound to "file:/c:/Dev/Tools/Apache/Felix/bundle/mybundle-1.0.0.jar" but the actual managed service is registered from "inputstream:publisher-4.3.jar" bundle
> Any idea of the root cause. It sounds like I don't have the permission to modify configuration of other bundles ?Right ? any way to do that ?
The 2nd argument you provide to confAdmin.getConfiguration denotes to what bundle this configuration
should be bound, in your case the “inputstream:publisher-4.3.jar”. WebConsole most probably doesn’t
know about that bundle-location, and tries to set the configuration without one causing the error.
Either you should use the same bundle-location in WebConsole (not sure that is possible), or do not
provide a bundle-location by supplying null as 2nd argument to confAdmin.getConfiguration implying
that the configuration can be bound to any bundle using the managed service PID.
Hope this helps,
--
Met vriendelijke groeten | Kind regards
Jan Willem Janssen | Software Architect
+31 631 765 814
My world is revolving around INAETICS and Amdatu
Luminis Technologies B.V.
Churchillplein 1
7314 BZ Apeldoorn
+31 88 586 46 00
http://www.luminis-technologies.com
http://www.luminis.eu
KvK (CoC) 09 16 28 93
BTW (VAT) NL8169.78.566.B.01