users@glassfish.java.net

Re: Migrate custom Valve from Tomcat 5.0/5.5

From: <glassfish_at_javadesktop.org>
Date: Mon, 31 Mar 2008 12:18:17 PST

The Valve interface in GlassFish is different from Tomcat.

It was changed to implement the optimization described at:

  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4665318
  ("Stack depth is excessive in iAS7SE")

This optimization flattens the valve invocations of a pipeline (and therefore the stack frames required during the processing of a servlet request): Instead of having one valve invoke the next valve on the pipeline, the GlassFish web container invokes one valve at a time, and decides whether to invoke the next valve in the pipeline by examining the return value of the current valve invocation.

To adapt a Tomcat valve to GlassFish, the following changes are required:

- Change the signature of the valve's implementation of invoke() from "void" to "int"

- Replace every

    return;

  with

    return Valve.END_PIPELINE;

- Replace

    getNext().invoke(request, response);

  with

    return Valve.INVOKE_NEXT;


Can you try out these steps and let us know how they work for you?

I am also going to add them to the GlassFish FAQ.


Jan
[Message sent by forum member 'jluehe' (jluehe)]

http://forums.java.net/jive/thread.jspa?messageID=266873