相关疑难解决方法(0)

Tomcat 7中的org.apache.catalina.ServerFactory.getServer()等价物

org.apache.catalina.ServerFactory.getServer()Tomcat 7中的等价物或者检索org.apache.catalina.Session实例的最佳方法是什么?

以下是用于处理Tomcat 6.0的示例代码:

public List<org.apache.catalina.Session> findActiveSessions() throws ServiceException {
    StandardEngine engine = (StandardEngine) ServerFactory.getServer().findService("Catalina").getContainer();
    StandardContext  context = (StandardContext) engine.findChild(engine.getDefaultHost())
        .findChild(ServletActionContext.getServletContext().getContextPath()); 
    List<org.apache.catalina.Session> list = new ArrayList<org.apache.catalina.Session>();
    for (org.apache.catalina.Session session : context.getManager().findSessions()) {
        list.add(session);
    }
    return list;
}
Run Code Online (Sandbox Code Playgroud)

tomcat7

18
推荐指数
1
解决办法
8014
查看次数

标签 统计

tomcat7 ×1