View Javadoc

1   package org.apache.velocity.runtime.resource;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.    
20   */
21  
22  import java.util.Iterator;
23  import org.apache.velocity.runtime.RuntimeServices;
24  
25  /**
26   * Interface that defines the shape of a pluggable resource cache
27   *  for the included ResourceManager
28   *
29   * @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
30   * @version $Id: ResourceCache.java 463298 2006-10-12 16:10:32Z henning $
31   */
32  public interface ResourceCache
33  {
34      /**
35       *  initializes the ResourceCache.  Will be
36       *  called before any utilization
37       *
38       *  @param rs RuntimeServices to use for logging, etc
39       */
40      public void initialize( RuntimeServices rs );
41  
42      /**
43       *  retrieves a Resource from the
44       *  cache
45       *
46       *  @param resourceKey key for Resource to be retrieved
47       *  @return Resource specified or null if not found
48       */
49      public Resource get( Object resourceKey );
50  
51      /**
52       *  stores a Resource in the cache
53       *
54       *  @param resourceKey key to associate with the Resource
55       *  @param resource Resource to be stored
56       *  @return existing Resource stored under this key, or null if none
57       */
58      public Resource put( Object resourceKey, Resource resource );
59  
60      /**
61       *  removes a Resource from the cache
62       *
63       *  @param resourceKey resource to be removed
64       *  @return stored under key
65       */
66      public Resource remove( Object resourceKey );
67  
68      /**
69       *  returns an Iterator of Keys in the cache.
70       * @return An Iterator of Keys in the cache.
71       */
72       public Iterator enumerateKeys();
73  }