This should be easy (or so I thought)...
I'm using ManagedServiceFactories and I register them with a set of properties.
When a new service is created, how can I access the properties that the
service was registered with?
Example:
In my Activator class:
:
private ServiceRegistration factoryService = null;
private LogDeliveryMSF modelFactory = null;
public void start(BundleContext context) throws Exception
{
Dictionary props = new Hashtable();
props.put("SomeKey", "SomeValue")); // <=== This is what I need to
access
modelFactory = new LogDeliveryMSF();
factoryService =
context.registerService(ManagedServiceFactory.class.getName(), modelFactory,
props);
}
When I use the ConfigAdmin service to create the service, I can't seem to find
the properties:
ServiceReference configurationAdminReference =
context.getServiceReference(ConfigurationAdmin.class.getName());
ConfigurationAdmin confAdmin = (ConfigurationAdmin)
context.getService(configurationAdminReference);
Configuration configuration =
confAdmin.createFactoryConfiguration(servicePID, null);
Dictionary properties = configuration.getProperties();
I would have thought that the last line above would return the properties that
the service was registered with, but I'm getting null.
I can use context.getBundle().getHeaders() to get the bundle's Manifest
Headers, but I'd rather just grab the properties that the service was
registered with. I can also pass them to the LogDeliveryMSF constructor, but I
thought that the newly created service would inherit them somehow.
Thanks,
Larry