|
Spring Framework example source code file (DefaultTransactionDefinition.java)
The Spring Framework DefaultTransactionDefinition.java source code
/*
* Copyright 2002-2007 the original author or authors.
*
* 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.springframework.transaction.support;
import java.io.Serializable;
import org.springframework.core.Constants;
import org.springframework.transaction.TransactionDefinition;
/**
* Default implementation of the {@link TransactionDefinition} interface,
* offering bean-style configuration and sensible default values
* (PROPAGATION_REQUIRED, ISOLATION_DEFAULT, TIMEOUT_DEFAULT, readOnly=false).
*
* <p>Base class for both {@link TransactionTemplate} and
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}.
*
* @author Juergen Hoeller
* @since 08.05.2003
*/
public class DefaultTransactionDefinition implements TransactionDefinition, Serializable {
/** Prefix for the propagation constants defined in TransactionDefinition */
public static final String PREFIX_PROPAGATION = "PROPAGATION_";
/** Prefix for the isolation constants defined in TransactionDefinition */
public static final String PREFIX_ISOLATION = "ISOLATION_";
/** Prefix for transaction timeout values in description strings */
public static final String PREFIX_TIMEOUT = "timeout_";
/** Marker for read-only transactions in description strings */
public static final String READ_ONLY_MARKER = "readOnly";
/** Constants instance for TransactionDefinition */
static final Constants constants = new Constants(TransactionDefinition.class);
private int propagationBehavior = PROPAGATION_REQUIRED;
private int isolationLevel = ISOLATION_DEFAULT;
private int timeout = TIMEOUT_DEFAULT;
private boolean readOnly = false;
private String name;
/**
* Create a new DefaultTransactionDefinition, with default settings.
* Can be modified through bean property setters.
* @see #setPropagationBehavior
* @see #setIsolationLevel
* @see #setTimeout
* @see #setReadOnly
* @see #setName
*/
public DefaultTransactionDefinition() {
}
/**
* Copy constructor. Definition can be modified through bean property setters.
* @see #setPropagationBehavior
* @see #setIsolationLevel
* @see #setTimeout
* @see #setReadOnly
* @see #setName
*/
public DefaultTransactionDefinition(TransactionDefinition other) {
this.propagationBehavior = other.getPropagationBehavior();
this.isolationLevel = other.getIsolationLevel();
this.timeout = other.getTimeout();
this.readOnly = other.isReadOnly();
this.name = other.getName();
}
/**
* Create a new DefaultTransactionDefinition with the the given
* propagation behavior. Can be modified through bean property setters.
* @param propagationBehavior one of the propagation constants in the
* TransactionDefinition interface
* @see #setIsolationLevel
* @see #setTimeout
* @see #setReadOnly
*/
public DefaultTransactionDefinition(int propagationBehavior) {
this.propagationBehavior = propagationBehavior;
}
/**
* Set the propagation behavior by the name of the corresponding constant in
* TransactionDefinition, e.g. "PROPAGATION_REQUIRED".
* @param constantName name of the constant
* @exception IllegalArgumentException if the supplied value is not resolvable
* to one of the <code>PROPAGATION_ constants or is
Other Spring Framework examples (source code examples)Here is a short list of links related to this Spring Framework DefaultTransactionDefinition.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.