[jboss-cvs] JBossAS SVN: r73866 - projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/lang.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat May 31 00:34:58 EDT 2008
Author: ALRubinger
Date: 2008-05-31 00:34:58 -0400 (Sat, 31 May 2008)
New Revision: 73866
Modified:
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/lang/SerializableMethod.java
Log:
[EJBTHREE-1345] Add conversion methods to obtain CL-specific non-Serializable Views
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/lang/SerializableMethod.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/lang/SerializableMethod.java 2008-05-30 20:47:58 UTC (rev 73865)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/lang/SerializableMethod.java 2008-05-31 04:34:58 UTC (rev 73866)
@@ -155,6 +155,108 @@
}
// ------------------------------------------------------------------------------||
+ // Functional Methods -----------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Method described by this view, using the
+ * TCL
+ *
+ * @return
+ */
+ public Method toMethod()
+ {
+ return this.toMethod(Thread.currentThread().getContextClassLoader());
+ }
+
+ /**
+ * Obtains the Method described by this view, using the
+ * ClassLoader specified
+ *
+ * @param cl
+ * @return
+ */
+ public Method toMethod(ClassLoader cl)
+ {
+ // Load the Class described by the Method
+ Class<?> invokingClass = this.getClassType(cl);
+
+ // Load the argument types
+ List<Object> argTypesList = new ArrayList<Object>();
+ for (String argTypeName : this.getArgumentTypes())
+ {
+ Class<?> argType = null;
+ try
+ {
+ argType = cl.loadClass(argTypeName);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new RuntimeException("Could not load class defined as the invoking class, " + argTypeName + ", by "
+ + cl, cnfe);
+ }
+ argTypesList.add(argType);
+ }
+ Class<?>[] argTypes = argTypesList.toArray(new Class<?>[]
+ {});
+
+ // Obtain the Method
+ String methodName = this.getName();
+ Method invokedMethod = null;
+ try
+ {
+ invokedMethod = invokingClass.getMethod(methodName, argTypes);
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ throw new RuntimeException("Method " + this + " does not exist in " + invokingClass.getName(), nsme);
+ }
+
+ // Return
+ return invokedMethod;
+ }
+
+ /**
+ * Obtains the Class described by this view, using the
+ * TCL
+ *
+ * @return
+ */
+ public Class<?> getClassType()
+ {
+ return this.getClassType(Thread.currentThread().getContextClassLoader());
+ }
+
+ /**
+ * Obtains the Class described by this view, using the
+ * specified ClassLoader
+ *
+ * @param cl
+ * @return
+ */
+ public Class<?> getClassType(ClassLoader cl)
+ {
+ // Perform assertions
+ assert cl != null : ClassLoader.class.getSimpleName() + "must be defined.";
+
+ // Load the Class described by the Method
+ String invokingClassName = this.getClassName();
+ Class<?> invokingClass = null;
+ try
+ {
+ invokingClass = cl.loadClass(invokingClassName);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new RuntimeException("Specified calling class, " + invokingClassName + " could not be found for " + cl,
+ cnfe);
+ }
+
+ // Return
+ return invokingClass;
+ }
+
+ // ------------------------------------------------------------------------------||
// Accessors / Mutators ---------------------------------------------------------||
// ------------------------------------------------------------------------------||
More information about the jboss-cvs-commits
mailing list