Example usage for org.springframework.transaction.interceptor MethodMapTransactionAttributeSource addTransactionalMethod

List of usage examples for org.springframework.transaction.interceptor MethodMapTransactionAttributeSource addTransactionalMethod

Introduction

In this page you can find the example usage for org.springframework.transaction.interceptor MethodMapTransactionAttributeSource addTransactionalMethod.

Prototype

public void addTransactionalMethod(Method method, TransactionAttribute attr) 

Source Link

Document

Add an attribute for a transactional method.

Usage

From source file:org.springframework.transaction.interceptor.TransactionAttributeSourceEditor.java

public void setAsText(String s) throws IllegalArgumentException {
    MethodMapTransactionAttributeSource source = new MethodMapTransactionAttributeSource();
    if (s == null || "".equals(s)) {
        // Leave value in property editor <code>null</code>
    } else {/*from  w  ww.ja  v a2 s  . co  m*/
        // Use properties editor to tokenize the hold string
        PropertiesEditor propertiesEditor = new PropertiesEditor();
        propertiesEditor.setAsText(s);
        Properties props = (Properties) propertiesEditor.getValue();

        // Now we have properties, process each one individually
        TransactionAttributeEditor tae = new TransactionAttributeEditor();
        for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
            String name = (String) iter.next();
            String value = props.getProperty(name);

            // Convert value to a transaction attribute
            tae.setAsText(value);
            TransactionAttribute attr = (TransactionAttribute) tae.getValue();

            // Register name and attribute
            source.addTransactionalMethod(name, attr);
        }
    }
    setValue(source);
}