/***********************************************************************
 * 
 * This software is published under the terms of the LGPL
 * version 2.1, a copy of which has been included with this
 * distribution in the 'lgpl.txt' file.
 * Copyright (C) 2004 Daniel Galn y Martins
 * 
 *********************************************************************** 
 *
 * Author:   	  Daniel "tentacle" Galn y Martins
 * Creation date: 25.04.2003
 *  
 * Revision:      $Revision: 1.2 $
 * Checked in by: $Author: danielgalan $
 * Last modified: $Date: 2005/05/23 18:10:20 $
 * 
 * $Log: SocketDispatcherThread.java,v $
 * Revision 1.2  2005/05/23 18:10:20  danielgalan
 * some cleaning and removing some cycles (not all removed yet)
 *
 * Revision 1.1  2004/07/26 21:40:28  danielgalan
 * Jalita initial cvs commit :)
 *
 **********************************************************************/
package net.sf.jalita.server;

import java.net.*;
import org.apache.log4j.Logger;

import net.sf.jalita.util.Configuration;



/**
 * Resolves incoming connections
 *
 * @author  Daniel "tentacle" Galn y Martins
 * @version $Revision: 1.2 $
 */

public class SocketDispatcherThread extends Thread {

    //--------------------------------------------------------------------------
    // class variables
    //--------------------------------------------------------------------------

    /** log4j reference */
    public final static Logger log = Logger.getLogger(Configuration.class);



    //--------------------------------------------------------------------------
    // instance variables
    //--------------------------------------------------------------------------

    /** Socket which represents a connection, which will create a new Session */
    private Socket socket = null;

    /** The SessionManager who will recive new connections */
    private SessionManager manager = SessionManager.getSessionManager();




    //--------------------------------------------------------------------------
    // constructors
    //--------------------------------------------------------------------------

    /** Creates a SocketDispatcherThread object */
    private SocketDispatcherThread() {
        this(null);
        log.debug("Creating instance of SocketDispatcherThread");
    }



    /** Creates a SocketDispatcherThread object */
    public SocketDispatcherThread(Socket acceptedSocket) {
        super();
        log.debug("Creating instance of SocketDispatcherThread");
        socket = acceptedSocket;
    }



    //--------------------------------------------------------------------------
    // implementation of the interface Runnable
    //--------------------------------------------------------------------------

    public void run() {
        log.debug("Connection received from " + socket.getInetAddress().getHostAddress() + ":" + socket.getPort());
        /* Better by lastActivity
        try {
            socket.setSoTimeout(config.getSessionTimeOut());
        }
        catch (SocketException ex) {
        }
        */

        // TODO Filter at this point IP-adresses?
        manager.addSession(socket);

        log.debug("Dispatcher for " + socket.getInetAddress().getHostAddress() + ":" + socket.getPort() + " has finished");
    }

}

@@ -463,25 +463,25 @@
 Revision: 1.
-2
+3
  $%0A * Checke
@@ -498,25 +498,20 @@
 Author: 
-danielgal
+ilgi
 an $%0A * 
@@ -535,32 +535,32 @@
 ate: 200
-5/05/23 18:10:20
+9/02/26 16:52:51
  $%0A * %0A 
@@ -599,16 +599,101 @@
 ava,v $%0A
+ * Revision 1.3  2009/02/26 16:52:51  ilgian%0A * Set thread name to socket address%0A *%0A
  * Revis
@@ -1196,17 +1196,17 @@
 sion: 1.
-2
+3
  $%0A */%0A%0A
@@ -3212,16 +3212,100 @@
 socket);
+%0A        setName(socket.getInetAddress().getHostAddress() + %22:%22 + socket.getPort());
 %0A%0A      

Set thread name to socket address