Class 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)
    Author:
    Dieter Wimberger
    • 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 the Connection at the given index.
        Parameters:
        idx - the index
        Returns:
        the connection
      • getConnectionsByAdddress

        public Connection[] getConnectionsByAdddress​(java.net.InetAddress addr)
        Get all Connection instances with the given InetAddress.
        Parameters:
        addr - the address
        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.
      • 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 interface java.lang.Runnable
      • 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)