Java 类org.apache.catalina.Manager 实例源码

项目:lazycat    文件:JvmRouteBinderValve.java   
/**
 * Detect possible the JVMRoute change at cluster backup node..
 * 
 * @param request
 *            tomcat request being processed
 * @param response
 *            tomcat response being processed
 * @exception IOException
 *                if an input/output error has occurred
 * @exception ServletException
 *                if a servlet error has occurred
 */
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {

    if (getEnabled() && request.getContext() != null && request.getContext().getDistributable()
            && !request.isAsyncDispatching()) {
        // valve cluster can access manager - other cluster handle turnover
        // at host level - hopefully!
        Manager manager = request.getContext().getManager();

        if (manager != null && ((manager instanceof ClusterManager && getCluster() != null
                && getCluster().getManager(((ClusterManager) manager).getName()) != null)
                || (manager instanceof PersistentManager)))
            handlePossibleTurnover(request);
    }
    // Pass this request on to the next valve in our pipeline
    getNext().invoke(request, response);
}
项目:apache-tomcat-7.0.73-with-comment    文件:JvmRouteBinderValve.java   
/**
 * Detect possible the JVMRoute change at cluster backup node..
 * 
 * @param request
 *            tomcat request being processed
 * @param response
 *            tomcat response being processed
 * @exception IOException
 *                if an input/output error has occurred
 * @exception ServletException
 *                if a servlet error has occurred
 */
@Override
public void invoke(Request request, Response response) throws IOException,
        ServletException {

     if (getEnabled() &&
             request.getContext() != null &&
             request.getContext().getDistributable() &&
             !request.isAsyncDispatching()) {
         // valve cluster can access manager - other cluster handle turnover 
         // at host level - hopefully!
         Manager manager = request.getContext().getManager();

         if (manager != null && (
                 (manager instanceof ClusterManager
                   && getCluster() != null
                   && getCluster().getManager(((ClusterManager)manager).getName()) != null)
                 ||
                 (manager instanceof PersistentManager)))
             handlePossibleTurnover(request);
    }
    // Pass this request on to the next valve in our pipeline
    getNext().invoke(request, response);
}
项目:tomcat7    文件:ReplicationValve.java   
/**
 * Mark Request that processed at primary node with attribute
 * primaryIndicatorName
 * 
 * @param request
 * @throws IOException
 */
protected void createPrimaryIndicator(Request request) throws IOException {
    String id = request.getRequestedSessionId();
    if ((id != null) && (id.length() > 0)) {
        Manager manager = request.getContext().getManager();
        Session session = manager.findSession(id);
        if (session instanceof ClusterSession) {
            ClusterSession cses = (ClusterSession) session;
            if (log.isDebugEnabled())
                log.debug(sm.getString(
                        "ReplicationValve.session.indicator", request.getContext().getName(),id,
                        primaryIndicatorName,
                        Boolean.valueOf(cses.isPrimarySession())));
            request.setAttribute(primaryIndicatorName, cses.isPrimarySession()?Boolean.TRUE:Boolean.FALSE);
        } else {
            if (log.isDebugEnabled()) {
                if (session != null) {
                    log.debug(sm.getString(
                            "ReplicationValve.session.found", request.getContext().getName(),id));
                } else {
                    log.debug(sm.getString(
                            "ReplicationValve.session.invalid", request.getContext().getName(),id));
                }
            }
        }
    }
}
项目:tomcat7    文件:SimpleTcpCluster.java   
/**
 * Create new Manager without add to cluster (comes with start the manager)
 * 
 * @param name
 *            Context Name of this manager
 * @see org.apache.catalina.Cluster#createManager(java.lang.String)
 * @see DeltaManager#start()
 */
