Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2010. Axon Framework
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.axonframework.commandhandling.interceptors;
A CommandHandlerInterceptor that uses a org.springframework.transaction.PlatformTransactionManager to manage transactions around command handling. If any events are handled synchronously (i.e. in the thread that processes the command), these handlers can use the same transaction.

Author(s):
Allard Buijze
Since:
0.5
See also:
org.springframework.transaction.PlatformTransactionManager
    @Override
    protected TransactionStatus startTransaction() {
    }
    @Override
    protected void commitTransaction(TransactionStatus transaction) {
        if (transaction.isNewTransaction()) {
            .commit(transaction);
        }
    }
    @Override
    protected void rollbackTransaction(TransactionStatus transaction) {
        if (transaction.isNewTransaction() && !transaction.isCompleted()) {
            .rollback(transaction);
        }
    }

    
Sets the transactionManager to use to manage transactions.

Parameters:
transactionManager the transactionManager to use to manage transactions.
    public void setTransactionManager(PlatformTransactionManager transactionManager) {
        this. = transactionManager;
    }

    
Sets the definition of the transaction to use.

Defaults to the org.springframework.transaction.support.DefaultTransactionDefinition, which uses propagation "REQUIRED" and the default isolation level of the underlying database.

Parameters:
definition The transaction definition to use
    public void setTransactionDefinition(TransactionDefinition definition) {
        this. = definition;
    }
New to GrepCode? Check out our FAQ X