Java 类javax.ejb.TransactionManagementType 实例源码

项目:lightmare    文件:BeanTransactions.java   
/**
 * 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;
}
项目: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);
}
项目:lightmare    文件:MetaData.java   
public TransactionManagementType getTransactionManType() {
    return transactionManType;
}
项目:lightmare    文件:MetaData.java   
public void setTransactionManType(TransactionManagementType transactionManType) {
    this.transactionManType = transactionManType;
}