Hi, I don't think this is gonna work. As I understand, the ComponentFactory service has the same dependencies as the factory component. So the service to be injected into the factory component is already decided when the ComponentFactory service is available.
Regards, Agemo On Thu, Jun 10, 2010 at 1:53 PM, Sangjin Lee <[email protected]> wrote: > I have a question on the behavior of ComponentFactory.newInstance() when > you inject a reference target dynamically. > > I have a factory component that has a unary mandatory reference to some > service, but the target is intentionally left blank (so I can provide it > dynamically). When I instantiate a specific instance, I want to pass in a > particular type so this specific instance can bind to the right service > instance. The code snippet is at http://bit.ly/dy8kFy. > > I am basically adding a property for "service.target" = "(type=foo)", so at > runtime this binds specifically to a service instance of type=foo. Will this > pattern work? > > Also, if so, how does ComponentFactory.newInstance() behave if that service > is not registered yet? Will it fail immediately or will it block/wait until > that particular service is registered? > > In a bigger context, I'm trying to see if I can use this pattern as a way > to "compel" a specific service with a type dynamically at runtime. Is there > a better pattern to compel a specific service type dynamically? Thanks much! > > Regards, > Sangjin > > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev >
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
