Hello all
If the published property of a service is based on a value in the actual
service object, and that value later changes, how can I update the
properties using DM?
Example: You have Device objects (and the corresponding impl)
public interface Device{
public int getRoom();
public void setRoom(int i);
}
Maybe you originally register the device like this
Device d = new DeviceImpl();
s.setRoom(12);
Dictionary<String, Object> props = new Hashtable<>();
props.put("room", d.getRoom());
mgr.add(createComponent()
.setImplementation(d)
.setInterface(Device.class.getName(), props));
... later somebody else (maybe a consumer of the service...) calls
d.setRoom(13)
How can I update the "room" property of the service?
I believe I could keep the Component from start(Component c) and later
use its setServiceProperties() but is that clean/correct?
like so:
class DeviceImpl implements Device {
private Component c;
private int room;
public void start(Component c){
this.c = c;
}
public void setRoom(int i){
room = i;
c.setServiceProperties(c.getServiceProperties().put("room", i));
}
}
Is this correct? Is there a better method or pattern to use? Any
problems to expect from keeping the Component around?
Also, what happens when the service consumer which is calling setRoom(),
is actually filtering on that property, so that his object gets removed
still while he is calling the method?
Regards Philipp
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]