Hi Sangjin

Not that I recommend this solution, but you should take a look at the synchronous service filter part of the 4.2 specification. This is the ultimate way to create services on demand when a service is requested (not through some external means, which is when you use ConfigAdmin).

Cheers
Chris

On 11/06/2010 5:25 AM, Sangjin Lee wrote:
Thanks for the quick reply. That's what I suspected, but I wanted to be sure. So, injecting a reference target has no effect on a factory component? I get ComponentExceptions under some situations, so it seems it is *not* used to bind a service but is used to check/resolve it...

Is there a better way to achieve what I'm trying to achieve (create dynamic instances of services that will be used to bind to specific service instances based on properties)? Perhaps Blueprint?

Thanks,
Sangjin

On Thu, Jun 10, 2010 at 11:24 AM, Agemo Cui <[email protected] <mailto:[email protected]>> wrote:

    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]
    <mailto:[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] <mailto:[email protected]>
        https://mail.osgi.org/mailman/listinfo/osgi-dev



    _______________________________________________
    OSGi Developer Mail List
    [email protected] <mailto:[email protected]>
    https://mail.osgi.org/mailman/listinfo/osgi-dev



_______________________________________________
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

Reply via email to