* Adds the right transaction interceptor depending of the transactional
* attribute set by the user.
* @param bean the given bean on which set the transactional interceptor.
*/
public static void resolve(final EasyBeansEjbJarClassMetadata bean) {
TransactionAttributeType beanTxType = bean.getTransactionAttributeType();
TransactionManagementType beanTxManaged = bean.getTransactionManagementType();
// Checks if Synchronization is needed for this stateful bean
boolean addSynchro = false;
if (bean.isStateful()) {
String[] interfaces = bean.getInterfaces();
if (interfaces != null) {
for (String itf : interfaces) {
if (SESSION_SYNCHRONIZATION_INTERFACE.equals(itf)) {
addSynchro = true;
break;
}
}
}
}
for (EasyBeansEjbJarMethodMetadata method : bean.getMethodMetadataCollection()) {
List<? extends IJClassInterceptor> previousInterceptors = method.getInterceptors();
List<IJClassInterceptor> interceptors = new ArrayList<IJClassInterceptor>();
if (previousInterceptors != null) {
interceptors.addAll(previousInterceptors);
}
// Bean managed or container managed ?
if (beanTxManaged.equals(BEAN)) {
// BMT
if (bean.isStateful()) {
interceptors.add(new JClassInterceptor(BMT_STATEFUL_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
} else if (bean.isStateless()) {
interceptors.add(new JClassInterceptor(BMT_STATELESS_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
} else {
interceptors.add(new JClassInterceptor(BMT_INTERCEPTOR, EASYBEANS_INTERCEPTOR));
}
} else {
// CMT
TransactionAttributeType methodTx = method.getTransactionAttributeType();
// Set method tx attribute to the class tx attribute if none was
// set.
if (methodTx == null) {
if (!method.isInherited()) {