org.jboss.metadata
Class XmlFileLoader

java.lang.Object
  extended by org.jboss.metadata.XmlFileLoader

public class XmlFileLoader
extends Object

XmlFileLoader class is used to read ejb-jar.xml, standardjboss.xml, jboss.xml files, process them using DTDs and create ApplicationMetaData object for future use. It also provides the local entity resolver for the JBoss specific DTDs.

Version:
$Revision: 1.47.4.3 $
Author:
Bill Burke, Sebastien Alborini, Wolfgang Werner, Darius Davidavicius, Scott Stark, Christoph G. Jung.

Constructor Summary
XmlFileLoader()
           
XmlFileLoader(boolean validateDTDs)
           
 
Method Summary
 ClassLoader getClassLoader()
          Gets the class loader
static boolean getDefaultValidateDTDs()
           
 Document getDocument(InputSource is, String inPath)
          Parses the xml document in is to create a DOM Document.
 Document getDocument(InputStream is, String inPath)
          Parses the xml document in is to create a DOM Document.
static Document getDocument(URL url)
          Invokes getDocument(url, defaultValidateDTDs)
static Document getDocument(URL url, boolean validateDTDs)
          Get the xml file from the URL and parse it into a Document object.
 Document getDocumentFromURL(URL url)
          Get the xml file from the URL and parse it into a Document object.
 ApplicationMetaData getMetaData()
           
 boolean getValidateDTDs()
          Get the flag indicating that ejb-jar.dtd, jboss.dtd & jboss-web.dtd conforming documents should be validated against the DTD.
 ApplicationMetaData load(URL alternativeDD)
          Creates the ApplicationMetaData.
 void setClassLoader(URLClassLoader cl)
          Set the class loader
static void setDefaultValidateDTDs(boolean validate)
           
 void setValidateDTDs(boolean validate)
          Set the flag indicating that ejb-jar.dtd, jboss.dtd & jboss-web.dtd conforming documents should be validated against the DTD.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlFileLoader

public XmlFileLoader()

XmlFileLoader

public XmlFileLoader(boolean validateDTDs)
Method Detail

getDefaultValidateDTDs

public static boolean getDefaultValidateDTDs()

setDefaultValidateDTDs

public static void setDefaultValidateDTDs(boolean validate)

getMetaData

public ApplicationMetaData getMetaData()

setClassLoader

public void setClassLoader(URLClassLoader cl)
Set the class loader


getClassLoader

public ClassLoader getClassLoader()
Gets the class loader

Returns:
ClassLoader - the class loader

getValidateDTDs

public boolean getValidateDTDs()
Get the flag indicating that ejb-jar.dtd, jboss.dtd & jboss-web.dtd conforming documents should be validated against the DTD.


setValidateDTDs

public void setValidateDTDs(boolean validate)
Set the flag indicating that ejb-jar.dtd, jboss.dtd & jboss-web.dtd conforming documents should be validated against the DTD.


load

public ApplicationMetaData load(URL alternativeDD)
                         throws Exception
Creates the ApplicationMetaData. The configuration files are found in the classLoader when not explicitly given as the alternativeDD. The default jboss.xml and jaws.xml files are always read first, then we override the defaults if the user provides them

Parameters:
alternativeDD - a URL to the alternative DD given in application.xml
Throws:
Exception

getDocument

public static Document getDocument(URL url)
                            throws org.jboss.deployment.DeploymentException
Invokes getDocument(url, defaultValidateDTDs)

Throws:
org.jboss.deployment.DeploymentException

getDocument

public static Document getDocument(URL url,
                                   boolean validateDTDs)
                            throws org.jboss.deployment.DeploymentException
Get the xml file from the URL and parse it into a Document object. Calls new XmlFileLoader(validateDTDs).getDocumentFromURL(url);

Parameters:
url - the URL from which the xml doc is to be obtained.
Returns:
Document
Throws:
org.jboss.deployment.DeploymentException

getDocumentFromURL

public Document getDocumentFromURL(URL url)
                            throws org.jboss.deployment.DeploymentException
Get the xml file from the URL and parse it into a Document object. Calls getDocument(new InputSource(url.openStream()), url.getPath()) with the InputSource.SystemId set to url.toExternalForm().

Parameters:
url - the URL from which the xml doc is to be obtained.
Returns:
Document
Throws:
org.jboss.deployment.DeploymentException

getDocument

public Document getDocument(InputStream is,
                            String inPath)
                     throws org.jboss.deployment.DeploymentException
Parses the xml document in is to create a DOM Document. DTD validation is enabled if validateDTDs is true and we install an EntityResolver and ErrorHandler to resolve J2EE DTDs and handle errors. We also create an InputSource for the InputStream and set the SystemId URI to the inPath value. This allows relative entity references to be resolved against the inPath URI. The is argument will be closed.

Parameters:
is - the InputStream containing the xml descriptor to parse
inPath - the path information for the xml doc. This is used as the InputSource SystemId URI for resolving relative entity references.
Returns:
Document
Throws:
org.jboss.deployment.DeploymentException

getDocument

public Document getDocument(InputSource is,
                            String inPath)
                     throws org.jboss.deployment.DeploymentException
Parses the xml document in is to create a DOM Document. DTD validation is enabled if validateDTDs is true and we install an EntityResolver and ErrorHandler to resolve J2EE DTDs and handle errors. We also create an InputSource for the InputStream and set the SystemId URI to the inPath value. This allows relative entity references to be resolved against the inPath URI.

Parameters:
is - the InputSource containing the xml descriptor to parse
inPath - the path information for the xml doc. This is used for only for error reporting.
Returns:
Document
Throws:
org.jboss.deployment.DeploymentException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.