use of jmri.jmrix.AbstractMRListener in project JMRI by JMRI.
the class SRCPTrafficController method notifyReply.
/**
* Forward a "Reply" from layout to registered listeners.
*
* @param r Reply to be forwarded intact
* @param dest One (optional) listener to be skipped, usually because it's
* the originating object.
*/
@SuppressWarnings("unchecked")
protected void notifyReply(SimpleNode r, AbstractMRListener dest) {
// make a copy of the listener vector to synchronized (not needed for transmit?)
Vector<AbstractMRListener> v;
synchronized (this) {
v = (Vector<AbstractMRListener>) cmdListeners.clone();
}
// forward to all listeners
int cnt = v.size();
for (int i = 0; i < cnt; i++) {
AbstractMRListener client = v.elementAt(i);
if (log.isDebugEnabled()) {
log.debug("notify client: " + client);
}
try {
//skip dest for now, we'll send the message to there last.
if (dest != client) {
forwardReply(client, r);
}
} catch (Exception ex) {
log.warn("notify: During reply dispatch to " + client + "\nException " + ex);
ex.printStackTrace();
}
// before a response is sent
if (dest != null) {
forwardReply(dest, r);
}
}
}
use of jmri.jmrix.AbstractMRListener in project JMRI by JMRI.
the class AddNodeFrameTest method testCTor.
@Test
public void testCTor() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
IEEE802154TrafficController tc = new IEEE802154TrafficController() {
@Override
public void setInstance() {
}
@Override
protected AbstractMRReply newReply() {
return null;
}
@Override
public IEEE802154Node newNode() {
return new IEEE802154Node() {
@Override
public AbstractMRMessage createInitPacket() {
return null;
}
@Override
public AbstractMRMessage createOutPacket() {
return null;
}
@Override
public boolean getSensorsActive() {
return false;
}
@Override
public boolean handleTimeout(AbstractMRMessage m, AbstractMRListener l) {
return false;
}
@Override
public void resetTimeout(AbstractMRMessage m) {
}
};
}
};
AddNodeFrame t = new AddNodeFrame(tc);
Assert.assertNotNull("exists", t);
}
use of jmri.jmrix.AbstractMRListener in project JMRI by JMRI.
the class EditNodeFrameTest method testCTor.
@Test
public void testCTor() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
IEEE802154TrafficController tc = new IEEE802154TrafficController() {
@Override
public void setInstance() {
}
@Override
protected AbstractMRReply newReply() {
return null;
}
@Override
public IEEE802154Node newNode() {
return new IEEE802154Node() {
@Override
public AbstractMRMessage createInitPacket() {
return null;
}
@Override
public AbstractMRMessage createOutPacket() {
return null;
}
@Override
public boolean getSensorsActive() {
return false;
}
@Override
public boolean handleTimeout(AbstractMRMessage m, AbstractMRListener l) {
return false;
}
@Override
public void resetTimeout(AbstractMRMessage m) {
}
};
}
};
EditNodeFrame t = new EditNodeFrame(tc, tc.newNode());
Assert.assertNotNull("exists", t);
}
Aggregations