Session 使用计时器从servletContext中删除会话

Session 使用计时器从servletContext中删除会话,session,servlets,timer,java-ee-6,servlet-3.0,Session,Servlets,Timer,Java Ee 6,Servlet 3.0,我需要从所有模块中删除servletContext中的会话,因此我创建了一个计时器,并将getServlet上下文作为TimerConnector对象中的一个参数进行传递 我从会话列表中删除会话,但我不知道如何将新列表设置为getSessionContext,也不知道如何从TimerConnectionr类中的getServletContext中删除属性 public class TimerConnector { static TimerConnector instance; public st

我需要从所有模块中删除
servletContext
中的会话,因此我创建了一个计时器,并将
getServlet
上下文作为
TimerConnector
对象中的一个参数进行传递

我从会话列表中删除会话,但我不知道如何将新列表设置为getSessionContext,也不知道如何从
TimerConnectionr
类中的
getServletContext
中删除属性

public class TimerConnector {
static TimerConnector instance;
public static synchronized TimerConnector getInstance() throws Exception {

    if (instance == null) {
        instance = new TimerConnector();
    }

    return instance;

}
protected TimerConnector(){
    getSessioContextForDestroy();
}
public TimerConnector() {

}
private TimerScheduler scheduler;
public void getSessioContextForDestroy() {
    // if scheduler is not init, try first.
    if (scheduler == null) {
        scheduler = TimerScheduler.getInstance();
    }   
}
}
我的学生:

public class TimerScheduler {
private final static Logger LOGGER = Logger.getLogger(DctmConnectorScheduler.class) ;

/** the sole instance */
private static TimerScheduler instance;

/**
 * The sole function to get an instance of the class
 */

public static synchronized TimerScheduler getInstance() {

    if (instance == null) {
        instance = new TimerScheduler();
    }

    return instance;

}

/** the flag */
private boolean isSchedulerStarted;

/** the timer for the connection tester scheduler */
private Timer timer;
protected TimerScheduler() {
    startScheduler();
}
private void startScheduler() {

    if (isSchedulerStarted) {
        return;
    }

    try {
        // default values
        int delay = 600000;
        int period = 600000;
        timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {

            @Override
            public void run() {
                //Do sameting.............

            } // end run()

        }, delay, period);

    } catch (final Exception ex) {
        LOGGER.error(ex.getMessage(), ex);
    }

    // trace in PROD
    LOGGER.error("*** Scheduler started");

    refreshDctmHashtables();

    isSchedulerStarted = true;
  }
}