1 46 package org.mr.kernel.services.topics; 47 48 import java.util.ArrayList ; 49 import java.util.List ; 50 51 import org.mr.IMessageListener; 52 import org.mr.core.protocol.MantaBusMessage; 53 54 58 public class TopicGatherListener implements IMessageListener{ 59 List messages = new ArrayList (); 60 int depth = 0; 61 62 public TopicGatherListener(int depth){ 63 this.depth =depth; 64 } 65 66 69 public int getDepth() { 70 return depth; 71 } 72 75 public void setDepth(int depth) { 76 this.depth = depth; 77 } 78 81 public synchronized void onMessage(MantaBusMessage message) { 82 if(messages.size()< depth){ 83 messages.add(message); 84 } 85 86 } 87 90 public List getMessages() { 91 return messages; 92 } 93 } 94 | Popular Tags |