Clover coverage report - JFox Service-Oriented Application Framework - 1.0-RC1 Coverage timestamp: 星期五 八月 19 2005 13:21:55 CST FRAMES NO FRAMES |
file stats: | LOC: | 105 |  | Methods: | 6
| NCLOC: | 32 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
OSCacheServiceImpl.java | - | 0% | 0% | 0% |

1 |  |
     /**
2 |  |
      * @(#)OSCacheServiceImpl.java
3 |  |
      *
4 |  |
      * JFoxSOAF, Service-Oriented Application Framework
5 |  |
      *
6 |  |
      * Copyright(c) JFoxSOAF Team
7 |  |
      *
8 |  |
      * Licensed under the GNU LGPL, Version 2.1 (the "License");
9 |  |
      * you may not use this file except in compliance with the License.
10 |  |
      * You may obtain a copy of the License at
11 |  |
      *
12 |  |
      * http://www.gnu.org/copyleft/lesser.html
13 |  |
      *
14 |  |
      * Unless required by applicable law or agreed to in writing, software
15 |  |
      * distributed under the License is distributed on an "AS IS" BASIS,
16 |  |
      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 |  |
      * See the License for the specific language governing permissions and
18 |  |
      * limitations under the License.
19 |  |
      *
20 |  |
      * For more information, please visit:
21 |  |
      * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
22 |  |
      * http://www.huihoo.org/jfox/jfoxsoaf
23 |  |
      */
24 |  |
25 |  |
     package org.huihoo.jfox.soaf.services.cache;
26 |  |
27 |  |
     import org.huihoo.jfox.soaf.exception.CacheServiceException;
28 |  |
29 |  |
     import com.opensymphony.oscache.base.NeedsRefreshException;
30 |  |
     import com.opensymphony.oscache.general.GeneralCacheAdministrator;
31 |  |
32 |  |
     /**
33 |  |
      * <p>
34 |  |
      * Support for OpenSymphony OSCache
35 |  |
      * </p>
36 |  |
      *
37 |  |
      * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
38 |  |
      * @author <a href="mailto:m.bogaert@intrasoft.be">Mathias Bogaert </a>
39 |  |
      * @version $Revision: 1.1 $ $Date: 2005/05/22 06:48:52 $
40 |  |
      * @version Revision: 1.0
41 |  |
      */
42 |  |
43 |  |
     public class OSCacheServiceImpl implements CacheService {
44 |  |
45 |  |
         private GeneralCacheAdministrator cache = new GeneralCacheAdministrator();
46 |  |
47 |  |
         private int refreshPeriod;
48 |  |
49 |  |
         private String cron;
50 |  |
51 |  |
         /**
52 |  |
          * Default constructor with given param
53 |  |
          *
54 |  |
          * @param refreshPeriod
55 |  |
          * @param cron
56 |  |
          */
57 | 0 |
         public OSCacheServiceImpl(int refreshPeriod, String cron) {
58 | 0 |
             this.refreshPeriod = refreshPeriod;
59 | 0 |
             this.cron = cron;
60 |  |
         }
61 |  |
62 |  |
         /**
63 |  |
          * @see org.huihoo.jfox.soaf.services.cache.CacheService#get(java.lang.Object)
64 |  |
          */
65 | 0 |
         public Object get(Object key) throws CacheServiceException {
66 | 0 |
             try {
67 | 0 |
                 return cache.getFromCache(String.valueOf(key), refreshPeriod, cron);
68 |  |
             } catch (NeedsRefreshException e) {
69 | 0 |
                 cache.cancelUpdate(String.valueOf(key));
70 | 0 |
                 return null;
71 |  |
             }
72 |  |
         }
73 |  |
74 |  |
         /**
75 |  |
          * @see org.huihoo.jfox.soaf.services.cache.CacheService#put(java.lang.Object,
76 |  |
          *      java.lang.Object)
77 |  |
          */
78 | 0 |
         public void put(Object key, Object value) throws CacheServiceException {
79 | 0 |
             cache.putInCache(String.valueOf(key), value);
80 |  |
         }
81 |  |
82 |  |
         /**
83 |  |
          * @see org.huihoo.jfox.soaf.services.cache.CacheService#remove(java.lang.Object)
84 |  |
          */
85 | 0 |
         public void remove(Object key) throws CacheServiceException {
86 | 0 |
             cache.flushEntry(String.valueOf(key));
87 |  |
         }
88 |  |
89 |  |
         /**
90 |  |
          * @see org.huihoo.jfox.soaf.services.cache.CacheService#clear()
91 |  |
          */
92 | 0 |
         public void clear() throws CacheServiceException {
93 | 0 |
             cache.flushAll();
94 |  |
         }
95 |  |
96 |  |
         /**
97 |  |
          * Set cache capacity
98 |  |
          *
99 |  |
          * @param cacheCapacity
100 |  |
          */
101 | 0 |
         public void setCacheCapacity(int cacheCapacity) {
102 | 0 |
             cache.setCacheCapacity(cacheCapacity);
103 |  |
         }
104 |  |
105 |  |
     }