add listener method for connection aborts
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Apr 2008 22:07:22 +0000 (22:07 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Apr 2008 22:07:22 +0000 (22:07 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@748 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/util/fcp/FcpAdapter.java
src/net/pterodactylus/util/fcp/FcpConnection.java
src/net/pterodactylus/util/fcp/FcpListener.java

index c2f7fbf..9b858cf 100644 (file)
@@ -267,4 +267,11 @@ public class FcpAdapter implements FcpListener {
                /* empty. */
        }
 
+       /**
+        * {@inheritDoc}
+        */
+       public void connectionClosed(FcpConnection fcpConnection) {
+               /* empty. */
+       }
+
 }
index f08c8cb..bb0ac40 100644 (file)
@@ -610,6 +610,17 @@ public class FcpConnection {
                }
        }
 
+       /**
+        * Notifies all listeners that the connection to the node was closed.
+        * 
+        * @see FcpListener#connectionClosed(FcpConnection)
+        */
+       private void fireConnectionClosed() {
+               for (FcpListener fcpListener: fcpListeners) {
+                       fcpListener.connectionClosed(this);
+               }
+       }
+
        //
        // ACTIONS
        //
@@ -767,6 +778,7 @@ public class FcpConnection {
                Closer.close(remoteOutputStream);
                Closer.close(remoteSocket);
                connectionHandler = null;
+               fireConnectionClosed();
        }
 
        //
index 65baa36..eafb5aa 100644 (file)
@@ -394,4 +394,14 @@ public interface FcpListener extends EventListener {
         */
        public void receivedMessage(FcpConnection fcpConnection, FcpMessage fcpMessage);
 
+       /**
+        * Notifies a listener that a connection was closed. A closed connection can
+        * be reestablished by calling {@link FcpConnection#connect()} on the same
+        * object again.
+        * 
+        * @param fcpConnection
+        *            The connection that was closed.
+        */
+       public void connectionClosed(FcpConnection fcpConnection);
+
 }