Hi,
On 15.07.2009, at 17:27, John Stump wrote:
Yes, I have been reading about that, and I might go this route. I
also saw mentioned that the @Provides annotation supports a
"strategy" property to allow me to create a new instance for every
request, another requirement I have. Something like this:
@Provides(strategy="instance")
However, "strategy" is not documented in the iPOJO reference card at http://felix.apache.org/site/ipojo-reference-card.html
. Is strategy an officially supported property? Will I run into
problems in the future if I use it?
It is supported, just the doc is somewhat incomplete ....
Some more info are available here :
http://ipojo-dark-side.blogspot.com/2009/04/customized-service-object-creation-with.html
In fact, it allows you to configure when service objects will be
created and deleted. You can provide your own strategy (one per
thread, limited life time ...). So, you create an instance providing a
service. As soon as another iPOJO instance (it must be an iPOJO
instance because the interaction pattern is different) uses this
service, the creation strategy is applied. It might be useful in your
case.
iPOJO provides several creation strategy:
- singleton : create one service object
- OSGi service factory : create one service object per asking bundle
- per instance : create one service object per component instance
In all case, those object are created only when required.
The main difference between creating / deleting instances and using a
creation strategy is that you're not on the same layer : the first one
creates component instances, the second one creates pojo objects.
Regards,
Clement
Thanks for your help!
john
-----Original Message-----
From: Clement Escoffier [mailto:[email protected]]
Sent: Wednesday, July 15, 2009 9:21 AM
To: [email protected]
Subject: Re: iPOJO temporary service instances?
On 15.07.2009, at 00:19, John Stump wrote:
There is a pattern I am trying to recreate within the iPOJO world,
but I can't quite figure it out.
I want to be able to look up a service, create an instance of it,
use it, and toss it away. What iPOJO seems to support is creating
instances of services up front and have them ready and waiting. But
I don't want that. I want a service to be instantiated on demand.
How do I do this?
One thought I had was to not create an instance of the service in
the metadata.xml, then the client can get the factory of the
service, create an instance, then discard it when it is through with
it. But this approach seems somewhat clumsy. Is there a better way?
By the way, iPOJO creates service objects only when they are needed
(laziness) except if you configure it to be immediate.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]