Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.TransactionTemplate


        overdueEndpoint.setResultWaitTime(8000);
    }

    protected RouteBuilder createRouteBuilder() throws Exception {
        JpaTemplate jpaTemplate = getMandatoryBean(JpaTemplate.class, "jpaTemplate");
        TransactionTemplate transactionTemplate = getMandatoryBean(TransactionTemplate.class, "transactionTemplate");

        // START SNIPPET: example
        return new ProcessBuilder(jpaTemplate, transactionTemplate) {
            public void configure() throws Exception {
View Full Code Here


    public void setMutableAclService(MutableAclService mutableAclService) {
        this.mutableAclService = mutableAclService;
    }

    public void setPlatformTransactionManager(PlatformTransactionManager platformTransactionManager) {
        this.tt = new TransactionTemplate(platformTransactionManager);
    }
View Full Code Here

                    try {
                        Thread.sleep((long) (Math.random() * SLEEP));
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    TransactionTemplate tt = new TransactionTemplate(this.txManager);


                    try {
                        tt.execute(new TransactionCallbackWithoutResult() {
                            @Override
                            protected void doInTransactionWithoutResult(TransactionStatus status) {
                                try {

                                    for (final String queue : QUEUES) {
View Full Code Here

                    try {
                        Thread.sleep((long) (Math.random() * SLEEP));
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    TransactionTemplate tt = new TransactionTemplate(this.txManager);


                    try {
                        tt.execute(new TransactionCallbackWithoutResult() {
                            @Override
                            protected void doInTransactionWithoutResult(TransactionStatus status) {
                                try {

                                    for (final String queue : QUEUES) {
View Full Code Here

    this.transactionPropagation = transactionPropagation;
  }
 
  @SuppressWarnings("unchecked")
  public <T> T execute(final Command<T> command) {
    TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
    transactionTemplate.setPropagationBehavior(transactionPropagation);
    T result = (T) transactionTemplate.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        return next.execute(command);
      }
    });
    return result;
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

    }

    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

     *
     * @param transactionManager the spring transaction manager
     * @return the created error handler
     */
    public TransactionErrorHandlerBuilder transactionErrorHandler(PlatformTransactionManager transactionManager) {
        TransactionTemplate template = new TransactionTemplate(transactionManager);
        return transactionErrorHandler(template);
    }
View Full Code Here

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

    writer.open(null);

    new TransactionTemplate(transactionManager).execute(new TransactionCallback<Object>() {
      @Override
      public Object doInTransaction(TransactionStatus status) {
        try {
          writer.write(items);
        } catch (Exception e) {
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.