Examples of PlatformTransactionManager


Examples of org.springframework.transaction.PlatformTransactionManager

     */
    @Override
    public void beginTransaction(TransactionalTest transactionalTest) {

        // retrieves the transaction manager
        PlatformTransactionManager transactionManager = getTransactionManager(
                transactionalTest.getManager());
        transactionManagerInstance.set(transactionManager);

        // create the transaction definition
        TransactionDefinition transactionDefinition = createTransactionDefinition();

        // begins transaction
        TransactionStatus transactionStatus = transactionManager.getTransaction(transactionDefinition);
        transactionStatusInstance.set(transactionStatus);
    }
View Full Code Here

Examples of org.springframework.transaction.PlatformTransactionManager

     * {@inheritDoc}
     */
    @Override
    public void commitTransaction(TransactionalTest transactionalTest) {

        PlatformTransactionManager transactionManager = transactionManagerInstance.get();
        TransactionStatus transactionStatus = transactionStatusInstance.get();

        // commits the transaction
        transactionManager.commit(transactionStatus);
    }
View Full Code Here

Examples of org.springframework.transaction.PlatformTransactionManager

     * {@inheritDoc}
     */
    @Override
    public void rollbackTransaction(TransactionalTest transactionalTest) {

        PlatformTransactionManager transactionManager = transactionManagerInstance.get();
        TransactionStatus transactionStatus = transactionStatusInstance.get();

        // rollbacks the transaction
        transactionManager.rollback(transactionStatus);
    }
View Full Code Here

Examples of org.springframework.transaction.PlatformTransactionManager

            incomingObserver.onMessage(inMessage);
           
            //need to propagate any exceptions back to Spring container
            //so transactions can occur
            if (inMessage.getContent(Exception.class) != null && session != null) {
                PlatformTransactionManager m = jmsConfig.getTransactionManager();
                if (m != null) {
                    TransactionStatus status = m.getTransaction(null);
                    JmsResourceHolder resourceHolder =
                        (JmsResourceHolder) TransactionSynchronizationManager
                            .getResource(jmsConfig.getConnectionFactory());
                    boolean trans = resourceHolder == null
                        || !resourceHolder.containsSession(session);
View Full Code Here

Examples of org.springframework.transaction.PlatformTransactionManager

        this.usePooledConnection = usePooledConnection;
    }

    @Override
    public PlatformTransactionManager getTransactionManager() {
        PlatformTransactionManager answer = super.getTransactionManager();
        if (isTransacted() && answer == null) {
            // lets auto-default the transaction manager if its not specified
            answer = createTransactionManager();
            setTransactionManager(answer);
            answer = getTransactionManager();
View Full Code Here

Examples of org.springframework.transaction.PlatformTransactionManager

        this.sessionInfo.setMarshallingHelper( this.marshallingHelper );
        ((InternalKnowledgeRuntime) this.ksession).setEndOperationListener( new EndOperationListenerImpl() );       
       
        // Use the App scoped EntityManager if the user has provided it, and it is open.

        PlatformTransactionManager txManager = GrailsIntegration.getTransactionManager();
        DefaultTransactionDefinition txDef = new DefaultTransactionDefinition();
        txDef.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRED);
        TransactionStatus status = txManager.getTransaction(txDef);
        try {
            registerRollbackSync();
           
            GrailsIntegration.getGormDomainService().saveDomain(this.sessionInfo);
            updateBlobs(false);
            txManager.commit(status);
        } catch ( Exception t1 ) {
            try {
                txManager.rollback(status);
            } catch ( Throwable t2 ) {
                throw new RuntimeException( "Could not commit session or rollback",
                                            t2 );
            }
            throw new RuntimeException( "Could not commit session",
View Full Code Here

Examples of org.springframework.transaction.PlatformTransactionManager

    public Context getContext() {
        return this.kContext;
    }

    public synchronized <T> T execute(Command<T> command) {
        PlatformTransactionManager txManager = GrailsIntegration.getTransactionManager();
        DefaultTransactionDefinition txDef = new DefaultTransactionDefinition();
        txDef.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRED);
        TransactionStatus status = txManager.getTransaction(txDef);

        try {
            initKsession( this.sessionInfo.getId(),
                          this.marshallingHelper.getKbase(),
                          this.marshallingHelper.getConf() );
           
            registerRollbackSync();
            configureEnvironment();

            T result = ((GenericCommand<T>) command).execute( this.kContext );
       
            updateBlobs(command instanceof DisposeCommand);
            txManager.commit(status);

            return result;
        } catch (RuntimeException e){
            status.setRollbackOnly();
            throw e;
View Full Code Here

Examples of org.springframework.transaction.PlatformTransactionManager

  /**
   * @param args
   */
  public static void main(String[] args) throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml", TestSpringTxnStuff.class);
    PlatformTransactionManager txnManager =ctx.getBean(PlatformTransactionManager.class);
    DataSource dataSource = ctx.getBean(DataSource.class);
    JdbcTemplate jdbcTemplate = new JdbcTemplate();
    jdbcTemplate.setDataSource(dataSource);

    TransactionStatus status = txnManager.getTransaction(new DefaultTransactionDefinition());
    try {
      long id = 1;
      jdbcTemplate.execute("DELETE FROM COP_AUDIT_TRAIL_EVENT");
      System.out.println("wait #1");
      Thread.sleep(10000);
      doTransactional(dataSource, "INSERT INTO COP_AUDIT_TRAIL_EVENT (SEQ_ID, OCCURRENCE, CONVERSATION_ID, LOGLEVEL, CONTEXT, LONG_MESSAGE) VALUES ("+(id++)+", SYSTIMESTAMP, '123', 1, 'CTX', 'Hello World!')");
      doTransactional(dataSource, "INSERT INTO COP_AUDIT_TRAIL_EVENT (SEQ_ID, OCCURRENCE, CONVERSATION_ID, LOGLEVEL, CONTEXT, LONG_MESSAGE) VALUES ("+(id++)+", SYSTIMESTAMP, '123', 1, 'CTX', 'Hello World!')");
      System.out.println("wait #2");
      Thread.sleep(10000);
    }
    catch(Exception e) {
      txnManager.rollback(status);
      throw e;
    }
    txnManager.commit(status);
    System.out.println("wait #3");
    Thread.sleep(10000);
  }
View Full Code Here

Examples of org.springframework.transaction.PlatformTransactionManager

            incomingObserver.onMessage(inMessage);
           
            //need to propagate any exceptions back to Spring container
            //so transactions can occur
            if (inMessage.getContent(Exception.class) != null && session != null) {
                PlatformTransactionManager m = jmsConfig.getTransactionManager();
                if (m != null) {
                    TransactionStatus status = m.getTransaction(null);
                    JmsResourceHolder resourceHolder =
                        (JmsResourceHolder) TransactionSynchronizationManager
                            .getResource(jmsConfig.getConnectionFactory());
                    boolean trans = resourceHolder == null
                        || !resourceHolder.containsSession(session);
View Full Code Here

Examples of org.springframework.transaction.PlatformTransactionManager

        this.usePooledConnection = usePooledConnection;
    }

    @Override
    public PlatformTransactionManager getTransactionManager() {
        PlatformTransactionManager answer = super.getTransactionManager();
        if (isTransacted() && answer == null) {
            // lets auto-default the transaction manager if its not specified
            answer = createTransactionManager();
            setTransactionManager(answer);
            answer = getTransactionManager();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.