You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nolan Johnson <n0...@yahoo.com> on 2009/06/08 16:57:42 UTC

implementing a Manager - how do I get a reference to it?

I'm implementing a Manager (session management) that stores sessions on shared servers (that is, a distributed manager, but not the default one that comes with tomcat).  A key difference between the implementation that I'm working on and the ClusteredManager is that the entire session is distributed when it changes, rather than sending individual parameters around over the network.

The problem that I'm having is that the Manager needs to be notified when the request has finished with the session.  I'm aware that I can create a ServletRequestListener, and I think that the requestDestroyed method would be a reasonable time for me to be telling the manager that it should distribute the session.  However, I can't for the life of me figure out how to get a reference to the Manager from a ServletRequestListener.

I've tried:
- having the ServletRequestListener also be a ServletContextListener, but I can't navigate to the manager from there.
- finding the Manager through the session, but that's a StandardSessionFacade, which doesn't reveal the manager.
- having the ServletRequestListener also be a ContainerListener, but I can't make the same instance of the Listener be registered as both (since registerting a ServletRequestListener through the StandardContext doesn't allow me to register an object, I can only tell it what class to use).

Any suggestions?  Either for how I can have my ServletRequestListener get a reference to the Manager, or for other strategies for knowing when the Request is finished with the Session so that I can distribute it.

Thanks.

Nolan



      

Re: implementing a Manager - how do I get a reference to it?

Posted by Bill Barker <wb...@wilshire.com>.
"Nolan Johnson" <n0...@yahoo.com> wrote in message 
news:291765.23953.qm@web38808.mail.mud.yahoo.com...
>
> I'm implementing a Manager (session management) that stores sessions on 
> shared servers (that is, a distributed manager, but not the default one 
> that comes with tomcat).  A key difference between the implementation that 
> I'm working on and the ClusteredManager is that the entire session is 
> distributed when it changes, rather than sending individual parameters 
> around over the network.
>
> The problem that I'm having is that the Manager needs to be notified when 
> the request has finished with the session.  I'm aware that I can create a 
> ServletRequestListener, and I think that the requestDestroyed method would 
> be a reasonable time for me to be telling the manager that it should 
> distribute the session.  However, I can't for the life of me figure out 
> how to get a reference to the Manager from a ServletRequestListener.
>
> I've tried:
> - having the ServletRequestListener also be a ServletContextListener, but 
> I can't navigate to the manager from there.
> - finding the Manager through the session, but that's a 
> StandardSessionFacade, which doesn't reveal the manager.
> - having the ServletRequestListener also be a ContainerListener, but I 
> can't make the same instance of the Listener be registered as both (since 
> registerting a ServletRequestListener through the StandardContext doesn't 
> allow me to register an object, I can only tell it what class to use).
>
> Any suggestions?  Either for how I can have my ServletRequestListener get 
> a reference to the Manager, or for other strategies for knowing when the 
> Request is finished with the Session so that I can distribute it.
>

Since you are already programming against Tomcat internals, the simplest is 
probably to write a Valve instead of a ServletRequestListener.  The Valve 
will have access to all Tomcat internal Objects, and so could get to the 
Manager fairly simplily.

> Thanks.
>
> Nolan
>
>
>
> 




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