Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.TransactionTemplate


    when(fileSystem.create(new Path(fileName))).thenReturn(fsDataOutputStream);

    writer.open(null);

    try {
      new TransactionTemplate(transactionManager).execute(new TransactionCallback<Object>() {
        @Override
        public Object doInTransaction(TransactionStatus status) {
          try {
            writer.write(items);
          } catch (Exception e) {
View Full Code Here


    when(fileSystem.create(new Path(fileName))).thenReturn(fsDataOutputStream);

    writer.open(null);

    try {
      TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
      transactionTemplate.setReadOnly(true);
      transactionTemplate.execute(new TransactionCallback<Object>() {

        @Override
        public Object doInTransaction(TransactionStatus status) {
          try {
            writer.write(items);
View Full Code Here

    this.transactionManager = transactionManager;
  }

  @Async
  public void doAsyncTask(final Map<Object, Object> context) {
    new TransactionTemplate(transactionManager)
    .execute(new TransactionCallbackWithoutResult(){
      @Override
      protected void doInTransactionWithoutResult(TransactionStatus status) {
          try {
            doTask(context);
View Full Code Here

        tcm = (TransactionContextManager) tcmfb.getObject();
        GeronimoTransactionManagerFactoryBean gtmfb = new GeronimoTransactionManagerFactoryBean();
        gtmfb.setTransactionContextManager(tcm);
        gtmfb.afterPropertiesSet();
        tm = (TransactionManager) gtmfb.getObject();
        tt = new TransactionTemplate(new JtaTransactionManager((UserTransaction) tm));
    }
View Full Code Here

        TransactionContextManager tcm = (TransactionContextManager) tcmfb.getObject();
        GeronimoTransactionManagerFactoryBean gtmfb = new GeronimoTransactionManagerFactoryBean();
        gtmfb.setTransactionContextManager(tcm);
        gtmfb.afterPropertiesSet();
        TransactionManager tm = (TransactionManager) gtmfb.getObject();
        tt = new TransactionTemplate(new JtaTransactionManager((UserTransaction) tm));
      
        BrokerFactoryBean bfb = new BrokerFactoryBean();
        bfb.setConfig(new ClassPathResource("org/servicemix/jbi/nmr/flow/jca/broker.xml"));
        bfb.afterPropertiesSet();
        broker = (BrokerContainer) bfb.getObject();
View Full Code Here

  /* (non-Javadoc)
   * @see com.apress.prospring.ch12.business.AbstractAccountManager#initManager()
   */
  protected void initManager() {
    super.initManager();
    transactionTemplate = new TransactionTemplate(transactionManager);
  }
View Full Code Here

    @SuppressWarnings("unchecked")
    protected void cleanupRepository() {
        jpaTemplate = (JpaTemplate)applicationContext.getBean("jpaTemplate", JpaTemplate.class);

        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new JpaTransactionManager(jpaTemplate.getEntityManagerFactory()));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

        transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus arg0) {
                List list = jpaTemplate.find(SELECT_ALL_STRING);
                for (Object item : list) {
                    jpaTemplate.remove(item);
                }
View Full Code Here

    @SuppressWarnings("unchecked")
    protected void cleanupRepository() {
        jpaTemplate = (JpaTemplate)applicationContext.getBean("jpaTemplate", JpaTemplate.class);

        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new JpaTransactionManager(jpaTemplate.getEntityManagerFactory()));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

        transactionTemplate.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus arg0) {
                List list = jpaTemplate.find(SELECT_ALL_STRING);
                for (Object item : list) {
                    jpaTemplate.remove(item);
                }
View Full Code Here

            }

            if (transactionTemplate == null) {
                Map<String, PlatformTransactionManager> map = routeContext.lookupByType(PlatformTransactionManager.class);
                if (map != null && map.size() == 1) {
                    transactionTemplate = new TransactionTemplate(map.values().iterator().next());
                } else if (LOG.isDebugEnabled()) {
                    if (map == null || map.isEmpty()) {
                        LOG.trace("No PlatformTransactionManager found in registry.");
                    } else {
                        LOG.debug("Found " + map.size() + " PlatformTransactionManager in registry. "
View Full Code Here

    public void setSpringTransactionPolicy(SpringTransactionPolicy policy) {
        this.transactionTemplate = policy.getTransactionTemplate();
    }

    public void setTransactionManager(PlatformTransactionManager transactionManager) {
        this.transactionTemplate = new TransactionTemplate(transactionManager);
    }
View Full Code Here

TOP

Related Classes of org.springframework.transaction.support.TransactionTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.