Thanks for the clarifications.

It's generally a bad idea to use non-interfaces for services...
because if the client knows the specific class, why bother looking up
a service? Nevertheless there are some edge cases where you might want
to do this, so I'll assume you're in one of those.

What you should do is register an object that implements
"ServiceFactory" from the core OSGi API. This object should be
registered under the classname of Foo but it is not actually a Foo...
instead it should return instances of Foo from its "getService"
method.

Regards,
Neil

On Sat, Aug 4, 2012 at 5:24 PM, Chetan Mehrotra
<[email protected]> wrote:
> Thanks Neil for the suggestions.
>
>> Not really. The problem is this part: "FooClient is created as
>> required". When is that exactly?
>
> I mean that Component activate method should be invoked only when any other
> bundle class performs a lookup for Foo service
>
>> component is not a service then there is no such signal, so DS is
>> forced to immediately activate the component.
>
> Yes that is the problem. Is it possible for component to say that I can
> provide Foo service without using @Service annotation.
>
> The problem is the Foo.class is not an interface hence I cannot proxy it
> (easily). The Component support used here is more like Factory pattern to
> create a class instance which cannot be instantiated directly by the
> container as i need to set some properties on FooClient before registering
> it.
>
> So to put it simple - Is it possible to use lazy activation for servies are
> created using a factory class and are not created directly by container?
>
> Chetan Mehrotra

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to