mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edouard De Oliveira <doe_wan...@yahoo.fr>
Subject Re : [MINA 3.0] filter chains
Date Fri, 26 Aug 2011 14:14:57 GMT
On Aug 26, 2011, at 6:40 AM, Julien Vermillard wrote:


> On Fri, Aug 26, 2011 at 3:24 PM, Alan D. Cabrera <list@toolazydogs.com> wrote:
>> 
>> On Aug 26, 2011, at 4:14 AM, Julien Vermillard wrote:
>> 
>>> I modified the API to remove IoFilterChain. Now you are supposed to
>>> give a list of filter to the service before starting it :
>>> 
>>> // create the fitler chain for this service
>>> List<IoFilter> filters = new ArrayList<IoFilter>();
>>> filters.add(new LoggingFilter("byte log filter"));
>>> filters.add(new MyCodecFilter());
>>> filters.add(new LoggingFilter("pojo log filter"));
>>> filters.add(newMyProtocolLogicFilter());
>>> 
>>> acceptor.setFilters(filters);
>>> 
>>> acceptor.bind(...);
>> 
>> 
>> How do we make chains where two filters feed into one or one filter feeds two filters? 
If you look in my sandbox we can accommodate this via:
>> 
>> static import a.m.util.Util. linkParentWithChild; // to be written
>> 
>> IoFilter foo = new FooFilter();
>> LinkStateFilter link = new LinkStateFilter();
>> IoFilter checksum = new ChecksumFilter();
>> IoFilter log = new LogFilter();
>> 
>> link.addLinkStateListener(foo);
>> linkParentWithChild(foo, checksum);
>> linkParentWithChild(link, checksum);
>> linkParentWithChild(checksum, log);
>> 
>> acceptor.setFilters(foo);
>> 
> About the code in the sandbox :
> http://svn.apache.org/repos/asf/mina/sandbox/adc/ahc/mina3/src/main/java/org/apache/mina/core/IoFilter.java
> I see no IoFilter.addLinkStateListener(..) method, am I looking at the
> right place ?

Oops, it was meant to just be a sketch.  :)

> About the "filters feed into one or one filter feeds two filters", do
> you have a concrete use case in mind for that ?


>The above example does, Foo and the link state filter.  I'm sure that we've discussed
this before.  Another example is a mux/demux situation.  How would all of this fit into
the grand scheme of >things?

>Regards,
>Alan

On my side, besides the @ fsm declaration api (which may be impossible to use as i think it
fixes the position of a filter in the chain which is not universal) 
i wrote a simple api i'd like your thoughts on (using the type of syntax used in hibernate
criteria) : 

FSMState init = getInitialState();
FSMState b = init.linksTo(FSMStateB.class);
b.linksTo(FSMStateZ.class);

FSMState d = b.linksTo(FSMStateC.class).linksTo(FSMStateD.class);
d.linksTo(FSMStateE.class);
d.linksTo(FSMStateF.class);

which represents obviously :

INIT -> B -> Z
      |-> C -> D -> E
|-> F
wdyt ?

Mime
View raw message