7878 * Access for groups.
7979 *
8080 * @author asmuts
81+ * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
8182 * @created January 15, 2002
8283 */
8384public class GroupCacheAccess extends CacheAccess implements IGroupCacheAccess
@@ -143,59 +144,26 @@ public static GroupCacheAccess getGroupAccess( String region, ICompositeCacheAtt
143144 return new GroupCacheAccess ( ( CompositeCache ) cacheMgr .getCache ( region , icca ) );
144145 }
145146
147+
148+
146149 /**
147150 * Gets an item out of the cache that is in a specified group.
148151 *
149152 * @param name The key name.
150153 * @param group The group name.
151- * @return The cahe value, null if not found.
154+ * @return The cached value, null if not found.
152155 */
153156 public Object getFromGroup ( Object name , String group )
154- {
155- return getAttribute ( name , group );
156- }
157-
158- /**
159- * Gets the attribute attribute of the GroupCacheAccess object
160- *
161- * @return The attribute value
162- */
163- public Object getAttribute ( Object name , String group )
164157 {
165158 ICacheElement element
166- = cacheControl .get ( new GroupAttrName ( group , name ) );
159+ = cacheControl .get ( getGroupAttrName ( group , name ) );
167160 return ( element != null ) ? element .getVal () : null ;
168161 }
169162
170- /**
171- * Allows the user to put an object into a group within a particular cache
172- * region. This method sets the object's attributes to the default for the
173- * region.
174- *
175- * @param key The key name.
176- * @param group The group name.
177- * @param value The object to cache
178- */
179- public void putInGroup ( Object key , String group , Object value )
180- throws CacheException
181- {
182- setAttribute ( key , group , value );
183- }
184-
185- /**
186- * Allows the user to put an object into a group within a particular cache
187- * region. This method allows the object's attributes to be individually
188- * specified.
189- *
190- * @param key The key name.
191- * @param group The group name.
192- * @param value The object to cache
193- * @param attr The objects attributes.
194- */
195- public void putInGroup ( Object key , String group , Object value , IElementAttributes attr )
196- throws CacheException
163+ private GroupAttrName getGroupAttrName (String group , Object name )
197164 {
198- setAttribute ( key , group , value , attr );
165+ GroupId gid = new GroupId (cacheControl .getCacheName (), group );
166+ return new GroupAttrName (gid , name );
199167 }
200168
201169 /**
@@ -292,28 +260,32 @@ public Set getAttributeNameSet( String groupName )
292260 }
293261
294262 /**
295- * Sets the attribute attribute of the GroupCacheAccess object
263+ * Allows the user to put an object into a group within a particular cache
264+ * region. This method sets the object's attributes to the default for the
265+ * region.
296266 *
297- * @param name The new attribute value
298- * @param group The new attribute value
299- * @param value The new attribute value
267+ * @param key The key name.
268+ * @param group The group name.
269+ * @param value The object to cache
300270 */
301- public void setAttribute ( Object name , String groupName , Object value )
271+ public void putInGroup ( Object name , String groupName , Object value )
302272 throws CacheException
303273 {
304- setAttribute (name , groupName , value , null );
274+ putInGroup (name , groupName , value , null );
305275 }
306276
307277 /**
308- * Sets the attribute attribute of the GroupCacheAccess object
278+ * Allows the user to put an object into a group within a particular cache
279+ * region. This method allows the object's attributes to be individually
280+ * specified.
309281 *
310- * @param name The new attribute value
311- * @param group The new attribute value
312- * @param value The new attribute value
313- * @param attr The new attribute value
282+ * @param key The key name.
283+ * @param group The group name.
284+ * @param value The object to cache
285+ * @param attr The objects attributes.
314286 */
315- public void setAttribute ( Object name , String groupName , Object value ,
316- IElementAttributes attr )
287+ public void putInGroup ( Object name , String groupName , Object value ,
288+ IElementAttributes attr )
317289 throws CacheException
318290 {
319291 Set group = (Set )
@@ -325,15 +297,15 @@ public void setAttribute( Object name, String groupName, Object value,
325297 }
326298
327299 // unbind object first if any.
328- boolean isPreviousObj = removeAttribute ( name , groupName , false );
300+ boolean isPreviousObj = remove ( name , groupName , false );
329301
330302 if (attr == null )
331303 {
332- put ( new GroupAttrName (groupName , name ), value );
304+ put ( getGroupAttrName (groupName , name ), value );
333305 }
334306 else
335307 {
336- put ( new GroupAttrName (groupName , name ), value , attr );
308+ put ( getGroupAttrName (groupName , name ), value , attr );
337309 }
338310
339311 if (!isPreviousObj )
@@ -343,16 +315,16 @@ public void setAttribute( Object name, String groupName, Object value,
343315 }
344316
345317 /** Description of the Method */
346- public void removeAttribute ( Object name , String group )
318+ public void remove ( Object name , String group )
347319 {
348- removeAttribute ( name , group , true );
320+ remove ( name , group , true );
349321 }
350322
351323 /** Description of the Method */
352- private boolean removeAttribute ( Object name , String groupName ,
353- boolean removeFromGroup )
324+ private boolean remove ( Object name , String groupName ,
325+ boolean removeFromGroup )
354326 {
355- GroupAttrName key = new GroupAttrName ( groupName , name );
327+ GroupAttrName key = getGroupAttrName ( groupName , name );
356328 // Needs to retrieve the attribute so as to do object unbinding,
357329 // if necessary.
358330 boolean isPreviousObj = cacheControl .get (key ) != null ;
@@ -368,22 +340,6 @@ private boolean removeAttribute( Object name, String groupName,
368340 return isPreviousObj ;
369341 }
370342
371- /**
372- * Removes an element from the group
373- *
374- * @deprecated
375- */
376- public void destroy ( Object name , String group )
377- {
378- removeAttribute ( name , group );
379- }
380-
381- /** Description of the Method */
382- public void remove ( Object name , String group )
383- {
384- removeAttribute ( name , group );
385- }
386-
387343 /** Invalidates a group */
388344 public void invalidateGroup ( String group )
389345 {
@@ -397,22 +353,11 @@ public void invalidateGroup( String group )
397353 int arS = ar .length ;
398354 for ( int i = 0 ; i < arS ; i ++ )
399355 {
400- removeAttribute ( ar [i ], group , false );
356+ remove ( ar [i ], group , false );
401357 }
402358
403- // get into concurrent modificaiton problems here.
359+ // get into concurrent modification problems here.
404360 // could make the removal of the ID invalidate the list?
405361 cacheControl .remove (new GroupId ( cacheControl .getCacheName (), group ));
406362 }
407-
408- /**
409- * Gets the valueNames attribute of the GroupCacheAccess object
410- *
411- * @return The valueNames value
412- */
413- public String [] getValueNames ( String group )
414- {
415- return ( String [] ) getAttributeNameSet ( group ).toArray ( new String [ 0 ] );
416- }
417-
418363}
0 commit comments