亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? jdotransactionmanager.java

?? spring framework 2.5.4源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Copyright 2002-2008 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.orm.jdo;

import javax.jdo.JDOException;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Transaction;
import javax.sql.DataSource;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.datasource.ConnectionHandle;
import org.springframework.jdbc.datasource.ConnectionHolder;
import org.springframework.jdbc.datasource.JdbcTransactionObjectSupport;
import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
import org.springframework.transaction.CannotCreateTransactionException;
import org.springframework.transaction.IllegalTransactionStateException;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionException;
import org.springframework.transaction.TransactionSystemException;
import org.springframework.transaction.support.AbstractPlatformTransactionManager;
import org.springframework.transaction.support.DefaultTransactionStatus;
import org.springframework.transaction.support.ResourceTransactionManager;
import org.springframework.transaction.support.TransactionSynchronizationManager;

/**
 * {@link org.springframework.transaction.PlatformTransactionManager} implementation
 * for a single JDO {@link javax.jdo.PersistenceManagerFactory}. Binds a JDO
 * PersistenceManager from the specified factory to the thread, potentially allowing
 * for one thread-bound PersistenceManager per factory.
 * {@link PersistenceManagerFactoryUtils} and {@link JdoTemplate} are aware of
 * thread-bound persistence managers and participate in such transactions automatically.
 * Using either of those (or going through a {@link TransactionAwarePersistenceManagerFactoryProxy}
 * is required for JDO access code supporting this transaction management mechanism.
 *
 * <p>This transaction manager is appropriate for applications that use a single
 * JDO PersistenceManagerFactory for transactional data access. JTA (usually through
 * {@link org.springframework.transaction.jta.JtaTransactionManager}) is necessary
 * for accessing multiple transactional resources within the same transaction.
 * Note that you need to configure your JDO provider accordingly in order to make
 * it participate in JTA transactions.
 *
 * <p>This transaction manager also supports direct DataSource access within a
 * transaction (i.e. plain JDBC code working with the same DataSource).
 * This allows for mixing services which access JDO and services which use plain
 * JDBC (without being aware of JDO)! Application code needs to stick to the
 * same simple Connection lookup pattern as with
 * {@link org.springframework.jdbc.datasource.DataSourceTransactionManager}
 * (i.e. {@link org.springframework.jdbc.datasource.DataSourceUtils#getConnection}
 * or going through a
 * {@link org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy}).
 *
 * <p>Note: To be able to register a DataSource's Connection for plain JDBC code,
 * this instance needs to be aware of the DataSource ({@link #setDataSource}).
 * The given DataSource should obviously match the one used by the given
 * PersistenceManagerFactory. This transaction manager will autodetect the DataSource
 * that acts as "connectionFactory" of the PersistenceManagerFactory, so you usually
 * don't need to explicitly specify the "dataSource" property.
 *
 * <p>On JDBC 3.0, this transaction manager supports nested transactions via JDBC 3.0
 * Savepoints. The {@link #setNestedTransactionAllowed} "nestedTransactionAllowed"}
 * flag defaults to "false", though, as nested transactions will just apply to the
 * JDBC Connection, not to the JDO PersistenceManager and its cached objects.
 * You can manually set the flag to "true" if you want to use nested transactions
 * for JDBC access code which participates in JDO transactions (provided that your
 * JDBC driver supports Savepoints). <i>Note that JDO itself does not support
 * nested transactions! Hence, do not expect JDO access code to semantically
 * participate in a nested transaction.</i>
 *
 * @author Juergen Hoeller
 * @since 03.06.2003
 * @see #setPersistenceManagerFactory
 * @see #setDataSource
 * @see javax.jdo.PersistenceManagerFactory#getConnectionFactory
 * @see LocalPersistenceManagerFactoryBean
 * @see PersistenceManagerFactoryUtils#getPersistenceManager
 * @see PersistenceManagerFactoryUtils#releasePersistenceManager
 * @see JdoTemplate
 * @see TransactionAwarePersistenceManagerFactoryProxy
 * @see org.springframework.jdbc.datasource.DataSourceUtils#getConnection
 * @see org.springframework.jdbc.datasource.DataSourceUtils#releaseConnection
 * @see org.springframework.jdbc.core.JdbcTemplate
 * @see org.springframework.jdbc.datasource.DataSourceTransactionManager
 * @see org.springframework.transaction.jta.JtaTransactionManager
 */
