--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina;
+
+import org.apache.catalina.core.StandardPipeline;
+
+/**
+ * Factory class used whenever a default implementation of a component is
+ * required. It provides both class names (for the digester) and objects for
+ * other components. The current implementation is as simple as possible. If
+ * there is demand it can be extended to support alternative factories and/or
+ * alternative defaults.
+ *
+ * TODO: Create the other standard components via this factory
+ */
+public class CatalinaFactory {
+
+ private static CatalinaFactory factory = new CatalinaFactory();
+
+ public static CatalinaFactory getFactory() {
+ return factory;
+ }
+
+ private CatalinaFactory() {
+ // Hide the default constructor
+ }
+
+ public String getDefaultPipelineClassName() {
+ return StandardPipeline.class.getName();
+ }
+
+ public Pipeline createPipeline(Container container) {
+ Pipeline pipeline = new StandardPipeline();
+ pipeline.setContainer(container);
+ return pipeline;
+ }
+}
* be associated with this Container, or <code>IllegalStateException</code>
* if it is already associated with a different Container.</p>
*
+ * <p>Implementation note: Implementations are expected to trigger the
+ * {@link Container#ADD_VALVE_EVENT} for the associated container if this
+ * call is successful.</p>
+ *
* @param valve Valve to be added
*
* @exception IllegalArgumentException if this Container refused to
* found and removed, the Valve's <code>setContainer(null)</code> method
* will be called if it implements <code>Contained</code>.
*
+ * <p>Implementation note: Implementations are expected to trigger the
+ * {@link Container#REMOVE_VALVE_EVENT} for the associated container if this
+ * call is successful.</p>
+ *
* @param valve Valve to be removed
*/
public void removeValve(Valve valve);
public boolean isAsyncSupported();
+ /**
+ * Return the Container with which this Pipeline is associated.
+ */
+ public Container getContainer();
+
+
+ /**
+ * Set the Container with which this Pipeline is associated.
+ *
+ * @param container The new associated container
+ */
+ public void setContainer(Container container);
+
}
import javax.naming.directory.DirContext;
import javax.servlet.ServletException;
+import org.apache.catalina.CatalinaFactory;
import org.apache.catalina.Cluster;
import org.apache.catalina.Container;
import org.apache.catalina.ContainerEvent;
/**
* The Pipeline object with which this Container is associated.
*/
- protected Pipeline pipeline = new StandardPipeline(this);
+ protected Pipeline pipeline =
+ CatalinaFactory.getFactory().createPipeline(this);
/**
pipeline.addValve(valve);
}
- public ObjectName[] getValveObjectNames() {
- return ((StandardPipeline)pipeline).getValveObjectNames();
- }
-
/**
* Execute a periodic task, such as reloading, etc. This method will be
"org.apache.catalina.valves.ErrorReportValve";
/**
- * The object name for the errorReportValve.
- */
- private ObjectName errorReportValveObjectName = null;
-
- /**
* The descriptive information string for this implementation.
*/
private static final String info =
&& (!errorReportValveClass.equals(""))) {
try {
boolean found = false;
- if(errorReportValveObjectName != null) {
- ObjectName[] names =
- ((StandardPipeline)pipeline).getValveObjectNames();
- for (int i=0; !found && i<names.length; i++)
- if(errorReportValveObjectName.equals(names[i]))
- found = true ;
- }
- if(!found) {
- Valve valve = (Valve) Class.forName(errorReportValveClass)
- .newInstance();
- getPipeline().addValve(valve);
- errorReportValveObjectName = ((ValveBase)valve).getObjectName() ;
+ Valve[] valves = getPipeline().getValves();
+ for (Valve valve : valves) {
+ if (errorReportValveClass.equals(
+ valve.getClass().getName())) {
+ found = true;
+ break;
}
+ }
+ if(!found) {
+ Valve valve = (Valve) Class.forName(errorReportValveClass).
+ newInstance();
+ getPipeline().addValve(valve);
+ }
} catch (Throwable t) {
log.error(sm.getString
("standardHost.invalidErrorReportValveClass",