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

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

Introduction

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

Prototype

MethodMapTransactionAttributeSource

Source Link

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 w w .  j  a  v  a 2  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);
}