diff --git a/src/main/java/com/kttdevelopment/simplehttpserver/handler/ConnectionThrottler.java b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ConnectionThrottler.java
index 0cef7de..49671e4 100644
--- a/src/main/java/com/kttdevelopment/simplehttpserver/handler/ConnectionThrottler.java
+++ b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ConnectionThrottler.java
@@ -5,10 +5,13 @@
/**
* Determines how connections are handled by the {@link ThrottledHandler}.
*
- * @see ServerThrottler
+ * @see ThrottledHandler
+ * @see ExchangeThrottler
+ * @see ServerExchangeThrottler
* @see SessionThrottler
+ * @see ServerSessionThrottler
* @since 03.03.00
- * @version 03.03.00
+ * @version 03.05.00
* @author Ktt Development
*/
abstract class ConnectionThrottler {
@@ -19,7 +22,9 @@ abstract class ConnectionThrottler {
* @param exchange exchange to process
* @return if exchange was able to be added
*
+ * @see HttpExchange
* @see #deleteConnection(HttpExchange)
+ * @see #getMaxConnections(HttpExchange)
* @since 03.03.00
* @author Ktt Development
*/
@@ -30,10 +35,26 @@ abstract class ConnectionThrottler {
*
* @param exchange exchange to process
*
+ * @see HttpExchange
* @see #addConnection(HttpExchange)
+ * @see #getMaxConnections(HttpExchange)
* @since 03.03.00
* @author Ktt Development
*/
abstract void deleteConnection(final HttpExchange exchange);
+ /**
+ * Returns the maximum number of connections for an exchange. A value of -1 means unlimited connections.
+ *
+ * @param exchange exchange to process
+ * @return maximum number of connections allowed
+ *
+ * @see HttpExchange
+ * @see #addConnection(HttpExchange)
+ * @see #deleteConnection(HttpExchange)
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public abstract int getMaxConnections(final HttpExchange exchange);
+
}
diff --git a/src/main/java/com/kttdevelopment/simplehttpserver/handler/ExchangeThrottler.java b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ExchangeThrottler.java
new file mode 100644
index 0000000..5b6713c
--- /dev/null
+++ b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ExchangeThrottler.java
@@ -0,0 +1,78 @@
+package com.kttdevelopment.simplehttpserver.handler;
+
+import com.sun.net.httpserver.HttpExchange;
+
+import java.net.InetAddress;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Limits connections per address to the server.
+ *
+ * @see HttpExchange
+ * @see ThrottledHandler
+ * @see ServerExchangeThrottler
+ * @see SessionThrottler
+ * @see ServerSessionThrottler
+ * @since 03.05.00
+ * @version 03.05.00
+ * @author Ktt Development
+ */
+public class ExchangeThrottler extends ConnectionThrottler {
+
+ private final Map connections = new ConcurrentHashMap<>();
+
+ /**
+ * Creates a throttler with limits on each exchange.
+ *
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public ExchangeThrottler(){ }
+
+ @Override
+ final boolean addConnection(final HttpExchange exchange){
+ final InetAddress address = exchange.getRemoteAddress().getAddress();
+ final int maxConn = getMaxConnections(exchange);
+
+ if(!connections.containsKey(address))
+ connections.put(address,new AtomicInteger(0));
+
+ final AtomicInteger conn = connections.get(address);
+
+ if(maxConn < 0){
+ conn.incrementAndGet();
+ return true;
+ }else{
+ final AtomicBoolean added = new AtomicBoolean(false);
+ conn.updateAndGet(operand -> {
+ if(operand < maxConn) added.set(true);
+ return operand < maxConn ? operand + 1 : operand;
+ });
+ return added.get();
+ }
+ }
+
+ @Override
+ final void deleteConnection(final HttpExchange exchange){
+ final InetAddress address = exchange.getRemoteAddress().getAddress();
+ if(connections.containsKey(address))
+ connections.get(address).decrementAndGet();
+ }
+
+ @Override
+ public int getMaxConnections(final HttpExchange exchange){
+ return -1;
+ }
+
+ @Override
+ public String toString(){
+ return
+ "Exchange Throttler" + '{' +
+ "connections" + '=' + connections.toString() +
+ '}';
+ }
+
+}
diff --git a/src/main/java/com/kttdevelopment/simplehttpserver/handler/ServerExchangeThrottler.java b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ServerExchangeThrottler.java
new file mode 100644
index 0000000..5b3d7d7
--- /dev/null
+++ b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ServerExchangeThrottler.java
@@ -0,0 +1,163 @@
+package com.kttdevelopment.simplehttpserver.handler;
+
+import com.sun.net.httpserver.HttpExchange;
+
+import java.net.InetAddress;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Limits connections per address to the server and total server connections.
+ *
+ * @see HttpExchange
+ * @see ThrottledHandler
+ * @see ExchangeThrottler
+ * @see SessionThrottler
+ * @see ServerSessionThrottler
+ * @since 03.05.00
+ * @version 03.05.00
+ * @author Ktt Development
+ */
+public class ServerExchangeThrottler extends ConnectionThrottler {
+
+ private final Map connections = new ConcurrentHashMap<>();
+
+ private final AtomicInteger uConn = new AtomicInteger(0);
+ private final AtomicInteger uConnMax = new AtomicInteger(-1);
+
+ /**
+ * Creates a throttler with connection limits on user and total connections.
+ *
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public ServerExchangeThrottler(){ }
+
+ /**
+ * Creates a throttler with connection limits on user and total connections.
+ *
+ * @param maxConnections maximum allowed server connections
+ *
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public ServerExchangeThrottler(final int maxConnections){
+ uConnMax.set(maxConnections);
+ }
+
+ @Override
+ final boolean addConnection(final HttpExchange exchange){
+ final InetAddress address = exchange.getRemoteAddress().getAddress();
+ final int maxConn = getMaxConnections(exchange);
+
+ if(!connections.containsKey(address))
+ connections.put(address,new AtomicInteger(0));
+
+ final AtomicInteger conn = connections.get(address);
+ final boolean exempt = canIgnoreConnectionLimit(exchange);
+
+ if(maxConn < 0){
+ if(!exempt){
+ synchronized(this){
+ final int umax = uConnMax.get();
+ if(umax < 0 || uConn.get() < umax){
+ conn.incrementAndGet();
+ uConn.incrementAndGet();
+ return true;
+ }
+ return false;
+ }
+ }else{
+ conn.incrementAndGet();
+ return true;
+ }
+ }else{
+ if(!exempt){
+ synchronized(this){
+ final int umax = uConnMax.get();
+ if(conn.get() < maxConn && (umax < 0 || uConn.get() < umax)){
+ conn.incrementAndGet();
+ uConn.incrementAndGet();
+ return true;
+ }
+ return false;
+ }
+ }else{
+ final AtomicBoolean added = new AtomicBoolean(false);
+ conn.updateAndGet(operand -> {
+ if(operand < maxConn) added.set(true);
+ return operand < maxConn ? operand + 1 : operand;
+ });
+ return added.get();
+ }
+ }
+ }
+
+ @Override
+ final void deleteConnection(final HttpExchange exchange){
+ final InetAddress address = exchange.getRemoteAddress().getAddress();
+ if(connections.containsKey(address)){
+ connections.get(address).decrementAndGet();
+ if(!canIgnoreConnectionLimit(exchange))
+ uConn.decrementAndGet();
+ }
+ }
+
+ @Override
+ public int getMaxConnections(final HttpExchange exchange){
+ return -1;
+ }
+
+ /**
+ * Returns if an exchange is exempt from the server connection limit only.
+ *
+ * @param exchange exchange to process
+ * @return if exchange ignores server connection limit
+ *
+ * @see HttpExchange
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public boolean canIgnoreConnectionLimit(final HttpExchange exchange){
+ return false;
+ }
+
+ /**
+ * Sets the maximum number of connections the server can have. A value of -1 means unlimited connections.
+ *
+ * @param connections maximum number of connections allowed on the server
+ *
+ * @see #getMaxConnections(HttpExchange)
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public synchronized final void setMaxServerConnections(final int connections){
+ uConnMax.set(connections);
+ }
+
+ /**
+ * Returns the maximum number of connections the server can have.
+ *
+ * @return maximum number of connections allowed on th server
+ *
+ * @see #setMaxServerConnections(int)
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public synchronized final int getMaxServerConnections(){
+ return uConnMax.get();
+ }
+
+ @Override
+ public String toString(){
+ return
+ "ServerExchangeThrottler" + '{' +
+ "connections" + '=' + connections.toString() + ", " +
+ "userConnections" + '=' + uConn + ", " +
+ "userConnectionsMax" + '=' + uConnMax +
+ '}';
+ }
+
+}
diff --git a/src/main/java/com/kttdevelopment/simplehttpserver/handler/ServerSessionThrottler.java b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ServerSessionThrottler.java
new file mode 100644
index 0000000..88e6b16
--- /dev/null
+++ b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ServerSessionThrottler.java
@@ -0,0 +1,191 @@
+package com.kttdevelopment.simplehttpserver.handler;
+
+import com.kttdevelopment.simplehttpserver.HttpSession;
+import com.kttdevelopment.simplehttpserver.HttpSessionHandler;
+import com.sun.net.httpserver.HttpExchange;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Limits connections per session to the server and total server sessions.
+ *
+ * @see HttpSession
+ * @see HttpSessionHandler
+ * @see ThrottledHandler
+ * @see ExchangeThrottler
+ * @see ServerExchangeThrottler
+ * @see SessionThrottler
+ * @since 03.05.00
+ * @version 03.05.00
+ * @author Ktt Development
+ */
+public class ServerSessionThrottler extends ConnectionThrottler{
+
+ private final HttpSessionHandler sessionHandler;
+ private final Map connections = new ConcurrentHashMap<>();
+
+ private final AtomicInteger uConn = new AtomicInteger(0);
+ private final AtomicInteger uConnMax = new AtomicInteger(-1);
+
+ /**
+ * Creates a throttler with limits on session and total connections.
+ *
+ * @param sessionHandler http session handler
+ *
+ * @see HttpSessionHandler
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public ServerSessionThrottler(final HttpSessionHandler sessionHandler){
+ this.sessionHandler = sessionHandler;
+ }
+
+ /**
+ * Creates a throttler with limits on session and total connections.
+ *
+ * @param sessionHandler http session handler
+ * @param maxConnections maximum allowed server connections
+ *
+ * @see HttpSessionHandler
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public ServerSessionThrottler(final HttpSessionHandler sessionHandler, final int maxConnections){
+ this.sessionHandler = sessionHandler;
+ uConnMax.set(maxConnections);
+ }
+
+ @Override
+ final boolean addConnection(final HttpExchange exchange){
+ final HttpSession session = sessionHandler.getSession(exchange);
+ final int maxConn = getMaxConnections(session,exchange);
+
+ if(!connections.containsKey(session))
+ connections.put(session,new AtomicInteger(0));
+
+ final AtomicInteger conn = connections.get(session);
+ final boolean exempt = canIgnoreConnectionLimit(session,exchange);
+
+ if(maxConn < 0){
+ if(!exempt){
+ synchronized(this){
+ final int uMax = uConnMax.get();
+ if(uMax < 0 || uConn.get() < uMax){
+ conn.incrementAndGet();
+ uConn.incrementAndGet();
+ return true;
+ }
+ return false;
+ }
+ }else{
+ conn.incrementAndGet();
+ return true;
+ }
+ }else{
+ if(!exempt){
+ synchronized(this){
+ final int umax = uConnMax.get();
+ if(conn.get() < maxConn && (umax < 0 || uConn.get() < umax)){
+ conn.incrementAndGet();
+ uConn.incrementAndGet();
+ return true;
+ }
+ return false;
+ }
+ }else{
+ final AtomicBoolean added = new AtomicBoolean(false);
+ conn.updateAndGet(operand -> {
+ if(operand < maxConn) added.set(true);
+ return operand < maxConn ? operand + 1 : operand;
+ });
+ return added.get();
+ }
+ }
+ }
+
+ @Override
+ final void deleteConnection(final HttpExchange exchange){
+ final HttpSession session = sessionHandler.getSession(exchange);
+ if(connections.containsKey(session)){
+ connections.get(session).decrementAndGet();
+ if(!canIgnoreConnectionLimit(session,exchange))
+ uConn.decrementAndGet();
+ }
+ }
+
+ @Override
+ public final int getMaxConnections(final HttpExchange exchange){
+ return getMaxConnections(sessionHandler.getSession(exchange),exchange);
+ }
+
+ /**
+ * Returns the maximum number of connections for a session. A value of -1 means unlimited connections.
+ *
+ * @param session session to process
+ * @param exchange exchange to process
+ * @return maximum number of connections allowed
+ *
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public int getMaxConnections(final HttpSession session, final HttpExchange exchange){
+ return -1;
+ }
+
+ /**
+ * Returns if a session is exempt from the server connection limit only.
+ *
+ * @param session session to process
+ * @param exchange exchange to process
+ * @return if exchange ignores server connection limit
+ *
+ * @see HttpSession
+ * @see HttpExchange
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public boolean canIgnoreConnectionLimit(final HttpSession session, final HttpExchange exchange){
+ return false;
+ }
+
+ /**
+ * Sets the maximum number of connections the server can have. A value of -1 means unlimited connections.
+ *
+ * @param connections maximum number of connections allowed on the server
+ *
+ * @see #getMaxConnections(HttpExchange)
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public synchronized final void setMaxServerConnections(final int connections){
+ uConnMax.set(connections);
+ }
+
+ /**
+ * Returns the maximum number of connections the server can have.
+ *
+ * @return maximum number of connections allowed on th server
+ *
+ * @see #setMaxServerConnections(int)
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public synchronized final int getMaxServerConnections(){
+ return uConnMax.get();
+ }
+
+ @Override
+ public String toString(){
+ return
+ "ServerSessionThrottler" + '{' +
+ "sessionHandler" + '=' + sessionHandler + ", " +
+ "connections" + '=' + connections.toString() + ", " +
+ "userConnections" + '=' + uConn + ", " +
+ "userConnectionsMax" + '=' + uConnMax +
+ '}';
+ }
+
+}
diff --git a/src/main/java/com/kttdevelopment/simplehttpserver/handler/ServerThrottler.java b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ServerThrottler.java
index e7b6535..899e438 100644
--- a/src/main/java/com/kttdevelopment/simplehttpserver/handler/ServerThrottler.java
+++ b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ServerThrottler.java
@@ -8,12 +8,15 @@
/**
* Limits connections for the server.
*
+ * @deprecated Use {@link ServerExchangeThrottler} instead
+ *
* @see ThrottledHandler
* @see SessionThrottler
* @since 03.03.00
* @version 03.05.00
* @author Ktt Development
*/
+@Deprecated
public class ServerThrottler extends ConnectionThrottler {
private final Predicate countsTowardsLimit;
@@ -97,6 +100,7 @@ public synchronized final void setMaxConnections(final int maxConnections){
this.maxConnections.set(maxConnections);
}
+ @Override
final boolean addConnection(final HttpExchange exchange){
if(!countsTowardsLimit.test(exchange)){
return true;
@@ -111,6 +115,7 @@ final boolean addConnection(final HttpExchange exchange){
return false;
}
+ @Override
final void deleteConnection(final HttpExchange exchange){
if(countsTowardsLimit.test(exchange))
synchronized(this){
@@ -118,6 +123,11 @@ final void deleteConnection(final HttpExchange exchange){
}
}
+ @Override
+ public int getMaxConnections(final HttpExchange exchange){
+ return getMaxConnections();
+ }
+
//
@Override
diff --git a/src/main/java/com/kttdevelopment/simplehttpserver/handler/SessionThrottler.java b/src/main/java/com/kttdevelopment/simplehttpserver/handler/SessionThrottler.java
index 75add9c..70783c1 100644
--- a/src/main/java/com/kttdevelopment/simplehttpserver/handler/SessionThrottler.java
+++ b/src/main/java/com/kttdevelopment/simplehttpserver/handler/SessionThrottler.java
@@ -4,28 +4,35 @@
import com.sun.net.httpserver.HttpExchange;
import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
/**
* Limits connections per http session. This can be used to limit simultaneous downloads.
*
- * @see ThrottledHandler
- * @see ServerThrottler
* @see HttpSession
+ * @see ThrottledHandler
+ * @see ExchangeThrottler
+ * @see ServerExchangeThrottler
+ * @see ServerSessionThrottler
* @since 03.03.00
* @version 03.05.00
* @author Ktt Development
*/
public class SessionThrottler extends ConnectionThrottler {
- private final HttpSessionHandler sessionHandler;
-
+ @Deprecated
private final Predicate countsTowardsLimit;
- private final Map sessions = Collections.synchronizedMap(new HashMap<>());
-
+ @Deprecated
private final AtomicInteger maxConnections = new AtomicInteger(0);
+
+ private final HttpSessionHandler sessionHandler;
+ private final Map connections = new ConcurrentHashMap<>();
+
+
/**
* Creates a throttler that allows no connections.
*
@@ -37,12 +44,13 @@ public class SessionThrottler extends ConnectionThrottler {
*/
public SessionThrottler(final HttpSessionHandler sessionHandler){
this.sessionHandler = sessionHandler;
- countsTowardsLimit = (exchange) -> true;
+ countsTowardsLimit = (exchange) -> true; // @depreciated
}
/**
* Creates a throttler that limits the amount of simultaneous connections a user can have.
*
+ * @deprecated Override {@link #getMaxConnections(HttpSession, HttpExchange)} for max connections
* @param sessionHandler session handler
* @param maxConnections maximum simultaneous connections (per user)
*
@@ -50,6 +58,7 @@ public SessionThrottler(final HttpSessionHandler sessionHandler){
* @since 03.03.00
* @author Ktt Development
*/
+ @Deprecated
public SessionThrottler(final HttpSessionHandler sessionHandler, final int maxConnections){
this.sessionHandler = sessionHandler;
countsTowardsLimit = (exchange) -> true;
@@ -59,6 +68,7 @@ public SessionThrottler(final HttpSessionHandler sessionHandler, final int maxCo
/**
* Creates a throttler that limits the amount of simultaneous connections a user can have and exempt connections.
*
+ * @deprecated Override {@link #getMaxConnections(HttpSession, HttpExchange)} for connection limit
* @param sessionHandler session handler
* @param countsTowardsLimit determines which users are subject to the limit
*
@@ -66,6 +76,7 @@ public SessionThrottler(final HttpSessionHandler sessionHandler, final int maxCo
* @since 03.03.00
* @author Ktt Development
*/
+ @Deprecated
public SessionThrottler(final HttpSessionHandler sessionHandler, final Predicate countsTowardsLimit){
this.sessionHandler = sessionHandler;
this.countsTowardsLimit = countsTowardsLimit;
@@ -74,10 +85,12 @@ public SessionThrottler(final HttpSessionHandler sessionHandler, final Predicate
/**
* Creates a throttler that limits the amount of simultaneous connections a user can have and exempt connections.
*
+ * @deprecated Override {{@link #getMaxConnections(HttpSession, HttpExchange)} for connection limit and max connections
* @param sessionHandler session handler
* @param countsTowardsLimit determines which users are subject to the limit
* @param maxConnections maximum simultaneous connections (per user)
*/
+ @Deprecated
public SessionThrottler(final HttpSessionHandler sessionHandler, final Predicate countsTowardsLimit, final int maxConnections){
this.sessionHandler = sessionHandler;
this.countsTowardsLimit = countsTowardsLimit;
@@ -87,12 +100,14 @@ public SessionThrottler(final HttpSessionHandler sessionHandler, final Predicate
/**
* Returns the maximum allowed connections.
*
+ * @deprecated Use {@link #getMaxConnections(HttpSession, HttpExchange)} instead
* @return maximum allowed connections (per user)
*
* @see #setMaxConnections(int)
* @since 03.03.00
* @author Ktt Development
*/
+ @Deprecated
public final int getMaxConnections(){
return maxConnections.get();
}
@@ -100,12 +115,14 @@ public final int getMaxConnections(){
/**
* Sets the maximum allowed connections. Must be a positive number.
*
+ * @deprecated Override {@link #getMaxConnections(HttpSession, HttpExchange)} instead
* @param maxConnections maximum allowed connections (per user)
*
* @see #getMaxConnections()
* @since 03.03.00
* @author Ktt Development
*/
+ @Deprecated
public synchronized final void setMaxConnections(final int maxConnections){
if(maxConnections >= 0)
this.maxConnections.set(maxConnections);
@@ -114,31 +131,50 @@ public synchronized final void setMaxConnections(final int maxConnections){
@Override
final boolean addConnection(final HttpExchange exchange){
final HttpSession session = sessionHandler.getSession(exchange);
- if(!countsTowardsLimit.test(session)){
+ final int maxConn = getMaxConnections(session,exchange);
+
+ if(!connections.containsKey(session))
+ connections.put(session,new AtomicInteger(0));
+
+ final AtomicInteger conn = connections.get(session);
+
+ if(maxConn < 0){
+ conn.incrementAndGet();
return true;
}else{
- synchronized(this){
- final AtomicInteger conn;
- if(!sessions.containsKey(session))
- sessions.put(session,conn = new AtomicInteger(0));
- else
- conn = sessions.get(session);
- if(conn.get() + 1 <= maxConnections.get()){
- conn.incrementAndGet();
- return true;
- }
- }
+ final AtomicBoolean added = new AtomicBoolean(false);
+ conn.updateAndGet(operand -> {
+ if(operand < maxConn) added.set(true);
+ return operand < maxConn ? operand + 1 : operand;
+ });
+ return added.get();
}
- return false;
}
@Override
final void deleteConnection(final HttpExchange exchange){
final HttpSession session = sessionHandler.getSession(exchange);
- if(countsTowardsLimit.test(session))
- synchronized(this){
- sessions.get(session).decrementAndGet();
- }
+ if(connections.containsKey(session))
+ connections.get(session).decrementAndGet();
+ }
+
+ @Override
+ public final int getMaxConnections(final HttpExchange exchange){
+ return getMaxConnections(sessionHandler.getSession(exchange),exchange);
+ }
+
+ /**
+ * Returns the maximum number of connections for a session. A value of -1 means unlimited connections.
+ *
+ * @param session session to process
+ * @param exchange exchange to process
+ * @return maximum number of connections allowed
+ *
+ * @since 03.05.00
+ * @author Ktt Development
+ */
+ public int getMaxConnections(final HttpSession session, final HttpExchange exchange){
+ return countsTowardsLimit.test(session) ? getMaxConnections() : -1;
}
//
@@ -146,10 +182,12 @@ final void deleteConnection(final HttpExchange exchange){
@Override
public String toString(){
return
- "SessionThrottler" + '{' +
- "condition" + '=' + countsTowardsLimit + ", " +
- "sessions" + '=' + sessions.toString() + ", " +
- "maxConnections" + '=' + maxConnections.get() +
+ "SessionThrottler" + '{' +
+ "condition@depreciated" + '=' + countsTowardsLimit + ", " +
+ "sessions@depreciated" + '=' + connections.toString() + ", " +
+ "maxConnections@depreciated" + '=' + maxConnections.get() + ", " +
+ "sessionHandler" + '=' + sessionHandler + ", " +
+ "connections" + '=' + connections.toString() +
'}';
}
diff --git a/src/main/java/com/kttdevelopment/simplehttpserver/handler/ThrottledHandler.java b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ThrottledHandler.java
index 13e326b..0d031f1 100644
--- a/src/main/java/com/kttdevelopment/simplehttpserver/handler/ThrottledHandler.java
+++ b/src/main/java/com/kttdevelopment/simplehttpserver/handler/ThrottledHandler.java
@@ -8,8 +8,10 @@
/**
* This handler limits the amount of active connections to a handler. This can be used to limit the amount of simultaneous downloads, or prevent duplicate connections by users.
*
- * @see ServerThrottler
+ * @see ExchangeThrottler
+ * @see ServerExchangeThrottler
* @see SessionThrottler
+ * @see ServerSessionThrottler
* @since 03.03.00
* @version 03.05.00
* @author Ktt Development
@@ -26,8 +28,10 @@ public class ThrottledHandler implements HttpHandler {
* @param throttler how to throttle connections
*
* @see HttpHandler
- * @see ServerThrottler
+ * @see ExchangeThrottler
+ * @see ServerExchangeThrottler
* @see SessionThrottler
+ * @see ServerSessionThrottler
* @since 03.03.00
* @author Ktt Development
*/
@@ -46,14 +50,12 @@ public final void handle(final HttpExchange exchange) throws IOException{
}
}
- //
-
@Override
public String toString(){
return
- "ThrottledHandler" + '{' +
- "handler" + '=' + handler + ", " +
- "throttler" + '=' + throttler +
+ "ThrottledHandler" + '{' +
+ "handler" + '=' + handler + ", " +
+ "throttler" + '=' + throttler +
'}';
}