View Javadoc

1   package org.apache.jcs.engine;
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.io.Serializable;
23  import java.util.Collections;
24  import java.util.Map;
25  import java.util.Set;
26  
27  import org.apache.commons.logging.Log;
28  import org.apache.commons.logging.LogFactory;
29  import org.apache.jcs.engine.behavior.ICacheElement;
30  import org.apache.jcs.engine.behavior.ICacheService;
31  import org.apache.jcs.engine.behavior.IZombie;
32  
33  /***
34   * Zombie adapter for any cache service. Balks at every call.
35   */
36  public class ZombieCacheService
37      implements ICacheService, IZombie
38  {
39      /*** The logger. */
40      private static final Log log = LogFactory.getLog( ZombieCacheService.class );
41  
42      /***
43       * @param item
44       */
45      public void put( ICacheElement item )
46      {
47          if ( log.isDebugEnabled() )
48          {
49              log.debug( "Zombie put for item " + item );
50          }
51          // zombies have no inner life
52      }
53  
54      /***
55       * Does nothing.
56       * <p>
57       * @param item
58       */
59      public void update( ICacheElement item )
60      {
61          // zombies have no inner life
62      }
63  
64      /***
65       * @param cacheName
66       * @param key
67       * @return null. zombies have no internal data
68       */
69      public ICacheElement get( String cacheName, Serializable key )
70      {
71          return null;
72      }
73  
74      /***
75       * Returns an empty map. Zombies have no internal data.
76       * <p>
77       * @param cacheName
78       * @param keys
79       * @return Collections.EMPTY_MAP
80       */
81      public Map getMultiple( String cacheName, Set keys )
82      {
83          return Collections.EMPTY_MAP;
84      }
85  
86      /***
87       * Returns an empty map. Zombies have no internal data.
88       * <p>
89       * @param cacheName
90       * @param pattern
91       * @return Collections.EMPTY_MAP
92       */
93      public Map getMatching( String cacheName, String pattern )
94      {
95          return Collections.EMPTY_MAP;
96      }
97  
98      /***
99       * Logs the get to debug, but always balks.
100      * <p>
101      * @param cacheName
102      * @param key
103      * @param container
104      * @return null always
105      */
106     public Serializable get( String cacheName, Serializable key, boolean container )
107     {
108         if ( log.isDebugEnabled() )
109         {
110             log.debug( "Zombie get for key [" + key + "] cacheName [" + cacheName + "] container [" + container + "]" );
111         }
112         // zombies have no inner life
113         return null;
114     }
115 
116     /***
117      * @param cacheName
118      * @param key
119      */
120     public void remove( String cacheName, Serializable key )
121     {
122         // zombies have no inner life
123     }
124 
125     /***
126      * @param cacheName
127      */
128     public void removeAll( String cacheName )
129     {
130         // zombies have no inner life
131     }
132 
133     /***
134      * @param cacheName
135      */
136     public void dispose( String cacheName )
137     {
138         // zombies have no inner life
139         return;
140     }
141 
142     /***
143      * Frees all caches.
144      */
145     public void release()
146     {
147         // zombies have no inner life
148         return;
149     }
150 }