use of org.apache.catalina.JmxEnabled in project tomcat by apache.
the class MBeanFactory method removeValve.
/**
* 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);
Container container = getParentContainerFromChild(oname);
Valve[] valves = container.getPipeline().getValves();
for (Valve valve : valves) {
ObjectName voname = ((JmxEnabled) valve).getObjectName();
if (voname.equals(oname)) {
container.getPipeline().removeValve(valve);
}
}
}
use of org.apache.catalina.JmxEnabled in project tomcat by apache.
the class MBeanFactory method createValve.
/**
* Create a new Valve and associate it with a {@link Container}.
*
* @param className The fully qualified class name of the {@link Valve} to
* create
* @param parent The MBean name of the associated parent
* {@link Container}.
*
* @return The MBean name of the {@link Valve} that was created or
* <code>null</code> if the {@link Valve} does not implement
* {@link JmxEnabled}.
* @exception Exception if an MBean cannot be created or registered
*/
public String createValve(String className, String parent) throws Exception {
// Look for the parent
ObjectName parentName = new ObjectName(parent);
Container container = getParentContainerFromParent(parentName);
if (container == null) {
// TODO
throw new IllegalArgumentException();
}
Valve valve = (Valve) Class.forName(className).getConstructor().newInstance();
container.getPipeline().addValve(valve);
if (valve instanceof JmxEnabled) {
return ((JmxEnabled) valve).getObjectName().toString();
} else {
return null;
}
}
use of org.apache.catalina.JmxEnabled in project tomcat by apache.
the class ContainerMBean method addValve.
/**
* Adds a valve to this Container instance.
*
* @param valveType ClassName of the valve to be added
* @return the MBean name of the new valve
* @throws MBeanException if adding the valve failed
*/
public String addValve(String valveType) throws MBeanException {
Valve valve = (Valve) newInstance(valveType);
Container container = doGetManagedResource();
container.getPipeline().addValve(valve);
if (valve instanceof JmxEnabled) {
return ((JmxEnabled) valve).getObjectName().toString();
} else {
return null;
}
}
use of org.apache.catalina.JmxEnabled in project tomcat by apache.
the class StandardHost method getValveNames.
// -------------------- JMX --------------------
/**
* @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] instanceof JmxEnabled) {
ObjectName oname = ((JmxEnabled) valves[i]).getObjectName();
if (oname != null) {
mbeanNames[i] = oname.toString();
}
}
}
return mbeanNames;
}
use of org.apache.catalina.JmxEnabled in project tomcat by apache.
the class StandardPipeline method getValveObjectNames.
public ObjectName[] getValveObjectNames() {
List<ObjectName> valveList = new ArrayList<>();
Valve current = first;
if (current == null) {
current = basic;
}
while (current != null) {
if (current instanceof JmxEnabled) {
valveList.add(((JmxEnabled) current).getObjectName());
}
current = current.getNext();
}
return valveList.toArray(new ObjectName[0]);
}
Aggregations