View Javadoc

1   package org.apache.jcs.auxiliary.disk;
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  
24  import org.apache.jcs.engine.behavior.ICacheElement;
25  import org.apache.jcs.engine.behavior.IElementAttributes;
26  
27  /***
28   * Wrapper for cache elements in purgatory.
29   * <p>
30   * Elements are stored in purgatory when they are spooled to the auxilliary cache, but have not yet
31   * been written to disk.
32   */
33  public class PurgatoryElement
34      implements ICacheElement, Serializable
35  {
36      /*** Don't change */
37      private static final long serialVersionUID = -8152034342684135628L;
38  
39      /*** Is the element ready to be spooled? */
40      protected boolean spoolable = false;
41  
42      /*** Wrapped cache Element */
43      protected ICacheElement cacheElement;
44  
45      /***
46       * Constructor for the PurgatoryElement object
47       * <p>
48       * @param cacheElement CacheElement to wrap.
49       */
50      public PurgatoryElement( ICacheElement cacheElement )
51      {
52          this.cacheElement = cacheElement;
53      }
54  
55      /***
56       * Gets the spoolable property.
57       * <p>
58       * @return The spoolable value
59       */
60      public boolean isSpoolable()
61      {
62          return spoolable;
63      }
64  
65      /***
66       * Sets the spoolable property.
67       * <p>
68       * @param spoolable The new spoolable value
69       */
70      public void setSpoolable( boolean spoolable )
71      {
72          this.spoolable = spoolable;
73      }
74  
75      /***
76       * Get the wrapped cache element.
77       * <p>
78       * @return ICacheElement
79       */
80      public ICacheElement getCacheElement()
81      {
82          return cacheElement;
83      }
84  
85      // ------------------------------------------------ interface ICacheElement
86  
87      /***
88       * @return cacheElement.getCacheName();
89       * @see ICacheElement#getCacheName
90       */
91      public String getCacheName()
92      {
93          return cacheElement.getCacheName();
94      }
95  
96      /***
97       * @return cacheElement.getKey();
98       * @see ICacheElement#getKey
99       */
100     public Serializable getKey()
101     {
102         return cacheElement.getKey();
103     }
104 
105     /***
106      * @return cacheElement.getVal();
107      * @see ICacheElement#getVal
108      */
109     public Serializable getVal()
110     {
111         return cacheElement.getVal();
112     }
113 
114     /***
115      * @return cacheElement.getElementAttributes();
116      * @see ICacheElement#getElementAttributes
117      */
118     public IElementAttributes getElementAttributes()
119     {
120         return cacheElement.getElementAttributes();
121     }
122 
123     /***
124      * @param attr
125      * @see ICacheElement#setElementAttributes
126      */
127     public void setElementAttributes( IElementAttributes attr )
128     {
129         cacheElement.setElementAttributes( attr );
130     }
131 }