01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.util;
05:
06: import com.tc.object.bytecode.ManagerUtil;
07: import com.tc.object.lockmanager.api.LockLevel;
08:
09: import java.util.Enumeration;
10: import java.util.Vector;
11:
12: public class EnumerationWrapper implements Enumeration {
13:
14: private final Vector vector;
15: private final Enumeration realEnumeration;
16:
17: public EnumerationWrapper(Vector vector, Enumeration realEnumeration) {
18: this .vector = vector;
19: this .realEnumeration = realEnumeration;
20: }
21:
22: public final boolean hasMoreElements() {
23: return realEnumeration.hasMoreElements();
24: }
25:
26: public final Object nextElement() {
27: ManagerUtil.monitorEnter(vector, LockLevel.WRITE);
28: Object o = null;
29: try {
30: o = realEnumeration.nextElement();
31: } finally {
32: ManagerUtil.monitorExit(vector);
33: }
34: return o;
35: }
36: }
|