You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Trustin Lee <tr...@gmail.com> on 2006/05/16 01:35:02 UTC
IoFuture design issues
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
Re: IoFuture design issues
Posted by Trustin Lee <tr...@gmail.com>.
On 5/17/06, Trustin Lee <tr...@gmail.com> wrote:
>
> On 5/16/06, peter royal <pr...@apache.org> wrote:
>
> > > 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?
> >
> > I like the idea, but I think the idea of the MutableXXX interfaces it
> > a bit much. If they're for internal use, lets wait until we need
> > them, and just use the DefaultXXX ones directly internally.
> >
>
> You're right except for WriteFuture. WriteFuture is exposed to IoFilter
> implementations and therefore a user can create his or her own WriteFuture
> implementation. Would it be inevitable to expose setWritten() to users?
> Then why not to other futures?
>
I created an issue:
http://issues.apache.org/jira/browse/DIRMINA-217
I will just expose setters for now instead of creating many mutable
interfaces.
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
Re: IoFuture design issues
Posted by Trustin Lee <tr...@gmail.com>.
On 5/16/06, peter royal <pr...@apache.org> wrote:
>
> > 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?
>
> I like the idea, but I think the idea of the MutableXXX interfaces it
> a bit much. If they're for internal use, lets wait until we need
> them, and just use the DefaultXXX ones directly internally.
>
You're right except for WriteFuture. WriteFuture is exposed to IoFilter
implementations and therefore a user can create his or her own WriteFuture
implementation. Would it be inevitable to expose setWritten() to users?
Then why not to other futures?
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
Re: IoFuture design issues
Posted by peter royal <pr...@apache.org>.
On May 15, 2006, at 7:35 PM, Trustin Lee wrote:
> 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.
this is fine w/me
> 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?
I like the idea, but I think the idea of the MutableXXX interfaces it
a bit much. If they're for internal use, lets wait until we need
them, and just use the DefaultXXX ones directly internally.
-pete
--
proyal@apache.org - http://fotap.org/~osi