You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by li...@kuhnle.net on 2005/04/07 21:53:31 UTC

Best way to initialize Context, Session and Request attributes

Hi,

in my webapp I need to initialize the Context, Session and Request 
attributes, e.g. with database connections, message queues etc. What is 
the best way to do this in Cocoon? Right now I'm using actions, but this 
is not satisfactory, as I have to put the action in many places in my 
sitemaps. Is there a better way to do this, e.g. some kind of hook that is 
called when Contexts, Sessions and Requests are created and disposed?

Regards,
Jochen

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Best way to initialize Context, Session and Request attributes

Posted by Jorg Heymans <jh...@domek.be>.

lists@kuhnle.net wrote:
> Thanks for the answer. Only, these listeners belong to the Servlet API and 
> not to Cocoon, so this will not work in batch mode, when there's a 
> BatchContext instead of a HttpContext. Is there a Cocoon specific method?
> 

You didn't mention your app is running in batch mode. I don't know much 
about cocoon batch mode. Do you even have Context, Session and Request 
attributes available without the HTTPContext?

But anyway, did you know an action can span multiple matchers? It's how 
the autentication framework works basically, you encapsulate one action 
around all the pipelines you want to protect. Maybe this helps you 
reducing your sitemap code enough already.

Regards
Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Best way to initialize Context, Session and Request attributes

Posted by li...@kuhnle.net.
Thanks for the answer. Only, these listeners belong to the Servlet API and 
not to Cocoon, so this will not work in batch mode, when there's a 
BatchContext instead of a HttpContext. Is there a Cocoon specific method?

Regards,
Jochen




Jorg Heymans <jh...@domek.be> 
Sent by: news <ne...@sea.gmane.org>
07.04.2005 22:24
Please respond to
users@cocoon.apache.org


To
users@cocoon.apache.org
cc

Subject
Re: Best way to initialize Context, Session and Request attributes







lists@kuhnle.net wrote:
> Hi,
> 
> in my webapp I need to initialize the Context, Session and Request 
> attributes, e.g. with database connections, message queues etc. What is 
> the best way to do this in Cocoon? Right now I'm using actions, but this 

> is not satisfactory, as I have to put the action in many places in my 
> sitemaps. Is there a better way to do this, e.g. some kind of hook that 
is 
> called when Contexts, Sessions and Requests are created and disposed?

There are listeners classes available that do just this.

http://java.sun.com/products/servlet/2.3/javadoc/


HTH
Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Best way to initialize Context, Session and Request attributes

Posted by Jorg Heymans <jh...@domek.be>.
lists@kuhnle.net wrote:
> Hi,
> 
> in my webapp I need to initialize the Context, Session and Request 
> attributes, e.g. with database connections, message queues etc. What is 
> the best way to do this in Cocoon? Right now I'm using actions, but this 
> is not satisfactory, as I have to put the action in many places in my 
> sitemaps. Is there a better way to do this, e.g. some kind of hook that is 
> called when Contexts, Sessions and Requests are created and disposed?

There are listeners classes available that do just this.

http://java.sun.com/products/servlet/2.3/javadoc/


HTH
Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Best way to initialize Context, Session and Request attributes

Posted by Upayavira <uv...@upaya.co.uk>.
lists@kuhnle.net wrote:
> Hi,
> 
> in my webapp I need to initialize the Context, Session and Request 
> attributes, e.g. with database connections, message queues etc. What is 
> the best way to do this in Cocoon? Right now I'm using actions, but this 
> is not satisfactory, as I have to put the action in many places in my 
> sitemaps. Is there a better way to do this, e.g. some kind of hook that is 
> called when Contexts, Sessions and Requests are created and disposed?

Can't you just say:

<map:pipeline>
   <map:action type="myaction"/>
   <map:match pattern="...

That way, your action is always called, on every request. Pretty sure 
that would work.

Regards, Upayavira

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org