Java Code Examples for org.apache.catalina.Pipeline#getValves()

The following examples show how to use org.apache.catalina.Pipeline#getValves() . 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: ContextConfig.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 * Process a "contextConfig" event for this Context.
 * ContextConfig监听器为这个Context处理一个contextConfig事件。
 * 解析web.xml事件。
 */
protected synchronized void configureStart() {
    // Called from StandardContext.start()

    if (log.isDebugEnabled()) {
        log.debug(sm.getString("contextConfig.start"));
    }

    if (log.isDebugEnabled()) {
        log.debug(sm.getString("contextConfig.xmlSettings",
                context.getName(),
                Boolean.valueOf(context.getXmlValidation()),
                Boolean.valueOf(context.getXmlNamespaceAware())));
    }

    //
    webConfig();

    // 添加JSP解析器,因为index.jsp需要加载。
    //add JasperInitializer,cause index.jsp need to load.
    final Set<Class<?>> nullObject4ClassesSet = null;
    context.addServletContainerInitializer(new JasperInitializer(), nullObject4ClassesSet);
    //
    if (!context.getIgnoreAnnotations()) {
        applicationAnnotationsConfig();
    }
    if (ok) {
        validateSecurityRoles();
    }

    // Configure an authenticator if we need one
    if (ok) {
        authenticatorConfig();
    }

    // Dump the contents of this pipeline if requested
    if (log.isDebugEnabled()) {
        log.debug("Pipeline Configuration:");
        Pipeline pipeline = context.getPipeline();
        Valve valves[] = null;
        if (pipeline != null) {
            valves = pipeline.getValves();
        }
        if (valves != null) {
            for (int i = 0; i < valves.length; i++) {
                log.debug("  " + valves[i].getClass().getName());
            }
        }
        log.debug("======================");
    }

    // Make our application available if no problems were encountered
    if (ok) {
        context.setConfigured(true);
    } else {
        log.error(sm.getString("contextConfig.unavailable"));
        context.setConfigured(false);
    }

}
 
Example 2
Source File: ValveBase.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public String getObjectNameKeyProperties() {
    StringBuilder name = new StringBuilder("type=Valve");

    Container container = getContainer();

    name.append(container.getMBeanKeyProperties());

    int seq = 0;

    // Pipeline may not be present in unit testing
    Pipeline p = container.getPipeline();
    if (p != null) {
        for (Valve valve : p.getValves()) {
            // Skip null valves
            if (valve == null) {
                continue;
            }
            // Only compare valves in pipeline until we find this valve
            if (valve == this) {
                break;
            }
            if (valve.getClass() == this.getClass()) {
                // Duplicate valve earlier in pipeline
                // increment sequence number
                seq ++;
            }
        }
    }

    if (seq > 0) {
        name.append(",seq=");
        name.append(seq);
    }

    String className = this.getClass().getName();
    int period = className.lastIndexOf('.');
    if (period >= 0) {
        className = className.substring(period + 1);
    }
    name.append(",name=");
    name.append(className);

    return name.toString();
}
 
Example 3
Source File: ContextConfig.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * Process a "contextConfig" event for this Context.
 */
protected synchronized void configureStart() {
    // Called from StandardContext.start()

    if (log.isDebugEnabled())
        log.debug(sm.getString("contextConfig.start"));

    if (log.isDebugEnabled()) {
        log.debug(sm.getString("contextConfig.xmlSettings",
                context.getName(),
                Boolean.valueOf(context.getXmlValidation()),
                Boolean.valueOf(context.getXmlNamespaceAware())));
    }

    webConfig();

    if (!context.getIgnoreAnnotations()) {
        applicationAnnotationsConfig();
    }
    if (ok) {
        validateSecurityRoles();
    }

    // Configure an authenticator if we need one
    if (ok)
        authenticatorConfig();

    // Dump the contents of this pipeline if requested
    if ((log.isDebugEnabled()) && (context instanceof ContainerBase)) {
        log.debug("Pipeline Configuration:");
        Pipeline pipeline = ((ContainerBase) context).getPipeline();
        Valve valves[] = null;
        if (pipeline != null)
            valves = pipeline.getValves();
        if (valves != null) {
            for (int i = 0; i < valves.length; i++) {
                log.debug("  " + valves[i].getInfo());
            }
        }
        log.debug("======================");
    }

    // Make our application available if no problems were encountered
    if (ok)
        context.setConfigured(true);
    else {
        log.error(sm.getString("contextConfig.unavailable"));
        context.setConfigured(false);
    }

}
 
Example 4
Source File: ValveBase.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public String getObjectNameKeyProperties() {
    StringBuilder name = new StringBuilder("type=Valve");

    Container container = getContainer();

    name.append(MBeanUtils.getContainerKeyProperties(container));

    int seq = 0;

    // Pipeline may not be present in unit testing
    Pipeline p = container.getPipeline();
    if (p != null) {
        for (Valve valve : p.getValves()) {
            // Skip null valves
            if (valve == null) {
                continue;
            }
            // Only compare valves in pipeline until we find this valve
            if (valve == this) {
                break;
            }
            if (valve.getClass() == this.getClass()) {
                // Duplicate valve earlier in pipeline
                // increment sequence number
                seq ++;
            }
        }
    }

    if (seq > 0) {
        name.append(",seq=");
        name.append(seq);
    }

    String className = this.getClass().getName();
    int period = className.lastIndexOf('.');
    if (period >= 0) {
        className = className.substring(period + 1);
    }
    name.append(",name=");
    name.append(className);

    return name.toString();
}
 
Example 5
Source File: ValveBase.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public String getObjectNameKeyProperties() {
    StringBuilder name = new StringBuilder("type=Valve");

    Container container = getContainer();

    name.append(MBeanUtils.getContainerKeyProperties(container));

    int seq = 0;

    // Pipeline may not be present in unit testing
    Pipeline p = container.getPipeline();
    if (p != null) {
        for (Valve valve : p.getValves()) {
            // Skip null valves
            if (valve == null) {
                continue;
            }
            // Only compare valves in pipeline until we find this valve
            if (valve == this) {
                break;
            }
            if (valve.getClass() == this.getClass()) {
                // Duplicate valve earlier in pipeline
                // increment sequence number
                seq ++;
            }
        }
    }

    if (seq > 0) {
        name.append(",seq=");
        name.append(seq);
    }

    String className = this.getClass().getName();
    int period = className.lastIndexOf('.');
    if (period >= 0) {
        className = className.substring(period + 1);
    }
    name.append(",name=");
    name.append(className);

    return name.toString();
}