1 46 50 package org.mr.kernel.services.queues; 51 52 import java.util.ArrayList ; 53 import java.util.Enumeration ; 54 55 56 import org.mr.MantaAgent; 57 import org.mr.MantaException; 58 import org.mr.kernel.services.ServiceConsumer; 59 60 61 67 public class RemoteQueueEnumeration implements Enumeration { 68 public ArrayList elements; 69 private ServiceConsumer consumer; 70 71 74 public RemoteQueueEnumeration(ServiceConsumer consumer ) { 75 this.consumer = consumer; 76 77 } 78 79 82 public boolean hasMoreElements() { 83 if(elements == null) 84 getRemoteQueue(); 85 86 return !elements.isEmpty(); 87 } 88 89 93 public Object nextElement() { 94 if(elements == null) 95 getRemoteQueue(); 96 return elements.remove(0); 97 } 99 102 private void getRemoteQueue() { 103 try { 104 elements = MantaAgent.getInstance().CopyQueueContent(consumer); 105 } catch (MantaException e) { 106 elements = new ArrayList (); 107 } 108 109 } 110 111 } 112 | Popular Tags |