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) 我在Tomcat 5.5文档中找到的只有:
如果要在此应用程序中调用ServletContext.getContext()以成功返回在此虚拟主机上运行的其他Web应用程序的请求调度程序,则设置为true.在安全意识环境中设置为false(默认值),以使getContext()始终返回null.
我发现一些论坛帖子评论该设置crossContext=true还允许在不同的Web应用程序之间共享会话对象,但我无法找到任何官方文档说明这一点.
Servlet.getContext()与不同Web应用程序之间共享会话状态的能力之间是否存在关系?
什么是crossContext属性真的 Tomcat中吗?
我的应用程序是Spring framework 3.1.2部署在其上的基于Web的应用程序Apache tomcat 6.
我需要在应用程序(服务器)启动时获取正在运行的应用程序端口号和主机名.所以我会在属性上覆盖它,并且需要其他bean初始化.
spring是否提供了检索这些详细信息并在Server Startup上设置它的任何选项?