You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by do...@apache.org on 2001/06/05 09:49:10 UTC

cvs commit: jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer DefaultRoleManager.java Deployment.java

donaldp     01/06/05 00:49:10

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer
                        DefaultRoleManager.java Deployment.java
  Log:
  Update to work with JAXP1.1 rather than SAX2 mechanisms.
  
  Revision  Changes    Path
  1.4       +16 -6     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultRoleManager.java
  
  Index: DefaultRoleManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/DefaultRoleManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultRoleManager.java	2001/06/04 12:42:38	1.3
  +++ DefaultRoleManager.java	2001/06/05 07:49:08	1.4
  @@ -10,17 +10,20 @@
   import java.net.URL;
   import java.util.Enumeration;
   import java.util.HashMap;
  +import javax.xml.parsers.SAXParser;
  +import javax.xml.parsers.SAXParserFactory;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  -import org.xml.sax.InputSource;
  +import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
  +import org.xml.sax.SAXException;
  +import org.xml.sax.XMLReader;
   
   /**
    * Interface to manage roles and mapping to names.
    *
    * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/06/04 12:42:38 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/06/05 07:49:08 $
    */
   public class DefaultRoleManager
       implements RoleManager, Initializable
  @@ -64,14 +67,21 @@
       public void initialize()
           throws Exception
       {
  -        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  +        final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
  +        final SAXParser saxParser = saxParserFactory.newSAXParser();
  +        final XMLReader parser = saxParser.getXMLReader();
  +        //parser.setFeature( "http://xml.org/sax/features/namespace-prefixes", false );
  +
  +        final SAXConfigurationHandler handler = new SAXConfigurationHandler();
  +        parser.setContentHandler( handler );
  +        parser.setErrorHandler( handler );
   
           final Enumeration enum = getClass().getClassLoader().getResources( ROLE_DESCRIPTOR );
           while( enum.hasMoreElements() )
           {
               final URL url = (URL)enum.nextElement();
  -            final Configuration descriptor = builder.build( new InputSource( url.toString() ) );
  -            handleDescriptor( descriptor );
  +            parser.parse( url.toString() );
  +            handleDescriptor( handler.getConfiguration() );
           }
       }
   
  
  
  
  1.3       +18 -7     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/Deployment.java
  
  Index: Deployment.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/components/deployer/Deployment.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Deployment.java	2001/06/04 12:41:36	1.2
  +++ Deployment.java	2001/06/05 07:49:08	1.3
  @@ -11,11 +11,14 @@
   import java.net.URL;
   import java.net.MalformedURLException;
   import java.io.IOException;
  +import javax.xml.parsers.SAXParser;
  +import javax.xml.parsers.SAXParserFactory;
  +import javax.xml.parsers.ParserConfigurationException;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
  +import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
   import org.xml.sax.SAXException;
  -import org.xml.sax.InputSource;
  +import org.xml.sax.XMLReader;
   
   /**
    * This class deploys a .tsk file into a registry.
  @@ -61,19 +64,27 @@
       {
           final String systemID = "jar:" + getURL() + "!/" + TSKDEF_FILE;
   
  -        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
  -
           try
           {
  -            return builder.build( new InputSource( systemID ) ); 
  +            final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
  +            final SAXParser saxParser = saxParserFactory.newSAXParser();
  +            final XMLReader parser = saxParser.getXMLReader();
  +            //parser.setFeature( "http://xml.org/sax/features/namespace-prefixes", false );
  +
  +            final SAXConfigurationHandler handler = new SAXConfigurationHandler();
  +            parser.setContentHandler( handler );
  +            parser.setErrorHandler( handler );
  +
  +            parser.parse( systemID );
  +            return handler.getConfiguration();
           }
           catch( final SAXException se )
           {
               throw new DeploymentException( "Malformed configuration data", se );
           }
  -        catch( final ConfigurationException ce )
  +        catch( final ParserConfigurationException pce )
           {
  -            throw new DeploymentException( "Error building configuration", ce );
  +            throw new DeploymentException( "Error configuring parser", pce );
           }
           catch( final IOException ioe )
           {