/** * Gets appropriated {@link TransactionAttributeType} for instant * {@link Method} of {@link javax.ejb.Stateless} bean * * @param metaData * @param method * @return {@link TransactionAttributeType} */ public static TransactionAttributeType getTransactionType(MetaData metaData, Method method) { TransactionAttributeType type; if (method == null) { type = null; } else { TransactionAttributeType attrType = metaData.getTransactionAttrType(); TransactionManagementType manType = metaData.getTransactionManType(); TransactionAttribute attr = method.getAnnotation(TransactionAttribute.class); if (manType.equals(TransactionManagementType.CONTAINER)) { type = getTransactionType(attr, attrType); } else { type = null; } } return type; }
/** * Checks if bean class is annotated as {@link TransactionAttribute} and * {@link TransactionManagement} and caches * {@link TransactionAttribute#value()} and * {@link TransactionManagement#value()} in {@link MetaData} object * * @param beanClass */ private void checkOnTransactional(Class<?> beanClass) { TransactionAttribute transactionAttribute = beanClass.getAnnotation(TransactionAttribute.class); TransactionManagement transactionManagement = beanClass.getAnnotation(TransactionManagement.class); boolean transactional = Boolean.FALSE; TransactionAttributeType transactionAttrType; TransactionManagementType transactionManType; if (transactionAttribute == null) { transactional = Boolean.TRUE; transactionAttrType = TransactionAttributeType.REQUIRED; transactionManType = TransactionManagementType.CONTAINER; } else if (transactionManagement == null) { transactionAttrType = transactionAttribute.value(); transactionManType = TransactionManagementType.CONTAINER; } else { transactionAttrType = transactionAttribute.value(); transactionManType = transactionManagement.value(); } metaData.setTransactional(transactional); metaData.setTransactionAttrType(transactionAttrType); metaData.setTransactionManType(transactionManType); }
public TransactionManagementType getTransactionManType() { return transactionManType; }
public void setTransactionManType(TransactionManagementType transactionManType) { this.transactionManType = transactionManType; }