sncp优化
This commit is contained in:
@@ -39,7 +39,7 @@ public class BsonMainTest {
|
||||
byte[] bytes = convert.convertTo(SimpleEntity.class, entry);
|
||||
System.out.println("长度: " + bytes.length);
|
||||
Assertions.assertEquals(271, bytes.length);
|
||||
BsonByteBufferWriter writer = convert.pollBsonWriter(() -> ByteBuffer.allocate(1));
|
||||
BsonByteBufferWriter writer = convert.pollWriter(() -> ByteBuffer.allocate(1));
|
||||
convert.convertTo(writer, SimpleEntity.class, entry);
|
||||
ByteBuffer[] buffers = writer.toBuffers();
|
||||
int len = 0;
|
||||
@@ -71,7 +71,7 @@ public class BsonMainTest {
|
||||
ComplextEntity bean = new ComplextEntity();
|
||||
byte[] bytes2 = convert.convertTo(Object.class, bean);
|
||||
final int len = bytes2.length;
|
||||
BsonByteBufferWriter writer = convert.pollBsonWriter(() -> ByteBuffer.allocate(len / 2));
|
||||
BsonByteBufferWriter writer = convert.pollWriter(() -> ByteBuffer.allocate(len / 2));
|
||||
convert.convertTo(writer, bean);
|
||||
bytes2 = writer.toArray();
|
||||
System.out.println(convert.convertFrom(ComplextEntity.class, bytes2).toString());
|
||||
|
||||
@@ -28,119 +28,123 @@ public interface TestService extends Service {
|
||||
|
||||
public CompletableFuture<String> changeName(TestBean bean, String name, int id);
|
||||
|
||||
@ResourceType(TestService.class)
|
||||
public static class TestServiceImpl implements TestService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean change(TestBean bean, String name, int id) {
|
||||
return false;
|
||||
}
|
||||
@ResourceType(TestService.class)
|
||||
class TestServiceImpl implements TestService {
|
||||
|
||||
@Override
|
||||
public void insert(BooleanHandler handler, TestBean bean, String name, int id) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(long show, short v2, CompletionHandler<Boolean, TestBean> handler, TestBean bean, String name, int id) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<String> changeName(TestBean bean, String name, int id) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean change(TestBean bean, String name, int id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class BooleanHandler implements CompletionHandler<Boolean, TestBean> {
|
||||
|
||||
@Override
|
||||
public void completed(Boolean result, TestBean attachment) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable exc, TestBean attachment) {
|
||||
}
|
||||
|
||||
public void delete(TestBean bean) {
|
||||
}
|
||||
|
||||
public static class DynActionTestService_change extends SncpActionServlet {
|
||||
|
||||
public DynActionTestService_change(String resourceName, Class resourceType, Service service, Uint128 serviceid, Uint128 actionid, final Method method) {
|
||||
super(resourceName, resourceType, service, serviceid, actionid, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(SncpRequest request, SncpResponse response) throws Throwable {
|
||||
Convert<Reader, Writer> convert = request.getConvert();
|
||||
Reader in = request.getReader();
|
||||
TestBean arg1 = convert.convertFrom(paramTypes[1], in);
|
||||
String arg2 = convert.convertFrom(paramTypes[2], in);
|
||||
int arg3 = convert.convertFrom(paramTypes[3], in);
|
||||
TestService serviceObj = (TestService) service();
|
||||
Object rs = serviceObj.change(arg1, arg2, arg3);
|
||||
response.finish(boolean.class, rs);
|
||||
}
|
||||
@Override
|
||||
public void insert(BooleanHandler handler, TestBean bean, String name, int id) {
|
||||
}
|
||||
|
||||
public static class DynActionTestService_insert extends SncpActionServlet {
|
||||
|
||||
public DynActionTestService_insert(String resourceName, Class resourceType, Service service, Uint128 serviceid, Uint128 actionid, final Method method) {
|
||||
super(resourceName, resourceType, service, serviceid, actionid, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(SncpRequest request, SncpResponse response) throws Throwable {
|
||||
Convert<Reader, Writer> convert = request.getConvert();
|
||||
Reader in = request.getReader();
|
||||
BooleanHandler arg0 = response.getParamAsyncHandler();
|
||||
convert.convertFrom(CompletionHandler.class, in);
|
||||
TestBean arg1 = convert.convertFrom(paramTypes[2], in);
|
||||
String arg2 = convert.convertFrom(paramTypes[3], in);
|
||||
int arg3 = convert.convertFrom(paramTypes[4], in);
|
||||
TestService serviceObj = (TestService) service();
|
||||
serviceObj.insert(arg0, arg1, arg2, arg3);
|
||||
response.finishVoid();
|
||||
}
|
||||
@Override
|
||||
public void update(long show, short v2, CompletionHandler<Boolean, TestBean> handler, TestBean bean, String name, int id) {
|
||||
}
|
||||
|
||||
public static class DynActionTestService_update extends SncpActionServlet {
|
||||
|
||||
public DynActionTestService_update(String resourceName, Class resourceType, Service service, Uint128 serviceid, Uint128 actionid, final Method method) {
|
||||
super(resourceName, resourceType, service, serviceid, actionid, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(SncpRequest request, SncpResponse response) throws Throwable {
|
||||
Convert<Reader, Writer> convert = request.getConvert();
|
||||
Reader in = request.getReader();
|
||||
long a1 = convert.convertFrom(paramTypes[1], in);
|
||||
short a2 = convert.convertFrom(paramTypes[2], in);
|
||||
CompletionHandler a3 = response.getParamAsyncHandler();
|
||||
convert.convertFrom(CompletionHandler.class, in);
|
||||
TestBean arg1 = convert.convertFrom(paramTypes[4], in);
|
||||
String arg2 = convert.convertFrom(paramTypes[5], in);
|
||||
int arg3 = convert.convertFrom(paramTypes[6], in);
|
||||
TestService serviceObj = (TestService) service();
|
||||
serviceObj.update(a1, a2, a3, arg1, arg2, arg3);
|
||||
response.finishVoid();
|
||||
}
|
||||
}
|
||||
|
||||
public static class DynActionTestService_changeName extends SncpActionServlet {
|
||||
|
||||
public DynActionTestService_changeName(String resourceName, Class resourceType, Service service, Uint128 serviceid, Uint128 actionid, final Method method) {
|
||||
super(resourceName, resourceType, service, serviceid, actionid, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(SncpRequest request, SncpResponse response) throws Throwable {
|
||||
Convert<Reader, Writer> convert = request.getConvert();
|
||||
Reader in = request.getReader();
|
||||
TestBean arg1 = convert.convertFrom(paramTypes[1], in);
|
||||
String arg2 = convert.convertFrom(paramTypes[2], in);
|
||||
int arg3 = convert.convertFrom(paramTypes[3], in);
|
||||
TestService serviceObj = (TestService) service();
|
||||
CompletableFuture future = serviceObj.changeName(arg1, arg2, arg3);
|
||||
response.finishFuture(paramHandlerResultType, future);
|
||||
}
|
||||
@Override
|
||||
public CompletableFuture<String> changeName(TestBean bean, String name, int id) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class BooleanHandler implements CompletionHandler<Boolean, TestBean> {
|
||||
|
||||
@Override
|
||||
public void completed(Boolean result, TestBean attachment) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable exc, TestBean attachment) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DynActionTestService_change extends SncpActionServlet {
|
||||
|
||||
public DynActionTestService_change(String resourceName, Class resourceType, Service service, Uint128 serviceid, Uint128 actionid, final Method method) {
|
||||
super(resourceName, resourceType, service, serviceid, actionid, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(SncpRequest request, SncpResponse response) throws Throwable {
|
||||
Convert<Reader, Writer> convert = request.getConvert();
|
||||
Reader in = request.getReader();
|
||||
TestBean arg1 = convert.convertFrom(paramTypes[1], in);
|
||||
String arg2 = convert.convertFrom(paramTypes[2], in);
|
||||
int arg3 = convert.convertFrom(paramTypes[3], in);
|
||||
TestService serviceObj = (TestService) service();
|
||||
Object rs = serviceObj.change(arg1, arg2, arg3);
|
||||
response.finish(boolean.class, rs);
|
||||
}
|
||||
}
|
||||
|
||||
class DynActionTestService_insert extends SncpActionServlet {
|
||||
|
||||
public DynActionTestService_insert(String resourceName, Class resourceType, Service service, Uint128 serviceid, Uint128 actionid, final Method method) {
|
||||
super(resourceName, resourceType, service, serviceid, actionid, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(SncpRequest request, SncpResponse response) throws Throwable {
|
||||
Convert<Reader, Writer> convert = request.getConvert();
|
||||
Reader in = request.getReader();
|
||||
BooleanHandler arg0 = response.getParamAsyncHandler();
|
||||
convert.convertFrom(CompletionHandler.class, in);
|
||||
TestBean arg1 = convert.convertFrom(paramTypes[2], in);
|
||||
String arg2 = convert.convertFrom(paramTypes[3], in);
|
||||
int arg3 = convert.convertFrom(paramTypes[4], in);
|
||||
TestService serviceObj = (TestService) service();
|
||||
serviceObj.insert(arg0, arg1, arg2, arg3);
|
||||
response.finishVoid();
|
||||
}
|
||||
}
|
||||
|
||||
class DynActionTestService_update extends SncpActionServlet {
|
||||
|
||||
public DynActionTestService_update(String resourceName, Class resourceType, Service service, Uint128 serviceid, Uint128 actionid, final Method method) {
|
||||
super(resourceName, resourceType, service, serviceid, actionid, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(SncpRequest request, SncpResponse response) throws Throwable {
|
||||
Convert<Reader, Writer> convert = request.getConvert();
|
||||
Reader in = request.getReader();
|
||||
long a1 = convert.convertFrom(paramTypes[1], in);
|
||||
short a2 = convert.convertFrom(paramTypes[2], in);
|
||||
CompletionHandler a3 = response.getParamAsyncHandler();
|
||||
convert.convertFrom(CompletionHandler.class, in);
|
||||
TestBean arg1 = convert.convertFrom(paramTypes[4], in);
|
||||
String arg2 = convert.convertFrom(paramTypes[5], in);
|
||||
int arg3 = convert.convertFrom(paramTypes[6], in);
|
||||
TestService serviceObj = (TestService) service();
|
||||
serviceObj.update(a1, a2, a3, arg1, arg2, arg3);
|
||||
response.finishVoid();
|
||||
}
|
||||
}
|
||||
|
||||
class DynActionTestService_changeName extends SncpActionServlet {
|
||||
|
||||
public DynActionTestService_changeName(String resourceName, Class resourceType, Service service, Uint128 serviceid, Uint128 actionid, final Method method) {
|
||||
super(resourceName, resourceType, service, serviceid, actionid, method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(SncpRequest request, SncpResponse response) throws Throwable {
|
||||
Convert<Reader, Writer> convert = request.getConvert();
|
||||
Reader in = request.getReader();
|
||||
TestBean arg1 = convert.convertFrom(paramTypes[1], in);
|
||||
String arg2 = convert.convertFrom(paramTypes[2], in);
|
||||
int arg3 = convert.convertFrom(paramTypes[3], in);
|
||||
TestService serviceObj = (TestService) service();
|
||||
CompletableFuture future = serviceObj.changeName(arg1, arg2, arg3);
|
||||
response.finishFuture(paramHandlerResultType, future);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user