Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » ManagedServices - update Configuration
ManagedServices - update Configuration [message #116568] Tue, 26 August 2008 20:37 Go to next message
Eclipse UserFriend
Originally posted by: ekkehard.gentz-software.de

I'm just doing some tests of bugfixes from Easybeans OSGI
to make it run under Equinox in combination with Riena.
Easybeans registers OSGI Services for the EJB Interfaces and
I need OSGI Services for Riena Remote Services.
Riena detects these Services if there are some Riena - specific
properties set.
Because I wanted to re-use the already registered Services from
Easybeans I must be able to set the Riena properties later.

this was the background story why I made a request at Easybeans
to make the Services ManagedServices.
this was done with the latest Easybeans 1.1.0 Snapshots.

if I run my OSGI server I can see that there are some hundred
ManagedServices for all my EJB Interfaces.
and there are some properties set from Easybeans.
so long so good.

now I want to update the Configuration and I think I've done it
the correct way:

snippet from my ServiceTracker:
------------------------------------------------------------
ServiceReference serviceReference =
context.getServiceReference(ConfigurationAdmin.class.getName ());
ConfigurationAdmin configAdmin = (ConfigurationAdmin)
context.getService(serviceReference);

String pid = (String)reference.getProperty("service.pid");

Configuration configuration = null;
try {
configuration = configAdmin.getConfiguration(pid);
}
catch (IOException e1) {
e1.printStackTrace();
}

Dictionary properties = configuration.getProperties();
if (properties == null) {
// the properties are always NULL
properties = new Hashtable();
}
properties.put("my.key", "my.value");

try {
configuration.update(properties);
}
catch (IOException e) {
e.printStackTrace();
}

------------------------------------------------------------

From my understanding the Dictionary should contain all
Properties and I can add some new and update the Configuration.

the ServiceTracker gets the right Services, the right
service.pid and I can also get other properties like
reference.getProperty("ejb.id")

if someone has an idea what could be wrong, please let me know.
I also asked at Easybeans Newsgroup - because they did something
wrong.

thanks
ekke
BTW: if I have all up and running I'll publish a small project
to demonstrate Equinox + Easybeans OSGI + Eclipse Riena
Re: ManagedServices - update Configuration [message #116609 is a reply to message #116568] Wed, 27 August 2008 17:38 Go to previous messageGo to next message
Simon Archer is currently offline Simon ArcherFriend
Messages: 24
Registered: July 2009
Junior Member
While I'm not entirely sure what your goal is here, I would like to warn
you about the ConfigurationAdmin API getConfiguration(String):

This API returns a configuration for the bundle making the call. The
Javadoc description is as follows:

"Get an existing or new Configuration object from the persistent store.
If the Configuration object for this PID does not exist, create a new
Configuration object for that PID, where properties are null. Bind its
location to the calling bundle's location."

This is quite different from getConfiguration(String, String), which
gets the configuration for another bundle described by the location
parameter. The Javadoc description is as follows:

"Get an existing Configuration object from the persistent store, or
create a new Configuration object. If a Configuration with this PID
already exists in Configuration Admin service return it. The location
parameter is ignored in this case. Else, return a new Configuration
object. This new object is bound to the location and the properties are
set to null. If the location parameter is null, it will be set when a
Managed Service with the corresponding PID is registered for the first
time."

For more see:
http://www.osgi.org/javadoc/r4/org/osgi/service/cm/Configura tionAdmin.html#getConfiguration(java.lang.String)
http://www.osgi.org/javadoc/r4/org/osgi/service/cm/Configura tionAdmin.html#getConfiguration(java.lang.String,%20java.lang.String)

My guess is that you should be using getConfiguration(String, String)
method.

Just my 2 cents.

Simon

ekke wrote:
> I'm just doing some tests of bugfixes from Easybeans OSGI
> to make it run under Equinox in combination with Riena.
> Easybeans registers OSGI Services for the EJB Interfaces and
> I need OSGI Services for Riena Remote Services.
> Riena detects these Services if there are some Riena - specific
> properties set.
> Because I wanted to re-use the already registered Services from
> Easybeans I must be able to set the Riena properties later.
>
> this was the background story why I made a request at Easybeans
> to make the Services ManagedServices.
> this was done with the latest Easybeans 1.1.0 Snapshots.
>
> if I run my OSGI server I can see that there are some hundred
> ManagedServices for all my EJB Interfaces.
> and there are some properties set from Easybeans.
> so long so good.
>
> now I want to update the Configuration and I think I've done it
> the correct way:
>
> snippet from my ServiceTracker:
> ------------------------------------------------------------
> ServiceReference serviceReference =
> context.getServiceReference(ConfigurationAdmin.class.getName ());
> ConfigurationAdmin configAdmin = (ConfigurationAdmin)
> context.getService(serviceReference);
>
> String pid = (String)reference.getProperty("service.pid");
>
> Configuration configuration = null;
> try {
> configuration = configAdmin.getConfiguration(pid);
> }
> catch (IOException e1) {
> e1.printStackTrace();
> }
>
> Dictionary properties = configuration.getProperties();
> if (properties == null) {
> // the properties are always NULL
> properties = new Hashtable();
> }
> properties.put("my.key", "my.value");
>
> try {
>
> configuration.update(properties);
> }
> catch (IOException e) {
> e.printStackTrace();
> }
>
> ------------------------------------------------------------
>
> From my understanding the Dictionary should contain all
> Properties and I can add some new and update the Configuration.
>
> the ServiceTracker gets the right Services, the right
> service.pid and I can also get other properties like
> reference.getProperty("ejb.id")
>
> if someone has an idea what could be wrong, please let me know.
> I also asked at Easybeans Newsgroup - because they did something
> wrong.
>
> thanks
> ekke
> BTW: if I have all up and running I'll publish a small project
> to demonstrate Equinox + Easybeans OSGI + Eclipse Riena
>
>
>
Re: ManagedServices - update Configuration [message #116624 is a reply to message #116609] Wed, 27 August 2008 20:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ekkehard.gentz-software.de

Simon,
thanks...
I have also tried the other method (PID, bundleLocation) without success.

so I'll create a small test to see where the problem is and post
the results

ekke

Simon Archer schrieb:
> While I'm not entirely sure what your goal is here, I would like to warn
> you about the ConfigurationAdmin API getConfiguration(String):
>
> This API returns a configuration for the bundle making the call. The
> Javadoc description is as follows:
>
> "Get an existing or new Configuration object from the persistent store.
> If the Configuration object for this PID does not exist, create a new
> Configuration object for that PID, where properties are null. Bind its
> location to the calling bundle's location."
>
> This is quite different from getConfiguration(String, String), which
> gets the configuration for another bundle described by the location
> parameter. The Javadoc description is as follows:
>
> "Get an existing Configuration object from the persistent store, or
> create a new Configuration object. If a Configuration with this PID
> already exists in Configuration Admin service return it. The location
> parameter is ignored in this case. Else, return a new Configuration
> object. This new object is bound to the location and the properties are
> set to null. If the location parameter is null, it will be set when a
> Managed Service with the corresponding PID is registered for the first
> time."
>
> For more see:
> http://www.osgi.org/javadoc/r4/org/osgi/service/cm/Configura tionAdmin.html#getConfiguration(java.lang.String)
>
> http://www.osgi.org/javadoc/r4/org/osgi/service/cm/Configura tionAdmin.html#getConfiguration(java.lang.String,%20java.lang.String)
>
>
> My guess is that you should be using getConfiguration(String, String)
> method.
>
> Just my 2 cents.
>
> Simon
>
> ekke wrote:
>> I'm just doing some tests of bugfixes from Easybeans OSGI
>> to make it run under Equinox in combination with Riena.
>> Easybeans registers OSGI Services for the EJB Interfaces and
>> I need OSGI Services for Riena Remote Services.
>> Riena detects these Services if there are some Riena - specific
>> properties set.
>> Because I wanted to re-use the already registered Services from
>> Easybeans I must be able to set the Riena properties later.
>>
>> this was the background story why I made a request at Easybeans
>> to make the Services ManagedServices.
>> this was done with the latest Easybeans 1.1.0 Snapshots.
>>
>> if I run my OSGI server I can see that there are some hundred
>> ManagedServices for all my EJB Interfaces.
>> and there are some properties set from Easybeans.
>> so long so good.
>>
>> now I want to update the Configuration and I think I've done it
>> the correct way:
>>
>> snippet from my ServiceTracker:
>> ------------------------------------------------------------
>> ServiceReference serviceReference =
>> context.getServiceReference(ConfigurationAdmin.class.getName ());
>> ConfigurationAdmin configAdmin = (ConfigurationAdmin)
>> context.getService(serviceReference);
>> String pid = (String)reference.getProperty("service.pid");
>> Configuration configuration = null;
>> try {
>> configuration = configAdmin.getConfiguration(pid);
>> }
>> catch (IOException e1) {
>> e1.printStackTrace();
>> }
>> Dictionary properties = configuration.getProperties();
>> if (properties == null) {
>> // the properties are always NULL
>> properties = new Hashtable();
>> }
>> properties.put("my.key", "my.value");
>> try {
>>
>> configuration.update(properties);
>> }
>> catch (IOException e) {
>> e.printStackTrace();
>> }
>>
>> ------------------------------------------------------------
>>
>> From my understanding the Dictionary should contain all
>> Properties and I can add some new and update the Configuration.
>>
>> the ServiceTracker gets the right Services, the right
>> service.pid and I can also get other properties like
>> reference.getProperty("ejb.id")
>>
>> if someone has an idea what could be wrong, please let me know.
>> I also asked at Easybeans Newsgroup - because they did something
>> wrong.
>>
>> thanks
>> ekke
>> BTW: if I have all up and running I'll publish a small project
>> to demonstrate Equinox + Easybeans OSGI + Eclipse Riena
>>
>>
>>
Re: ManagedServices - update Configuration [message #116650 is a reply to message #116624] Thu, 28 August 2008 14:53 Go to previous message
Eclipse UserFriend
Originally posted by: ekkehard.gentz-software.de

it was a misunderstanding about the implementation from easybeans,
I expected that Easybeans has already created a Configuration with
their properties, but they only implemented the ManagedService
Interface for me and created no Configuration.
so all my results are ok - I receive an empty Configuration (null)
and can then create a new Configuration and update the Managed
Service with my properties

ekke

ekke schrieb:
> Simon,
> thanks...
> I have also tried the other method (PID, bundleLocation) without success.
>
> so I'll create a small test to see where the problem is and post
> the results
>
> ekke
>
> Simon Archer schrieb:
>> While I'm not entirely sure what your goal is here, I would like to
>> warn you about the ConfigurationAdmin API getConfiguration(String):
>>
>> This API returns a configuration for the bundle making the call. The
>> Javadoc description is as follows:
>>
>> "Get an existing or new Configuration object from the persistent
>> store. If the Configuration object for this PID does not exist, create
>> a new Configuration object for that PID, where properties are null.
>> Bind its location to the calling bundle's location."
>>
>> This is quite different from getConfiguration(String, String), which
>> gets the configuration for another bundle described by the location
>> parameter. The Javadoc description is as follows:
>>
>> "Get an existing Configuration object from the persistent store, or
>> create a new Configuration object. If a Configuration with this PID
>> already exists in Configuration Admin service return it. The location
>> parameter is ignored in this case. Else, return a new Configuration
>> object. This new object is bound to the location and the properties
>> are set to null. If the location parameter is null, it will be set
>> when a Managed Service with the corresponding PID is registered for
>> the first time."
>>
>> For more see:
>> http://www.osgi.org/javadoc/r4/org/osgi/service/cm/Configura tionAdmin.html#getConfiguration(java.lang.String)
>>
>> http://www.osgi.org/javadoc/r4/org/osgi/service/cm/Configura tionAdmin.html#getConfiguration(java.lang.String,%20java.lang.String)
>>
>>
>> My guess is that you should be using getConfiguration(String, String)
>> method.
>>
>> Just my 2 cents.
>>
>> Simon
>>
>> ekke wrote:
>>> I'm just doing some tests of bugfixes from Easybeans OSGI
>>> to make it run under Equinox in combination with Riena.
>>> Easybeans registers OSGI Services for the EJB Interfaces and
>>> I need OSGI Services for Riena Remote Services.
>>> Riena detects these Services if there are some Riena - specific
>>> properties set.
>>> Because I wanted to re-use the already registered Services from
>>> Easybeans I must be able to set the Riena properties later.
>>>
>>> this was the background story why I made a request at Easybeans
>>> to make the Services ManagedServices.
>>> this was done with the latest Easybeans 1.1.0 Snapshots.
>>>
>>> if I run my OSGI server I can see that there are some hundred
>>> ManagedServices for all my EJB Interfaces.
>>> and there are some properties set from Easybeans.
>>> so long so good.
>>>
>>> now I want to update the Configuration and I think I've done it
>>> the correct way:
>>>
>>> snippet from my ServiceTracker:
>>> ------------------------------------------------------------
>>> ServiceReference serviceReference =
>>> context.getServiceReference(ConfigurationAdmin.class.getName ());
>>> ConfigurationAdmin configAdmin = (ConfigurationAdmin)
>>> context.getService(serviceReference);
>>> String pid =
>>> (String)reference.getProperty("service.pid");
>>> Configuration configuration = null;
>>> try {
>>> configuration = configAdmin.getConfiguration(pid);
>>> }
>>> catch (IOException e1) {
>>> e1.printStackTrace();
>>> }
>>> Dictionary properties = configuration.getProperties();
>>> if (properties == null) {
>>> // the properties are always NULL
>>> properties = new Hashtable();
>>> }
>>> properties.put("my.key", "my.value");
>>> try {
>>>
>>> configuration.update(properties);
>>> }
>>> catch (IOException e) {
>>> e.printStackTrace();
>>> }
>>>
>>> ------------------------------------------------------------
>>>
>>> From my understanding the Dictionary should contain all
>>> Properties and I can add some new and update the Configuration.
>>>
>>> the ServiceTracker gets the right Services, the right
>>> service.pid and I can also get other properties like
>>> reference.getProperty("ejb.id")
>>>
>>> if someone has an idea what could be wrong, please let me know.
>>> I also asked at Easybeans Newsgroup - because they did something
>>> wrong.
>>>
>>> thanks
>>> ekke
>>> BTW: if I have all up and running I'll publish a small project
>>> to demonstrate Equinox + Easybeans OSGI + Eclipse Riena
>>>
>>>
>>>
Previous Topic:Protect bundles from start
Next Topic:Errors when storing passwords in secure storage
Goto Forum:
  


Current Time: Mon Sep 23 09:02:04 GMT 2024

Powered by FUDForum. Page generated in 0.04112 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top