This commit is contained in:
@@ -11,6 +11,7 @@ import java.net.*;
|
||||
import java.nio.*;
|
||||
import java.nio.charset.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
/**
|
||||
@@ -89,6 +90,10 @@ public class Context {
|
||||
return bufferCapacity;
|
||||
}
|
||||
|
||||
public Supplier<ByteBuffer> getBufferSupplier() {
|
||||
return bufferPool;
|
||||
}
|
||||
|
||||
public ByteBuffer pollBuffer() {
|
||||
return bufferPool.get();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.nio.channels.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.function.*;
|
||||
|
||||
/**
|
||||
* 传输客户端
|
||||
@@ -115,6 +116,10 @@ public final class Transport {
|
||||
return bufferPool.get();
|
||||
}
|
||||
|
||||
public Supplier<ByteBuffer> getBufferSupplier() {
|
||||
return bufferPool;
|
||||
}
|
||||
|
||||
public void offerBuffer(ByteBuffer buffer) {
|
||||
bufferPool.offer(buffer);
|
||||
}
|
||||
|
||||
@@ -60,10 +60,6 @@ public final class HttpContext extends Context {
|
||||
return responsePool;
|
||||
}
|
||||
|
||||
protected ObjectPool<ByteBuffer> getBufferPool() {
|
||||
return bufferPool;
|
||||
}
|
||||
|
||||
public JsonConvert getJsonConvert() {
|
||||
return jsonFactory.getConvert();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.nio.file.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.function.*;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -148,10 +147,6 @@ public class HttpResponse<R extends HttpRequest> extends Response<R> {
|
||||
return v == null ? defValue : v;
|
||||
}
|
||||
|
||||
protected Supplier<ByteBuffer> getByteBufferSupplier() {
|
||||
return ((HttpContext) context).getBufferPool();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpContext getContext() {
|
||||
return (HttpContext) context;
|
||||
@@ -170,17 +165,17 @@ public class HttpResponse<R extends HttpRequest> extends Response<R> {
|
||||
|
||||
public void finishJson(Object obj) {
|
||||
this.contentType = "text/plain; charset=utf-8";
|
||||
finish(request.convert.convertTo(context.getCharset(), getByteBufferSupplier(), obj));
|
||||
finish(request.convert.convertTo(context.getCharset(), context.getBufferSupplier(), obj));
|
||||
}
|
||||
|
||||
public void finishJson(Type type, Object obj) {
|
||||
this.contentType = "text/plain; charset=utf-8";
|
||||
finish(request.convert.convertTo(context.getCharset(), getByteBufferSupplier(), type, obj));
|
||||
finish(request.convert.convertTo(context.getCharset(), context.getBufferSupplier(), type, obj));
|
||||
}
|
||||
|
||||
public void finishJson(Object... objs) {
|
||||
this.contentType = "text/plain; charset=utf-8";
|
||||
finish(request.convert.convertTo(context.getCharset(), getByteBufferSupplier(), objs));
|
||||
finish(request.convert.convertTo(context.getCharset(), context.getBufferSupplier(), objs));
|
||||
}
|
||||
|
||||
public void finish(String obj) {
|
||||
|
||||
Reference in New Issue
Block a user