You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Stéphane Amaudruz <st...@wikima4.com> on 2009/03/13 11:28:06 UTC
IPojo - Retrieving Instance
Hi,
I think I am missing some point in iPOJO.
The use case is:
* I have an interface, lets say IRuleStrategy, that define
execution strategies for Rule.
* I have different implementations: Strategy1 to execute Rule on
system version1 and Strategy2 to execute Rule on system version2.
* I will create a singleton instance of each of these implementation
with IPOJO
Now in my ExecutionEngine I want to retrieve the strategy for a rule,
depending on a the system version, something as getStrategy(int version). I
do not see how to do that with IPOJO component? That means how to retrieve
are component from its interface and some properties.
The only solution I think about is that the component publishes an OSGi
service and then I can retrieve the service by properties. But can I avoid
it and requesting component instead of service, what are the best practices?
Is fear an overhead using services and also I am not confident about OSGi
service and multithreading ?
Thanks,
Steph
Re: IPojo - Retrieving Instance
Posted by Karl Pauls <ka...@gmail.com>.
You might want to have a look at the extender pattern und the iPOJO
extender handler:
http://felix.apache.org/site/extender-pattern-handler.html
not sure that this is what you want exactly but it might come close.
regards,
Karl
On Fri, Mar 13, 2009 at 2:53 PM, Richard S. Hall <he...@ungoverned.org> wrote:
> Hmm. iPOJO is intended to be a component model for OSGi, so you are sort of
> wanting to go against the grain if you don't want to use services.
>
> I understand your concern about overhead, but I think any system that
> manages your components' lifecycle is going to have to keep some registry of
> instances too, unless you have a purely static management framework that
> just creates instances once and forgets about them. Your request is
> essentially asking iPOJO to duplicate the service registry as some sort of
> hidden "component registry".
>
> However, Clement and I did discuss this topic before for iPOJO, but I don't
> think anything was done here.
>
> Maybe Clement has more to add.
>
> -> richard
>
> On 3/13/09 6:28 AM, Stéphane Amaudruz wrote:
>>
>> Hi,
>>
>>
>>
>> I think I am missing some point in iPOJO.
>>
>>
>>
>> The use case is:
>>
>> * I have an interface, let’s say IRuleStrategy, that define
>> execution strategies for Rule.
>>
>> * I have different implementations: Strategy1 to execute Rule on
>> system version1 and Strategy2 to execute Rule on system version2.
>>
>> * I will create a singleton instance of each of these
>> implementation
>> with IPOJO
>>
>>
>>
>> Now in my ExecutionEngine I want to retrieve the strategy for a rule,
>> depending on a the system version, something as getStrategy(int version).
>> I
>> do not see how to do that with IPOJO component? That means how to retrieve
>> are component from its interface and some properties.
>>
>>
>>
>> The only solution I think about is that the component publishes an OSGi
>> service and then I can retrieve the service by properties. But can I avoid
>> it and requesting component instead of service, what are the best
>> practices?
>> Is fear an overhead using services and also I am not confident about OSGi
>> service and multithreading ?
>>
>>
>>
>> Thanks,
>>
>> Steph
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>
--
Karl Pauls
karlpauls@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: IPojo - Retrieving Instance
Posted by "Richard S. Hall" <he...@ungoverned.org>.
Hmm. iPOJO is intended to be a component model for OSGi, so you are sort
of wanting to go against the grain if you don't want to use services.
I understand your concern about overhead, but I think any system that
manages your components' lifecycle is going to have to keep some
registry of instances too, unless you have a purely static management
framework that just creates instances once and forgets about them. Your
request is essentially asking iPOJO to duplicate the service registry as
some sort of hidden "component registry".
However, Clement and I did discuss this topic before for iPOJO, but I
don't think anything was done here.
Maybe Clement has more to add.
-> richard
On 3/13/09 6:28 AM, Stéphane Amaudruz wrote:
> Hi,
>
>
>
> I think I am missing some point in iPOJO.
>
>
>
> The use case is:
>
> * I have an interface, let’s say IRuleStrategy, that define
> execution strategies for Rule.
>
> * I have different implementations: Strategy1 to execute Rule on
> system version1 and Strategy2 to execute Rule on system version2.
>
> * I will create a singleton instance of each of these implementation
> with IPOJO
>
>
>
> Now in my ExecutionEngine I want to retrieve the strategy for a rule,
> depending on a the system version, something as getStrategy(int version). I
> do not see how to do that with IPOJO component? That means how to retrieve
> are component from its interface and some properties.
>
>
>
> The only solution I think about is that the component publishes an OSGi
> service and then I can retrieve the service by properties. But can I avoid
> it and requesting component instead of service, what are the best practices?
> Is fear an overhead using services and also I am not confident about OSGi
> service and multithreading ?
>
>
>
> Thanks,
>
> Steph
>
>
>
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org
Re: IPojo - Retrieving Instance
Posted by Clement Escoffier <cl...@gmail.com>.
On 13.03.2009, at 11:28, Stéphane Amaudruz wrote:
> Hi,
>
>
>
> I think I am missing some point in iPOJO.
>
>
>
> The use case is:
>
> * I have an interface, let’s say IRuleStrategy, that define
> execution strategies for Rule.
>
> * I have different implementations: Strategy1 to execute
> Rule on
> system version1 and Strategy2 to execute Rule on system version2.
>
> * I will create a singleton instance of each of these
> implementation
> with IPOJO
>
>
>
> Now in my ExecutionEngine I want to retrieve the strategy for a rule,
> depending on a the system version, something as getStrategy(int
> version). I
> do not see how to do that with IPOJO component? That means how to
> retrieve
> are component from its interface and some properties.
Nope, iPOJO relies on services for regular injection. Injecting
component directly is not really supported. However, you can filter
injected services.
To avoid having too much services in the registry, iPOJO provides a
way to isolate services inside a "private" service registry (with
composites).
>
>
> The only solution I think about is that the component publishes an
> OSGi
> service and then I can retrieve the service by properties. But can I
> avoid
> it and requesting component instead of service, what are the best
> practices?
> Is fear an overhead using services and also I am not confident about
> OSGi
> service and multithreading ?
In the case of OSGi, the overhead is relatively small as you get
direct references on the service (no proxy). So, once you get the
service, there is no more overhead. However, synchronization can be
more tricky. iPOJO simplifies this with a "thread confinement",
however I'm working a another type of synchronization management.
Clement
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org