}
public void build(final BeanContext beanContext, final EnterpriseBeanInfo beanInfo) {
Class<?> clazz = beanContext.getBeanClass();
final InterceptorData beanAsInterceptor = new InterceptorData(clazz);
if (beanInfo instanceof StatelessBeanInfo || beanInfo instanceof MessageDrivenBeanInfo) {
/*
* 4.3.10.2 and 4.5.8
* If the stateless session bean or MDB instance has an ejbCreate method,
* the container treats the ejbCreate method as the instance’s PostConstruct method,
* and, in this case, the PostConstruct annotation (or deployment descriptor metadata)
* can only be applied to the bean’s ejbCreate method.
*/
final NamedMethodInfo info = new NamedMethodInfo();
info.className = clazz.getName();
info.methodName = "ejbCreate";
info.methodParams = new ArrayList<String>();
try {
final Method ejbcreate = MethodInfoUtil.toMethod(clazz, info);
if (ejbcreate != null) {
final CallbackInfo ejbcreateAsPostConstruct = new CallbackInfo();
ejbcreateAsPostConstruct.className = ejbcreate.getDeclaringClass().getName();
ejbcreateAsPostConstruct.method = "ejbCreate";
beanInfo.postConstruct.add(ejbcreateAsPostConstruct);
}
} catch (final IllegalStateException e) {
// there's no ejbCreate method in stateless bean.
}
}
toMethods(clazz, beanInfo.aroundInvoke, beanAsInterceptor.getAroundInvoke());
toCallback(clazz, beanInfo.postConstruct, beanAsInterceptor.getPostConstruct());
toCallback(clazz, beanInfo.preDestroy, beanAsInterceptor.getPreDestroy());
if (beanInfo instanceof StatefulBeanInfo) {
final StatefulBeanInfo stateful = (StatefulBeanInfo) beanInfo;
toCallback(clazz, stateful.postActivate, beanAsInterceptor.getPostActivate());
toCallback(clazz, stateful.prePassivate, beanAsInterceptor.getPrePassivate());
toCallback(clazz, stateful.afterBegin, beanAsInterceptor.getAfterBegin());
toCallback(clazz, stateful.beforeCompletion, beanAsInterceptor.getBeforeCompletion());
toCallback(clazz, stateful.afterCompletion, beanAsInterceptor.getAfterCompletion(), boolean.class);
} else {
toMethods(clazz, beanInfo.aroundTimeout, beanAsInterceptor.getAroundTimeout());
}
while (clazz != null && clazz != Object.class) {
for (final Method method : clazz.getDeclaredMethods()) {