Java 类javax.ejb.TransactionManagement 实例源码

项目:lightmare    文件:BeanDeployer.java   
/**
 * 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);
}