7171import org .apache .jcs .engine .control .CompositeCache ;
7272import org .apache .jcs .engine .control .CompositeCacheManager ;
7373import org .apache .jcs .engine .control .group .GroupAttrName ;
74- import org .apache .jcs .engine .control .group .GroupCacheHub ;
7574import org .apache .jcs .engine .control .group .GroupId ;
7675
7776/**
@@ -86,9 +85,6 @@ public class GroupCacheAccess extends CacheAccess implements IGroupCacheAccess
8685 private final static Log log =
8786 LogFactory .getLog ( GroupCacheAccess .class );
8887
89- private static boolean SET_ATTR_INVOCATION = true ;
90- private static boolean REMOVE_ATTR_INVOCATION = false ;
91-
9288 private static CompositeCacheManager cacheMgr ;
9389
9490 /**
@@ -115,7 +111,7 @@ public static GroupCacheAccess getGroupAccess( String region )
115111 {
116112 if ( cacheMgr == null )
117113 {
118- cacheMgr = GroupCacheHub .getInstance ();
114+ cacheMgr = CompositeCacheManager .getInstance ();
119115 }
120116 }
121117 }
@@ -136,7 +132,7 @@ public static GroupCacheAccess getGroupAccess( String region, ICompositeCacheAtt
136132 {
137133 if ( cacheMgr == null )
138134 {
139- cacheMgr = GroupCacheHub .getInstance ();
135+ cacheMgr = CompositeCacheManager .getInstance ();
140136 }
141137 }
142138 }
@@ -166,99 +162,6 @@ private GroupAttrName getGroupAttrName(String group, Object name)
166162 return new GroupAttrName (gid , name );
167163 }
168164
169- /**
170- * DefineGroup is used to create a new group object. Attributes may be set
171- * on the group. If no attributes are specified, the attributes of the
172- * region or group the new group is associated with are used. If group is
173- * specified the new group will be associated with the group specified.
174- *
175- * @param name Name of the gorup.
176- */
177- public void defineGroup ( String name )
178- throws CacheException
179- {
180- defineGroup (name , null );
181- }
182-
183- /**
184- * Description of the Method
185- *
186- * @param name Name of the group
187- * @param attr Default attributes for the group.
188- */
189- public void defineGroup ( String name , IElementAttributes attr )
190- throws CacheException
191- {
192- // update the attribute name set.
193- GroupId groupId = new GroupId ( cacheControl .getCacheName (), name );
194- if ( get (groupId ) != null )
195- {
196- throw new CacheException ( "group " + name + " already exists " );
197- }
198-
199- // TODO: revisit and verify that this works
200- // not sure it will, need special id putting
201- if (attr == null )
202- {
203- put ( groupId , new HashSet () );
204- }
205- else
206- {
207- put ( groupId , new HashSet (), attr );
208- }
209- }
210-
211- /**
212- * Gets the groupAttributes attribute of the GroupCacheAccess object.
213- * Slighly confusing since the other method conside an "attribute" to be an
214- * element of the cache and not the parameters governing an element.
215- *
216- * @return The Element Attributes for the group
217- */
218- public IElementAttributes getGroupAttributes ( String name )
219- throws CacheException
220- {
221- IElementAttributes attr = null ;
222- try
223- {
224- attr = cacheControl .getElementAttributes ( ( Serializable ) name );
225- }
226- catch ( IOException ioe )
227- {
228- throw new CacheException (
229- "Failure getting element attributes due to " , ioe );
230- }
231- return attr ;
232- }
233-
234- /**
235- * Gets the attributeNames attribute of the GroupCacheAccess object
236- *
237- * @return The attributeNames value
238- */
239- public Enumeration getAttributeNames ( String group_name )
240- {
241- //Set s = getAttributeNameSet( name );
242- //p( s.toString() );
243- //return Collections.enumeration(s);
244- return Collections .enumeration ( getAttributeNameSet ( group_name ) );
245- }
246-
247- /**
248- * Gets the attributeNameSet attribute of the GroupCacheAccess object
249- *
250- * @return The attributeNameSet value
251- */
252- public Set getAttributeNameSet ( String groupName )
253- {
254- Object obj = get (new GroupId (cacheControl .getCacheName (), groupName ));
255- if ( obj == null || !( obj instanceof Set ) )
256- {
257- return new HashSet ();
258- }
259- return (Set ) obj ;
260- }
261 <
8096
td data-grid-cell-id="diff-4c83236ca0bdaf3aae9a42db562fbada83760d6863eb2976f829e0422111a33e-261-164-1" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionNum-bgColor, var(--diffBlob-deletion-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">-
262165 /**
263166 * Allows the user to put an object into a group within a particular cache
264167 * region. This method sets the object's attributes to the default for the
@@ -288,16 +191,8 @@ public void putInGroup( Object name, String groupName, Object value,
288191 IElementAttributes attr )
289192 throws CacheException
290193 {
291- Set group = (Set )
292- get (new GroupId (cacheControl .getCacheName (), groupName ));
293- if (group == null )
294- {
295- throw new CacheException (
296- "Group must be defined prior to being used." );
297- }
298-
299194 // unbind object first if any.
300- boolean isPreviousObj = remove ( name , groupName , false );
195+ remove ( name , groupName );
301196
302197 if (attr == null )
303198 {
@@ -307,57 +202,27 @@ public void putInGroup( Object name, String groupName, Object value,
307202 {
308203 put ( getGroupAttrName (groupName , name ), value , attr );
309204 }
310-
311- if (!isPreviousObj )
312- {
313- group .add (name );
314- }
315205 }
316206
317207 /** Description of the Method */
318208 public void remove ( Object name , String group )
319209 {
320- remove ( name , group , true );
210+ GroupAttrName key = getGroupAttrName ( group , name );
211+ cacheControl .remove (key );
321212 }
322213
323- /** Description of the Method */
324- private boolean remove ( Object name , String groupName ,
325- boolean removeFromGroup )
214+ /**
215+ * Gets the set of keys of objects currently in the group
216+ */
217+ public Set getGroupKeys (String group )
326218 {
327- GroupAttrName key = getGroupAttrName ( groupName , name );
328- // Needs to retrieve the attribute so as to do object unbinding,
329- // if necessary.
330- boolean isPreviousObj = cacheControl .get (key ) != null ;
331- if (isPreviousObj )
332- {
333- cacheControl .remove (key );
334- }
335- if (removeFromGroup )
336- {
337- Set group = getAttributeNameSet (groupName );
338- group .remove (name );
339- }
340- return isPreviousObj ;
219+ return cacheControl .getGroupKeys (group );
341220 }
342221
222+
343223 /** Invalidates a group */
344224 public void invalidateGroup ( String group )
345225 {
346- // Removes all the attributes and attribute names from the Cache.
347- // In doing so, need to unbind any object associated with the session.
348- // need a static list not dependent on the current state of the source
349- // remove each item, may want to try using partial delete here
350- // move to gorupcache?
351- Set set = getAttributeNameSet ( group );
352- Object [] ar = set .toArray ();
353- int arS = ar
56FB
.length ;
354- for ( int i = 0 ; i < arS ; i ++ )
355- {
356- remove ( ar [i ], group , false );
357- }
358-
359- // get into concurrent modification problems here.
360- // could make the removal of the ID invalidate the list?
361226 cacheControl .remove (new GroupId ( cacheControl .getCacheName (), group ));
362227 }
363228}
0 commit comments