Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.TransactionTemplate


    /**
     * @param transactionTemplate the transactionTemplate to set
     */
    public void setTransactionManager(PlatformTransactionManager transactionManager) {
        this.transactionTemplate = new TransactionTemplate(transactionManager);
    }
View Full Code Here


     * The transaction manager to use for updates to the counter table
     */
    @Required
    public void setTransactionManager(PlatformTransactionManager transactionManager) {
        Validate.notNull(transactionManager);
        this.transactionTemplate = new TransactionTemplate(transactionManager);
    }
View Full Code Here

    /* (non-Javadoc)
     * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
     */
    public void afterPropertiesSet() throws Exception {
      this.transactionTemplate = new TransactionTemplate(this.transactionManager);
      this.transactionTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRES_NEW);
      this.transactionTemplate.setReadOnly(true);
      this.transactionTemplate.afterPropertiesSet();     
     
      this.runDatabaseTests();
View Full Code Here

  protected String[] getConfigLocations() {
    return new String[] { "org/jencks/samples/outbound/jencks-genericjmsra.xml" };
  }

  protected void checkIfMessageExist(final String sentMessage) {
    TransactionTemplate tt = new TransactionTemplate(getTransactionManager());
    tt.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        JmsTemplate template=new JmsTemplate(getConnectionFactory());
        template.setReceiveTimeout(10);
        String receivedMessage=(String)template.receiveAndConvert(getQueue());
        assertEquals(sentMessage,receivedMessage);
View Full Code Here

      }
    });
  }

  protected void checkIfMessageNotExist() {
    TransactionTemplate tt = new TransactionTemplate(getTransactionManager());
    tt.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        JmsTemplate template=new JmsTemplate(getConnectionFactory());
        template.setReceiveTimeout(10);
        String receivedMessage=null;
        receivedMessage=(String)template.receiveAndConvert(getQueue());
View Full Code Here

    // create the transaction manager
    DataSourceTransactionManager tsMan = new DataSourceTransactionManager(ds);

    // create the transaction template
    TransactionTemplate txTemplate = new TransactionTemplate(tsMan);

    // set behavior
    txTemplate.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRES_NEW);
    final String noCommentSql[] = removeCommentsAndSemicolons(connectionModel.getSchema(), sql);
    try {
      // run the code in a transaction
      txTemplate.execute(new TransactionCallbackWithoutResult() {
        public void doInTransactionWithoutResult(TransactionStatus status) {
          jt.batchUpdate(noCommentSql);
        }
      });
    } catch (DataAccessException e) {
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(new ClassPathResource("org/apache/servicemix/jbi/nmr/flow/jca/broker.xml"));
        bfb.afterPropertiesSet();
        broker = bfb.getBroker();
        broker.start();
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

    @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

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.