001 /** 002 * Copyright 2005-2011 The Kuali Foundation 003 * 004 * Licensed under the Educational Community 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 * http://www.opensource.org/licenses/ecl2.php 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 package org.kuali.rice.krad.util; 017 018 import org.apache.log4j.Logger; 019 import org.apache.ojb.broker.PBKey; 020 import org.apache.ojb.broker.TransactionAbortedException; 021 import org.apache.ojb.broker.TransactionInProgressException; 022 import org.apache.ojb.broker.TransactionNotInProgressException; 023 import org.apache.ojb.broker.core.PersistenceBrokerFactoryIF; 024 import org.apache.ojb.broker.core.PersistenceBrokerImpl; 025 026 public class KualiPersistenceBrokerImpl extends PersistenceBrokerImpl { 027 private static final Logger LOG = Logger.getLogger(KualiPersistenceBrokerImpl.class); 028 029 030 private boolean fresh = true; 031 032 public KualiPersistenceBrokerImpl(PBKey key, PersistenceBrokerFactoryIF pbf) { 033 super(key, pbf); 034 } 035 036 public boolean isFresh() { 037 return fresh; 038 } 039 040 041 /** 042 * @see org.apache.ojb.broker.core.PersistenceBrokerImpl#beginTransaction() 043 */ 044 public synchronized void beginTransaction() throws TransactionInProgressException, TransactionAbortedException { 045 LOG.debug("beginning transaction for persistenceBroker " + getClass().getName() + "@" + hashCode()); 046 047 super.beginTransaction(); 048 } 049 050 /** 051 * @see org.apache.ojb.broker.core.PersistenceBrokerImpl#abortTransaction() 052 */ 053 public synchronized void abortTransaction() throws TransactionNotInProgressException { 054 LOG.debug("aborting transaction for persistenceBroker " + getClass().getName() + "@" + hashCode()); 055 056 super.abortTransaction(); 057 } 058 059 /** 060 * @see org.apache.ojb.broker.core.PersistenceBrokerImpl#commitTransaction() 061 */ 062 public synchronized void commitTransaction() throws TransactionNotInProgressException, TransactionAbortedException { 063 LOG.debug("committing transaction for persistenceBroker " + getClass().getName() + "@" + hashCode()); 064 065 super.commitTransaction(); 066 } 067 068 /** 069 * @see org.apache.ojb.broker.core.PersistenceBrokerImpl#close() 070 */ 071 public boolean close() { 072 LOG.debug("closing persistenceBroker " + getClass().getName() + "@" + hashCode()); 073 fresh = false; 074 075 return super.close(); 076 } 077 }