avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pro...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/configuration/validator JarvConfigurationValidator.java
Date Tue, 16 Jul 2002 17:54:13 GMT
proyal      2002/07/16 10:54:13

  Modified:    src/java/org/apache/avalon/phoenix/components/configuration/validator
                        JarvConfigurationValidator.java
  Log:
  Added config option to specify a path to serialize
  configurations out to for debugging.
  
  Revision  Changes    Path
  1.3       +37 -0     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/configuration/validator/JarvConfigurationValidator.java
  
  Index: JarvConfigurationValidator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/configuration/validator/JarvConfigurationValidator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JarvConfigurationValidator.java	15 Jul 2002 16:17:46 -0000	1.2
  +++ JarvConfigurationValidator.java	16 Jul 2002 17:54:13 -0000	1.3
  @@ -7,6 +7,7 @@
    */
   package org.apache.avalon.phoenix.components.configuration.validator;
   
  +import java.io.File;
   import java.util.Collections;
   import java.util.HashMap;
   import java.util.Map;
  @@ -17,6 +18,7 @@
   
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.excalibur.io.FileUtil;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
  @@ -47,6 +49,7 @@
       private String m_schemaType;
       private String m_schemaLanguage;
       private String m_verifierFactoryClass;
  +    private String m_debugPath;
   
       private final DefaultConfigurationSerializer m_serializer =
           new DefaultConfigurationSerializer();
  @@ -68,6 +71,7 @@
       public void configure( Configuration configuration )
           throws ConfigurationException
       {
  +        this.m_debugPath = configuration.getChild( "debug-output-path" ).getValue( null
);
           this.m_schemaType = configuration.getAttribute( "schema-type" );
           this.m_schemaLanguage = configuration.getChild( "schema-language" ).getValue( null
);
           this.m_verifierFactoryClass =
  @@ -92,6 +96,13 @@
               this.m_verifierFactory =
                   ( VerifierFactory ) Class.forName( this.m_verifierFactoryClass ).newInstance();
           }
  +
  +        if( null != this.m_debugPath )
  +        {
  +            FileUtil.forceMkdir( new File( m_debugPath ) );
  +        }
  +
  +        this.m_serializer.setIndent( true );
       }
   
       private String createKey( String application, String block )
  @@ -163,6 +174,11 @@
               throw new ConfigurationException( msg );
           }
   
  +        if( null != this.m_debugPath )
  +        {
  +            writeDebugConfiguration( application, block, configuration );
  +        }
  +
           try
           {
               final Verifier verifier = schema.newVerifier();
  @@ -221,6 +237,27 @@
               final String msg = REZ.getString( "jarv.valid.badparse", application, block
);
   
               throw new ConfigurationException( msg, e );
  +        }
  +    }
  +
  +    private void writeDebugConfiguration( final String application,
  +                                          final String block,
  +                                          final Configuration configuration )
  +    {
  +        try
  +        {
  +            final File temp = File.createTempFile( application + "-" + block + "-",
  +                                                   ".xml",
  +                                                   new File( this.m_debugPath ) );
  +
  +            this.m_serializer.serializeToFile( temp, configuration );
  +
  +            if( getLogger().isDebugEnabled() )
  +                getLogger().debug( "Configuration written at: " + temp );
  +        }
  +        catch( Exception e )
  +        {
  +            getLogger().error( "Unable to write debug output", e );
           }
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message