Author: markt Date: Fri Feb 5 17:53:29 2010 New Revision: 907018 URL: http://svn.apache.org/viewvc?rev=907018&view=rev Log: Remainder of Pipeline clean up. The Pipeline interface is now used in place of StandardPipeline throughout the code base.
Added: tomcat/trunk/java/org/apache/catalina/CatalinaFactory.java (with props) Modified: tomcat/trunk/java/org/apache/catalina/Pipeline.java tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java tomcat/trunk/java/org/apache/catalina/core/StandardHost.java Added: tomcat/trunk/java/org/apache/catalina/CatalinaFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/CatalinaFactory.java?rev=907018&view=auto ============================================================================== --- tomcat/trunk/java/org/apache/catalina/CatalinaFactory.java (added) +++ tomcat/trunk/java/org/apache/catalina/CatalinaFactory.java Fri Feb 5 17:53:29 2010 @@ -0,0 +1,52 @@ +/* + * 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; + } +} Propchange: tomcat/trunk/java/org/apache/catalina/CatalinaFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/java/org/apache/catalina/Pipeline.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Pipeline.java?rev=907018&r1=907017&r2=907018&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/Pipeline.java (original) +++ tomcat/trunk/java/org/apache/catalina/Pipeline.java Fri Feb 5 17:53:29 2010 @@ -80,6 +80,10 @@ * 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 @@ -106,6 +110,10 @@ * 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); @@ -124,4 +132,17 @@ 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); + } Modified: tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java?rev=907018&r1=907017&r2=907018&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/ContainerBase.java Fri Feb 5 17:53:29 2010 @@ -36,6 +36,7 @@ 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; @@ -229,7 +230,8 @@ /** * The Pipeline object with which this Container is associated. */ - protected Pipeline pipeline = new StandardPipeline(this); + protected Pipeline pipeline = + CatalinaFactory.getFactory().createPipeline(this); /** @@ -1216,10 +1218,6 @@ pipeline.addValve(valve); } - public ObjectName[] getValveObjectNames() { - return ((StandardPipeline)pipeline).getValveObjectNames(); - } - /** * Execute a periodic task, such as reloading, etc. This method will be Modified: tomcat/trunk/java/org/apache/catalina/core/StandardHost.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardHost.java?rev=907018&r1=907017&r2=907018&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/StandardHost.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/StandardHost.java Fri Feb 5 17:53:29 2010 @@ -128,11 +128,6 @@ "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 = @@ -742,19 +737,19 @@ && (!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", --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org