• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TransactionProxyFactoryBean类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.springframework.transaction.interceptor.TransactionProxyFactoryBean的典型用法代码示例。如果您正苦于以下问题:Java TransactionProxyFactoryBean类的具体用法?Java TransactionProxyFactoryBean怎么用?Java TransactionProxyFactoryBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TransactionProxyFactoryBean类属于org.springframework.transaction.interceptor包,在下文中一共展示了TransactionProxyFactoryBean类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: requireNewTransaction

点赞 3

import org.springframework.transaction.interceptor.TransactionProxyFactoryBean; //导入依赖的package包/类
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();
}
 

开发者ID:holisticon,
项目名称:holunda,
代码行数:20,
代码来源:RequireNewTransaction.java

示例2: create

点赞 3

import org.springframework.transaction.interceptor.TransactionProxyFactoryBean; //导入依赖的package包/类
/**
 * <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();
}
 

开发者ID:qoswork,
项目名称:opennmszh,
代码行数:25,
代码来源:DefaultCollectionAgentService.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)