You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Roland <wg...@ids.de> on 2013/07/09 16:18:04 UTC
Re: Why OSGI Configuration is bound to a admin bundle temporary?
hi,
I have a similar issue. I get the below debug output if I register the
service and the parameter "properties" of the callback-function
ManagedService::updated() is null. If I call Configuration::update() no
event is fired.
No SynchronousConfigurationListeners to send {0} event to.
public void start(BundleContext context) throws NullPointerException {
bundlecontext = context;
new Thread() {
public void run() {
...
MyClass ctrl = new MyClass();
Dictionary<String, Object> properties = new Hashtable<String,
Object>();
properties.put(Constants.SERVICE_PID, MyClass.class.getName());
String[] classnames = {ManagedService.class.getName(),
MyClass.class.getName()};
rs = bundlecontext.registerService(classnames, ctrl, properties);
...
configuration =
configAdmin.createFactoryConfiguration(MyClass.class.getName(), null);
configuration.update(properties);
}
}.start();
}
Does anyone have an idea or a suggestion?
Thanks in advance!
Roland
--
View this message in context: http://apache-felix.18485.x6.nabble.com/OSGI-Configuration-cannot-take-effect-immediately-tp4833849p5004254.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Why OSGI Configuration is bound to a admin bundle temporary?
Posted by Roland <wg...@ids.de>.
Ok, now I know why.
I was not aware that service.pid and service.factoryPid are totally
different things. My fault!
--Solved--
Roland wrote
> I still do not know why that does not work but I have a solution.
>
> This code does not work...
> ConfigurationAdmin confAdmin =
> getConfigurationAdminService(bundlecontext);
> if(confAdmin != null){
> try{
> configuration = confAdmin.getConfiguration(
*
> pid
*
> );
> }catch(IOException e){
> ...
> }
> if(configuration != null){
> return configuration.getProperties(); //returns null
> }
> }
>
> Workaround...
> ConfigurationAdmin confAdmin =
> getConfigurationAdminService(bundlecontext);
> if(confAdmin != null){
> Configuration[] configs = null;
>
*
> String filter = "(service.factoryPid=" + pid + *)";
*
> try{
> configs = confAdmin.listConfigurations(filter);
> }catch(IOException e){
> ...
> }catch(InvalidSyntaxException e){
> ...
> }
> if(configs != null){
> for(Configuration conf : configs)
> {
> Dictionary<String, Object>properties =
> conf.getProperties();
> ...
> }
> }
>
> Regards...
> Roland
--
View this message in context: http://apache-felix.18485.x6.nabble.com/OSGI-Configuration-cannot-take-effect-immediately-tp4833849p5004266.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Why OSGI Configuration is bound to a admin bundle temporary?
Posted by Roland <wg...@ids.de>.
I still do not know why that does not work, but I have a problem solution.
This code does not work...
ConfigurationAdmin confAdmin =
getConfigurationAdminService(bundlecontext);
if(confAdmin != null){
try{
configuration = confAdmin.getConfiguration(*pid*);
}catch(IOException e){
...
}
if(configuration != null){
return configuration.getProperties(); //returns null
}
}
Workaround...
ConfigurationAdmin confAdmin =
getConfigurationAdminService(bundlecontext);
if(confAdmin != null){
Configuration[] configs = null;
*String filter = "(service.pid=" + pid + *)";*
try{
configs = confAdmin.listConfigurations(filter);
}catch(IOException e){
...
}catch(InvalidSyntaxException e){
...
}
if(configs != null){
for(Configuration conf : configs)
{
Dictionary<String, Object>properties = conf.getProperties();
...
}
}
Regards...
Roland
--
View this message in context: http://apache-felix.18485.x6.nabble.com/OSGI-Configuration-cannot-take-effect-immediately-tp4833849p5004265.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Why OSGI Configuration is bound to a admin bundle temporary?
Posted by Roland <wg...@ids.de>.
I switched to ManagedServiceFactory and the parameter "properties" of the
callback-function ManagedService::updated() is now valid. But
Configuration::getProperties() still returns null even though I had set some
properties and had updated the service. hm...I'll let you know when I've
figured out why this happens.
Regards...
Roland
--
View this message in context: http://apache-felix.18485.x6.nabble.com/OSGI-Configuration-cannot-take-effect-immediately-tp4833849p5004264.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Why OSGI Configuration is bound to a admin bundle temporary?
Posted by Roland <wg...@ids.de>.
Hello Jan,
Thank for your fast response! Ok, I made a stupid mistake.
Bye
Roland
--
View this message in context: http://apache-felix.18485.x6.nabble.com/OSGI-Configuration-cannot-take-effect-immediately-tp4833849p5004258.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: Why OSGI Configuration is bound to a admin bundle temporary?
Posted by Jan Willem Janssen <ja...@luminis.eu>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 7/9/13 4:18 PM, Roland wrote:
> MyClass ctrl = new MyClass(); Dictionary<String, Object> properties
> = new Hashtable<String, Object>();
> properties.put(Constants.SERVICE_PID, MyClass.class.getName());
> String[] classnames = {ManagedService.class.getName(),
> MyClass.class.getName()}; rs =
> bundlecontext.registerService(classnames, ctrl, properties);
>
> ...
>
> configuration =
> configAdmin.createFactoryConfiguration(MyClass.class.getName(),
> null); configuration.update(properties);
You're creating a _factory_ configuration, but you've registered your
service not as ManagedServiceFactory, but as plain ManagedService. Use
ConfigAdmin#getConfiguration() instead (it will create a configuration
for you, if needed).
- --
Met vriendelijke groeten | Kind regards
Jan Willem Janssen | Software Architect
+31 631 765 814
/My world is revolving around PulseOn and Amdatu/
Luminis Technologies B.V.
J.C. Wilslaan 29
7313 HK Apeldoorn
+31 88 586 46 30
http://www.luminis-technologies.com
http://www.luminis.eu
KvK (CoC) 09 16 28 93
BTW (VAT) NL8169.78.566.B.01
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQIcBAEBAgAGBQJR3B2NAAoJEKF/mP2eHDc4GKoP/1pwGiUSTLVaO+hyEl/zW4W8
zHCf2CqIBeVHXrAasT5c4YufDwhDGF70iSUKrtillQXVi4bC1+LZ6B93+973+Xz5
nobYSviPSP1ITraUMzj/Lws/EE/loZSirB/S/Jx9SWJz9KIJ3WNfoMfCSvjT6KGM
EEQpHACLGZgNoDPzl5zzNUpPlx5mO2C7sDxFLHqzDByCufsCIqVDwC8nSNg26+RF
wGHhHwjPrpkb/UhuypfY5Q3G57odxMP8UrVHjIZ8g1r/yu3KT2HrJ4U+eBvYQhns
Lg4cbUVTmVVlFnkFkXryCvB5/IjFAqqtkehlDgt8hEfFkp7kbWwk+zSOmLe79y1n
AP24KLIcjH6/DjF5/aMsSQytW0kUXeSvnyRx4wP/RhHPiSeB5S+NvngSZGnt3Fdx
akmBzrZhxlWKoriukMjmX/PYfS0skrHEe8laY9RHE4PZ5t96CiwpC+ROTH0OrYKI
a8yCUrlcNMjYRVzaBto2OeUOcP//U3ZVwnvLUikbDQvwvwF7Sajy2N2qyWLiRo62
g+k9PXZrIKoswvDeFmXEn40ARzB5SVSww2DJgislJRpBe8qgqTEr32JGKzRZiYNB
NhtIfboxoq1oLoxu0gp1V46KltyF7D/Ig/fh0LHjSpicbzv6MUHCq5gzYUhJUJBN
0pxabKAEmmMnd9ZcGa1Z
=UMbt
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org