Hi!
I'm sorry for all these lame questions but I'm totally new to SoP and to Hivemind too. so far I really appriciate all the help I got as
I could make most of my stuff work, and it's really great. I make reusability 'really" come true.
But here is my next problem I'm facing.
Having downloaded some examples from Jira. I'm little confused how should I solve DESIGN-wise the best with Hivemind.
I have a system which has Clients pooled.
In my web application using Hivemind I need the a client and when request is gone I need to give it back to the pool.
so far I did the following
I have a
public interface Client {
public abstract void execute(...);
}Here I implement the Discardable as I believe that of I use the Thread model my ClientImpl will be called to clean up resources
Is that right ??? Or Do I have to do something else ????
public class ClientImpl implements Client, Discardable {
.....
}and of course I have a factory ->
public interface ClientFactory {
public abstract Client getClient();
}and the implementation class ( I need to know when Registry is going down to clean up my pool etc... that works great !!)
public class ClientFactoryImpl implements RegistryShutdownListener, ClientFactory {
private Log _log;
private Messages _messages;
private ThreadLocalStorage storage;
private ThreadEventNotifier notifier;
public R3Client getClient() {
ClientImpl client = (ClientImpl) storage.get(SESSION_KEY);
if (client == null ) {
client = new ClientImpl();
client.setClient(getClient(poolName)); }
return client;
}
}
I configures the Factory like this
<service-point id="ClientFactory" interface="ClientFactory">
<invoke-factory service-id="hivemind.BuilderFactory"> <construct class="ClientFactoryImpl">
<set property="poolSize" value="${poolsize}"/>
<set property="poolName" value="${poolname}"/>
<event-listener service-id="hivemind.ShutdownCoordinator"/> </construct> </invoke-factory> </service-point>
Now I'm stucked with how to do best the Client SEFVICE????
when someone
Client cl = (Client) registry.getService( Clien.class);
it should give back the one ClientImpl from the actual ThreadLocal...
in one example I saw that someone using his own factory at the when defining the Client service with Threaded model.
<invoke-factory service-id="hivemind.BuilderFactory"> line like -> <invoke-factory service-id="ClientFactory">
Also I have seen code that just simple injected the Factory into the Client.
What is the best and the prefered way to end up with the most flexible code???
Thanks for any idea!
Istvano
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
