01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.net.protocol.transport;
06:
07: public class ConnectionWatcher implements MessageTransportListener {
08:
09: protected final ClientMessageTransport cmt;
10: protected final ClientConnectionEstablisher cce;
11: protected final MessageTransportListener target;
12:
13: /**
14: * Listens to events from a MessageTransport, acts on them, and passes events through to target
15: */
16: public ConnectionWatcher(ClientMessageTransport cmt,
17: MessageTransportListener target,
18: ClientConnectionEstablisher cce) {
19: this .cmt = cmt;
20: this .target = target;
21: this .cce = cce;
22: }
23:
24: public void notifyTransportClosed(MessageTransport transport) {
25: cce.quitReconnectAttempts();
26: target.notifyTransportClosed(transport);
27: }
28:
29: public void notifyTransportDisconnected(MessageTransport transport) {
30: cce.asyncReconnect(cmt);
31: target.notifyTransportDisconnected(transport);
32: }
33:
34: public void notifyTransportConnectAttempt(MessageTransport transport) {
35: target.notifyTransportConnectAttempt(transport);
36: }
37:
38: public void notifyTransportConnected(MessageTransport transport) {
39: target.notifyTransportConnected(transport);
40: }
41: }
|