User: mulder
Date: 00/10/24 16:16:28
Modified: src/main/org/jboss/metadata XmlFileLoader.java
Log:
Move the standardjboss.xml and standardjaws.xml files to the conf
directory. This make it much easier to change global defaults
(such as the JRMP JDK version, optimizations, RMI port, etc.)
Add the RMI port option to standardjboss.xml
Revision Changes Path
1.6 +29 -29 jboss/src/main/org/jboss/metadata/XmlFileLoader.java
Index: XmlFileLoader.java
===================================================================
RCS file: /products/cvs/ejboss/jboss/src/main/org/jboss/metadata/XmlFileLoader.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XmlFileLoader.java 2000/09/28 01:17:09 1.5
+++ XmlFileLoader.java 2000/10/24 23:16:27 1.6
@@ -30,7 +30,7 @@
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Sebastien Alborini</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Wolfgang Werner</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class XmlFileLoader {
// Constants -----------------------------------------------------
@@ -39,7 +39,7 @@
ClassLoader classLoader;
ApplicationMetaData metaData;
-
+
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
@@ -50,7 +50,7 @@
public ApplicationMetaData getMetaData() {
return metaData;
}
-
+
public void setClassLoader(ClassLoader cl) {
classLoader = cl;
}
@@ -62,58 +62,58 @@
/**
* load()
*
- * This method creates the ApplicationMetaData.
+ * This method creates the ApplicationMetaData.
* The configuration files are found in the classLoader.
- * The default jboss.xml and jaws.xml files are always read first, then we
override
+ * The default jboss.xml and jaws.xml files are always read first, then we
override
* the defaults if the user provides them
*
*/
public ApplicationMetaData load() throws Exception {
// 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");
}
-
+
Logger.debug("Loading ejb-jar.xml : " + ejbjarUrl.toString());
Document ejbjarDocument = getDocument(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
- URL defaultJbossUrl = getClass().getResource("standardjboss.xml");
-
+ URL defaultJbossUrl =
getClassLoader().getResource("standardjboss.xml");
+
if (defaultJbossUrl == null) {
throw new DeploymentException("no standardjboss.xml found");
}
-
+
Logger.debug("Loading standardjboss.xml : " +
defaultJbossUrl.toString());
Document defaultJbossDocument = getDocument(defaultJbossUrl);
-
+
metaData.setUrl(defaultJbossUrl);
metaData.importJbossXml(defaultJbossDocument.getDocumentElement());
-
+
// Load jboss.xml
// if this file is provided, then we override the defaults
URL jbossUrl = getClassLoader().getResource("META-INF/jboss.xml");
-
+
if (jbossUrl != null) {
Logger.debug(jbossUrl.toString() + " found. Overriding
defaults");
Document jbossDocument = getDocument(jbossUrl);
-
+
metaData.setUrl(jbossUrl);
metaData.importJbossXml(jbossDocument.getDocumentElement());
- }
-
+ }
+
return metaData;
}
@@ -124,18 +124,18 @@
try {
Reader in = new InputStreamReader(url.openStream());
com.sun.xml.tree.XmlDocumentBuilder xdb = new
com.sun.xml.tree.XmlDocumentBuilder();
-
+
Parser parser = new com.sun.xml.parser.Parser();
-
+
// Use a local entity resolver to get rid of the DTD loading
via internet
EntityResolver er = new LocalResolver();
parser.setEntityResolver(er);
xdb.setParser(parser);
-
+
parser.parse(new InputSource(in));
return xdb.getDocument();
- } catch (Exception e) {
- throw new DeploymentException(e.getMessage());
+ } catch (Exception e) {
+ throw new DeploymentException(e.getMessage());
}
}
@@ -149,18 +149,18 @@
**/
private static class LocalResolver implements EntityResolver {
private Hashtable dtds = new Hashtable();
-
+
public LocalResolver() {
registerDTD("-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 1.1//EN", "ejb-jar.dtd");
}
-
+
public void registerDTD(String publicId, String dtdFileName) {
dtds.put(publicId, dtdFileName);
}
public InputSource resolveEntity (String publicId, String systemId) {
String dtd = (String)dtds.get(publicId);
-
+
if (dtd != null) {
try {
InputStream dtdStream =
getClass().getResourceAsStream(dtd);
@@ -172,5 +172,5 @@
return null;
}
}
-
+
}