net.wimpi.telnetd.net
Class ConnectionManager

java.lang.Object
  extended by net.wimpi.telnetd.net.ConnectionManager
All Implemented Interfaces:
java.lang.Runnable

public class ConnectionManager
extends java.lang.Object
implements java.lang.Runnable

Class that takes care for active and queued connection. Housekeeping is done also for connections that were just broken off, or exceeded their timeout.

Version:
2.0 (16/07/2006)
Author:
Dieter Wimberger

Constructor Summary
ConnectionManager()
           
ConnectionManager(int con, int timew, int timedis, int hoke, ConnectionFilter filter, java.lang.String lsh, boolean lm)
           
 
Method Summary
static ConnectionManager createConnectionManager(java.lang.String name, java.util.Properties settings)
          Factory method for the ConnectionManager.
A class operation that will return a new ConnectionManager instance.
 Connection getConnection(int idx)
          Returns the Connection at the given index.
 ConnectionFilter getConnectionFilter()
          Gets the active ConnectionFilter instance or returns null if no filter is set.
 Connection[] getConnectionsByAdddress(java.net.InetAddress addr)
          Get all Connection instances with the given InetAddress.
 int getDisconnectTimeout()
           
 int getHousekeepingInterval()
           
 java.lang.String getLoginShell()
           
 int getMaxConnections()
           
 int getWarningTimeout()
           
 boolean isLineMode()
           
 void makeConnection(java.net.Socket insock)
          Method that that tries to connect an incoming request.
 int openConnectionCount()
          Returns the number of open connections.
 void registerClosedConnection(Connection con)
          Called by connections that got broken (i.e.
 void run()
          Periodically does following work: cleaning up died connections.
 void setConnectionFilter(ConnectionFilter filter)
          Set a connection filter for this ConnectionManager instance.
 void setDisconnectTimeout(int disconnectTimeout)
           
 void setHousekeepingInterval(int housekeepingInterval)
           
 void setLineMode(boolean lineMode)
           
 void setLoginShell(java.lang.String loginShell)
           
 void setMaxConnections(int maxConnections)
           
 void setWarningTimeout(int warningTimeout)
           
 void start()
          Starts this ConnectionManager.
 void stop()
          Stops this ConnectionManager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionManager

public ConnectionManager()

ConnectionManager

public ConnectionManager(int con,
                         int timew,
                         int timedis,
                         int hoke,
                         ConnectionFilter filter,
                         java.lang.String lsh,
                         boolean lm)
Method Detail

setConnectionFilter

public void setConnectionFilter(ConnectionFilter filter)
Set a connection filter for this ConnectionManager instance. The filter is used to handle IP level allow/deny of incoming connections.

Parameters:
filter - ConnectionFilter instance.

getConnectionFilter

public ConnectionFilter getConnectionFilter()
Gets the active ConnectionFilter instance or returns null if no filter is set.

Returns:
the managers ConnectionFilter.

openConnectionCount

public int openConnectionCount()
Returns the number of open connections.

Returns:
the number of open connections as int.

getConnection

public Connection getConnection(int idx)
Returns the Connection at the given index.

Parameters:
idx -
Returns:

getConnectionsByAdddress

public Connection[] getConnectionsByAdddress(java.net.InetAddress addr)
Get all Connection instances with the given InetAddress.

Returns:
all Connection instances with the given InetAddress.

start

public void start()
Starts this ConnectionManager.


stop

public void stop()
Stops this ConnectionManager.


makeConnection

public void makeConnection(java.net.Socket insock)
Method that that tries to connect an incoming request. Properly queueing.

Parameters:
insock - Socket thats representing the incoming connection.

run

public void run()
Periodically does following work:

Specified by:
run in interface java.lang.Runnable

registerClosedConnection

public void registerClosedConnection(Connection con)
Called by connections that got broken (i.e. I/O errors). The housekeeper will properly close the connection, and take care for misc necessary cleanup.

Parameters:
con - the connection that is broken. public void registerBrokenConnection(Connection con) { if (!m_BrokenConnections.contains(con) && !m_ClosedConnections.contains(con)) { log.debug("registerBrokenConnection()::" + con.toString()); m_BrokenConnections.push(con); } }//registerBrokenConnection

createConnectionManager

public static ConnectionManager createConnectionManager(java.lang.String name,
                                                        java.util.Properties settings)
                                                 throws BootException
Factory method for the ConnectionManager.
A class operation that will return a new ConnectionManager instance.

Parameters:
settings - Properties containing the settings for this instance.
Throws:
BootException

getDisconnectTimeout

public int getDisconnectTimeout()

setDisconnectTimeout

public void setDisconnectTimeout(int disconnectTimeout)

getHousekeepingInterval

public int getHousekeepingInterval()

setHousekeepingInterval

public void setHousekeepingInterval(int housekeepingInterval)

isLineMode

public boolean isLineMode()

setLineMode

public void setLineMode(boolean lineMode)

getLoginShell

public java.lang.String getLoginShell()

setLoginShell

public void setLoginShell(java.lang.String loginShell)

getMaxConnections

public int getMaxConnections()

setMaxConnections

public void setMaxConnections(int maxConnections)

getWarningTimeout

public int getWarningTimeout()

setWarningTimeout

public void setWarningTimeout(int warningTimeout)


Copyright © 2010. All Rights Reserved.