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

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb DescriptorHandler.java

conor       01/06/27 06:10:00

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/ejb
                        DescriptorHandler.java
  Log:
  Allow DTD locations to be URLs effectvely mapping the URLs
  
  Submitted by:	Benoit MOUSSAUD <be...@criltelecom.com>
  
  Revision  Changes    Path
  1.10      +26 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
  
  Index: DescriptorHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DescriptorHandler.java	2001/06/25 15:17:28	1.9
  +++ DescriptorHandler.java	2001/06/27 13:09:58	1.10
  @@ -56,6 +56,7 @@
   
   import java.util.*;
   import java.io.*;
  +import java.net.*;
   
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
  @@ -129,6 +130,8 @@
       
       private Hashtable resourceDTDs = new Hashtable();
   
  +    private Hashtable urlDTDs = new Hashtable();
  +
       /**
        * The directory containing the bean classes and interfaces. This is 
        * used for performing dependency file lookups.
  @@ -160,6 +163,16 @@
                   owningTask.log("Mapped publicId " + publicId + " to resource " + location, Project.MSG_VERBOSE);
               }
           }
  +
  +        try {
  +            if (publicId != null) {
  +                URL urldtd = new URL(location);
  +                urlDTDs.put(publicId, urldtd);
  +            }            
  +        } catch ( java.net.MalformedURLException   e) {
  +            //ignored
  +        } 
  +        
       }
   
       public InputSource resolveEntity(String publicId, String systemId)
  @@ -180,12 +193,23 @@
           String dtdResourceName = (String)resourceDTDs.get(publicId); 
           if (dtdResourceName != null) {
               InputStream is = this.getClass().getResourceAsStream(dtdResourceName);
  -            if( is != null ) {
  +            if (is != null) {
                   owningTask.log("Resolved " + publicId + " to local resource " + dtdResourceName, Project.MSG_VERBOSE);
                   return new InputSource(is);
               }
           }
  -        
  +
  +        URL dtdUrl = (URL) urlDTDs.get(publicId);
  +        if ( dtdUrl != null ) {
  +            try {
  +                InputStream is = dtdUrl.openStream();
  +                owningTask.log("Resolved " + publicId + " to url " + dtdUrl, Project.MSG_VERBOSE);
  +                return new InputSource(is);
  +            } catch ( IOException ioe) {
  +                //ignore
  +            }            
  +        } 
  +                
           owningTask.log("Could not resolve ( publicId: " + publicId + ", systemId: " + systemId + ") to a local entity", 
                           Project.MSG_INFO);