User: juha
Date: 00/07/22 00:13:45
Modified: src/main/org/jboss/metadata/ejbjar EJBXMLReader.java
Log:
Warnings are collected to a list and printed after parse, and
SAXExceptions are no longer thrown if classloader fails.
Revision Changes Path
1.4 +41 -6 jboss/src/main/org/jboss/metadata/ejbjar/EJBXMLReader.java
Index: EJBXMLReader.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/metadata/ejbjar/EJBXMLReader.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EJBXMLReader.java 2000/07/18 19:35:07 1.3
+++ EJBXMLReader.java 2000/07/22 07:13:44 1.4
@@ -21,6 +21,12 @@
private Vector methods = new Vector();
private ClassLoader loader;
+ /*
+ * Contains the list of warnings generated by the SAX parser.
+ */
+ private List warningList = new LinkedList();
+
+
public EJBXMLReader() {
}
@@ -38,6 +44,15 @@
InputSource is = new InputSource(input);
try {
parser.parse(is);
+
+ Iterator it = warningList.iterator();
+
+ while (it.hasNext()) {
+ System.out.println("Warning : " + (String)it.next());
+ }
+
+ warningList.clear();
+
} catch(SAXException e) {
e.printStackTrace();
throw new IOException(e.getMessage());
@@ -46,6 +61,8 @@
return server;
}
+
+
public void startDocument() throws SAXException {
}
@@ -152,7 +169,7 @@
bean.homeClass = loadClass(contents);
}
catch(ClassNotFoundException e) {
- throw new SAXException("Unable to locate class '"+contents+"'");
+ addWarning("Unable to locate class '"+contents+"'");
}
}
}
@@ -170,7 +187,7 @@
bean.remoteClass = loadClass(contents);
}
catch(ClassNotFoundException e) {
- throw new SAXException("Unable to locate class '"+contents+"'");
+ addWarning("Unable to locate class '"+contents+"'");
}
}
}
@@ -179,7 +196,7 @@
try {
bean.implementationClass = loadClass(contents);
} catch(ClassNotFoundException e) {
- throw new SAXException("Unable to locate class '"+contents+"'");
+ addWarning("Unable to locate class '"+contents+"'");
}
else if(name.equals("prim-key-class"))
@@ -189,7 +206,7 @@
else
bean.primaryKeyClass = loadClass(contents);
} catch(ClassNotFoundException e) {
- throw new SAXException("Unable to locate class '"+contents+"'");
+ addWarning("Unable to locate class '"+contents+"'");
}
else if(name.equals("persistence-type"))
@@ -217,7 +234,7 @@
list.add(loadClass(contents));
method.method.setParameterTypes((Class[])list.toArray(new
Class[list.size()]));
} catch(ClassNotFoundException e) {
- throw new SAXException("Unable to locate class '"+contents+"'");
+ addWarning("Unable to locate class '"+contents+"'");
}
}
@@ -226,19 +243,31 @@
else if(name.equals("trans-attribute")) {
byte value;
+
if(contents.equals("Required"))
value = EJBMethod.TX_REQUIRED;
+
else if(contents.equals("RequiresNew"))
value = EJBMethod.TX_REQUIRES_NEW;
+
else if(contents.equals("Supports"))
value = EJBMethod.TX_SUPPORTS;
+
else if(contents.equals("Never"))
value = EJBMethod.TX_NEVER;
+
else if(contents.equals("NotSupported"))
value = EJBMethod.TX_NOT_SUPPORTED;
+
else if(contents.equals("Mandatory"))
value = EJBMethod.TX_MANDATORY;
- else throw new SAXException("Unknown transaction type '"+contents+"'");
+
+ else {
+ addWarning("Unknown transaction type '"+contents+"'");
+ return;
+ }
+
+
for(int i=0; i<methods.size(); i++)
((EJBMethod)methods.get(i)).transactionAttribute = value;
}
@@ -251,9 +280,15 @@
return loader.loadClass(name);
}
+ private void addWarning(String warning) {
+ warningList.add(warning);
+ }
+
private class MethodHolder {
EJBMethod method = new EJBMethod();
String ejbName;
boolean isHome;
}
+
+
}