Example usage for org.springframework.transaction.interceptor TransactionProxyFactoryBean setTransactionAttributes

List of usage examples for org.springframework.transaction.interceptor TransactionProxyFactoryBean setTransactionAttributes

Introduction

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

Prototype

public void setTransactionAttributes(Properties transactionAttributes) 

Source Link

Document

Set properties with method names as keys and transaction attribute descriptors (parsed via TransactionAttributeEditor) as values: e.g.

Usage

From source file:org.opennms.ng.services.collectd.DefaultCollectionAgentService.java

/**
 * <p>create</p>// w w  w .  j  a  va  2 s  .c  om
 *
 * @param ifaceId a {@link Integer} object.
 * @param ifaceDao a {@link org.opennms.netmgt.dao.api.IpInterfaceDao} object.
 * @param transMgr a {@link org.springframework.transaction.PlatformTransactionManager} object.
 * @return a {@link CollectionAgentService} object.
 */
public static CollectionAgentService create(Integer ifaceId, final OnmsIpInterfaceDao ifaceDao,
        final PlatformTransactionManager transMgr) {
    CollectionAgentService agent = new DefaultCollectionAgentService(ifaceId, ifaceDao);

    TransactionProxyFactoryBean bean = new TransactionProxyFactoryBean();
    bean.setTransactionManager(transMgr);
    bean.setTarget(agent);

    Properties props = new Properties();
    props.put("*", "PROPAGATION_REQUIRED,readOnly");

    bean.setTransactionAttributes(props);

    bean.afterPropertiesSet();

    return (CollectionAgentService) bean.getObject();
}