001/* 002 * Copyright 2002-2007 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.orm.jdo; 018 019import javax.jdo.PersistenceManager; 020 021import org.springframework.transaction.support.ResourceHolderSupport; 022import org.springframework.util.Assert; 023 024/** 025 * Holder wrapping a JDO PersistenceManager. 026 * JdoTransactionManager binds instances of this class 027 * to the thread, for a given PersistenceManagerFactory. 028 * 029 * <p>Note: This is an SPI class, not intended to be used by applications. 030 * 031 * @author Juergen Hoeller 032 * @since 03.06.2003 033 * @see JdoTransactionManager 034 * @see PersistenceManagerFactoryUtils 035 */ 036public class PersistenceManagerHolder extends ResourceHolderSupport { 037 038 private final PersistenceManager persistenceManager; 039 040 private boolean transactionActive; 041 042 043 public PersistenceManagerHolder(PersistenceManager persistenceManager) { 044 Assert.notNull(persistenceManager, "PersistenceManager must not be null"); 045 this.persistenceManager = persistenceManager; 046 } 047 048 049 public PersistenceManager getPersistenceManager() { 050 return this.persistenceManager; 051 } 052 053 protected void setTransactionActive(boolean transactionActive) { 054 this.transactionActive = transactionActive; 055 } 056 057 protected boolean isTransactionActive() { 058 return this.transactionActive; 059 } 060 061 @Override 062 public void clear() { 063 super.clear(); 064 this.transactionActive = false; 065 } 066 067}