proyal 2002/11/12 19:24:51 Added: configuration/src/java/org/apache/excalibur/configuration/validation ConfigurationValidator.java ConfigurationValidatorFactory.java DelegateEntry.java DelegatingConfigurationValidatorFactory.java JarvConfigurationValidator.java JarvConfigurationValidatorFactory.java ValidationResult.java Log: * Initial cut at factoring out configuration validation from Phoenix * DelgatingConfigurationValidatorFactory for use with multiple impls * JarvConfigurationValidatorFactory uses the JARV api to allow pluggable validators that implement the JARV api Revision Changes Path 1.1 jakarta-avalon-excalibur/configuration/src/java/org/apache/excalibur/configuration/validation/ConfigurationValidator.java Index: ConfigurationValidator.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.excalibur.configuration.validation; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.Configuration; /** * * @author <a href="[EMAIL PROTECTED]">peter royal</a> */ public interface ConfigurationValidator { /** * Check to see if configuration is feasibly valid. That is, does this configuration match * the schema in its current state, but not neccessarily fullfill the requirements of the * schema. * * Implementations are not required to support checking feasibility. If feasibility cannot * be checked, the implementation should always return true * * @param configuration Configuration to check * * @return ValidationResult containing results of validation * * @throws ConfigurationException if no schema is found */ ValidationResult isFeasiblyValid( Configuration configuration ) throws ConfigurationException; /** * Check to see if configuration is valid. * * @param configuration Configuration to check * * @return ValidationResult containing results of validation * * @throws ConfigurationException if no schema is found */ ValidationResult isValid( Configuration configuration ) throws ConfigurationException; } 1.1 jakarta-avalon-excalibur/configuration/src/java/org/apache/excalibur/configuration/validation/ConfigurationValidatorFactory.java Index: ConfigurationValidatorFactory.java =================================================================== package org.apache.excalibur.configuration.validation; import java.io.InputStream; import org.apache.avalon.framework.configuration.ConfigurationException; /** * * @author <a href="[EMAIL PROTECTED]">peter royal</a> */ public interface ConfigurationValidatorFactory { String ROLE = ConfigurationValidatorFactory.class.getName(); /** * Add configuration schema to validator * * @param application Application name * @param block Block name to store configuration for * @param url url that the schema may be located at * * @throws ConfigurationException if schema is invalid */ ConfigurationValidator createValidator( String schemaType, InputStream schema ) throws ConfigurationException; } 1.1 jakarta-avalon-excalibur/configuration/src/java/org/apache/excalibur/configuration/validation/DelegateEntry.java Index: DelegateEntry.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.excalibur.configuration.validation; import org.apache.avalon.framework.configuration.Configuration; /** * Configuration Validator entry for the DelegatingConfigurationValidator. * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Royal</a> */ class DelegateEntry { private final String m_schemaType; private final String m_className; private final Configuration m_configuration; private ConfigurationValidatorFactory m_validatorFactory; public DelegateEntry( String schemaType, String className, Configuration configuration ) { this.m_className = className; this.m_configuration = configuration; this.m_schemaType = schemaType; } public String getSchemaType() { return this.m_schemaType; } public Configuration getConfiguration() { return this.m_configuration; } public String getClassName() { return this.m_className; } public ConfigurationValidatorFactory getValidatorFactory() { return m_validatorFactory; } public void setValidatorFactory( ConfigurationValidatorFactory validatorFactory ) { m_validatorFactory = validatorFactory; } } 1.1 jakarta-avalon-excalibur/configuration/src/java/org/apache/excalibur/configuration/validation/DelegatingConfigurationValidatorFactory.java Index: DelegatingConfigurationValidatorFactory.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.excalibur.configuration.validation; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.io.InputStream; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.container.ContainerUtil; import org.apache.avalon.framework.logger.AbstractLogEnabled; /** * Default ConfigurationValidator implementation that allows schemas to be plugged-in * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Royal</a> */ public class DelegatingConfigurationValidatorFactory extends AbstractLogEnabled implements Configurable, Initializable, Disposable, ConfigurationValidatorFactory { private Map m_delegates = new HashMap(); private String m_supportedTypes; public void configure( Configuration configuration ) throws ConfigurationException { final Configuration[] delegates = configuration.getChildren( "delegate" ); final StringBuffer types = new StringBuffer(); for( int i = 0; i < delegates.length; i++ ) { final String type = delegates[i].getAttribute( "schema-type" ); this.m_delegates.put( type, new DelegateEntry( type, delegates[i].getAttribute( "class" ), delegates[i] ) ); if( i > 0 ) { types.append( "," ); } types.append( type ); } this.m_supportedTypes = types.toString(); } public void initialize() throws Exception { for( Iterator i = m_delegates.values().iterator(); i.hasNext(); ) { final DelegateEntry entry = (DelegateEntry)i.next(); final Class clazz = Class.forName( entry.getClassName() ); final ConfigurationValidatorFactory validator = (ConfigurationValidatorFactory)clazz.newInstance(); ContainerUtil.enableLogging( validator, getLogger() ); ContainerUtil.configure( validator, entry.getConfiguration() ); ContainerUtil.initialize( validator ); entry.setValidatorFactory( validator ); } } public void dispose() { for( Iterator i = m_delegates.values().iterator(); i.hasNext(); ) { ContainerUtil.dispose( ( (DelegateEntry)i.next() ).getValidatorFactory() ); } } public ConfigurationValidator createValidator( String schemaType, InputStream schema ) throws ConfigurationException { final DelegateEntry entry = (DelegateEntry)this.m_delegates.get( schemaType ); if( entry == null ) { final String msg = "Invalid schema type: " + schemaType + ". Validator only supports: " + m_supportedTypes; throw new ConfigurationException( msg ); } return entry.getValidatorFactory().createValidator( schemaType, schema ); } } 1.1 jakarta-avalon-excalibur/configuration/src/java/org/apache/excalibur/configuration/validation/JarvConfigurationValidator.java Index: JarvConfigurationValidator.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.excalibur.configuration.validation; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.DefaultConfigurationSerializer; import org.apache.excalibur.configuration.ConfigurationUtil; import org.iso_relax.verifier.Schema; import org.iso_relax.verifier.Verifier; import org.iso_relax.verifier.VerifierHandler; import org.iso_relax.verifier.VerifierConfigurationException; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXParseException; import org.xml.sax.SAXException; /** * * @author <a href="[EMAIL PROTECTED]">peter royal</a> */ public class JarvConfigurationValidator implements ConfigurationValidator { private final DefaultConfigurationSerializer m_serializer = new DefaultConfigurationSerializer(); private final Logger m_logger; private final Schema m_schema; public JarvConfigurationValidator( Logger logger, Schema schema ) { m_logger = logger; m_schema = schema; } public ValidationResult isFeasiblyValid( Configuration configuration ) throws ConfigurationException { final ValidationResult result = new ValidationResult(); result.setResult( true ); return result; } public ValidationResult isValid( Configuration configuration ) throws ConfigurationException { final ValidationResult result = new ValidationResult(); final Configuration branched = ConfigurationUtil.branch( configuration, "root" ); try { final Verifier verifier = m_schema.newVerifier(); final VerifierHandler handler = verifier.getVerifierHandler(); verifier.setErrorHandler( new ErrorHandler() { public void warning( SAXParseException exception ) throws SAXException { result.addWarning( exception.getMessage() ); } public void error( SAXParseException exception ) throws SAXException { result.addError( exception.getMessage() ); } public void fatalError( final SAXParseException exception ) throws SAXException { result.addError( exception.getMessage() ); } } ); m_serializer.serialize( handler, branched ); result.setResult( handler.isValid() ); return result; } catch( final VerifierConfigurationException e ) { final String message = "Unable to verify configuration"; throw new ConfigurationException( message, e ); } catch( final SAXException e ) { final String message = "Unable to parse configuration"; throw new ConfigurationException( message, e ); } catch( final IllegalStateException e ) { final String message = "Unable to parse configuration"; throw new ConfigurationException( message, e ); } } } 1.1 jakarta-avalon-excalibur/configuration/src/java/org/apache/excalibur/configuration/validation/JarvConfigurationValidatorFactory.java Index: JarvConfigurationValidatorFactory.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 1997-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software * itself, if and wherever such third-party acknowledgments * normally appear. * * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation" * must not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.excalibur.configuration.validation; import java.io.InputStream; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.iso_relax.verifier.VerifierConfigurationException; import org.iso_relax.verifier.VerifierFactory; import org.xml.sax.SAXParseException; /** * A validator that is capable of validating any schema supported by the JARV * engine. <a href="http://iso-relax.sourceforge.net/">http://iso-relax.sourceforge.net/</a> * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Royal</a> */ public class JarvConfigurationValidatorFactory extends AbstractLogEnabled implements Configurable, Initializable, ConfigurationValidatorFactory { private String m_schemaType; private String m_schemaLanguage; private String m_verifierFactoryClass; private VerifierFactory m_verifierFactory; /** * There are two possible configuration options for this class. They are mutually exclusive. * <ol> * <li><schema-language><i>schema language uri</i></schema-language></li> * <li><verifier-factory-class><i>classname</i></verifier-factory-class><br> * The fully-qualified classname to use as a verifier factory. * </li> * </ol> * * @see http://iso-relax.sourceforge.net/apiDoc/org/iso_relax/verifier/VerifierFactory.html#newInstance(java.lang.String) */ public void configure( Configuration configuration ) throws ConfigurationException { m_schemaType = configuration.getAttribute( "schema-type" ); m_schemaLanguage = configuration.getChild( "schema-language" ).getValue( null ); m_verifierFactoryClass = configuration.getChild( "verifier-factory-class" ).getValue( null ); if( ( null == m_schemaLanguage && null == m_verifierFactoryClass ) || ( null != m_schemaLanguage && null != m_verifierFactoryClass ) ) { final String msg = "Must specify either schema-language or verifier-factory-class"; throw new ConfigurationException( msg ); } } public void initialize() throws Exception { if( null != m_schemaLanguage ) { m_verifierFactory = VerifierFactory.newInstance( m_schemaLanguage ); } else if( null != m_verifierFactoryClass ) { m_verifierFactory = (VerifierFactory)Class.forName( m_verifierFactoryClass ).newInstance(); } } public ConfigurationValidator createValidator( String schemaType, InputStream schema ) throws ConfigurationException { if( !m_schemaType.equals( schemaType ) ) { final String msg = "Invalid schema type: " + schemaType + ". Validator only supports " + m_schemaType; throw new ConfigurationException( msg ); } try { return new JarvConfigurationValidator( getLogger(), m_verifierFactory.compileSchema( schema ) ); } catch( VerifierConfigurationException e ) { final String msg = "Unable to create schema"; throw new ConfigurationException( msg, e ); } catch( SAXParseException e ) { final String msg = "Unable to parse schema [line: " + e.getLineNumber() + ", column: " + e.getColumnNumber() + ", msg: " + e.getMessage() + "]"; throw new ConfigurationException( msg, e ); } catch( Exception e ) { final String msg = "Unable to parse schema [url: " + schema + ", msg: " + e.getMessage() + "]"; throw new ConfigurationException( msg, e ); } } } 1.1 jakarta-avalon-excalibur/configuration/src/java/org/apache/excalibur/configuration/validation/ValidationResult.java Index: ValidationResult.java =================================================================== package org.apache.excalibur.configuration.validation; import java.util.ArrayList; import java.util.List; /** * * @author <a href="[EMAIL PROTECTED]">peter royal</a> */ public final class ValidationResult { private final List m_warnings = new ArrayList( 16 ); private final List m_errors = new ArrayList( 16 ); private boolean m_valid; private boolean m_readOnly; public void addWarning( final String warning ) { checkWriteable(); m_warnings.add( warning ); } public void addError( final String error ) { checkWriteable(); m_errors.add( error ); } public void setResult( final boolean valid ) { checkWriteable(); m_valid = valid; m_readOnly = true; } public List getWarnings() { return m_warnings; } public List getErrors() { return m_errors; } public boolean isValid() { return m_valid; } protected final void checkWriteable() throws IllegalStateException { if( m_readOnly ) { throw new IllegalStateException( "ValidationResult is read only " + "and can not be modified" ); } } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>