Package org.jline.builtins.telnet
Class ConnectionManager
- java.lang.Object
-
- org.jline.builtins.telnet.ConnectionManager
-
- All Implemented Interfaces:
java.lang.Runnable
public abstract 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)
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Stack<Connection>
closedConnections
private ConnectionFilter
connectionFilter
private int
disconnectTimeout
private int
housekeepingInterval
private boolean
lineMode
private static java.util.logging.Logger
LOG
private java.lang.String
loginShell
private int
maxConnections
private java.util.List<Connection>
openConnections
private boolean
stopping
private java.lang.Thread
thread
private java.lang.ThreadGroup
threadGroup
private int
warningTimeout
-
Constructor Summary
Constructors Constructor Description ConnectionManager()
ConnectionManager(int con, int timew, int timedis, int hoke, ConnectionFilter filter, java.lang.String lsh, boolean lm)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void
checkOpenConnections()
private void
cleanupClosed()
protected abstract Connection
createConnection(java.lang.ThreadGroup threadGroup, ConnectionData newCD)
Connection
getConnection(int idx)
Returns theConnection
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 allConnection
instances with the givenInetAddress
.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)
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 thisConnectionManager
.void
stop()
Stops thisConnectionManager
.
-
-
-
Field Detail
-
LOG
private static java.util.logging.Logger LOG
-
openConnections
private final java.util.List<Connection> openConnections
-
thread
private java.lang.Thread thread
-
threadGroup
private java.lang.ThreadGroup threadGroup
-
closedConnections
private java.util.Stack<Connection> closedConnections
-
connectionFilter
private ConnectionFilter connectionFilter
-
maxConnections
private int maxConnections
-
warningTimeout
private int warningTimeout
-
disconnectTimeout
private int disconnectTimeout
-
housekeepingInterval
private int housekeepingInterval
-
loginShell
private java.lang.String loginShell
-
lineMode
private boolean lineMode
-
stopping
private boolean stopping
-
-
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
-
getConnectionFilter
public ConnectionFilter getConnectionFilter()
Gets the active ConnectionFilter instance or returns null if no filter is set.- Returns:
- the managers ConnectionFilter.
-
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.
-
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 theConnection
at the given index.- Parameters:
idx
- the index- Returns:
- the connection
-
getConnectionsByAdddress
public Connection[] getConnectionsByAdddress(java.net.InetAddress addr)
Get allConnection
instances with the givenInetAddress
.- Parameters:
addr
- the address- Returns:
- all
Connection
instances with the givenInetAddress
.
-
start
public void start()
Starts thisConnectionManager
.
-
stop
public void stop()
Stops thisConnectionManager
.
-
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.
-
createConnection
protected abstract Connection createConnection(java.lang.ThreadGroup threadGroup, ConnectionData newCD)
-
run
public void run()
Periodically does following work:- cleaning up died connections.
- checking managed connections if they are working properly.
- checking the open connections.
- Specified by:
run
in interfacejava.lang.Runnable
-
cleanupClosed
private void cleanupClosed()
-
checkOpenConnections
private void checkOpenConnections()
-
registerClosedConnection
public void registerClosedConnection(Connection con)
-
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)
-
-