Search in sources :

Example 1 with TransactionAnnotationData

use of jodd.jtx.meta.TransactionAnnotationData in project jodd by oblac.

the class AnnotationTxAdviceManager method getTxMode.

/**
	 * Reads transaction mode from method annotation. Annotations are cached for better performances.
	 * @param type target class
	 * @param methodName target method name over which the transaction should be wrapped
	 * @param methodArgTypes types of arguments, used to find the method
	 * @param unique unique method fingerprint that contains return and arguments type information
	 */
public synchronized JtxTransactionMode getTxMode(Class type, String methodName, Class[] methodArgTypes, String unique) {
    String signature = type.getName() + '#' + methodName + '%' + unique;
    JtxTransactionMode txMode = txmap.get(signature);
    if (txMode == null) {
        if (!txmap.containsKey(signature)) {
            Method m;
            try {
                m = type.getMethod(methodName, methodArgTypes);
            } catch (NoSuchMethodException nsmex) {
                throw new ProxettaException(nsmex);
            }
            TransactionAnnotationData txAnn = getTransactionAnnotation(m);
            if (txAnn != null) {
                txMode = new JtxTransactionMode();
                txMode.setPropagationBehaviour(txAnn.getPropagation());
                txMode.setIsolationLevel(txAnn.getIsolation());
                txMode.setReadOnly(txAnn.isReadOnly());
                txMode.setTransactionTimeout(txAnn.getTimeout());
            } else {
                txMode = defaultTransactionMode;
            }
            txmap.put(signature, txMode);
        }
    }
    return txMode;
}
Also used : TransactionAnnotationData(jodd.jtx.meta.TransactionAnnotationData) ProxettaException(jodd.proxetta.ProxettaException) JtxTransactionMode(jodd.jtx.JtxTransactionMode) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)1 JtxTransactionMode (jodd.jtx.JtxTransactionMode)1 TransactionAnnotationData (jodd.jtx.meta.TransactionAnnotationData)1 ProxettaException (jodd.proxetta.ProxettaException)1