Marcus,
I used to use Spring as the glue for my projects but i've got several
libraries which interacts with databases so i think that the couple
hivemind+honeycomb should be more suitable for this goal (mainly because
Hivemind allows a clear partition of each library).
But i'm a newbie to Hivemind !
In Spring i just set the singleton property to false and it gave me a
new instance at each call.
I've tried to implement a simple sample using Hivemind : just one object
to inject in my code.
<module id="com.cariboonetworks.test" version="1.0.0"
package="com.cariboonetworks.test">
<service-point id="Test" interface="ITest">
<invoke-factory service-id="hivemind.BuilderFactory" model="threaded">
<construct class="impl.Test"/>
</invoke-factory>
<interceptor service-id="hivemind.LoggingInterceptor"/>
</service-point>
</module>
public void testApp() {
Registry registry = RegistryBuilder.constructDefaultRegistry();
ITest test1 = (ITest) registry.getService(ITest.class);
ITest test2 = (ITest) registry.getService(ITest.class);
assertNotSame(test1, test2);
registry.shutdown();
}
This gave me the same instance at each call. This is the expected result
according to James and you.
I've search on the net samples of the ObjectInstanceObjectProvider
implementations without success.
Could you show me how to use ObjectInstanceObjectProvider in such a
simple test in order to get a new instance at each call ?
Thanks in advance !
Stephane
[EMAIL PROTECTED] a écrit :
If you need multiple instances of an object per thread, it doesn't fit well
with the concept of a service. Probably, you should just setup an
object-factory as a service which vends out new instances on each call. Very
much like the ObjectInstanceObjectProvider, or Tapestry's ASO-Factories
Marcus
-----Original Message-----
From: Stephane Decleire [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 28, 2007 6:19 PM
To: [email protected]
Subject: Re: Pooled BuilderFactory
Thanks James,
But is there a way to get 2 different objects ??
Stephane
James Carman a écrit :
Two calls within the same thread will return the same instance.
Basically, the pooled model is a threaded model, but the instances
returned are obtained from a pool rather than created from scratch
every time they're bound to the thread.
On 6/28/07, *Stephane Decleire* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Hi,
I don't understand why 2 calls to a BuilderFactory
which model is
set to
pooled return the same object.
Isn't it the behavior of singletons ?
Thanks in advance for any explanation.
Stephane