@Override
public synchronized Manager createManager(String name) {
    if (log.isDebugEnabled()) {
        log.debug("Creating ClusterManager for context " + name +
                " using class " + getManagerTemplate().getClass().getName());
    }
    ClusterManager manager = null;
    try {
        manager = managerTemplate.cloneFromTemplate();
        manager.setName(name);
    } catch (Exception x) {
        log.error("Unable to clone cluster manager, defaulting to org.apache.catalina.ha.session.DeltaManager", x);
        manager = new org.apache.catalina.ha.session.DeltaManager();
    } finally {
        if ( manager != null) manager.setCluster(this);
    }
    return manager;
}
项目:tomcat7    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Manager</code> object.
 *
 * @param manager The Manager to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 * @deprecated  Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static void destroyMBean(Manager manager)
    throws Exception {

    String mname = createManagedName(manager);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, manager);
    if( mserver.isRegistered(oname) )
        mserver.unregisterMBean(oname);

}
项目:tomcat7    文件:SingleSignOnListener.java   
@Override
public void sessionEvent(SessionEvent event) {
    if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType())) {
        return;
    }

    Session session = event.getSession();
    Manager manager = session.getManager();
    if (manager == null) {
        return;
    }
    Context context = (Context) manager.getContainer();
    Authenticator authenticator = context.getAuthenticator();
    if (!(authenticator instanceof AuthenticatorBase)) {
        return;
    }
    SingleSignOn sso = ((AuthenticatorBase) authenticator).sso;
    if (sso == null) {
        return;
    }
    sso.sessionDestroyed(ssoId, session);
}
项目:lams    文件:Request.java   
/**
 * Return <code>true</code> if the session identifier included in this
 * request identifies a valid session.
 */
public boolean isRequestedSessionIdValid() {

    if (requestedSessionId == null)
        return (false);
    if (context == null)
        return (false);
    Manager manager = context.getManager();
    if (manager == null)
        return (false);
    Session session = null;
    try {
        session = manager.findSession(requestedSessionId);
    } catch (IOException e) {
        session = null;
    }
    if ((session != null) && session.isValid())
        return (true);
    else
        return (false);

}
项目:lazycat    文件:SimpleTcpCluster.java   
/**
 * Create new Manager without add to cluster (comes with start the manager)
 * 
 * @param name
 *            Context Name of this manager
 * @see org.apache.catalina.Cluster#createManager(java.lang.String)
 * @see DeltaManager#start()
 */
@Override
public synchronized Manager createManager(String name) {
    if (log.isDebugEnabled()) {
        log.debug("Creating ClusterManager for context " + name + " using class "
                + getManagerTemplate().getClass().getName());
    }
    ClusterManager manager = null;
    try {
        manager = managerTemplate.cloneFromTemplate();
        manager.setName(name);
    } catch (Exception x) {
        log.error("Unable to clone cluster manager, defaulting to org.apache.catalina.ha.session.DeltaManager", x);
        manager = new org.apache.catalina.ha.session.DeltaManager();
    } finally {
        if (manager != null)
            manager.setCluster(this);
    }
    return manager;
}
项目:lams    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Manager</code> object.
 *
 * @param manager The Manager to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
static DynamicMBean createMBean(Manager manager)
    throws Exception {

    String mname = createManagedName(manager);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(manager);
    ObjectName oname = createObjectName(domain, manager);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:lazycat    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this <code>Manager</code> object.
 *
 * @param manager
 *            The Manager to be managed
 *
 * @exception Exception
 *                if an MBean cannot be deregistered
 * @deprecated Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static void destroyMBean(Manager manager) throws Exception {

    String mname = createManagedName(manager);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, manager);
    if (mserver.isRegistered(oname))
        mserver.unregisterMBean(oname);

}
项目:jerrydog    文件:HttpRequestBase.java   
/**
 * Return <code>true</code> if the session identifier included in this
 * request identifies a valid session.
 */
public boolean isRequestedSessionIdValid() {

    if (requestedSessionId == null)
        return (false);
    if (context == null)
        return (false);
    Manager manager = context.getManager();
    if (manager == null)
        return (false);
    Session session = null;
    try {
        session = manager.findSession(requestedSessionId);
    } catch (IOException e) {
        session = null;
    }
    if ((session != null) && session.isValid())
        return (true);
    else
        return (false);

}
项目:apache-tomcat-7.0.73-with-comment    文件:SingleSignOnListener.java   
@Override
public void sessionEvent(SessionEvent event) {
    if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType())) {
        return;
    }

    Session session = event.getSession();
    Manager manager = session.getManager();
    if (manager == null) {
        return;
    }
    Context context = (Context) manager.getContainer();
    Authenticator authenticator = context.getAuthenticator();
    if (!(authenticator instanceof AuthenticatorBase)) {
        return;
    }
    SingleSignOn sso = ((AuthenticatorBase) authenticator).sso;
    if (sso == null) {
        return;
    }
    sso.sessionDestroyed(ssoId, session);
}
项目:jerrydog    文件:MBeanUtils.java   
/**
 * Create, register, and return an MBean for this
 * <code>Manager</code> object.
 *
 * @param manager The Manager to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(Manager manager)
    throws Exception {

    String mname = createManagedName(manager);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(manager);
    ObjectName oname = createObjectName(domain, manager);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
项目:jerrydog    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Manager</code> object.
 *
 * @param manager The Manager to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
public static void destroyMBean(Manager manager)
    throws Exception {

    String mname = createManagedName(manager);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, manager);
    mserver.unregisterMBean(oname);

}
项目:jerrydog    文件:StandardServer.java   
/**
 * Is this an instance of the default <code>Manager</code> configuration,
 * with all-default properties?
 *
 * @param manager Manager to be tested
 */
