directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trustin Lee <>
Subject Re: [mina] IoHandlerFilter question
Date Wed, 26 Jan 2005 03:18:59 GMT

On Tue, 25 Jan 2005 19:54:42 +0100, Jan Andersson <> wrote:
> I have started to (try to) implement SSL IO filter for Mina, but
> I'm somewhat confused regarding the API...
> I implement the IoHandlerFilter interface and was planning on
> saving a handler for SSL using IoSession.setAttachment().
> In sessionOpened() i create my SSL handler so save information per
> client session. I store my handler using session.setAttachment().
> In dataRead() I get my SSL handler using session.getAttachment()
> and use the handler to decrypt the read data.

Filters should not set attachments because it can be overwritten by
user's IoHandler.  For example, IoProtocolAcceptor and
IoProtocolConnector stores its internal object as an attachment.  The
easiest solution is to maintain an IdentityHashMap whose key is

Do you feel this solution is uncomfortable?  Then you could suggest me
better API. :)

> But now to my question... I was planning on using the filterWrite()
> method to encrypt the data to be written. But this method do not provide
> an IoSession object. So I obviously can't use session.getAttachment()
> to get a handle to my SSL handler.
> I must be missing something here? What is the preferred way to
> handle session dependent state information, when implementing
> IoHandlerFilter.filterWrite()?

It is my fault.  I had to include IoSession parameter.  I'll fix this
as soon as possible.  Thank you so much for pointing this out.

> /Janne

what we call human nature is actually human habit

View raw message