public class JdoTransactionManager extends AbstractPlatformTransactionManager
		implements ResourceTransactionManager, InitializingBean {

	private PersistenceManagerFactory persistenceManagerFactory;

	private DataSource dataSource;

	private boolean autodetectDataSource = true;

	private JdoDialect jdoDialect;


	/**
	 * Create a new JdoTransactionManager instance.
	 * A PersistenceManagerFactory has to be set to be able to use it.
	 * @see #setPersistenceManagerFactory
	 */
	public JdoTransactionManager() {
	}

	/**
	 * Create a new JdoTransactionManager instance.
	 * @param pmf PersistenceManagerFactory to manage transactions for
	 */
	public JdoTransactionManager(PersistenceManagerFactory pmf) {
		this.persistenceManagerFactory = pmf;
		afterPropertiesSet();
	}


	/**
	 * Set the PersistenceManagerFactory that this instance should manage transactions for.
	 * <p>The PersistenceManagerFactory specified here should be the target
	 * PersistenceManagerFactory to manage transactions for, not a
	 * TransactionAwarePersistenceManagerFactoryProxy. Only data access
	 * code may work with TransactionAwarePersistenceManagerFactoryProxy, while the
	 * transaction manager needs to work on the underlying target PersistenceManagerFactory.
	 * @see TransactionAwarePersistenceManagerFactoryProxy
	 */
	public void setPersistenceManagerFactory(PersistenceManagerFactory pmf) {
		this.persistenceManagerFactory = pmf;
	}

	/**
	 * Return the PersistenceManagerFactory that this instance should manage transactions for.
	 */
	public PersistenceManagerFactory getPersistenceManagerFactory() {
		return this.persistenceManagerFactory;
	}

	/**
	 * Set the JDBC DataSource that this instance should manage transactions for.
   * The DataSource should match the one used by the JDO PersistenceManagerFactory:
	 * for example, you could specify the same JNDI DataSource for both.
	 * <p>If the PersistenceManagerFactory uses a DataSource as connection factory,
	 * the DataSource will be autodetected: You can still explictly specify the
	 * DataSource, but you don't need to in this case.
	 * <p>A transactional JDBC Connection for this DataSource will be provided to
	 * application code accessing this DataSource directly via DataSourceUtils
	 * or JdbcTemplate. The Connection will be taken from the JDO PersistenceManager.
	 * <p>Note that you need to use a JDO dialect for a specific JDO provider to
	 * allow for exposing JDO transactions as JDBC transactions.
	 * <p>The DataSource specified here should be the target DataSource to manage
	 * transactions for, not a TransactionAwareDataSourceProxy. Only data access
	 * code may work with TransactionAwareDataSourceProxy, while the transaction
	 * manager needs to work on the underlying target DataSource. If there's
	 * nevertheless a TransactionAwareDataSourceProxy passed in, it will be
	 * unwrapped to extract its target DataSource.
	 * @see #setAutodetectDataSource
	 * @see #setJdoDialect
	 * @see javax.jdo.PersistenceManagerFactory#getConnectionFactory
	 * @see org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy
	 * @see org.springframework.jdbc.datasource.DataSourceUtils
	 * @see org.springframework.jdbc.core.JdbcTemplate
	 */
	public void setDataSource(DataSource dataSource) {
		if (dataSource instanceof TransactionAwareDataSourceProxy) {
			// If we got a TransactionAwareDataSourceProxy, we need to perform transactions
			// for its underlying target DataSource, else data access code won't see
			// properly exposed transactions (i.e. transactions for the target DataSource).
			this.dataSource = ((TransactionAwareDataSourceProxy) dataSource).getTargetDataSource();
		}
		else {
			this.dataSource = dataSource;
		}
	}

	/**
	 * Return the JDBC DataSource that this instance manages transactions for.
	 */
	public DataSource getDataSource() {
		return this.dataSource;
	}

	/**
	 * Set whether to autodetect a JDBC DataSource used by the JDO PersistenceManagerFactory,
	 * as returned by the <code>getConnectionFactory()</code> method. Default is "true".
	 * <p>Can be turned off to deliberately ignore an available DataSource,
	 * to not expose JDO transactions as JDBC transactions for that DataSource.
	 * @see #setDataSource
	 * @see javax.jdo.PersistenceManagerFactory#getConnectionFactory
	 */
	public void setAutodetectDataSource(boolean autodetectDataSource) {
		this.autodetectDataSource = autodetectDataSource;
	}

	/**
	 * Set the JDO dialect to use for this transaction manager.
	 * <p>The dialect object can be used to retrieve the underlying JDBC connection
	 * and thus allows for exposing JDO transactions as JDBC transactions.
	 * @see JdoDialect#getJdbcConnection
	 */
	public void setJdoDialect(JdoDialect jdoDialect) {
		this.jdoDialect = jdoDialect;
	}

	/**
	 * Return the JDO dialect to use for this transaction manager.
	 * <p>Creates a default one for the specified PersistenceManagerFactory if none set.
	 */
	public JdoDialect getJdoDialect() {
		if (this.jdoDialect == null) {
			this.jdoDialect = new DefaultJdoDialect();
		}
		return this.jdoDialect;
	}

	/**
	 * Eagerly initialize the JDO dialect, creating a default one
	 * for the specified PersistenceManagerFactory if none set.
	 * Auto-detect the PersistenceManagerFactory's DataSource, if any.
	 */
	public void afterPropertiesSet() {
		if (getPersistenceManagerFactory() == null) {
			throw new IllegalArgumentException("Property 'persistenceManagerFactory' is required");
		}
		// Build default JdoDialect if none explicitly specified.
		if (this.jdoDialect == null) {
			this.jdoDialect = new DefaultJdoDialect(getPersistenceManagerFactory().getConnectionFactory());
		}

		// Check for DataSource as connection factory.
		if (this.autodetectDataSource && getDataSource() == null) {
			Object pmfcf = getPersistenceManagerFactory().getConnectionFactory();
			if (pmfcf instanceof DataSource) {
				// Use the PersistenceManagerFactory's DataSource for exposing transactions to JDBC code.
				this.dataSource = (DataSource) pmfcf;
				if (logger.isInfoEnabled()) {
					logger.info("Using DataSource [" + this.dataSource +
							"] of JDO PersistenceManagerFactory for JdoTransactionManager");
				}
			}
		}
	}


	public Object getResourceFactory() {
		return getPersistenceManagerFactory();
	}

	protected Object doGetTransaction() {
		JdoTransactionObject txObject = new JdoTransactionObject();
		txObject.setSavepointAllowed(isNestedTransactionAllowed());

		PersistenceManagerHolder pmHolder = (PersistenceManagerHolder)
				TransactionSynchronizationManager.getResource(getPersistenceManagerFactory());
		if (pmHolder != null) {
			if (logger.isDebugEnabled()) {
				logger.debug("Found thread-bound PersistenceManager [" +
						pmHolder.getPersistenceManager() + "] for JDO transaction");
			}
			txObject.setPersistenceManagerHolder(pmHolder, false);
		}

		if (getDataSource() != null) {
			ConnectionHolder conHolder = (ConnectionHolder)
					TransactionSynchronizationManager.getResource(getDataSource());
			txObject.setConnectionHolder(conHolder);
		}

		return txObject;
	}

	protected boolean isExistingTransaction(Object transaction) {
		return ((JdoTransactionObject) transaction).hasTransaction();
	}

	protected void doBegin(Object transaction, TransactionDefinition definition) {
		JdoTransactionObject txObject = (JdoTransactionObject) transaction;

		if (txObject.hasConnectionHolder() && !txObject.getConnectionHolder().isSynchronizedWithTransaction()) {
			throw new IllegalTransactionStateException(
					"Pre-bound JDBC Connection found! JdoTransactionManager does not support " +
					"running within DataSourceTransactionManager if told to manage the DataSource itself. " +

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一级二级三级在线免费观看| 国产一区二区精品在线观看| 久久久久久久久久久99999| 91美女片黄在线观看| 国产成人精品一区二区三区四区| 日韩精品久久久久久| 亚洲高清不卡在线观看| 一区二区三区欧美激情| 亚洲视频在线一区二区| 亚洲欧洲无码一区二区三区| 欧美国产一区二区| 亚洲色图欧美激情| 一区二区三区欧美日韩| 一二三四社区欧美黄| 亚洲成av人片一区二区三区| 亚洲大型综合色站| 石原莉奈在线亚洲三区| 老司机精品视频在线| 激情偷乱视频一区二区三区| 国产一区999| 成人av电影在线播放| 色噜噜偷拍精品综合在线| 91成人在线精品| 欧美精品在线观看播放| 日韩欧美黄色影院| 欧美国产精品v| 亚洲精品高清在线观看| 日本亚洲免费观看| 国产精品69久久久久水密桃| 成人一区二区在线观看| 91精品办公室少妇高潮对白| 91精品国产乱码| 久久亚洲综合av| 一区二区三区欧美日韩| 免费成人深夜小野草| 国产suv精品一区二区6| 欧美日韩精品是欧美日韩精品| 日韩视频一区二区三区在线播放| 欧美激情一区二区| 亚洲成a人v欧美综合天堂下载| 免费在线观看一区| 97久久人人超碰| 欧美电视剧免费观看| 亚洲欧洲日韩综合一区二区| 日韩黄色片在线观看| 成人av午夜电影| 欧美一级生活片| 亚洲精品免费在线观看| 激情综合五月婷婷| 欧美亚洲国产怡红院影院| 久久影院视频免费| 丝袜脚交一区二区| 91在线porny国产在线看| 精品电影一区二区| 亚洲国产婷婷综合在线精品| 粉嫩嫩av羞羞动漫久久久| 欧美精品aⅴ在线视频| 久久精品男人的天堂| 日韩成人一区二区| 99久久精品国产毛片| 精品嫩草影院久久| 青娱乐精品视频| www.日韩大片| 日韩视频永久免费| 五月婷婷久久丁香| 日本丰满少妇一区二区三区| 国产清纯在线一区二区www| 免费国产亚洲视频| 欧美日本在线一区| 一二三区精品视频| 色婷婷久久久亚洲一区二区三区 | 欧美日本不卡视频| 精品福利一二区| 亚洲福利视频一区二区| 色哟哟一区二区三区| 国产精品免费久久| 国产成+人+日韩+欧美+亚洲| 精品粉嫩aⅴ一区二区三区四区| 亚洲高清久久久| 欧美精品丝袜中出| 午夜欧美一区二区三区在线播放| 欧洲精品一区二区| 亚洲国产欧美一区二区三区丁香婷| 91在线视频播放| 最近中文字幕一区二区三区| 成人做爰69片免费看网站| 国产精品久久久久久久久久久免费看 | 国产欧美日韩麻豆91| 国产一区二区福利| 国产亚洲精品久| 国产成人精品综合在线观看| 欧美高清一级片在线观看| 国产成人激情av| 国产精品久久久久久福利一牛影视 | 欧美一级欧美三级| 久久成人av少妇免费| 久久久精品免费免费| 久久99热国产| 国产精品网站在线观看| 成人免费观看av| 日本一区二区动态图| 成人毛片在线观看| 亚洲欧洲日韩在线| 91超碰这里只有精品国产| 青娱乐精品视频| 国产日韩欧美在线一区| 色婷婷综合久久久久中文一区二区| 五月婷婷久久丁香| 久久伊人中文字幕| 日本黄色一区二区| 麻豆成人在线观看| 中文字幕免费一区| 欧美性高清videossexo| 九九精品视频在线看| 国产精品久久久久永久免费观看| 一本色道久久综合狠狠躁的推荐 | 美女性感视频久久| 制服.丝袜.亚洲.中文.综合| 日本不卡视频在线观看| 欧美一区二区三区视频免费播放 | 粉嫩av一区二区三区粉嫩| 中文字幕乱码亚洲精品一区| 成人激情图片网| 亚洲欧美日韩电影| 欧洲精品一区二区| 日日夜夜免费精品| 欧美精品一区二区三区蜜桃| 精品一区二区三区av| 欧美videos大乳护士334| 欧美一个色资源| 国内精品在线播放| 国产精品成人免费| 欧美性感一区二区三区| 久久激情五月激情| 亚洲国产激情av| 在线观看视频一区| 免费看日韩精品| 中文字幕第一区第二区| 色偷偷久久一区二区三区| 日韩电影在线免费看| 精品成人一区二区三区四区| 高清国产一区二区三区| 一区二区三区日韩在线观看| 欧美一区二区在线播放| 国产激情一区二区三区| 亚洲精品免费在线| 色综合久久天天综合网| 亚洲一区在线电影| 91精品婷婷国产综合久久| 亚洲综合在线视频| 亚洲欧美日本在线| 亚洲精品免费播放| 国产乱码一区二区三区| 亚洲免费观看在线观看| 日韩一卡二卡三卡国产欧美| 国产精品一区二区久久不卡 | 91精品国产欧美一区二区18| 粉嫩13p一区二区三区| 亚洲一二三区在线观看| 337p日本欧洲亚洲大胆精品| 在线亚洲高清视频| 国产成人亚洲精品青草天美 | 国产精品中文字幕一区二区三区| 亚洲欧洲精品成人久久奇米网| 91精品国产高清一区二区三区| 91偷拍与自偷拍精品| 久久国产视频网| 亚洲va天堂va国产va久| 国产精品免费视频观看| 日韩限制级电影在线观看| 亚洲图片有声小说| 精品久久久久久无| 国产亚洲综合在线| 不卡一区二区三区四区| 亚洲自拍偷拍av| 中文字幕精品综合| 欧美亚洲图片小说| 国内精品国产三级国产a久久| 国产亚洲成aⅴ人片在线观看 | 日韩三级视频在线看| 99re6这里只有精品视频在线观看| 久久狠狠亚洲综合| 亚洲成人福利片| 日韩美女主播在线视频一区二区三区| 成人福利视频在线| 国产精品国产三级国产aⅴ无密码| 日韩欧美色综合网站| 欧亚一区二区三区| 亚洲一区二区在线播放相泽| 国产在线精品一区二区不卡了| 一区二区三区精品视频| 亚洲欧美一区二区三区国产精品| 国产精品免费视频观看| 国产精品美女视频| 精品国产免费人成电影在线观看四季| 91精品国产综合久久久久久久 | 欧美日韩视频不卡| 色爱区综合激月婷婷| 欧美高清精品3d| 欧美一区二区三区白人|