1 16 17 package org.springframework.transaction.interceptor; 18 19 import java.beans.PropertyEditorSupport ; 20 import java.util.Iterator ; 21 import java.util.Properties ; 22 23 import org.springframework.beans.propertyeditors.PropertiesEditor; 24 import org.springframework.util.StringUtils; 25 26 49 public class TransactionAttributeSourceEditor extends PropertyEditorSupport { 50 51 public void setAsText(String text) throws IllegalArgumentException { 52 MethodMapTransactionAttributeSource source = new MethodMapTransactionAttributeSource(); 53 if (StringUtils.hasLength(text)) { 54 PropertiesEditor propertiesEditor = new PropertiesEditor(); 56 propertiesEditor.setAsText(text); 57 Properties props = (Properties ) propertiesEditor.getValue(); 58 59 TransactionAttributeEditor tae = new TransactionAttributeEditor(); 61 for (Iterator iter = props.keySet().iterator(); iter.hasNext();) { 62 String name = (String ) iter.next(); 63 String value = props.getProperty(name); 64 65 tae.setAsText(value); 67 TransactionAttribute attr = (TransactionAttribute) tae.getValue(); 68 69 source.addTransactionalMethod(name, attr); 71 } 72 } 73 setValue(source); 74 } 75 76 } 77 | Popular Tags |