Topic
No replies
heinzhubert
heinzhubert
1 Post
ACCEPTED ANSWER

Pinned topic Configuration Admin Service

‏2013-03-05T10:31:14Z |
Hello

i am trying to make a simple usage of the osgi configuration Admin Service in WAS Liberty Profile 8.5

I used the sample code shown in the documention page 320.

Chapter Receiving configuration data by using the ManagedService
interface

When i add the line <simpleBundle color=”red” flavor=”raspberry” /> to the server.xml, no updates are received to the registered ManagedService

Code:

import java.util.Dictionary;
import java.util.Hashtable;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedService;

public class Activator implements BundleActivator, ManagedService {

private ServiceRegistration serviceReg;

public void start(BundleContext context) throws Exception {

ServiceRegistration serviceReg = context.registerService(ManagedService.class.getName(), this , getDefaults());

System.out.println(serviceReg.toString());

}
public void stop(BundleContext context) throws Exception {
serviceReg.unregister();
}

@Override
public void updated(Dictionary arg0) throws ConfigurationException {
System.out.println("update !");
}
public Hashtable getDefaults() {
Hashtable defaults = new Hashtable();
defaults.put(org.osgi.framework.Constants.SERVICE_PID,"simpleBundle");
return defaults;
}

}