continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r573608 - in /maven/continuum/trunk: continuum-core/src/main/java/org/apache/maven/continuum/notification/ continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/
Date Fri, 07 Sep 2007 15:21:17 GMT
Author: evenisse
Date: Fri Sep  7 08:21:11 2007
New Revision: 573608

URL: http://svn.apache.org/viewvc?rev=573608&view=rev
Log:
[CONTINUUM-522] reconnect if disconnected, allow to join more than one channel

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java?rev=573608&r1=573607&r2=573608&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
Fri Sep  7 08:21:11 2007
@@ -200,7 +200,7 @@
         }
         catch ( NotificationException e )
         {
-            getLogger().error( "Error while trying to use the " + notifierType + "notifier.",
e );
+            getLogger().error( "Error while trying to use the " + notifierType + " notifier.",
e );
         }
     }
 }

Modified: maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java?rev=573608&r1=573607&r2=573608&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
(original)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
Fri Sep  7 08:21:11 2007
@@ -40,6 +40,7 @@
 import org.schwering.irc.lib.ssl.SSLIRCConnection;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -78,10 +79,12 @@
     private int defaultPort;
 
     /**
-     * key is upper(hostname) + port
+     * key is upper(hostname) + port + upper(nick)
      */
     private Map<String, IRCConnection> hostConnections = new HashMap<String, IRCConnection>();
 
+    private Map<String, List> channelConnections = new HashMap<String, List>();
+
 
     // ----------------------------------------------------------------------
     // Plexus Lifecycle
@@ -93,7 +96,7 @@
         {
             String key = keys.next();
             IRCConnection connection = hostConnections.get( key );
-            connection.doQuit( "Application shutting down" );
+            connection.doQuit( "Continuum shutting down" );
             connection.close();
         }
 
@@ -106,11 +109,11 @@
                                            String realName, String channel, boolean ssl )
         throws IOException
     {
-        String key = host.toUpperCase() + Integer.toString( port );
+        String key = host.toUpperCase() + Integer.toString( port ) + nick.toUpperCase();
         IRCConnection conn = hostConnections.get( key );
         if ( conn != null )
         {
-            checkConnection( conn );
+            checkConnection( conn, key );
             return conn;
         }
 
@@ -125,13 +128,13 @@
         }
 
         conn.addIRCEventListener( new Listener() );
-        checkConnection( conn );
-        conn.doJoin( channel );
+        checkConnection( conn, key );
+        checkChannel( conn, key, channel );
         hostConnections.put( key, conn );
         return conn;
     }
 
-    private void checkConnection( IRCConnection conn )
+    private void checkConnection( IRCConnection conn, String key )
         throws IOException
     {
         if ( !conn.isConnected() )
@@ -146,7 +149,51 @@
             {
                 //nothing to do
             }
+
+            //join to all channels
+            List channels = channelConnections.get( key );
+            if ( channels != null )
+            {
+                for ( Iterator i = channels.iterator(); i.hasNext(); )
+                {
+                    String channel = (String) i.next();
+                    connectToChannel( conn, channel);
+                }
+            }
         }
+    }
+
+    private void checkChannel( IRCConnection conn, String key, String channel )
+    {
+        List channels = channelConnections.get( key );
+        if ( channels == null )
+        {
+            connectToChannel( conn, channel );
+            channels = new ArrayList();
+            channels.add( channel );
+            channelConnections.put( key, channels );
+        }
+        else
+        {
+            boolean found = false;
+            for ( Iterator i = channels.iterator(); i.hasNext(); )
+            {
+                String c = (String) i.next();
+                if ( c.equalsIgnoreCase( channel ) )
+                {
+                    found = true;
+                }
+            }
+            if ( !found )
+            {
+                connectToChannel( conn, channel );
+            }
+        }
+    }
+
+    private void connectToChannel( IRCConnection conn, String channel )
+    {
+        conn.doJoin( channel );
     }
 
     // ----------------------------------------------------------------------



Mime
View raw message