Yes, I read about that and tried to find out a bit more about
HTTPSessionBindingListener. However I don't quite get the "store your
component as a session attribute"-part. 

1. I'm using my component in the pipline implementation. I assume you'd do
it some way like this (made it short):
 
ObjectModelHelper.getRequest(environment.getObjectModel()).getSession().setA
ttribute("mycomponent",component);

However, this would be called everytime the pipeline is processed, which
makes no sense. I might get this wrong though. If it was this way, it seems
easier to me to do it that way:

2. 
session = ObjectModelHelper.getRequest(...).getSession();
if (session.isNew()) {
        mycomponent.newSession(session.getId())
}

This leaves me with two problems:
Using 1. I does not seem to be able to store my component in a new session
ONCE, but anew with every request.
Using 2. I cannot track if a session has been destroyed.

Stefan 

| -----Ursprüngliche Nachricht-----
| Von: Ralph Goers [mailto:[EMAIL PROTECTED]
| Gesendet: Sonntag, 11. Dezember 2005 18:49
| An: [email protected]
| Betreff: Re: How to connect Avalon Component and SessionListener
| 
| 
| 
| Stefan Pietschmann wrote:
| 
| > It's a new day and a new problem arises for me:
| >
| >
| >
| > I want to notify my Avalon component when a session is created or
| > destroyed. I had previously written a simple HttpSessionListener which
| > I declared in web.xml. sessionCreated() and sessionDestroyed() get
| > invoked just as they should.
| >
| > Now what's the best practise to notify my component from there? These
| > are the ideas I had:
| >
| >
| >
| > 1)       Make the SessionListener a Serviceable Component itself, so
| > it can use the ServiceManager to lookup my other component and invoke
| > some method there.
| >
| > 2)       Make my Avalon component a SessionListener itself (I don't
| > think that's possible, is it? I added it to web.xml as listener class
| > and cocoon.xconf as component, but the session methods were not invoked)
| >
| > 3)       Keep both classes as they are and do it the right way ;) ?
| >
| >
| >
| > How would you go about this?
| >
| I'd do it the way I have told folks before. Don't use
| HttpSessionListener.  Make your component implement
| HttpSessionBindingListener. Then store your component as a session
| attribute.  When the session is destroyed it will be notified.  This
| doesn't require anything in web.xml.
| 
| Ralph

Reply via email to