模块 org.redkale

类 SncpServlet.SncpActionServlet

    • 字段详细资料

      • method

        protected final Method method
      • actionid

        protected final Uint128 actionid
      • nonBlocking

        protected final boolean nonBlocking
      • paramTypes

        protected final Type[] paramTypes
      • returnObjectType

        protected final Type returnObjectType
      • paramHandlerIndex

        protected final int paramHandlerIndex
      • paramHandlerResultType

        protected final Type paramHandlerResultType
      • returnFutureResultType

        protected final Type returnFutureResultType
    • 方法详细资料

      • service

        public <T extends Service> T service()
      • getActionid

        public Uint128 getActionid()
      • actionName

        public String actionName()
      • create

        public static SncpServlet.SncpActionServlet create​(String resourceName,
                                                           Class resourceType,
                                                           Class serviceImplClass,
                                                           Service service,
                                                           Uint128 serviceid,
                                                           Uint128 actionid,
                                                           Method method)
              public interface TestService extends Service {
        
             public boolean change(TestBean bean, String name, int id);
        
             public void insert(BooleanHandler handler, TestBean bean, String name, int id);
        
             public void update(long show, short v2, CompletionHandler<Boolean, TestBean> handler, TestBean bean, String name, int id);
        
            public CompletableFuture<String> changeName(TestBean bean, String name, int id);
        
         }
        
         @ResourceType(TestService.class)
         class TestServiceImpl implements TestService {
        
             @Override
             public boolean change(TestBean bean, String name, int id) {
                 return false;
             }
        
             @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;
             }
         }
        
         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);
             }
         }
        
         
        参数:
        resourceName - 资源名
        resourceType - 资源类
        serviceImplClass - Service实现类
        service - Service
        serviceid - 类ID
        actionid - 操作ID
        method - 方法
        返回:
        SncpActionServlet