View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.util;
17  
18  import org.apache.log4j.Logger;
19  import org.apache.ojb.broker.PBKey;
20  import org.apache.ojb.broker.TransactionAbortedException;
21  import org.apache.ojb.broker.TransactionInProgressException;
22  import org.apache.ojb.broker.TransactionNotInProgressException;
23  import org.apache.ojb.broker.core.PersistenceBrokerFactoryIF;
24  import org.apache.ojb.broker.core.PersistenceBrokerImpl;
25  
26  public class KualiPersistenceBrokerImpl extends PersistenceBrokerImpl {
27      private static final Logger LOG = Logger.getLogger(KualiPersistenceBrokerImpl.class);
28  
29  
30      private boolean fresh = true;
31  
32      public KualiPersistenceBrokerImpl(PBKey key, PersistenceBrokerFactoryIF pbf) {
33          super(key, pbf);
34      }
35  
36      public boolean isFresh() {
37          return fresh;
38      }
39  
40  
41      /**
42       * @see org.apache.ojb.broker.core.PersistenceBrokerImpl#beginTransaction()
43       */
44      public synchronized void beginTransaction() throws TransactionInProgressException, TransactionAbortedException {
45          LOG.debug("beginning transaction for persistenceBroker " + getClass().getName() + "@" + hashCode());
46  
47          super.beginTransaction();
48      }
49  
50      /**
51       * @see org.apache.ojb.broker.core.PersistenceBrokerImpl#abortTransaction()
52       */
53      public synchronized void abortTransaction() throws TransactionNotInProgressException {
54          LOG.debug("aborting transaction for persistenceBroker " + getClass().getName() + "@" + hashCode());
55  
56          super.abortTransaction();
57      }
58  
59      /**
60       * @see org.apache.ojb.broker.core.PersistenceBrokerImpl#commitTransaction()
61       */
62      public synchronized void commitTransaction() throws TransactionNotInProgressException, TransactionAbortedException {
63          LOG.debug("committing transaction for persistenceBroker " + getClass().getName() + "@" + hashCode());
64  
65          super.commitTransaction();
66      }
67  
68      /**
69       * @see org.apache.ojb.broker.core.PersistenceBrokerImpl#close()
70       */
71      public boolean close() {
72          LOG.debug("closing persistenceBroker " + getClass().getName() + "@" + hashCode());
73          fresh = false;
74  
75          return super.close();
76      }
77  }