dev@grizzly.java.net

Re: Creating a "router" filter

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Thu, 27 Nov 2008 14:55:52 +0100

Please try the latest code.
If you'll see the problem - please give me a working testcase, so it
will be easier to fix the issue.

Thanks for your interest!

WBR,
Alexey.

On Nov 26, 2008, at 20:53 , psyops wrote:

>
> I'm am trying this:
> public NextAction handleRead(FilterChainContext ctx, NextAction
> nextAction)
> throws IOException {
> NextAction route_next_action = nextAction;
> // Get the read message
> Object message = ctx.getMessage();
>
>
> IRoutingMap rm = getRoutingMap(message);
> for(int i=0;i<rm.getMessageFilters().size();i++){
> Class<?> c = (Class<?>)rm.getMessageFilters().get(i);
> try {
> route_next_action = new NextAction();
> FilterAdapter rfb = (FilterAdapter)c.newInstance();
> route_next_action.set(NextAction.Action.INVOKE, rfb);
> //nextAction.set(NextAction.Action.INVOKE, rfb);
> } catch (InstantiationException e) {
> e.printStackTrace(); //To change body of catch
> statement
> use File | Settings | File Templates.
> } catch (IllegalAccessException e) {
> e.printStackTrace(); //To change body of catch
> statement
> use File | Settings | File Templates.
> }
> }
>
>
>
> /* Send the same message on the connection. The filter chain
> write
> * will pass each filter on a filter chain (interceptWrite
> method),
> * before sending the message on a wire. It means each filter
> can
> modify
> * the message, before it will be sent to the recipient
> */
>
>
> //ByteBuffer testmessage = (ByteBuffer)message;
> //testmessage.put(ByteBuffer.wrap("hello".getBytes()));
>
> //ctx.getFilterChain().write(ctx.getConnection(),
> ByteBuffer.wrap("hello".getBytes()));
>
> return route_next_action;
> }
>
>
> I would like to be able to set the Next filter to process but it
> seems to go
> in an endless loop. The scenario is a basic content message router.
> Get
> message->extract routing code->Set next filters to process and add
> to to the
> chain.
>
> Doesnt seem to be working.....Am I doing something wrong?
>
> Thanks,
> -psyops
>
>
> Oleksiy Stashok wrote:
>>
>> Hi Ronnie,
>>
>>
>>> I was wondering if your filters are similar to
>>> https://www.openadaptor.org/
>>> where I could create a "Router Filter" where I could direct the
>>> chain on where I need it to go?
>>
>> I think we can not compare Grizzly and Openadaptor. Project Grizzly
>> is
>> NIO framework, which doesn't have much to do with J2EE.
>> Using Grizzly you can implement your own protocol, which can work on
>> top of TCP, UDP or some custom transport. Grizzly has very good
>> support for HTTP related technologies, it can work as lightweight Web
>> server, support Comet etc.
>> Openadaptor, in its turn, implements adapters for different J2EE
>> services like JMS, JDBC etc.
>>
>>> Can I basically do everything in Grizzly 2.0 that I could do with
>>> openadaptor?
>> No. We can not compare these 2 projects.
>>
>>> If you can make a router from Grizzly 2.0, do you have an example or
>>> could you make a simple example for us?
>> Not sure what you mean by Router here. If it's some Router for J2EE
>> technologies like HTTP <-> JMS - then, IMHO, it's better to use some
>> special solution as openadaptor is.
>> If by Router you meant something different - please provide more
>> details, what exactly it should be.
>>
>> Thanks.
>>
>> WBR,
>> Alexey.
>>>
>>>
>>> Thanks,
>>> Ronnie
>>>
>>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Creating-a-%22router%22-filter-tp20660492p20707880.html
> Sent from the Grizzly - Development mailing list archive at
> Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>