@ManagedObject public class ConnectionLimit extends AbstractLifeCycle implements Connection.Listener
A Connection Listener that limits the number of Connections.
This listener applies a limit to the number of connections, which when
exceeded results in a call to AbstractConnector.setAccepting(boolean)
to prevent further connections being received. It can be applied to an
entire server or to a specific connector.
Connection.ListenerAbstractLifeCycle.AbstractLifeCycleListenerConnection.Listener.AdapterLifeCycle.Listener| Modifier and Type | Field and Description |
|---|---|
private boolean |
_accepting |
private int |
_connections |
private java.util.List<AbstractConnector> |
_connectors |
private int |
_maxConnections |
private Server |
_server |
private static Logger |
LOG |
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING| Constructor and Description |
|---|
ConnectionLimit(int maxConnections,
Connector... connectors) |
ConnectionLimit(int maxConnections,
Server server) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doStart() |
protected void |
doStop() |
int |
getConnections() |
int |
getMaxConnections() |
void |
onClosed(Connection connection) |
void |
onOpened(Connection connection) |
void |
setMaxConnections(int max) |
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stopprivate static final Logger LOG
private final Server _server
private final java.util.List<AbstractConnector> _connectors
private int _connections
private int _maxConnections
private boolean _accepting
public ConnectionLimit(int maxConnections,
Server server)
public ConnectionLimit(int maxConnections,
Connector... connectors)
@ManagedAttribute(value="The maximum number of connections allowed") public int getMaxConnections()
public void setMaxConnections(int max)
@ManagedAttribute(value="The current number of connections ") public int getConnections()
protected void doStart()
throws java.lang.Exception
doStart in class AbstractLifeCyclejava.lang.Exceptionprotected void doStop()
throws java.lang.Exception
doStop in class AbstractLifeCyclejava.lang.Exceptionpublic void onOpened(Connection connection)
onOpened in interface Connection.Listenerpublic void onClosed(Connection connection)
onClosed in interface Connection.Listener