chj0771 发表于 2018-12-5 07:44:03

Tomcat的Session过期处理策略

protected class ContainerBackgroundProcessor implements Runnable {  
      public void run() {
  
            while (!threadDone) {
  
                try {
  
                  Thread.sleep(backgroundProcessorDelay * 1000L);
  
                } catch (InterruptedException e) {
  
                  ;
  
                }
  
                if (!threadDone) {
  
                  Container parent = (Container) getMappingObject();//得到StandardEngine
  
                  ClassLoader cl =
  
                        Thread.currentThread().getContextClassLoader();
  
                  if (parent.getLoader() != null) {
  
                        cl = parent.getLoader().getClassLoader();
  
                  }
  
                  processChildren(parent, cl);
  
                }
  
            }
  
      }
  
      protected void processChildren(Container container, ClassLoader cl) {
  
            try {
  
                if (container.getLoader() != null) {
  
                  Thread.currentThread().setContextClassLoader
  
                        (container.getLoader().getClassLoader());
  
                }
  
                container.backgroundProcess();
  
            } catch (Throwable t) {
  
                log.error("Exception invoking periodic operation: ", t);
  
            } finally {
  
                Thread.currentThread().setContextClassLoader(cl);
  
            }
  
            Container[] children = container.findChildren();
  
            for (int i = 0; i < children.length; i++) {
  
                if (children.getBackgroundProcessorDelay()
页: [1]
查看完整版本: Tomcat的Session过期处理策略