1 4 package com.tc.util; 5 6 import com.tc.object.bytecode.ManagerUtil; 7 import com.tc.object.lockmanager.api.LockLevel; 8 9 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 } 37 | Popular Tags |