Java Code Examples for org.apache.catalina.util.ContextName#getPath()

The following examples show how to use org.apache.catalina.util.ContextName#getPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HTMLManagerServlet.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected List<Session> getSessionsForName(ContextName cn,
        StringManager smClient) {
    if ((cn == null) || !(cn.getPath().startsWith("/") ||
            cn.getPath().equals(""))) {
        String path = null;
        if (cn != null) {
            path = cn.getPath();
        }
        throw new IllegalArgumentException(smClient.getString(
                "managerServlet.invalidPath",
                Escape.htmlElementContent(path)));
    }

    Context ctxt = (Context) host.findChild(cn.getName());
    if (null == ctxt) {
        throw new IllegalArgumentException(smClient.getString(
                "managerServlet.noContext",
                Escape.htmlElementContent(cn.getDisplayName())));
    }
    Manager manager = ctxt.getManager();
    List<Session> sessions = new ArrayList<>();
    sessions.addAll(Arrays.asList(manager.findSessions()));
    if (manager instanceof DistributedManager && showProxySessions) {
        // Add dummy proxy sessions
        Set<String> sessionIds =
            ((DistributedManager) manager).getSessionIdsFull();
        // Remove active (primary and backup) session IDs from full list
        for (Session session : sessions) {
            sessionIds.remove(session.getId());
        }
        // Left with just proxy sessions - add them
        for (String sessionId : sessionIds) {
            sessions.add(new DummyProxySession(sessionId));
        }
    }
    return sessions;
}
 
Example 2
Source File: HTMLManagerServlet.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
protected List<Session> getSessionsForName(ContextName cn,
        StringManager smClient) {
    if ((cn == null) || !(cn.getPath().startsWith("/") ||
            cn.getPath().equals(""))) {
        String path = null;
        if (cn != null) {
            path = cn.getPath();
        }
        throw new IllegalArgumentException(smClient.getString(
                "managerServlet.invalidPath",
                RequestUtil.filter(path)));
    }

    Context ctxt = (Context) host.findChild(cn.getName());
    if (null == ctxt) {
        throw new IllegalArgumentException(smClient.getString(
                "managerServlet.noContext",
                RequestUtil.filter(cn.getDisplayName())));
    }
    Manager manager = ctxt.getManager();
    List<Session> sessions = new ArrayList<Session>();
    sessions.addAll(Arrays.asList(manager.findSessions()));
    if (manager instanceof DistributedManager && showProxySessions) {
        // Add dummy proxy sessions
        Set<String> sessionIds =
            ((DistributedManager) manager).getSessionIdsFull();
        // Remove active (primary and backup) session IDs from full list
        for (Session session : sessions) {
            sessionIds.remove(session.getId());
        }
        // Left with just proxy sessions - add them
        for (String sessionId : sessionIds) {
            sessions.add(new DummyProxySession(sessionId));
        }
    }
    return sessions;
}
 
Example 3
Source File: HTMLManagerServlet.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
protected List<Session> getSessionsForName(ContextName cn,
        StringManager smClient) {
    if ((cn == null) || !(cn.getPath().startsWith("/") ||
            cn.getPath().equals(""))) {
        String path = null;
        if (cn != null) {
            path = cn.getPath();
        }
        throw new IllegalArgumentException(smClient.getString(
                "managerServlet.invalidPath",
                RequestUtil.filter(path)));
    }

    Context ctxt = (Context) host.findChild(cn.getName());
    if (null == ctxt) {
        throw new IllegalArgumentException(smClient.getString(
                "managerServlet.noContext",
                RequestUtil.filter(cn.getDisplayName())));
    }
    Manager manager = ctxt.getManager();
    List<Session> sessions = new ArrayList<Session>();
    sessions.addAll(Arrays.asList(manager.findSessions()));
    if (manager instanceof DistributedManager && showProxySessions) {
        // Add dummy proxy sessions
        Set<String> sessionIds =
            ((DistributedManager) manager).getSessionIdsFull();
        // Remove active (primary and backup) session IDs from full list
        for (Session session : sessions) {
            sessionIds.remove(session.getId());
        }
        // Left with just proxy sessions - add them
        for (String sessionId : sessionIds) {
            sessions.add(new DummyProxySession(sessionId));
        }
    }
    return sessions;
}