pero 2005/04/15 13:14:46 Modified: modules/storeconfig/src/share/org/apache/catalina/storeconfig server-registry.xml modules/storeconfig/test/src/share/org/apache/catalina/storeconfig StandardHostSFTest.java StoreAppenderTest.java StoreLoaderTest.java Added: modules/storeconfig/src/share/org/apache/catalina/storeconfig IDynamicPropertyStoreAppender.java Removed: modules/storeconfig/src/share/org/apache/catalina/storeconfig ReplicationTransmitterStoreAppender.java Log: Refactoring and redesign cluster Revision Changes Path 1.6 +3 -2 jakarta-tomcat-catalina/modules/storeconfig/src/share/org/apache/catalina/storeconfig/server-registry.xml Index: server-registry.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/storeconfig/src/share/org/apache/catalina/storeconfig/server-registry.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- server-registry.xml 10 Apr 2005 16:22:15 -0000 1.5 +++ server-registry.xml 15 Apr 2005 20:14:46 -0000 1.6 @@ -132,7 +132,8 @@ default="false" childs="true" tagClass="org.apache.catalina.cluster.CatalinaCluster" - storeFactoryClass="org.apache.catalina.storeconfig.CatalinaClusterSF"> + storeFactoryClass="org.apache.catalina.storeconfig.CatalinaClusterSF" + storeAppenderClass="org.apache.catalina.storeconfig.IDynamicPropertyStoreAppender"> </Description> <Description tag="Realm" @@ -296,7 +297,7 @@ default="false" tagClass="org.apache.catalina.cluster.tcp.ReplicationTransmitter" storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase" - storeAppenderClass="org.apache.catalina.storeconfig.ReplicationTransmitterStoreAppender"> + storeAppenderClass="org.apache.catalina.storeconfig.IDynamicPropertyStoreAppender"> </Description> <Description tag="Sender" 1.1 jakarta-tomcat-catalina/modules/storeconfig/src/share/org/apache/catalina/storeconfig/IDynamicPropertyStoreAppender.java Index: IDynamicPropertyStoreAppender.java =================================================================== /** * Copyright 1999-2001,2004 The Apache Software Foundation. * * Licensed 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.storeconfig; import java.beans.IndexedPropertyDescriptor; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.catalina.cluster.util.IDynamicProperty; import org.apache.tomcat.util.IntrospectionUtils; /** * Store the IDynamicProperty attributes. * * @author Peter Rossbach * */ public class IDynamicPropertyStoreAppender extends StoreAppender { /** * Store the relevant attributes of the specified JavaBean. * * @param writer * PrintWriter to which we are storing * @param include * Should we include a <code>className</code> attribute? * @param bean * Bean whose properties are to be rendered as attributes, * @param desc * RegistryDescrpitor from this bean * * @exception Exception * if an exception occurs while storing */ public void printAttributes(PrintWriter writer, int indent, boolean include, Object bean, StoreDescription desc) throws Exception { // Render the relevant properties of this bean String className = bean.getClass().getName(); // Render a className attribute if requested if (include && desc != null && !desc.isStandard()) { writer.print(" className=\""); writer.print(bean.getClass().getName()); writer.print("\""); } if (bean instanceof IDynamicProperty) { List propertyKeys = getPropertyKeys((IDynamicProperty) bean); // Create blank instance Object bean2 = defaultInstance(bean); for (Iterator propertyIterator = propertyKeys.iterator(); propertyIterator .hasNext();) { String key = (String) propertyIterator.next(); Object value = (Object) IntrospectionUtils.getProperty(bean, key); if (desc.isTransientAttribute(key)) { continue; // Skip the specified exceptions } if (value == null) { continue; // Null values are not persisted } if (!isPersistable(value.getClass())) { continue; } Object value2 = IntrospectionUtils.getProperty(bean2, key); if (value.equals(value2)) { // The property has its default value continue; } if (isPrintValue(bean, bean2, key, desc)) printValue(writer, indent, key, value); } } } /** * Get all properties from ReplicationTransmitter (also dynamic properties) * * @param bean * @return List of Connector Properties * @throws IntrospectionException */ protected List getPropertyKeys(IDynamicProperty bean) throws IntrospectionException { ArrayList propertyKeys = new ArrayList(); // Acquire the list of properties for this bean PropertyDescriptor descriptors[] = Introspector.getBeanInfo( bean.getClass()).getPropertyDescriptors(); if (descriptors == null) { descriptors = new PropertyDescriptor[0]; } for (int i = 0; i < descriptors.length; i++) { if (descriptors[i] instanceof IndexedPropertyDescriptor) { continue; // Indexed properties are not persisted } if (!isPersistable(descriptors[i].getPropertyType()) || (descriptors[i].getReadMethod() == null) || (descriptors[i].getWriteMethod() == null)) { continue; // Must be a read-write primitive or String } propertyKeys.add(descriptors[i].getName()); } for (Iterator propertyIterator = bean.getPropertyNames(); propertyIterator .hasNext();) { Object key = propertyIterator.next(); if (propertyKeys.contains(key)) continue; if ("className".equals(key)) continue; propertyKeys.add(key); } return propertyKeys; } } 1.3 +1 -2 jakarta-tomcat-catalina/modules/storeconfig/test/src/share/org/apache/catalina/storeconfig/StandardHostSFTest.java Index: StandardHostSFTest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/storeconfig/test/src/share/org/apache/catalina/storeconfig/StandardHostSFTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- StandardHostSFTest.java 3 Apr 2005 16:05:10 -0000 1.2 +++ StandardHostSFTest.java 15 Apr 2005 20:14:46 -0000 1.3 @@ -198,8 +198,7 @@ public void testCluster() throws Exception { SimpleTcpCluster cluster = new SimpleTcpCluster(); cluster.setClusterName("cluster"); - cluster.setExpireSessionsOnShutdown(false); - cluster.setPrintToScreen(false); + cluster.setProperty("expireSessionsOnShutdown","false"); cluster .setManagerClassName("org.apache.catalina.cluster.session.DeltaManager"); McastService service = new McastService(); 1.3 +1 -1 jakarta-tomcat-catalina/modules/storeconfig/test/src/share/org/apache/catalina/storeconfig/StoreAppenderTest.java Index: StoreAppenderTest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/storeconfig/test/src/share/org/apache/catalina/storeconfig/StoreAppenderTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- StoreAppenderTest.java 15 Feb 2005 09:36:58 -0000 1.2 +++ StoreAppenderTest.java 15 Apr 2005 20:14:46 -0000 1.3 @@ -80,7 +80,7 @@ ReplicationTransmitter bean = new ReplicationTransmitter(); bean.setReplicationMode("asynchronous"); bean.setProperty("keepAliveTimeout","80000"); - new ReplicationTransmitterStoreAppender().printAttributes(writer, 0, true, bean, desc); + new IDynamicPropertyStoreAppender().printAttributes(writer, 0, true, bean, desc); String aspectedResult =LF.LINE_SEPARATOR + " replicationMode=\"asynchronous\"" + LF.LINE_SEPARATOR + " keepAliveTimeout=\"80000\"" ; 1.3 +1 -1 jakarta-tomcat-catalina/modules/storeconfig/test/src/share/org/apache/catalina/storeconfig/StoreLoaderTest.java Index: StoreLoaderTest.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/modules/storeconfig/test/src/share/org/apache/catalina/storeconfig/StoreLoaderTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- StoreLoaderTest.java 15 Feb 2005 09:36:58 -0000 1.2 +++ StoreLoaderTest.java 15 Apr 2005 20:14:46 -0000 1.3 @@ -81,7 +81,7 @@ assertEquals(ReplicationTransmitter.class.getName(), desc .getTagClass()); assertNotNull(desc.getStoreFactory()); - assertEquals(ReplicationTransmitterStoreAppender.class, desc.getStoreFactory().getStoreAppender().getClass() + assertEquals(IDynamicPropertyStoreAppender.class, desc.getStoreFactory().getStoreAppender().getClass() ); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]