Java 类org.springframework.transaction.interceptor.TransactionProxyFactoryBean 实例源码

项目:holunda    文件:RequireNewTransaction.java   
public <T> T requireNewTransaction(T target) {
  final TransactionProxyFactoryBean proxy = new TransactionProxyFactoryBean();

  // Inject transaction manager here
  proxy.setTransactionManager(transactionManager);

  // Define which object instance is to be proxied (your bean)
  proxy.setTarget(target);

  // Programmatically setup transaction attributes
  proxy.setTransactionAttributes(transactionAttributes);

  // Is needed since Spring 4.3.1
  proxy.setProxyTargetClass(true);

  // Finish FactoryBean setup
  proxy.afterPropertiesSet();
  return (T) proxy.getObject();
}
项目:opennmszh    文件:DefaultCollectionAgentService.java   
/**
 * <p>create</p>
 *
 * @param ifaceId a {@link java.lang.Integer} object.
 * @param ifaceDao a {@link org.opennms.netmgt.dao.IpInterfaceDao} object.
 * @param transMgr a {@link org.springframework.transaction.PlatformTransactionManager} object.
 * @return a {@link org.opennms.netmgt.collectd.CollectionAgentService} object.
 */
public static CollectionAgentService create(Integer ifaceId, final IpInterfaceDao 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();
}
项目:OpenNMS    文件:DefaultCollectionAgentService.java   
/**
 * <p>create</p>
 *
 * @param ifaceId a {@link java.lang.Integer} object.
 * @param ifaceDao a {@link org.opennms.netmgt.dao.IpInterfaceDao} object.
 * @param transMgr a {@link org.springframework.transaction.PlatformTransactionManager} object.
 * @return a {@link org.opennms.netmgt.collectd.CollectionAgentService} object.
 */
public static CollectionAgentService create(Integer ifaceId, final IpInterfaceDao 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();
}