KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > controller > cache > InstanceCache


1 /*
2  * Copyright 2003-2006 the original author or authors.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *
15  */

16 package com.jdon.controller.cache;
17
18 import java.util.HashMap JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import com.jdon.container.pico.Startable;
22 import com.jdon.util.Debug;
23
24 /**
25  * simple instance cache
26  * this class can be used cache some components.
27  * @author <a HREF="mailto:banqiao@jdon.com">banq</a>
28  *
29  */

30 public class InstanceCache implements Startable{
31     public final static String JavaDoc NAME = "InstanceCache";
32     
33     private Map JavaDoc pool = new HashMap JavaDoc();
34          
35     public void start(){
36         
37     }
38     
39     public void stop(){
40         pool.clear();
41     }
42
43     /* (non-Javadoc)
44      * @see com.jdon.controller.cache.Cache#get(java.lang.Object)
45      */

46     public Object JavaDoc get(Object JavaDoc key) {
47         return pool.get(key);
48     }
49
50     /* (non-Javadoc)
51      * @see com.jdon.controller.cache.Cache#put(java.lang.Object, java.lang.Object)
52      */

53     public void put(Object JavaDoc key, Object JavaDoc value) {
54         pool.put(key, value);
55     }
56
57     /* (non-Javadoc)
58      * @see com.jdon.controller.cache.Cache#remove(java.lang.Object)
59      */

60     public void remove(Object JavaDoc key) {
61         pool.remove(key);
62     }
63
64     /* (non-Javadoc)
65      * @see com.jdon.controller.cache.Cache#size()
66      */

67     public long size() {
68         return pool.size();
69     }
70
71     /* (non-Javadoc)
72      * @see com.jdon.controller.cache.Cache#clear()
73      */

74     public void clear() {
75         pool.clear();
76     }
77
78     /* (non-Javadoc)
79      * @see com.jdon.controller.cache.Cache#contain(java.lang.Object)
80      */

81     public boolean contain(Object JavaDoc key) {
82         return pool.containsKey(key);
83     }
84
85 }
86
Popular Tags