First of all, thanks Peter, I got confused over the 'real definition' and how I have used it in the past, i.e. combine ServiceFactory with ManagedServcieFactory. That said, read below;

On 11/10/06, Makas Tzavellas <[EMAIL PROTECTED]> wrote:
Client only *shares* the same instance if they have the share same
configuration. Meaning, Client A and B wants to connect to database
MESH, so they share the same instance, Client C wants to connect to
database SMASH, which then will be using another instance of the service.

Sounds like a case of standard simple services;

JdoProvider provider1 = new JdoProviderImpl();
Properties props = new Properties();
props.put( Constants.SERVICE_PID, "org.hedhman.niclas.jdo.MESH " );
props.put( Constants.SERVICE_ID, "org.hedhman.niclas.jdo.MESH" );
reg1 = ctx.registerService( JdoProvider.class.getName(), provider1, props );

JdoProvider provider2 = new JdoProvider();
props = new Properties();
props.put( Constants.SERVICE_PID, "org.hedhman.niclas.jdo.SMASH " );
props.put( Constants.SERVICE_ID, "org.hedhman.niclas.jdo.SMASH" );
reg1 = ctx.registerService( JdoProvider.class.getName(), provider2, props );


And the client looking up with serviceID;

ServiceReference[] refs = ctx.getServiceReferences(
        JdoProvider.class.getName(),
        "("+Constants.SERVICE_ID + "=MESH)" );


or the equivalent in the ServiceTracker.


However, IF you want to create new JdoProvider instances on-the-fly from the Config Admin service, you should use the ManagedServiceFactory.

When ManagedServiceFactory receives a Service PID that doesn't exist before, it creates a new JdoProvider. IIUIC, if the service instance that the factory registers is a managed service, it too will receive the Configuration in its updated() method. Likewise, on deleted() the MSF removes the service registration from the framework registry.

Hope that helps


Cheers
_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to