Coverage Report - org.kuali.rice.core.impl.cache.CacheServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
CacheServiceImpl
0%
0/19
0%
0/12
3.25
 
 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.core.impl.cache;
 17  
 
 18  
 import org.kuali.rice.core.api.cache.CacheService;
 19  
 import org.kuali.rice.core.api.cache.CacheTarget;
 20  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 21  
 import org.springframework.beans.factory.InitializingBean;
 22  
 import org.springframework.cache.Cache;
 23  
 import org.springframework.cache.CacheManager;
 24  
 
 25  
 import java.util.Collection;
 26  
 
 27  0
 public class CacheServiceImpl implements CacheService, InitializingBean {
 28  
 
 29  
     private CacheManager cacheManager;
 30  
 
 31  
     @Override
 32  
     public void flush(Collection<CacheTarget> cacheTargets) throws RiceIllegalArgumentException {
 33  0
         if (cacheTargets == null) {
 34  0
             throw new RiceIllegalArgumentException("cacheTargets is null");
 35  
         }
 36  0
         for (CacheTarget cacheTarget : cacheTargets) {
 37  0
             if (cacheTarget == null) {
 38  0
                 throw new RiceIllegalArgumentException("cacheTarget is null");
 39  
             }
 40  0
             final Cache c = getCache(cacheTarget.getCache());
 41  0
             if (c != null) {
 42  0
                 if (cacheTarget.containsKey()) {
 43  0
                     c.evict(cacheTarget.getKey());
 44  
                 } else {
 45  0
                     c.clear();
 46  
                 }
 47  
             }
 48  0
         }
 49  0
     }
 50  
 
 51  
     private Cache getCache(String cache) {
 52  0
         return cacheManager.getCache(cache);
 53  
     }
 54  
 
 55  
     public void setCacheManager(CacheManager cacheManager) {
 56  0
         this.cacheManager = cacheManager;
 57  0
     }
 58  
 
 59  
     @Override
 60  
     public void afterPropertiesSet() throws Exception {
 61  0
         if (cacheManager == null) {
 62  0
             throw new IllegalStateException("the cacheManager must be set");
 63  
         }
 64  0
     }
 65  
 }