Пример #1
0
  public void init() {
    if (initialized) return;
    initialized = true;

    StandardContext ctx = (StandardContext) this.getContainer();
    distributable = ctx.getDistributable();
    if (org.apache.tomcat.util.Constants.ENABLE_MODELER) {
      if (oname == null) {
        try {
          Engine eng = (Engine) ctx.getParent().getParent();
          domain = ctx.getEngineName();
          StandardHost hst = (StandardHost) ctx.getParent();
          String path = ctx.getPath();
          if (path.equals("")) {
            path = "/";
          }
          oname = new ObjectName(domain + ":type=Manager,path=" + path + ",host=" + hst.getName());
          Registry.getRegistry(null, null).registerComponent(this, oname, null);
        } catch (Exception e) {
          CatalinaLogger.SESSION_LOGGER.failedSessionManagerJmxRegistration(oname, e);
        }
      }
    }

    if (CatalinaLogger.SESSION_LOGGER.isDebugEnabled())
      CatalinaLogger.SESSION_LOGGER.debug("Registering " + oname);
  }
Пример #2
0
  /** Invalidate all sessions that have expired. */
  public void processExpires() {

    long timeNow = System.currentTimeMillis();
    Session sessions[] = findSessions();
    int expireHere = 0;

    if (CatalinaLogger.SESSION_LOGGER.isDebugEnabled())
      CatalinaLogger.SESSION_LOGGER.debug(
          "Start expire sessions "
              + getName()
              + " at "
              + timeNow
              + " sessioncount "
              + sessions.length);
    for (int i = 0; i < sessions.length; i++) {
      if (sessions[i] != null && !sessions[i].isValid()) {
        expireHere++;
      }
    }
    long timeEnd = System.currentTimeMillis();
    if (CatalinaLogger.SESSION_LOGGER.isDebugEnabled())
      CatalinaLogger.SESSION_LOGGER.debug(
          "End expire sessions "
              + getName()
              + " processingTime "
              + (timeEnd - timeNow)
              + " expired sessions: "
              + expireHere);
    processingTime += (timeEnd - timeNow);
  }