Typically one has to use ServiceReference.getProprty() method to know the properties of the service object. But, I have a feeling you are not using config admin correctly. Why are you interested in what properties are used to configure the ManagedServiceFactory? Typically, one sets only PID of the ManagesServiceFactory. This PID is then used to create a configuration using ConfigurationAdmin.createFactoryConfiguration. What are you going to achieve by setting all those extra properties in the ManagedServiceFactory object?

Sahoo
On Friday 25 June 2010 10:43 PM, Larry Touve wrote:
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




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to