private boolean isDefaultManager(Manager manager) {

    if (!(manager instanceof StandardManager)) {
        return (false);
    }
    StandardManager smanager = (StandardManager) manager;
    if ((smanager.getDebug() != 0) ||
        !smanager.getPathname().equals("SESSIONS.ser") ||
        (smanager.getCheckInterval() != 60) ||
        !smanager.getRandomClass().equals("java.security.SecureRandom") ||
        (smanager.getMaxActiveSessions() != -1) ||
        !smanager.getAlgorithm().equals("MD5")) {
        return (false);
    }
    return (true);

}
项目:lazycat    文件:SimpleTcpCluster.java   
@Override
public void registerManager(Manager manager) {

    if (!(manager instanceof ClusterManager)) {
        log.warn("Manager [ " + manager
                + "] does not implement ClusterManager, addition to cluster has been aborted.");
        return;
    }
    ClusterManager cmanager = (ClusterManager) manager;
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(BEFORE_MANAGERREGISTER_EVENT, manager);
    String clusterName = getManagerName(cmanager.getName(), manager);
    cmanager.setName(clusterName);
    cmanager.setCluster(this);

    managers.put(clusterName, cmanager);
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(AFTER_MANAGERREGISTER_EVENT, manager);
}
项目:apache-tomcat-7.0.73-with-comment    文件:ReplicationValve.java   
/**
 * Mark Request that processed at primary node with attribute
 * primaryIndicatorName
 * 
 * @param request
 * @throws IOException
 */
