|
From: Jose Alberto
Fernandez [mailto:[EMAIL PROTECTED] Well, I hope you are
right. From: Trustin
Lee [mailto:[EMAIL PROTECTED] 2a) Instead,
insert ProtocolCodecFilter with your codec factory in your
IoHandler.sessionCreated() method. For example: This is one place, where
the approach I mentioned would make a lot of sense. You are running several
protocols using several different handlers. You really do not want to specify
on every session the adding of new CodecFilters, for example. You know all
sessions will use the same filters and if your filters are stateless, they
should be using the same one. It would make a lot of sense to be able to set
this things once during bind() and not need to do it on every session creation.
(My reply) If I understand you correctly
you want your IoHandler to implement IoFilterManager: public class MyIoHandler
implements IoHandler, IoFilterManager { public
void configureFilters(IoFilterChain chain) {
chain.addFirst( "codec", new ProtocolCodecFilter( YOUR_CODEC_FACTORY
) ); } //
Other IoHandler methods } configureFilters will be
called at bind-time.Of course the passed in IoFilterChain which is modified has
to be local to that port you are binding to. Otherwise the next bind-call using
another IoFilterManager and port will mess up the chain modified by the first
call to bind. You can achieve exactly the same thing using a shared filter and
Trustin’s approach above: public class MyIoHandler
implements IoHandler {
private ProtocolCodecFilter codecFilter = new ProtocolCodecFilter(
YOUR_CODEC_FACTORY ); public void sessionCreated( IoSession session ) throws
Exception { session.getFilterChain().addFirst(
"codec", codecFilter ); } //
Other IoHandler methods } These two approaches look
very similar to me. There’s really no difference. The same filter
instance (which must be stateless) will be used anytime the same MyIoHandler
instance is used. You still need to know in
your IoHandler/IoFilterManager how the filter chain should be modified which is
exactly what I want to avoid. Let’s say I have a POP3Handler and want to
support both SSL and non-SSL. With your approach I will have the make my
POP3Handler implement IoFilterManager and somehow determine in configureFilters
if the current bind is for the SLL or non-SSL port to know whether an SSLFilter
should be added or not. I want my POP3Handler to be completely unaware of whether
traffic is being encrypted or not. It doesn’t have to known that. If you have an additional
bind method where you may specify an IoFilterChain for that binding if will be
quite easy to set up that chain using Spring. BTW, I just realized that
I have no idea whether SSLFilter is stateless or not. Is it? /Niklas |
- RE: [mina] Filter management (was Spring Integratio... Niklas Therning
- Re: [mina] Filter management (was Spring Integ... Trustin Lee
- Re: [mina] Filter management (was Spring Integ... Maarten Bosteels
- Re: [mina] Filter management (was Spring I... Trustin Lee
- Re: [mina] Filter management (was Spring Integ... Trustin Lee
- RE: [mina] Filter management (was Spring Integ... Jose Alberto Fernandez
- Re: [mina] Filter management (was Spring I... Trustin Lee
- RE: [mina] Filter management (was Spring Integ... Jose Alberto Fernandez
- Re: [mina] Filter management (was Spring I... Trustin Lee
- RE: [mina] Filter management (was Spring Integ... Jose Alberto Fernandez
- Re: [mina] Filter management (was Spring I... Trustin Lee
