On 12/15/05, Aleksei Valikov <[EMAIL PROTECTED]> wrote:
Hi.

> Various ways... you could use Spring application events on the servlet core
> you could use phase listeners etc....

yes, I've considered using phase listeners.
The ide was that phase listener gets notified of the phase, then it
takes the HTTP session from the faces context, iterates over objects
implementing a special interface and invokes the appropriate method.

However, this does'nt seem very standard for me...

>From Servlet 2.4 on, you can define a listener (the container will create a singleton instance for each <listener> element) in your web.xml file that, based on what interfaces it implements, receives notifications of interesting events.  The ones most relevant to your use case would be:

* Implement ServletRequestListener to receive events requestCreated() and requestDestroyed().

* You'll probably also want to implement ServletContextListener to receive events
  contextInitialized() and contextDestroyed(), so you can set things up at webapp
  startup, and clean up after yourself at webapp shutdown.

For example, in your requestCreated() handler (which gets handed an event object that includes a reference to the request itself) you can call getSession() and then iterate through the session attributes, calling the callback methods you want to fire.

If you're in a servlet 2.3 world, you do not have ServletRequestListener, but you can accomplish pretty much the same thing using a filter.


Bye.
/lexi

Craig

Reply via email to