Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.TransactionTemplate


    }

    public TransactionTemplate getTransactionTemplate() {
        if (template == null) {
            ObjectHelper.notNull(transactionManager, "transactionManager");
            template = new TransactionTemplate(transactionManager);
            if (propagationBehaviorName != null) {
                template.setPropagationBehaviorName(propagationBehaviorName);
            }
        }
        return template;
View Full Code Here


    public static JdbcMessageIdRepository jpaMessageIdRepository(DataSource dataSource, String processorName) {
        return new JdbcMessageIdRepository(dataSource, processorName);
    }

    private static TransactionTemplate createTransactionTemplate(DataSource dataSource) {
        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new DataSourceTransactionManager(dataSource));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
        return transactionTemplate;
    }
View Full Code Here

    }

    public final void setTransactionManager(PlatformTransactionManager transactionManager) {
        this.transactionManager = transactionManager;
       
        transactionTemplate = new TransactionTemplate(transactionManager);
        transactionTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRED);

        transactionTemplateReadOnly = new TransactionTemplate(transactionManager);
        transactionTemplateReadOnly.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRED);
        transactionTemplateReadOnly.setReadOnly(true);
    }
View Full Code Here

    protected void cleanupRepository() {
        // must type cast with Spring 2.x
        jpaTemplate = (JpaTemplate) applicationContext.getBean("jpaTemplate");

        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

    ApplicationContext appContext = null;      
        try {
            appContext = new ClassPathXmlApplicationContext(defaultConfigPaths);
            final ApplicationContext fappContext = appContext;
            //BeanLocatorFactory.setApplicationContext(appContext);
             TransactionTemplate txTemplate = (TransactionTemplate) BeanLocatorFactory.getBean("transactionTemplate");

                 txTemplate.execute(new TransactionCallbackWithoutResult() {
                     public void doInTransactionWithoutResult(TransactionStatus status)
                     {
                         try {
                          
                           ObjectDAO objectDAO = (ObjectDAO)fappContext.getBean("objectDAO");
View Full Code Here

  @Override
  public String intercept(ActionInvocation invoker) throws Exception {
    final ActionInvocation finalInvoker = invoker;
    try
    {     
      TransactionTemplate txTemplate =(TransactionTemplate) BeanLocatorFactory.getBean("transactionTemplate");
     
      txTemplate.execute(new TransactionCallbackWithoutResult(){
        public void doInTransactionWithoutResult(TransactionStatus status) {
          try {
                        logger.debug("Begin transaction interceptor");
            finalInvoker.invoke();
                        logger.debug("End transaction interceptor");
View Full Code Here

  @Override
  public String intercept(ActionInvocation invoker) throws Exception {
    final ActionInvocation finalInvoker = invoker;
    try
    {     
      TransactionTemplate txTemplate =(TransactionTemplate) BeanLocatorFactory.getBean("transactionTemplate");
     
      txTemplate.execute(new TransactionCallbackWithoutResult(){
        public void doInTransactionWithoutResult(TransactionStatus status) {
          try {
                        //logger.debug("Begin transaction interceptor");
            finalInvoker.invoke();
                        //logger.debug("End transaction interceptor");
View Full Code Here

        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

        overdueEndpoint.assertIsSatisfied();
    }

    protected void sendAMessages() {
        TransactionTemplate transaction = getMandatoryBean(TransactionTemplate.class, "transactionTemplate");
        transaction.execute(new TransactionCallbackWithoutResult() {
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                template.sendBody("direct:a", "<hello id='123'>A</hello>");
                template.sendBody("direct:a", "<hello id='124'>B</hello>");
                template.sendBody("direct:a", "<hello id='125'>C</hello>");
            }
View Full Code Here

            }
        });
    }

    protected void sendBMessages() {
        TransactionTemplate transaction = getMandatoryBean(TransactionTemplate.class, "transactionTemplate");
        transaction.execute(new TransactionCallbackWithoutResult() {
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                template.sendBody("direct:b", "<hello id='123'>A</hello>");
                template.sendBody("direct:b", "<hello id='125'>C</hello>");
            }
        });
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.