Hi, > I am sorry, but I don't understand what you are trying to explain. > Perhaps you can explain with some more concrete examples?
Let us assume 3 Components A,B,C:
A:
@Component ( property = {"prop1=A"} )
class A implements ServiceA {
...
}
B:
@Component ( property = {"prop2=B"} )
class B implements ServiceB {
...
}
C:
@Component(factory="Cfactory")
class C {
@Reference
[..] bindServiceA(ServiceA s) {...}
@Reference
[..] bindServiceB(ServiceB s) {...}
}
and we want to dynamically (the static properties are just here for the
sake of simplicity) specialize these references for a specific component
instances to bind to the ServiceA with prop1=A and the ServiceB with
prop2=B.
props.put("ServiceA.target", "(prop1=A)");
props.put("ServiceB.target", "(prop2=B)");
ComponentInstance i = componentFactory.newInstance(props);
In my scenario the instance returned is not immediately used by the
calling code but may be used by other components.
With the current ComponentFactory semantics it is necessary that both of
these references are satisfied when calling newInstance(), otherwise
newInstance() will fail with a ComponentException.
If there is only a single reference that needs to be specialized this
can be achieved easily, e.g. using a service tracker on the reference
target service. But, in the case of multiple references of this type,
ensuring that they are all satisfied becomes quite difficult for the caller.
What I propose is another ComponentFactory mechanism which will register
a component as if it was manually defined. This means it potentially
creates the component in unsatified state which will be activated when
the references are satisfied and deactivated when they are no more. In
this case the alternative factory can not return an activated instance
but should only return a handle for disposal (which in this case needs
to be performed manually).
On a second thought, this should be already possible trough ConfigAdmin.
Will check it out, this may be a sufficient work-around.
Hope this clears things up a bit.
Moritz
--
AgNO3 GmbH & Co. KG, Sitz Tübingen, Amtsgericht Stuttgart HRA 728731
Persönlich haftend:
Metagesellschaft mbH, Sitz Tübingen, Amtsgericht Stuttgart HRB 744820,
Vertreten durch Joachim Keltsch
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
