users@grizzly.java.net

Re: async filter help

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Mon, 01 Dec 2008 16:47:51 -0500

Salut,

answering that one before the others :-)

rama wrote:
> Hello,
>
> after reading a bit, i am ready for some new question :)
>
> this is not the real code, i don't think
> that this will work :D
> but, the question is, if i get a shtml or ehtml file
> i will do something (still to do)
> if not, return true, should go to EulerStaticAdapter
> but, the print is not executed.
>
> can someone give to me a little hint?
>
>
> ---server---
> st = new SelectorThread();
> st.setPort(port);
> st.setMaxThreads(maxThreads);
> isStarted = true;
>
>
>
> st.setAdapter(new EulerStaticAdapter(root1,root2));
>
>
>
> st.setEnableAsyncExecution(true);
> AsyncHandler asyncHandler = new DefaultAsyncHandler();
> asyncHandler.addAsyncFilter(new EulerAsyncAdapter());
> st.setAsyncHandler(asyncHandler);
>
>
>
> try {
> st.listen();
> } catch (InstantiationException ex) {
> throw new IOException(ex.getMessage());
> }

So far so good.

> ---asyncadapter---
> public class EulerAsyncAdapter implements AsyncFilter{
>
> public boolean doFilter(AsyncExecutor ex) {
> ProcessorTask pt = ex.getProcessorTask();
> String uri = pt.getRequestURI();
>
>
> if (uri.endsWith(".shtml") || uri.endsWith(".ehtml"))
> return serverStupid();
> System.out.println(uri);
> return true;
> }

Yes it will works :-) But what serverStupid will do? if you want to see
an example of AsyncFilter, take a look at:

https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/comet/CometAsyncFilter.html

Thanks

-- Jeanfrancois


>
> private boolean serverStupid() {
> // TODO Auto-generated method stub
> return false;
> }
>
> }
> ---sync---
> public class EulerStaticAdapter implements Adapter {
> public void service(Request req, final Response res) throws Exception {
>
> System.out.println(hey);
>
> }
>
> }