[jboss-cvs] JBossAS SVN: r67867 - trunk/ejb3/src/main/org/jboss/ejb3.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 4 06:27:27 EST 2007
Author: wolfc
Date: 2007-12-04 06:27:27 -0500 (Tue, 04 Dec 2007)
New Revision: 67867
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
Log:
EJBTHREE-1067: added code for lifecycle callback class
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2007-12-04 11:14:12 UTC (rev 67866)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2007-12-04 11:27:27 UTC (rev 67867)
@@ -266,6 +266,29 @@
return findEjbsByClass(dd, cf.getName()).size() > 0;
}
+ /**
+ * Helper method to load classes. If no class name is specified
+ * the bean class is returned.
+ *
+ * @param container The EJB container
+ * @param name The name of the class or null for the bean class
+ * @return The resulting <tt>Class</tt> object or the bean class
+ */
+ private Class<?> loadClass(EJBContainer container, String name)
+ {
+ if(name == null)
+ return container.getBeanClass();
+ try
+ {
+ return di.getClassLoader().loadClass(name);
+ }
+ catch(ClassNotFoundException e)
+ {
+ // TODO: what shall be the proper exception
+ throw new RuntimeException(e);
+ }
+ }
+
protected void populateBaseInfo() throws Exception
{
super.populateBaseInfo();
@@ -1849,10 +1872,10 @@
}
}
- private void addInterceptorMethodAnnotation(EJBContainer container, String methodName, Class<? extends Annotation> ann, String xmlName)
+ private void addInterceptorMethodAnnotation(EJBContainer container, Class<?> cls, String methodName, Class<? extends Annotation> ann, String xmlName)
{
Method found = null;
- for (Method rm : container.getBeanClass().getDeclaredMethods())
+ for (Method rm : cls.getDeclaredMethods())
{
if (rm.getName().equals(methodName))
{
@@ -1877,7 +1900,7 @@
if (found == null)
{
- log.warn("No method found within " + container.getBeanClassName()
+ log.warn("No method found within " + cls.getName()
+ " with name " + methodName
+ " with the right signature for " + xmlName + "was found");
return;
@@ -1900,10 +1923,9 @@
for(AroundInvokeMetaData callback : callbacks)
{
- if(callback.getClassName() != null)
- throw new RuntimeException("around invoke with a class name is NYI");
+ Class<?> callbackClass = loadClass(container, callback.getClassName());
- addInterceptorMethodAnnotation(container, callback.getMethodName(), ann, xmlName);
+ addInterceptorMethodAnnotation(container, callbackClass, callback.getMethodName(), ann, xmlName);
}
}
@@ -1915,10 +1937,9 @@
for(LifecycleCallbackMetaData callback : callbacks)
{
- if(callback.getClassName() != null)
- throw new RuntimeException("lifecycle callback with a class name is NYI");
+ Class<?> callbackClass = loadClass(container, callback.getClassName());
- addInterceptorMethodAnnotation(container, callback.getMethodName(), ann, xmlName);
+ addInterceptorMethodAnnotation(container, callbackClass, callback.getMethodName(), ann, xmlName);
}
}
More information about the jboss-cvs-commits
mailing list