This commit is contained in:
@@ -18,7 +18,7 @@ import java.util.logging.*;
|
|||||||
* @param <R>
|
* @param <R>
|
||||||
* @param <P>
|
* @param <P>
|
||||||
*/
|
*/
|
||||||
public abstract class PrepareServlet<R extends Request, P extends Response<R>> implements Servlet<R, P> {
|
public abstract class PrepareServlet<R extends Request, P extends Response<R>> extends Servlet<R, P> {
|
||||||
|
|
||||||
protected final AtomicLong executeCounter = new AtomicLong(); //执行请求次数
|
protected final AtomicLong executeCounter = new AtomicLong(); //执行请求次数
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public abstract class Response<R extends Request> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <A> void send(final ByteBuffer[] buffers, A attachment, CompletionHandler<Integer, A> handler) {
|
protected <A> void send(final ByteBuffer[] buffers, A attachment, final CompletionHandler<Integer, A> handler) {
|
||||||
this.channel.write(buffers, attachment, new CompletionHandler<Integer, A>() {
|
this.channel.write(buffers, attachment, new CompletionHandler<Integer, A>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -207,9 +207,7 @@ public abstract class Response<R extends Request> {
|
|||||||
ByteBuffer[] newattachs = new ByteBuffer[buffers.length - index];
|
ByteBuffer[] newattachs = new ByteBuffer[buffers.length - index];
|
||||||
System.arraycopy(buffers, index, newattachs, 0, newattachs.length);
|
System.arraycopy(buffers, index, newattachs, 0, newattachs.length);
|
||||||
channel.write(newattachs, attachment, this);
|
channel.write(newattachs, attachment, this);
|
||||||
} else {
|
} else if (handler != null) handler.completed(result, attachment);
|
||||||
if (handler != null) handler.completed(result, attachment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ import java.io.IOException;
|
|||||||
* @param <R>
|
* @param <R>
|
||||||
* @param <P>
|
* @param <P>
|
||||||
*/
|
*/
|
||||||
public interface Servlet<R extends Request, P extends Response<R>> {
|
public abstract class Servlet<R extends Request, P extends Response<R>> {
|
||||||
|
|
||||||
default void init(Context context, AnyValue config) {
|
public void init(Context context, AnyValue config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(R request, P response) throws IOException;
|
public abstract void execute(R request, P response) throws IOException;
|
||||||
|
|
||||||
default void destroy(Context context, AnyValue config) {
|
public void destroy(Context context, AnyValue config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.redkale.util.*;
|
|||||||
* @see http://www.redkale.org
|
* @see http://www.redkale.org
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
public abstract class HttpServlet implements Servlet<HttpRequest, HttpResponse<HttpRequest>> {
|
public abstract class HttpServlet extends Servlet<HttpRequest, HttpResponse<HttpRequest>> {
|
||||||
|
|
||||||
AnyValue conf; //当前HttpServlet的配置
|
AnyValue conf; //当前HttpServlet的配置
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.redkale.util.*;
|
|||||||
* @see http://www.redkale.org
|
* @see http://www.redkale.org
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
public abstract class SncpServlet implements Servlet<SncpRequest, SncpResponse> {
|
public abstract class SncpServlet extends Servlet<SncpRequest, SncpResponse> {
|
||||||
|
|
||||||
AnyValue conf;
|
AnyValue conf;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user