KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > velocity > runtime > resource > ResourceCacheImpl


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

18
19 import java.util.Hashtable JavaDoc;
20 import java.util.Map JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import org.apache.velocity.runtime.RuntimeServices;
23
24 /**
25  * Default implementation of the resource cache for the default
26  * ResourceManager.
27  *
28  * @author <a HREF="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
29  * @author <a HREF="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
30  * @version $Id: ResourceCacheImpl.java,v 1.2.8.1 2004/03/03 23:23:01 geirm Exp $
31  */

32 public class ResourceCacheImpl implements ResourceCache
33 {
34     /**
35      * Cache storage, assumed to be thread-safe.
36      */

37     protected Map JavaDoc cache = new Hashtable JavaDoc();
38
39     /**
40      * Runtime services, generally initialized by the
41      * <code>initialize()</code> method.
42      */

43     protected RuntimeServices rsvc = null;
44     
45     public void initialize( RuntimeServices rs )
46     {
47         rsvc = rs;
48         
49         rsvc.info("ResourceCache : initialized. (" + this.getClass() + ")");
50     }
51     
52     public Resource get( Object JavaDoc key )
53     {
54         return (Resource) cache.get( key );
55     }
56     
57     public Resource put( Object JavaDoc key, Resource value )
58     {
59         return (Resource) cache.put( key, value );
60     }
61     
62     public Resource remove( Object JavaDoc key )
63     {
64         return (Resource) cache.remove( key );
65     }
66     
67     public Iterator JavaDoc enumerateKeys()
68     {
69         return cache.keySet().iterator();
70     }
71 }
72
Popular Tags