User: reverbel
Date: 01/11/26 16:00:09
Modified: iiop/src/main/org/jboss/ejb/plugins/iiop/client
StubStrategy.java
Log:
Added field exceptionList and method that checks if a given Throwable
instance corresponds to a declared exception of the method described
by a StubStrategy target.
Fixed typos in comments.
Revision Changes Path
1.2 +36 -5
contrib/iiop/src/main/org/jboss/ejb/plugins/iiop/client/StubStrategy.java
Index: StubStrategy.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/iiop/src/main/org/jboss/ejb/plugins/iiop/client/StubStrategy.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StubStrategy.java 2001/08/28 22:19:00 1.1
+++ StubStrategy.java 2001/11/27 00:00:09 1.2
@@ -6,7 +6,10 @@
*/
package org.jboss.ejb.plugins.iiop.client;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.rmi.UnexpectedException;
@@ -24,7 +27,7 @@
* from a CDR input stream an application exception thrown by the method.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Francisco Reverbel</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class StubStrategy
{
@@ -37,6 +40,11 @@
private CDRStreamWriter[] paramWriters;
/**
+ * List of exception classes.
+ */
+ private List exceptionList;
+
+ /**
* Maps exception repository ids into exception classes.
*/
private Map exceptionMap;
@@ -60,7 +68,7 @@
* exceptions thrown by the method
* @param excepTypes a string array with the Java class names of the
* exceptions thrown by the method
- * @param retvalTypes marshaller abbreaviated name for the return value of
+ * @param retvalType marshaller abbreaviated name for the return value of
* the method
* @param cl a <code>ClassLoader</code> to load value classes
* (if null, the current thread's context class loader
@@ -98,7 +106,7 @@
* exceptions thrown by the method
* @param excepTypes a string array with the Java class names of the
* exceptions thrown by the method
- * @param retvalTypes marshaller abbreaviated name for the return value of
+ * @param retvalType marshaller abbreaviated name for the return value of
* the method
* @param cl a <code>ClassLoader</code> to load value classes
* (if null, the current thread's context class loader
@@ -120,12 +128,15 @@
paramWriters[i] = CDRStream.writerFor(paramTypes[i], cl);
}
- // Initialize exception map
+ // Initialize exception list and exception map
+ exceptionList = new ArrayList();
exceptionMap = new HashMap();
len = excepIds.length;
for (int i = 0; i < len; i++) {
try {
- exceptionMap.put(excepIds[i] , cl.loadClass(excepTypes[i]));
+ Class clz = cl.loadClass(excepTypes[i]);
+ exceptionList.add(clz);
+ exceptionMap.put(excepIds[i] , clz);
}
catch (ClassNotFoundException e) {
throw new RuntimeException("Error loading class "
@@ -193,6 +204,26 @@
else {
return (Exception)in.read_value(exceptionClass);
}
+ }
+
+ /**
+ * Checks if a given <code>Throwable</code> instance corresponds to an
+ * exception declared by this <code>StubStrategy</code>'s method.
+ *
+ * @param t an exception class
+ * @return true if <code>t</code> is an instance of any of the
+ * exceptions declared by this <code>StubStrategy</code>'s
+ * method, false otherwise.
+ */
+ public boolean isDeclaredException(Throwable t)
+ {
+ Iterator iterator = exceptionList.iterator();
+ while (iterator.hasNext()) {
+ if (((Class)iterator.next()).isInstance(t)) {
+ return true;
+ }
+ }
+ return false;
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development