User: luke_t  
  Date: 02/01/05 19:28:55

  Modified:    src/main/org/jboss/metadata Tag: Branch_2_4
                        XmlFileLoader.java
  Log:
  Added logging of exceptions thrown during getDocument(), to enable stacktrace to be 
obtained.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.15.2.5  +43 -42    jboss/src/main/org/jboss/metadata/XmlFileLoader.java
  
  Index: XmlFileLoader.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/metadata/XmlFileLoader.java,v
  retrieving revision 1.15.2.4
  retrieving revision 1.15.2.5
  diff -u -r1.15.2.4 -r1.15.2.5
  --- XmlFileLoader.java        2001/12/10 02:52:03     1.15.2.4
  +++ XmlFileLoader.java        2002/01/06 03:28:55     1.15.2.5
  @@ -37,7 +37,7 @@
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Wolfgang Werner</a>
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Darius Davidavicius</a>
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Scott Stark</a>
  - *   @version $Revision: 1.15.2.4 $
  + *   @version $Revision: 1.15.2.5 $
    *
    *   Revisions:
    *   20010620 Bill Burke: Print an error message when failing to load 
standardjboss.xml
  @@ -48,13 +48,13 @@
   {
      private static Logger log = Logger.getLogger(XmlFileLoader.class);
      // Constants -----------------------------------------------------
  -   
  +
      // Attributes ----------------------------------------------------
      private static boolean defaultValidateDTDs = false;
      private ClassLoader classLoader;
      private ApplicationMetaData metaData;
      private boolean validateDTDs;
  -   
  +
      // Static --------------------------------------------------------
      public static boolean getDefaultValidateDTDs()
      {
  @@ -64,7 +64,7 @@
      {
         defaultValidateDTDs = validate;
      }
  -   
  +
      // Constructors --------------------------------------------------
      public XmlFileLoader()
      {
  @@ -74,13 +74,13 @@
      {
         this.validateDTDs = validateDTDs;
      }
  -   
  +
      // Public --------------------------------------------------------
      public ApplicationMetaData getMetaData()
      {
         return metaData;
      }
  -   
  +
      /**
       Set the class loader
       @param ClassLoader cl - class loader
  @@ -89,7 +89,7 @@
      {
         classLoader = cl;
      }
  -   
  +
      /**
       Gets the class loader
       @return ClassLoader - the class loader
  @@ -98,7 +98,7 @@
      {
         return classLoader;
      }
  -   
  +
      /** Get the flag indicating that ejb-jar.dtd, jboss.dtd &
       jboss-web.dtd conforming documents should be validated
       against the DTD.
  @@ -115,7 +115,7 @@
      {
         this.validateDTDs = validate;
      }
  -   
  +
      /**
       * load()
       *
  @@ -129,40 +129,40 @@
      {
         // create the metadata
         metaData = new ApplicationMetaData();
  -      
  +
         // Load ejb-jar.xml
  -      
  +
         // we can always find the files in the classloader
         URL ejbjarUrl = getClassLoader().getResource("META-INF/ejb-jar.xml");
  -      
  +
         if (ejbjarUrl == null)
         {
            throw new DeploymentException("no ejb-jar.xml found");
         }
  -      
  +
         Document ejbjarDocument = getDocumentFromURL(ejbjarUrl);
  -      
  +
         // the url may be used to report errors
         metaData.setUrl(ejbjarUrl);
         metaData.importEjbJarXml(ejbjarDocument.getDocumentElement());
  -      
  +
         // Load jbossdefault.xml from the default classLoader
         // we always load defaults first
         // we use the context classloader, because this guy has to know where
         // this file is
         URL defaultJbossUrl = 
Thread.currentThread().getContextClassLoader().getResource("standardjboss.xml");
  -      
  +
         if (defaultJbossUrl == null)
         {
            throw new DeploymentException("no standardjboss.xml found");
         }
  -      
  +
         Document defaultJbossDocument = null;
  -      
  +
         try
         {
            defaultJbossDocument = getDocumentFromURL(defaultJbossUrl);
  -         
  +
            metaData.setUrl(defaultJbossUrl);
            metaData.importJbossXml(defaultJbossDocument.getDocumentElement());
         }
  @@ -176,12 +176,12 @@
         try
         {
            URL jbossUrl = getClassLoader().getResource("META-INF/jboss.xml");
  -         
  +
            if (jbossUrl != null)
            {
               //                       Logger.debug(jbossUrl.toString() + " found. 
Overriding defaults");
               Document jbossDocument = getDocumentFromURL(jbossUrl);
  -            
  +
               metaData.setUrl(jbossUrl);
               metaData.importJbossXml(jbossDocument.getDocumentElement());
            }
  @@ -191,10 +191,10 @@
            log.error("failed to load jboss.xml.  There could be a syntax error.");
            throw ex;
         }
  -      
  +
         return metaData;
      }
  -   
  +
      /** Invokes getDocument(url, defaultValidateDTDs)
       */
      public static Document getDocument(URL url) throws DeploymentException
  @@ -211,7 +211,7 @@
         XmlFileLoader loader = new XmlFileLoader(validateDTDs);
         return loader.getDocumentFromURL(url);
      }
  -   
  +
      /** Get the xml file from the URL and parse it into a Document object.
       Calls getDocument(url.openStream(), url.getPath());
       @param url, the URL from which the xml doc is to be obtained.
  @@ -229,7 +229,7 @@
            throw new DeploymentException("Failed to obtain xml doc from URL", e);
         }
      }
  -   
  +
      /** Parses the xml document in is and created the DOM Document. DTD validation
       is enabled if validateDTDs is true and we install an EntityResolver and
       ErrorHandler to resolve J2EE DTDs and handle errors.
  @@ -246,12 +246,12 @@
            // Enable DTD validation based on our validateDTDs flag
            docBuilderFactory.setValidating(validateDTDs);
            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
  -         
  +
            LocalResolver lr = new LocalResolver();
            ErrorHandler eh = new LocalErrorHandler( inPath, lr );
            docBuilder.setEntityResolver(lr);
            docBuilder.setErrorHandler(eh );
  -         
  +
            Document doc = docBuilder.parse(is);
            return doc;
         }
  @@ -267,17 +267,18 @@
         }
         catch (Exception e)
         {
  +         log.warn("Unexpected exception while attempting to parse document ", e);
            throw new DeploymentException(e.getMessage(), e);
         }
      }
  -   
  +
      // Package protected ---------------------------------------------
  -   
  +
      // Protected -----------------------------------------------------
  -   
  -   
  +
  +
      // Private -------------------------------------------------------
  -   
  +
      // Inner classes -------------------------------------------------
      /**
       * Local entity resolver to handle J2EE DTDs. With this a http connection
  @@ -291,7 +292,7 @@
      {
         private Hashtable dtds = new Hashtable();
         private boolean hasDTD = false;
  -      
  +
         public LocalResolver()
         {
            registerDTD("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN", 
"ejb-jar.dtd");
  @@ -303,7 +304,7 @@
            registerDTD("-//JBoss//DTD JBOSS//EN","jboss.dtd");
            registerDTD("-//JBoss//DTD JBOSS 2.4//EN","jboss_2_4.dtd");
         }
  -      
  +
         /**
          Registers available DTDs
          @param String publicId    - Public ID of DTD
  @@ -313,7 +314,7 @@
         {
            dtds.put(publicId, dtdFileName);
         }
  -      
  +
         /**
          Returns DTD inputSource. Is DTD was found in the hashtable and inputSource 
was created
          flad hasDTD is ser to true.
  @@ -325,7 +326,7 @@
         {
            hasDTD = false;
            String dtd = (String)dtds.get(publicId);
  -         
  +
            if (dtd != null)
            {
               hasDTD = true;
  @@ -341,7 +342,7 @@
            }
            return null;
         }
  -      
  +
         /**
          Returns the boolean value to inform id DTD was found in the XML file or not
          @return boolean - true if DTD was found in XML
  @@ -350,9 +351,9 @@
         {
            return hasDTD;
         }
  -      
  +
      }
  -   
  +
      /** Local error handler for entity resolver to DocumentBuilder parser.
       Error is printed to output just if DTD was detected in the XML file.
       If DTD was not found in XML file it is assumed that the EJB builder
  @@ -372,7 +373,7 @@
            this.theFileName = inFileName;
            this.localResolver = localResolver;
         }
  -      
  +
         public void error(SAXParseException exception)
         {
            if ( localResolver.hasDTD() )
  @@ -413,10 +414,10 @@
            }//end if
         }
      }// end class LocalErrorHandler
  -   
  +
   }
   /* Change log:
  - 
  +
    * Author: starksm, Date: Thu Jun 14 17:14:14  2001 GMT
    Incorporated Darius Davidavicius changes to support DTD validation.
    */
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to