On Apr 26, 2006, at 6:19 PM, list cs wrote:
Ideally, I'd like to hide any mina implementation details so that the user never sees it (and has no access to it), and would like to know if anyonehas done something similiar.
...
Does anyone have any idea what would be the best way to try and implementsomething like this?
You'll want an encapsulation-based relationship with MINA, rather than an inheritance-based one.
With that said, if you want to mimic a synchronous API, you'll want to make a 'Future' to hold the result of your call. Something akin to:
IoSession session = // your MINA session;
MyCustomFuture future = new MyCustomFuture();
session.setAttribute("next-future", future);
session.write( object );
future.await();
return future.get();
.. And then in your IoHandler,
void messageReceived( Object message ) {
MyCustomFuture future = getAttribute( "next-future" );
future.setValue( message );
}
You can use the Future in MINA as an example. Or build off of Java5's
or what is in util.concurrent.
-pete -- [EMAIL PROTECTED] - http://fotap.org/~osi
smime.p7s
Description: S/MIME cryptographic signature
