package org.mockejb.jms;
import javax.jms.*;
import java.util.*;
public class MockTopic extends MockDestination implements Topic {
private final Collection listeners = new ArrayList();
public MockTopic(String name) {
super(name);
}
public String getTopicName() throws JMSException {
return getName();
}
public void addMessageListener(MessageListener listener) {
listeners.add(listener);
}
public void dispatch(Message msg) {
Iterator it = listeners.iterator();
while (it.hasNext()) {
MessageListener l = (MessageListener)it.next();
l.onMessage(msg);
}
}
}