Filter flow question

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Filter flow question

yangjun2
How to  return to  filter's handleread method  directly when  some business logic in handleWrite method?
eg. authenticate failure.
Best Regards,
Young
Reply | Threaded
Open this post in threaded view
|

Re: Filter flow question

oleksiys
Administrator
Hi Young,

can you pls. give handleRead/Write example and describe what exactly
you'd like to achieve? :)

Thanks.

WBR,
Alexey.

On 07/22/2011 09:57 AM, yangjun2 wrote:

> How to  return to  filter's handleread method  directly when  some business
> logic in handleWrite method?
> eg. authenticate failure.
>
> -----
> Best Regards,
> Young
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/Filter-flow-question-tp4622125p4622125.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Filter flow question

yangjun2
eg.
public class MyFilter {
    @Override
    public NextAction handleWrite(final FilterChainContext ctx) throws IOException {
             if (some biz logic)  {
                  do something normally.
             }  else {
               // I want to dispatch to handleRead method and stop NextAction, not throw exception.
               
             }
     }

     
     @Override
    public NextAction handleRead(FilterChainContext ctx) throws IOException {
        //accept response.
   }
}
Best Regards,
Young
Reply | Threaded
Open this post in threaded view
|

Re: Filter flow question

oleksiys
Administrator
Hi Young,

> public class MyFilter {
>      @Override
>      public NextAction handleWrite(final FilterChainContext ctx) throws
> IOException {
>               if (some biz logic)  {
>                    do something normally.
>               }  else {
>                 // I want to dispatch to handleRead method and stop
> NextAction, not throw exception.
>
>               }
>       }
>
>
>       @Override
>      public NextAction handleRead(FilterChainContext ctx) throws IOException
> {
>          //accept response.
>     }
> }
In general it's not possible, handleRead() is called only when you have
to process data, which has been read.

Don't you have the usecase like:
handleRead()->ctx.write(...)->handleWrite() ?
Most probably you'd need to refactor the code to do what you need. I can
try to help if you give me more details or share your code, so I
understand it better.

Thanks.

Alexey.

>
> -----
> Best Regards,
> Young
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/Filter-flow-question-tp4622125p4629191.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Filter flow question

yangjun2
This post was updated on .
I have another question :

In my demo application , include  SSLFilter,Authentication Fillter ,custom Filter, how to config filter sequence?
SSLFilter must send greeting message,  but my custom Filter message is Object , how to handle the case?
whether all of my custom Filter must decide  message that stored in context   is String object or Custom Object ,and handle diffrence case?
Best Regards,
Young
Reply | Threaded
Open this post in threaded view
|

Re: Filter flow question

oleksiys
Administrator
On 07/25/2011 11:44 AM, yangjun2 wrote:
> I have another question ?
>
> In my demo application , include  SSLFilter,Authentication Fillter ,custom
> Filter, how to config filter sequence?
> SSLFilter must send greeting message,  but my custom Filter message is
> Object , how to handle the case?
> whether all of my custom Filter must decide  message that stored in context
> is String object or Custom Object ,and handle diffrence case?
Are we talking about client side Connections? How do you initiate SSL
handshake?

WBR,
Alexey.

> -----
> Best Regards,
> Young
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/Filter-flow-question-tp4622125p4630195.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Filter flow question

yangjun2
like grizzly ssl demo sourcecode
Best Regards,
Young
Reply | Threaded
Open this post in threaded view
|

Re: Filter flow question

oleksiys
Administrator
Hi Young,

> like grizzly ssl demo sourcecode
Then I'm not sure why you have to care about more than 1 type of message
in your Filter implementation?
Does it happen that your Filter gets different types of messages? Any
test I can run to check it?

Thanks.

WBR,
Alexey.

> -----
> Best Regards,
> Young
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/Filter-flow-question-tp4622125p4633170.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.