質問

iPOJO provides a mechanism to create composites that contain instances of primitive type components. I am interested in understanding the mechanism in which iPOJO provides an isolation for the services provided by the composite sub-instances from being accessed from outside the composite.

For exmaple, assume I have the following composition (Using iPOJO API):

 PrimitiveComponentType prov = createAProvider(); // Create a primitive type
 PrimitiveComponentType cons = createAConsumer(); // Create another primitive type

       CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("comp1")
           .addInstance(new Instance(prov.getFactory().getName())) // Create an instance in the composite
           .addInstance(new Instance(cons.getFactory().getName())); 

       ComponentInstance ci = type.createInstance();

Let's say that the component "prov" implements a service interface called HelloService. What does it mean that this service is isolated?

Does it mean that if I tried to access the service from an external bundle (not part of the composite) by having a service reference:

   ServiceReference ref = 
                  context.getServiceReference(HelloService.class.getName());

Is this reference really going to fail because its scope is outside the composite?

What if a component inside the composite contains a reference to a service published outside the composite? Is this reference also going to fail?

Note: I am not interested in the imported or exported services for the moment.

役に立ちましたか?

解決

iPOJO composite relies on the iPOJO Service Context. In iPOJO the regular OSGi bundle context is composed by two parts: the bundle-centric part responsible for a class loading activities and the service-centric part responsible for all service interactions (publication, lookup, binding...).

When an instance runs inside a composite it as a 'local' service context, using a local service registry (the one from the composite). So services registered from inside the composite are not accessible from from outside as they are using two different service registries: the composite's one and the one from the OSGi framework.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top