[jboss-cvs] JBossAS SVN: r107933 - projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 1 06:50:49 EDT 2010
Author: wolfc
Date: 2010-09-01 06:50:48 -0400 (Wed, 01 Sep 2010)
New Revision: 107933
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java
Log:
EJBTHREE-2160: process ejbCreate method
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java 2010-08-31 21:40:03 UTC (rev 107932)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java 2010-09-01 10:50:48 UTC (rev 107933)
@@ -21,21 +21,14 @@
*/
package org.jboss.ejb3;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-
import javassist.bytecode.AnnotationsAttribute;
import javassist.bytecode.ClassFile;
import javassist.bytecode.annotation.Annotation;
import javassist.bytecode.annotation.StringMemberValue;
-
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-
import org.jboss.aop.AspectManager;
import org.jboss.aop.Domain;
import org.jboss.aop.DomainDefinition;
+import org.jboss.ejb3.annotation.impl.PostConstructImpl;
import org.jboss.ejb3.mdb.ConsumerContainer;
import org.jboss.ejb3.mdb.MDB;
import org.jboss.ejb3.service.ServiceContainer;
@@ -50,6 +43,13 @@
import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
* @author <a href="mailto:bill at jboss.com">Bill Burke</a>
@@ -107,6 +107,11 @@
visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
}
+ private static void addAnnotation(java.lang.annotation.Annotation annotation, EJBContainer container, Method method)
+ {
+ container.getAnnotations().addAnnotation(method, annotation.annotationType(), annotation);
+ }
+
/**
* The link from an enterprise bean to it's interceptors is via the EJB Jar meta data.
* So we try to recreate that link it's not already established.
@@ -353,9 +358,41 @@
MDB container = new MDB(ejbNames.get(ejbIndex), (Domain) domain.getManager(), di.getClassLoader(), className,
ctxProperties, deployment, beanMetaData);
+ // EJB 3.0 5.6.3: the class or any super-class may implement the ejbCreate method
+ Method method = getMethod(container.getBeanClass(), "ejbCreate");
+ if(method != null)
+ {
+ addAnnotation(new PostConstructImpl(), container, method);
+ }
+
return container;
}
+ /**
+ * Find a specific public method on a class (slow).
+ *
+ * Note that this method is slow, because it uses exception for control flow.
+ * Also Class does a brute search in its private method cache.
+ *
+ * @param cls
+ * @param methodName
+ * @param parameterTypes
+ * @return the method or null if not found
+ * @see Class#getMethod(String, Class[])
+ */
+ private static Method getMethod(Class<?> cls, String methodName, Class<?>... parameterTypes)
+ {
+ try
+ {
+ // call to cls.getMethod is slow
+ return cls.getMethod(methodName, parameterTypes);
+ }
+ catch (NoSuchMethodException e)
+ {
+ return null;
+ }
+ }
+
protected void populateBaseInfo() throws Exception
{
String ejbName = null;
More information about the jboss-cvs-commits
mailing list