Coverage Report - org.kuali.rice.krad.util.KualiObjectCachePerBrokerImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
KualiObjectCachePerBrokerImpl
0%
0/19
0%
0/10
1.6
 
 1  
 /**
 2  
  * Copyright 2005-2011 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 java.util.Properties;
 19  
 
 20  
 import org.apache.log4j.Logger;
 21  
 import org.apache.ojb.broker.Identity;
 22  
 import org.apache.ojb.broker.PersistenceBroker;
 23  
 import org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl;
 24  
 
 25  
 public class KualiObjectCachePerBrokerImpl extends ObjectCachePerBrokerImpl {
 26  0
     private static final Logger LOG = Logger.getLogger(KualiObjectCachePerBrokerImpl.class);
 27  
 
 28  
 
 29  
     private final String brokerId;
 30  
 
 31  
     public KualiObjectCachePerBrokerImpl(PersistenceBroker broker, Properties prop) {
 32  0
         super(broker, prop);
 33  0
         brokerId = broker.getClass().getName() + "@" + broker.hashCode();
 34  
 
 35  0
         LOG.debug("created objectCache for broker " + brokerId);
 36  0
     }
 37  
 
 38  
     /**
 39  
      * Clear ObjectCache. I.e. remove all entries for classes and objects.
 40  
      */
 41  
     public void clear() {
 42  0
         super.clear();
 43  
 
 44  0
         LOG.debug("cleared objectCache for broker " + brokerId);
 45  0
     }
 46  
 
 47  
     /**
 48  
      * @see org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl#cache(org.apache.ojb.broker.Identity, java.lang.Object)
 49  
      */
 50  
     public void cache(Identity oid, Object obj) {
 51  0
         super.cache(oid, obj);
 52  
 
 53  0
         boolean cached = (super.lookup(oid) != null);
 54  0
         LOG.debug((cached ? "cached oid " : "unable to cache oid ") + oid + " in objectCache for broker " + brokerId);
 55  0
     }
 56  
 
 57  
     /**
 58  
      * @see org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl#cacheIfNew(org.apache.ojb.broker.Identity, java.lang.Object)
 59  
      */
 60  
     public boolean cacheIfNew(Identity oid, Object obj) {
 61  0
         boolean cachedIfNew = super.cacheIfNew(oid, obj);
 62  
 
 63  0
         boolean cached = (super.lookup(oid) != null);
 64  0
         LOG.debug((cached ? "cached new oid " : "unable to cache new oid ") + oid + " in objectCache for broker " + brokerId);
 65  
 
 66  0
         return cachedIfNew;
 67  
     }
 68  
 
 69  
     /**
 70  
      * @see org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl#lookup(org.apache.ojb.broker.Identity)
 71  
      */
 72  
     public Object lookup(Identity oid) {
 73  0
         Object o = super.lookup(oid);
 74  
 
 75  0
         LOG.debug((o != null ? "found oid " : "cannot find oid ") + oid + " in objectCache for broker " + brokerId);
 76  
 
 77  0
         return o;
 78  
     }
 79  
 }