You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Filip Hanik <ma...@filip.net> on 2003/01/14 05:00:13 UTC

Valve question

hi,
is it possible from the valve to get hold of the Manager for the context the
request is in?

getContainer().getManager() returns null in the invoke method.
Filip


~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
www.filip.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Valve question

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 13 Jan 2003, Filip Hanik wrote:

> Date: Mon, 13 Jan 2003 21:13:16 -0800
> From: Filip Hanik <ma...@filip.net>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: Tomcat Developers List <to...@jakarta.apache.org>
> Subject: RE: Valve question
>
> what places can I define <valve> in?

You mean in server.xml?  It can go inside an <Engine>, a <Host>, or a
<Context>.

Where you define it determines which subset of requests that the Valve
implementation actually sees:

* Nested in <Engine> -- sees all requests for all virtual hosts and
  webapps.

* Nested in <Host> -- sees all requests for this virtual host.

* Nested in <Context> -- sees all requests for this webapp.

> actually casting request as HttpRequest seems to work fine,
> ((HttpRequest)request).getContext().getManager() seems to be just dandy :)

As long as your Valve is nested inside a <Context> (which makes sense for
something related to clustering a particular webapp) this will work.  If
the valve was nested in an engine or a host, the getContext() method would
return null and this would still cause an NPE.

> but I would still like where I can define valve, you are saying I can define
> it under a specific context and under the entire engine for all requests?
>

Yes ... but a Valve nested in an engine or a host doesn't know what webapp
will be processing this request, because that's not actually decided until
StandardHostValve (the last Valve in the chain for a particular <Host>) is
executed.

> Filip

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Valve question

Posted by Filip Hanik <ma...@filip.net>.
what places can I define <valve> in?
actually casting request as HttpRequest seems to work fine,
((HttpRequest)request).getContext().getManager() seems to be just dandy :)

but I would still like where I can define valve, you are saying I can define
it under a specific context and under the entire engine for all requests?

Filip

~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
www.filip.net

>-----Original Message-----
>From: Craig R. McClanahan [mailto:craigmcc@apache.org]
>Sent: Monday, January 13, 2003 8:42 PM
>To: Tomcat Developers List
>Subject: Re: Valve question
>
>
>
>
>On Mon, 13 Jan 2003, Filip Hanik wrote:
>
>> Date: Mon, 13 Jan 2003 20:00:13 -0800
>> From: Filip Hanik <ma...@filip.net>
>> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
>> To: Tomcat Developers List <to...@jakarta.apache.org>
>> Subject: Valve question
>>
>> hi,
>> is it possible from the valve to get hold of the Manager for the
>context the
>> request is in?
>>
>> getContainer().getManager() returns null in the invoke method.
>> Filip
>>
>>
>
>If the Valve making this call is associated with the Context itself, this
>should work fine.  If the Valve making this call is associated with an
>Engine or a Host, the appropriate Context won't have been identified yet,
>so getManager() will fail.  Where is the Valve you are trying this from?
>
>Craig
>
>
>
>--
>To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Valve question

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 13 Jan 2003, Filip Hanik wrote:

> Date: Mon, 13 Jan 2003 20:00:13 -0800
> From: Filip Hanik <ma...@filip.net>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: Tomcat Developers List <to...@jakarta.apache.org>
> Subject: Valve question
>
> hi,
> is it possible from the valve to get hold of the Manager for the context the
> request is in?
>
> getContainer().getManager() returns null in the invoke method.
> Filip
>
>

If the Valve making this call is associated with the Context itself, this
should work fine.  If the Valve making this call is associated with an
Engine or a Host, the appropriate Context won't have been identified yet,
so getManager() will fail.  Where is the Valve you are trying this from?

Craig



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>