protected void createPrimaryIndicator(Request request) throws IOException {
    String id = request.getRequestedSessionId();
    if ((id != null) && (id.length() > 0)) {
        Manager manager = request.getContext().getManager();
        Session session = manager.findSession(id);
        if (session instanceof ClusterSession) {
            ClusterSession cses = (ClusterSession) session;
            if (log.isDebugEnabled())
                log.debug(sm.getString(
                        "ReplicationValve.session.indicator", request.getContext().getName(),id,
                        primaryIndicatorName,
                        Boolean.valueOf(cses.isPrimarySession())));
            request.setAttribute(primaryIndicatorName, cses.isPrimarySession()?Boolean.TRUE:Boolean.FALSE);
        } else {
            if (log.isDebugEnabled()) {
                if (session != null) {
                    log.debug(sm.getString(
                            "ReplicationValve.session.found", request.getContext().getName(),id));
                } else {
                    log.debug(sm.getString(
                            "ReplicationValve.session.invalid", request.getContext().getName(),id));
                }
            }
        }
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:MBeanUtils.java   
/**
 * Deregister the MBean for this
 * <code>Manager</code> object.
 *
 * @param manager The Manager to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 * @deprecated  Unused. Will be removed in Tomcat 8.0.x
 */
@Deprecated
static void destroyMBean(Manager manager)
    throws Exception {

    String mname = createManagedName(manager);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, manager);
    if( mserver.isRegistered(oname) )
        mserver.unregisterMBean(oname);

}
项目:apache-tomcat-7.0.73-with-comment    文件:SimpleTcpCluster.java   
@Override
public void registerManager(Manager manager) {

    if (! (manager instanceof ClusterManager)) {
        log.warn("Manager [ " + manager + "] does not implement ClusterManager, addition to cluster has been aborted.");
        return;
    }
    ClusterManager cmanager = (ClusterManager) manager;
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(BEFORE_MANAGERREGISTER_EVENT, manager);
    String clusterName = getManagerName(cmanager.getName(), manager);
    cmanager.setName(clusterName);
    cmanager.setCluster(this);

    managers.put(clusterName, cmanager);
    // Notify our interested LifecycleListeners
    fireLifecycleEvent(AFTER_MANAGERREGISTER_EVENT, manager);    
}
项目:lazycat    文件:StandardSession.java   
/**
 * Construct a new Session associated with the specified Manager.
 *
 * @param manager
 *            The manager with which this Session is associated
 */
public StandardSession(Manager manager) {

    super();
    this.manager = manager;

    // Initialize access count
    if (ACTIVITY_CHECK) {
        accessCount = new AtomicInteger();
    }

}
项目:lazycat    文件:StoreBase.java   
/**
 * Set the Manager with which this Store is associated.
 *
 * @param manager
 *            The newly associated Manager
 */
@Override
public void setManager(Manager manager) {
    Manager oldManager = this.manager;
    this.manager = manager;
    support.firePropertyChange("manager", oldManager, this.manager);
}
项目:micrometer    文件:TomcatMetricsConfiguration.java   
@Bean
public TomcatMetrics metrics(ApplicationContext applicationContext) {
    Manager manager = null;
    if (applicationContext instanceof EmbeddedWebApplicationContext) {
        manager = getManagerFromContext((EmbeddedWebApplicationContext) applicationContext);
    }
    return new TomcatMetrics(manager, Collections.emptyList());
}
项目:micrometer    文件:TomcatMetricsConfiguration.java   
private Manager getManagerFromContext(EmbeddedWebApplicationContext applicationContext) {
    EmbeddedServletContainer embeddedServletContainer = applicationContext.getEmbeddedServletContainer();
    if (embeddedServletContainer instanceof TomcatEmbeddedServletContainer) {
        return getManagerFromContainer((TomcatEmbeddedServletContainer) embeddedServletContainer);
    }
    return null;
}
项目:micrometer    文件:TomcatMetricsConfiguration.java   
private Manager getManagerFromContainer(TomcatEmbeddedServletContainer servletContainer) {
    for (Container container : servletContainer.getTomcat().getHost().findChildren()) {
        if (container instanceof Context) {
            return ((Context) container).getManager();
        }
    }
    return null;
}
项目:tomcat7    文件:JvmRouteBinderValve.java   
/**
 * get jvmroute from engine
 * 
 * @param request current request
 * @return return jvmRoute from ManagerBase or null
 */
protected String getLocalJvmRoute(Request request) {
    Manager manager = getManager(request);
    if(manager instanceof ManagerBase)
        return ((ManagerBase) manager).getJvmRoute();
    return null ;
}
项目:tomcat7    文件:JvmRouteBinderValve.java   
/**
 * get ClusterManager
 * 
 * @param request current request
 * @return manager or null
 */
protected Manager getManager(Request request) {
    Manager manager = request.getContext().getManager();
    if (log.isDebugEnabled()) {
        if(manager != null)
            log.debug(sm.getString("jvmRoute.foundManager", manager,  request.getContext().getName()));
        else 
            log.debug(sm.getString("jvmRoute.notFoundManager", request.getContext().getName()));
    }
    return manager;
}
项目:lazycat    文件:JvmRouteBinderValve.java   
/**
 * get ClusterManager
 * 
 * @param request
 *            current request
 * @return manager or null
 */
protected Manager getManager(Request request) {
    Manager manager = request.getContext().getManager();
    if (log.isDebugEnabled()) {
        if (manager != null)
            log.debug(sm.getString("jvmRoute.foundManager", manager, request.getContext().getName()));
        else
            log.debug(sm.getString("jvmRoute.notFoundManager", request.getContext().getName()));
    }
    return manager;
}
项目:tomcat7    文件:SimpleTcpCluster.java   
/**
 * Remove an application from cluster replication bus.
 * 
 * @see org.apache.catalina.Cluster#removeManager(Manager)
 */
@Override
public void removeManager(Manager manager) {
    if (manager != null && manager instanceof ClusterManager ) {
        ClusterManager cmgr = (ClusterManager) manager;
        // Notify our interested LifecycleListeners
        fireLifecycleEvent(BEFORE_MANAGERUNREGISTER_EVENT,manager);
        managers.remove(getManagerName(cmgr.getName(),manager));
        cmgr.setCluster(null);
        // Notify our interested LifecycleListeners
        fireLifecycleEvent(AFTER_MANAGERUNREGISTER_EVENT, manager);
    }
}
项目:tomcat7    文件:HTMLManagerServlet.java   
protected List<Session> getSessionsForName(ContextName cn,
        StringManager smClient) {
    if ((cn == null) || !(cn.getPath().startsWith("/") ||
            cn.getPath().equals(""))) {
        String path = null;
        if (cn != null) {
            path = cn.getPath();
        }
        throw new IllegalArgumentException(smClient.getString(
                "managerServlet.invalidPath",
                RequestUtil.filter(path)));
    }

    Context ctxt = (Context) host.findChild(cn.getName());
    if (null == ctxt) {
        throw new IllegalArgumentException(smClient.getString(
                "managerServlet.noContext",
                RequestUtil.filter(cn.getDisplayName())));
    }
    Manager manager = ctxt.getManager();
    List<Session> sessions = new ArrayList<Session>();
    sessions.addAll(Arrays.asList(manager.findSessions()));
    if (manager instanceof DistributedManager && showProxySessions) {
        // Add dummy proxy sessions
        Set<String> sessionIds =
            ((DistributedManager) manager).getSessionIdsFull();
        // Remove active (primary and backup) session IDs from full list
        for (Session session : sessions) {
            sessionIds.remove(session.getId());
        }
        // Left with just proxy sessions - add them
        for (String sessionId : sessionIds) {
            sessions.add(new DummyProxySession(sessionId));
        }
    }
    return sessions;
}
项目:lazycat    文件:ContainerBase.java   
/**
 * Return the Manager with which this Container is associated. If there is
 * no associated Manager, return the Manager associated with our parent
 * Container (if any); otherwise return <code>null</code>.
 */
@Override
public Manager getManager() {

    if (manager != null)
        return (manager);
    if (parent != null)
        return (parent.getManager());
    return (null);

}
项目:tomcat7    文件:StoreBase.java   
/**
 * Set the Manager with which this Store is associated.
 *
 * @param manager The newly associated Manager
 */
@Override
public void setManager(Manager manager) {
    Manager oldManager = this.manager;
    this.manager = manager;
    support.firePropertyChange("manager", oldManager, this.manager);
}
项目:tomcat7    文件:StandardSession.java   
/**
 * Construct a new Session associated with the specified Manager.
 *
 * @param manager The manager with which this Session is associated
 */
public StandardSession(Manager manager) {

    super();
    this.manager = manager;

    // Initialize access count
    if (ACTIVITY_CHECK) {
        accessCount = new AtomicInteger();
    }

}
项目:tomcat7    文件:SingleSignOn.java   
private void expire(SingleSignOnSessionKey key) {
    if (engine == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.engineNull", key));
        return;
    }
    Container host = engine.findChild(key.getHostName());
    if (host == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.hostNotFound", key));
        return;
    }
    Context context = (Context) host.findChild(key.getContextName());
    if (context == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.contextNotFound", key));
        return;
    }
    Manager manager = context.getManager();
    if (manager == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerNotFound", key));
        return;
    }
    Session session = null;
    try {
        session = manager.findSession(key.getSessionId());
    } catch (IOException e) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerError", key), e);
        return;
    }
    if (session == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.sessionNotFound", key));
        return;
    }
    session.expire();
}
项目:tomcat7    文件:ApplicationHttpRequest.java   
/**
 * Returns true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 *
 * @return true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 */
