Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implements #129 (Migrate TimeoutFactory functionality to Timeout) (cl…

…oses #129)
  • Loading branch information...
commit c01fb78b1d342112e90b15fb8d8a158973718b68 1 parent f3b1edf
@rschildmeijer authored
View
10 src/main/java/org/deftserver/io/timeout/Timeout.java
@@ -1,5 +1,8 @@
package org.deftserver.io.timeout;
+import java.nio.channels.SocketChannel;
+
+import org.deftserver.util.Closeables;
import org.deftserver.web.AsyncCallback;
@@ -29,5 +32,12 @@ public boolean isCancelled() {
public AsyncCallback getCallback() {
return cancelled ? AsyncCallback.nopCb : cb;
}
+
+ public static Timeout newKeepAliveTimeout(final SocketChannel clientChannel, long keepAliveTimeout) {
+ return new Timeout(
+ System.currentTimeMillis() + keepAliveTimeout,
+ new AsyncCallback() { public void onCallback() { Closeables.closeQuietly(clientChannel); } }
+ );
+ }
}
View
2  src/main/java/org/deftserver/util/NopAsyncResult.java
@@ -10,7 +10,7 @@ private NopAsyncResult() {}
@Override public void onFailure(Throwable caught) {}
- @Override public void onSuccess(T result) {System.out.println();}
+ @Override public void onSuccess(T result) {}
};
View
21 src/main/java/org/deftserver/util/TimeoutFactory.java
@@ -1,21 +0,0 @@
-package org.deftserver.util;
-
-import java.nio.channels.SocketChannel;
-
-import org.deftserver.io.timeout.Timeout;
-import org.deftserver.web.AsyncCallback;
-
-public class TimeoutFactory {
-
- public static Timeout keepAliveTimeout(final SocketChannel clientChannel, long keepAliveTimeout) {
- return new Timeout(
- System.currentTimeMillis() + keepAliveTimeout,
- new AsyncCallback() {
-
- @Override public void onCallback() { Closeables.closeQuietly(clientChannel); }
-
- }
- );
- }
-
-}
View
4 src/main/java/org/deftserver/web/http/HttpProtocol.java
@@ -15,8 +15,8 @@
import org.deftserver.io.IOHandler;
import org.deftserver.io.IOLoop;
import org.deftserver.io.buffer.DynamicByteBuffer;
+import org.deftserver.io.timeout.Timeout;
import org.deftserver.util.Closeables;
-import org.deftserver.util.TimeoutFactory;
import org.deftserver.web.Application;
import org.deftserver.web.handler.RequestHandler;
import org.slf4j.Logger;
@@ -59,7 +59,7 @@ public void handleRead(SelectionKey key) throws IOException {
if (request.isKeepAlive()) {
IOLoop.INSTANCE.addKeepAliveTimeout(
clientChannel,
- TimeoutFactory.keepAliveTimeout(clientChannel, KEEP_ALIVE_TIMEOUT)
+ Timeout.newKeepAliveTimeout(clientChannel, KEEP_ALIVE_TIMEOUT)
);
}
HttpResponse response = new HttpResponse(this, key, request.isKeepAlive());
Please sign in to comment.
Something went wrong with that request. Please try again.