View Javadoc

1   package org.apache.jcs.engine.behavior;
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.ArrayList;
23  
24  import org.apache.jcs.engine.control.event.behavior.IElementEventHandler;
25  
26  /***
27   * Interface for cache element attributes classes. Every item is the cache is
28   * associated with an element attributes object. It is used to track the life of
29   * the object as well as to restrict its behavior. By default, elements get a
30   * clone of the region's attributes.
31   *
32   */
33  public interface IElementAttributes
34  {
35  
36      /***
37       * Sets the version attribute of the IAttributes object
38       *
39       * @param version
40       *            The new version value
41       */
42      public void setVersion( long version );
43  
44      /***
45       * Sets the maxLife attribute of the IAttributes object.
46       *
47       * @param mls
48       *            The new MaxLifeSeconds value
49       */
50      public void setMaxLifeSeconds( long mls );
51  
52      /***
53       * Sets the maxLife attribute of the IAttributes object. How many seconds it
54       * can live after creation.
55       * <p>
56       * If this is exceeded the element will not be returned, instead it will be
57       * removed. It will be removed on retrieval, or removed actively if the
58       * memory shrinker is turned on.
59       *
60       *
61       * @return The MaxLifeSeconds value
62       */
63      public long getMaxLifeSeconds();
64  
65      /***
66       * Sets the idleTime attribute of the IAttributes object. This is the
67       * maximum time the item can be idle in the cache, that is not accessed.
68       * <p>
69       * If this is exceeded the element will not be returned, instead it will be
70       * removed. It will be removed on retrieval, or removed actively if the
71       * memory shrinker is turned on.
72       *
73       * @param idle
74       *            The new idleTime value
75       */
76      public void setIdleTime( long idle );
77  
78      /***
79       * Size in bytes. This is not used except in the admin pages. It will be -1
80       * by default.
81       *
82       * @param size
83       *            The new size value
84       */
85      public void setSize( int size );
86  
87      /***
88       * Gets the size attribute of the IAttributes object
89       *
90       * @return The size value
91       */
92      public int getSize();
93  
94      /***
95       * Gets the createTime attribute of the IAttributes object.
96       * <p>
97       * This shoudd be the current time in milliseconds returned by the sysutem
98       * call when the element is put in the cache.
99       * <p>
100      * Putting an item in the cache overrides any existing items.
101      *
102      * @return The createTime value
103      */
104     public long getCreateTime();
105 
106     /***
107      * Gets the LastAccess attribute of the IAttributes object.
108      *
109      * @return The LastAccess value.
110      */
111     public long getLastAccessTime();
112 
113     /***
114      * Sets the LastAccessTime as now of the IElementAttributes object
115      */
116     public void setLastAccessTimeNow();
117 
118     /***
119      * Gets the version attribute of the IAttributes object
120      *
121      * @return The version value
122      */
123     public long getVersion();
124 
125     /***
126      * Gets the idleTime attribute of the IAttributes object
127      *
128      * @return The idleTime value
129      */
130     public long getIdleTime();
131 
132     /***
133      * Gets the time left to live of the IAttributes object.
134      * <p>
135      * This is the (max life + create time) - current time.
136      *
137      * @return The TimeToLiveSeconds value
138      */
139     public long getTimeToLiveSeconds();
140 
141     /***
142      * Returns a copy of the object.
143      *
144      * @return IElementAttributes
145      */
146     public IElementAttributes copy();
147 
148     /***
149      * Can this item be spooled to disk
150      * <p>
151      * By default this is true.
152      *
153      * @return The spoolable value
154      */
155     public boolean getIsSpool();
156 
157     /***
158      * Sets the isSpool attribute of the IElementAttributes object
159      * <p>
160      * By default this is true.
161      *
162      * @param val
163      *            The new isSpool value
164      */
165     public void setIsSpool( boolean val );
166 
167     /***
168      * Is this item laterally distributable. Can it be sent to auxiliaries of
169      * type lateral.
170      * <p>
171      * By default this is true.
172      *
173      * @return The isLateral value
174      */
175     public boolean getIsLateral();
176 
177     /***
178      * Sets the isLateral attribute of the IElementAttributes object
179      * <p>
180      * By default this is true.
181      *
182      * @param val
183      *            The new isLateral value
184      */
185     public void setIsLateral( boolean val );
186 
187     /***
188      * Can this item be sent to the remote cache.
189      * <p>
190      * By default this is true.
191      *
192      * @return The isRemote value
193      */
194     public boolean getIsRemote();
195 
196     /***
197      * Sets the isRemote attribute of the IElementAttributes object.
198      * <p>
199      * By default this is true.
200      *
201      * @param val
202      *            The new isRemote value
203      */
204     public void setIsRemote( boolean val );
205 
206     /***
207      * This turns off expiration if it is true.
208      *
209      * @return The IsEternal value
210      */
211     public boolean getIsEternal();
212 
213     /***
214      * Sets the isEternal attribute of the IElementAttributes object
215      *
216      * @param val
217      *            The new isEternal value
218      */
219     public void setIsEternal( boolean val );
220 
221     /***
222      * Adds a ElementEventHandler. Handler's can be registered for multiple
223      * events. A registered handler will be called at every recognized event.
224      *
225      * @param eventHandler
226      *            The feature to be added to the ElementEventHandler
227      */
228     public void addElementEventHandler( IElementEventHandler eventHandler );
229 
230     /***
231      * Gets the elementEventHandlers.
232      * <p>
233      * Event handlers are transient. The only events defined are in memory
234      * events. All handlers are lost if the item goes to disk.
235      *
236      * @return The elementEventHandlers value, null if there are none
237      */
238     public ArrayList getElementEventHandlers();
239 
240     /***
241      * Sets the eventHandlers of the IElementAttributes object
242      *
243      * @param eventHandlers
244      *            value
245      */
246     public void addElementEventHandlers( ArrayList eventHandlers );
247 
248 }