OPENDJ-808 Implement a simple commons REST based HTTP connection handler
ConcurrentHashMap does not accept putting in null values, so I will put in the key itself (It is redundant, but this is not a problem here.)
HTTPConnectionHandler.java:
clientConnections changed from Map<ClientConnection, Void> to Map<ClientConnection, ClientConnection>.
CollectClientConnectionsFilter.java:
Consequence of the change to HTTPConnectionHandler.
Use the key to put in the value.
| | |
| | | |
| | | /** The connection handler that created this servlet filter. */ |
| | | private HTTPConnectionHandler connectionHandler; |
| | | private final Map<ClientConnection, Void> clientConnections; |
| | | private final Map<ClientConnection, ClientConnection> clientConnections; |
| | | |
| | | /** |
| | | * Constructs a new instance of this class. |
| | |
| | | */ |
| | | public CollectClientConnectionsFilter( |
| | | HTTPConnectionHandler connectionHandler, |
| | | Map<ClientConnection, Void> clientConnections) |
| | | Map<ClientConnection, ClientConnection> clientConnections) |
| | | { |
| | | this.connectionHandler = connectionHandler; |
| | | this.clientConnections = clientConnections; |
| | |
| | | { |
| | | final ClientConnection clientConnection = |
| | | new HTTPClientConnection(this.connectionHandler, request); |
| | | this.clientConnections.put(clientConnection, null); |
| | | this.clientConnections.put(clientConnection, clientConnection); |
| | | try |
| | | { |
| | | String ipAddress = request.getRemoteAddr(); |
| | |
| | | |
| | | /** |
| | | * Holds the current client connections. Using {@link ConcurrentHashMap} to |
| | | * ensure no concurrent reads/writes can happen and adds/removes are fast. |
| | | * Using Void for the value since it has no use. |
| | | * ensure no concurrent reads/writes can happen and adds/removes are fast. We |
| | | * only use the keys, so it does not matter what value is put there. |
| | | */ |
| | | private Map<ClientConnection, Void> clientConnections = |
| | | new ConcurrentHashMap<ClientConnection, Void>(); |
| | | private Map<ClientConnection, ClientConnection> clientConnections = |
| | | new ConcurrentHashMap<ClientConnection, ClientConnection>(); |
| | | |
| | | /** The unique name assigned to this connection handler. */ |
| | | private String handlerName; |