@Override
public boolean isRequestedSessionIdValid() {

    if (crossContext) {

        String requestedSessionId = getRequestedSessionId();
        if (requestedSessionId == null)
            return (false);
        if (context == null)
            return (false);
        Manager manager = context.getManager();
        if (manager == null)
            return (false);
        Session session = null;
        try {
            session = manager.findSession(requestedSessionId);
        } catch (IOException e) {
            // Ignore
        }
        if ((session != null) && session.isValid()) {
            return (true);
        } else {
            return (false);
        }

    } else {
        return super.isRequestedSessionIdValid();
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:ApplicationHttpRequest.java   
/**
 * Returns true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 *
 * @return true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 */
@Override
public boolean isRequestedSessionIdValid() {

    if (crossContext) {

        String requestedSessionId = getRequestedSessionId();
        if (requestedSessionId == null)
            return (false);
        if (context == null)
            return (false);
        Manager manager = context.getManager();
        if (manager == null)
            return (false);
        Session session = null;
        try {
            session = manager.findSession(requestedSessionId);
        } catch (IOException e) {
            // Ignore
        }
        if ((session != null) && session.isValid()) {
            return (true);
        } else {
            return (false);
        }

    } else {
        return super.isRequestedSessionIdValid();
    }
}
项目:lazycat    文件:HTMLManagerServlet.java   
protected List<Session> getSessionsForName(ContextName cn, StringManager smClient) {
    if ((cn == null) || !(cn.getPath().startsWith("/") || cn.getPath().equals(""))) {
        String path = null;
        if (cn != null) {
            path = cn.getPath();
        }
        throw new IllegalArgumentException(
                smClient.getString("managerServlet.invalidPath", RequestUtil.filter(path)));
    }

    Context ctxt = (Context) host.findChild(cn.getName());
    if (null == ctxt) {
        throw new IllegalArgumentException(
                smClient.getString("managerServlet.noContext", RequestUtil.filter(cn.getDisplayName())));
    }
    Manager manager = ctxt.getManager();
    List<Session> sessions = new ArrayList<Session>();
    sessions.addAll(Arrays.asList(manager.findSessions()));
    if (manager instanceof DistributedManager && showProxySessions) {
        // Add dummy proxy sessions
        Set<String> sessionIds = ((DistributedManager) manager).getSessionIdsFull();
        // Remove active (primary and backup) session IDs from full list
        for (Session session : sessions) {
            sessionIds.remove(session.getId());
        }
        // Left with just proxy sessions - add them
        for (String sessionId : sessionIds) {
            sessions.add(new DummyProxySession(sessionId));
        }
    }
    return sessions;
}
项目:Equella    文件:TomcatServiceImpl.java   
private Manager getSessionManager(Context context)
{
    // Must be set for the persistent manager to work correctly.
    System.setProperty("org.apache.catalina.session.StandardSession.ACTIVITY_CHECK", "true");

    PersistentManager manager = new PersistentManager();
    StoreBase store;

    // Check if Migration has run and setup JDBC persistence
    if( !hibernateMigrationService.hasRunSystemMigration("com.tle.tomcat.migration.CreateTomcatSessionEntity") )
    {
        // Use filestore until JDBC setup complete
        LOGGER.info("Setting up temporary file session store");
        FileStore fileStore = new FileStore();
        fileStore.setDirectory(System.getProperty("java.io.tmpdir"));
        store = fileStore;
    }
    else
    {
        LOGGER.info("Setting up JDBC session store");
        JDBCStore jdbcStore = new JDBCStore();
        jdbcStore.setConnectionURL(dataSourceService.getSystemUrl());
        jdbcStore.setConnectionName(dataSourceService.getSystemUsername());
        jdbcStore.setConnectionPassword(dataSourceService.getSystemPassword());
        jdbcStore.setDriverName(dataSourceService.getDriverClass());
        jdbcStore.setSessionTable("tomcat_sessions");
        store = jdbcStore;
    }

    manager.setContext(context);
    manager.setProcessExpiresFrequency(3); // Every 30 seconds
    manager.setStore(store);
    // Persist immediately but leave in memory
    manager.setMaxIdleBackup(0);
    // Don't remove from memory for 30 minutes
    manager.setMaxIdleSwap((int) TimeUnit.MINUTES.toSeconds(30));

    return manager;
}
项目:lams    文件:StandardSession.java   
/**
 * Construct a new Session associated with the specified Manager.
 *
 * @param manager The manager with which this Session is associated
 */
public StandardSession(Manager manager) {

    super();
    this.manager = manager;

    // Initialize access count
    if (ACTIVITY_CHECK) {
        accessCount = new AtomicInteger();
    }

}
项目:lazycat    文件:SimpleTcpCluster.java   
/**
 * @param name
 * @param manager
 * @return TODO
 */
@Override
public String getManagerName(String name, Manager manager) {
    String clusterName = name;
    if (clusterName == null)
        clusterName = manager.getContainer().getName();
    if (getContainer() instanceof Engine) {
        Context context = (Context) manager.getContainer();
        Container host = context.getParent();
        if (host instanceof Host && clusterName != null && !(clusterName.startsWith(host.getName() + "#"))) {
            clusterName = host.getName() + "#" + clusterName;
        }
    }
    return clusterName;
}
项目:lams    文件:ApplicationHttpRequest.java   
/**
 * Returns true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 *
 * @return true if the request specifies a JSESSIONID that is valid within
 * the context of this ApplicationHttpRequest, false otherwise.
 */
public boolean isRequestedSessionIdValid() {

    if (crossContext) {

        String requestedSessionId = getRequestedSessionId();
        if (requestedSessionId == null)
            return (false);
        if (context == null)
            return (false);
        Manager manager = context.getManager();
        if (manager == null)
            return (false);
        Session session = null;
        try {
            session = manager.findSession(requestedSessionId);
        } catch (IOException e) {
            session = null;
        }
        if ((session != null) && session.isValid()) {
            return (true);
        } else {
            return (false);
        }

    } else {
        return super.isRequestedSessionIdValid();
    }
}