org.apache.catalina.valves.ValveBase Java Examples

The following examples show how to use org.apache.catalina.valves.ValveBase. 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: StandardPipeline.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
public ObjectName[] getValveObjectNames() {

        ArrayList<ObjectName> valveList = new ArrayList<ObjectName>();
        Valve current = first;
        if (current == null) {
            current = basic;
        }
        while (current != null) {
            if (current instanceof ValveBase) {
                valveList.add(((ValveBase) current).getObjectName());
            }
            current = current.getNext();
        }

        return valveList.toArray(new ObjectName[0]);

    }
 
Example #2
Source File: StandardPipeline.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
public ObjectName[] getValveObjectNames() {

        ArrayList<ObjectName> valveList = new ArrayList<ObjectName>();
        Valve current = first;
        if (current == null) {
            current = basic;
        }
        while (current != null) {
            if (current instanceof ValveBase) {
                valveList.add(((ValveBase) current).getObjectName());
            }
            current = current.getNext();
        }

        return valveList.toArray(new ObjectName[0]);

    }
 
Example #3
Source File: InstanceCustomizerTest.java    From openwebbeans-meecrowave with Apache License 2.0 6 votes vote down vote up
@Test
public void instanceCustomizer() throws IOException {
    try (final Meecrowave meecrowave = new Meecrowave(new Meecrowave.Builder()
            .randomHttpPort()
            .instanceCustomizer(t -> t.getHost().getPipeline().addValve(new ValveBase() {
                @Override
                public void invoke(final Request request, final Response response) throws IOException, ServletException {
                    response.getWriter().write("custom");
                }
            }))
            .includePackages(InstanceCustomizerTest.class.getName())).bake()) {
        try (final InputStream stream = new URL("http://localhost:" + meecrowave.getConfiguration().getHttpPort() + "/whatever").openStream()) {
            assertEquals("custom", Streams.asString(stream, "UTF-8"));
        }
    }
}
 
Example #4
Source File: MBeanFactory.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Remove an existing Valve.
 *
 * @param name MBean Name of the component to remove
 *
 * @exception Exception if a component cannot be removed
 */
public void removeValve(String name) throws Exception {

    // Acquire a reference to the component to be removed
    ObjectName oname = new ObjectName(name);
    ContainerBase container = getParentContainerFromChild(oname);
    Valve[] valves = container.getPipeline().getValves();
    for (int i = 0; i < valves.length; i++) {
        ObjectName voname = ((ValveBase) valves[i]).getObjectName();
        if (voname.equals(oname)) {
            container.getPipeline().removeValve(valves[i]);
        }
    }
}
 
Example #5
Source File: StandardHost.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
  * Return the MBean Names of the Valves associated with this Host
  *
  * @exception Exception if an MBean cannot be created or registered
  */
 public String [] getValveNames()
     throws Exception
{
     Valve [] valves = this.getPipeline().getValves();
     String [] mbeanNames = new String[valves.length];
     for (int i = 0; i < valves.length; i++) {
         if( valves[i] == null ) continue;
         if( ((ValveBase)valves[i]).getObjectName() == null ) continue;
         mbeanNames[i] = ((ValveBase)valves[i]).getObjectName().toString();
     }

     return mbeanNames;

 }
 
Example #6
Source File: MBeanFactory.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Remove an existing Valve.
 *
 * @param name MBean Name of the component to remove
 *
 * @exception Exception if a component cannot be removed
 */
public void removeValve(String name) throws Exception {

    // Acquire a reference to the component to be removed
    ObjectName oname = new ObjectName(name);
    ContainerBase container = getParentContainerFromChild(oname);
    Valve[] valves = container.getPipeline().getValves();
    for (int i = 0; i < valves.length; i++) {
        ObjectName voname = ((ValveBase) valves[i]).getObjectName();
        if (voname.equals(oname)) {
            container.getPipeline().removeValve(valves[i]);
        }
    }
}
 
Example #7
Source File: StandardHost.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
  * Return the MBean Names of the Valves associated with this Host
  *
  * @exception Exception if an MBean cannot be created or registered
  */
 public String [] getValveNames()
     throws Exception
{
     Valve [] valves = this.getPipeline().getValves();
     String [] mbeanNames = new String[valves.length];
     for (int i = 0; i < valves.length; i++) {
         if( valves[i] == null ) continue;
         if( ((ValveBase)valves[i]).getObjectName() == null ) continue;
         mbeanNames[i] = ((ValveBase)valves[i]).getObjectName().toString();
     }

     return mbeanNames;

 }
 
Example #8
Source File: Tomcat7Valve.java    From flex-blazeds with Apache License 2.0 4 votes vote down vote up
TomcatLoginImpl(ValveBase valve, Request request)
{
    this.valve = valve;
    this.request = request;
}