Hi,

Would it be nice if we have IoFuture.getSession()?
IoFuture.Callbackdoesn't have any mean to get the session associated
with the future.  For
example, in DIRMINA-215 (http://issues.apache.org/jira/browse/DIRMINA-215),
we have to create a new intanceof ClosingCallback every time we set the
callback.  If we can get the associated session by calling
IoFuture.getSession(), then it will look like this:

public interface Callback {
   static Callback CLOSE = new Callback() {
       public void operationComplete(IoFuture future) {
           future.getSession().close();
       }
   }
   ...
}

session.write(...).setCallback(ioFuture.Callback.CLOSE);

The only issue with this change is that the throws clause of
ConnectFuture.getSession() should be removed and it should throw
RuntimeIOException instead of IOException.  This will cause compilation
errors in legacy code, for the use of connectors.

The second design issue with IoFuture is about making it interface.  For
now, they are concrete classes which expose internal methods that change
their state.  I'd like to change them look like this:

* IoFuture
  * WriteFuture (extends IoFuture)
     * MutableWriteFuture (extends WriteFuture, internal use only)
        * DefaultWriteFuture (implements MutableWriteFuture, internal use
only)
  * ConnectFuture (extends IoFuture)
     * MutableConnectFuture (extends ConnectFuture, internal use only)
        * DefaultConnectFuture (implements MutableConnectFuture, internal
use only)
  * CloseFuture (extends IoFuture)
     * MutableCloseFuture (extends CloseFuture, internal use only)
        * DefaultCloseFuture (implements MutableCloseFuture, internal use
only)

Would this be too complex?

Making them interfaces has an advantage in that we can create more complex
futures such as CompositeWriteFuture or dummy futures which never impacts
performance due to synchronized block.

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Reply via email to