The SessionManager is saved as a note in the context.

context.getContainer().getNote("tomcat.standardManager")


Session management is at a higher level than tomcat.core, and
the goal was to modularize tomcat and keep the components as
independent as possible - with interceptors used as  'glue' between
components.

SimpleSessionManager uses notes to associate a manager instance
with each Context.

More sophisticated solutions could use a single manager for
the entire tomcat - this would scale much better, and would
probably be easier to control.

Costin



On Sun, 9 Sep 2001, chiu ming luk wrote:

> Costin,
> after I get the specific Context object in
> org.apache.tomcat.core.Context.
>
> How can I get the SessionManager for that Context?
>
> thanks again.
> ===============================================
> realRequest = facadeM.getRealRequest(request);
> cm = realRequest.getContext().getContextManager();
> Enumeration e = cm.getContexts();
> while ( e.hasMoreElements() ){
>    Context con = (Context) e.nextElement();
>    //how to get sessionManager?
>    int size = sessionMgr.getSessions().size();
> }
> ===============================================
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --- [EMAIL PROTECTED] wrote:
> > Hi,
> >
> > What you can do is use ContextManager.getContexts(),
> > then for each context you can get its
> > SessionManager.
> >
> >
> > Costin
> >
> >
> > On Sat, 8 Sep 2001, chiu ming luk wrote:
> >
> > > Hi,
> > > I had asked this question before. But I didn't get
> > any
> > > reply.  So I post this again in hope someone could
> > > help me getting number of active session currect
> > > Tomcat holds.
> > >
> > > The following code will return number of sessions
> > in a
> > > Context(web app)
> > > but not all the sessions in the whole JVM (tomcat
> > > instance).
> > >
> > > For example:
> > > if I call the class LocalMon in /admintool
> > context:
> > > /tomcat/webapps/admintool/WEB-INF/classes/LocalMon
> > > then it will only report # of sessions in
> > /admintool
> > > web application.
> > >
> > > Any way I can get the total number of sessions for
> > all
> > > web applications
> > > (context)? -OR-
> > > How to call LocalMon in /admintool context but
> > reports
> > > session on other
> > > context(web app)?
> > >
> > > My source file (class) return # of session and a
> > (jsp)
> > > is also
> > > attached.
> > >
> > >
> > ===================================================
> > > import java.util.Vector;
> > > import java.util.Enumeration;
> > > import java.io.File;
> > > import java.net.URL;
> > > import javax.servlet.http.*;
> > >
> > > import org.apache.tomcat.core.Request;
> > > import org.apache.tomcat.core.FacadeManager;
> > > import org.apache.tomcat.core.Context;
> > > import org.apache.tomcat.core.ContextManager;
> > > import org.apache.tomcat.util.RequestUtil;
> > > import org.apache.tomcat.session.StandardManager;
> > >
> > > public class LocalMon
> > > {
> > >   private ContextManager cm;
> > >   private Request realRequest;
> > >   private StandardManager _sessionMgr;
> > >
> > >   public void init( HttpServletRequest request ){
> > >     FacadeManager facadeM =
> > > (FacadeManager)request.getAttribute(
> > > FacadeManager.FACADE_ATTRIBUTE);
> > >     realRequest = facadeM.getRealRequest(request);
> > >     cm =
> > realRequest.getContext().getContextManager();
> > >     try{
> > >         int manager_note = cm.getNoteId(
> > > ContextManager.CONTAINER_NOTE,
> > > "tomcat.standardManager" );
> > >         _sessionMgr =
> > >
> >
> (StandardManager)realRequest.getContext().getContainer().getNote(manager_note);
> > >
> > >     } catch( Exception ignored ){
> > >     }
> > >   }
> > >
> > >   public boolean initialized(){
> > >       return ( cm != null );
> > >   }
> > >
> > >   public String getNumSessions(){
> > >       return( String.valueOf(
> > > _sessionMgr.getSessions().size() ) );
> > >   }
> > > }
> > >
> >
> ==============================================================
> > >
> > > thanks a lot
> > >
> > > -cm
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Get email alerts & NEW webcam video instant
> > messaging with Yahoo! Messenger
> > > http://im.yahoo.com
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
> http://im.yahoo.com
>

Reply via email to