Technoboy- commented on a change in pull request #1384: URL: https://github.com/apache/shardingsphere-elasticjob/pull/1384#discussion_r472205600
########## File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/deserializer/impl/JsonRequestBodyDeserializer.java ########## @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.elasticjob.restful.deserializer.impl; + +import com.google.gson.Gson; +import io.netty.handler.codec.http.HttpHeaderValues; +import org.apache.shardingsphere.elasticjob.restful.deserializer.RequestBodyDeserializer; + +import java.nio.charset.StandardCharsets; + +/** + * Deserializer for <code>application/json</code>. + */ +public class JsonRequestBodyDeserializer implements RequestBodyDeserializer { Review comment: Add final ########## File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/deserializer/impl/TextPlainRequestBodyDeserializer.java ########## @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.elasticjob.restful.deserializer.impl; + +import io.netty.handler.codec.http.HttpHeaderValues; +import org.apache.shardingsphere.elasticjob.restful.deserializer.RequestBodyDeserializer; + +import java.nio.charset.StandardCharsets; +import java.text.MessageFormat; + +/** + * Deserializer for <code>text/plain</code>. + */ +public class TextPlainRequestBodyDeserializer implements RequestBodyDeserializer { Review comment: Add final ########## File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/pipeline/ExceptionHandling.java ########## @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.elasticjob.restful.pipeline; + +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandler.Sharable; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.handler.codec.http.DefaultFullHttpResponse; +import io.netty.handler.codec.http.FullHttpResponse; +import io.netty.handler.codec.http.HttpHeaderNames; +import io.netty.handler.codec.http.HttpResponseStatus; +import io.netty.handler.codec.http.HttpUtil; +import io.netty.handler.codec.http.HttpVersion; +import lombok.extern.slf4j.Slf4j; +import org.apache.shardingsphere.elasticjob.restful.ExceptionHandleResult; +import org.apache.shardingsphere.elasticjob.restful.ExceptionHandler; +import org.apache.shardingsphere.elasticjob.restful.Http; +import org.apache.shardingsphere.elasticjob.restful.serializer.ResponseBodySerializer; +import org.apache.shardingsphere.elasticjob.restful.serializer.ResponseBodySerializerFactory; + +import java.util.Map; + +/** + * Catch exceptions and look for a ExceptionHandler. + */ +@Sharable +public class ExceptionHandling extends ChannelInboundHandlerAdapter { Review comment: Add final ########## File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/pipeline/HandleMethodExecutor.java ########## @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.elasticjob.restful.pipeline; + +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandler.Sharable; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.handler.codec.http.DefaultFullHttpResponse; +import io.netty.handler.codec.http.FullHttpResponse; +import io.netty.handler.codec.http.HttpHeaderNames; +import io.netty.handler.codec.http.HttpResponseStatus; +import io.netty.handler.codec.http.HttpUtil; +import io.netty.handler.codec.http.HttpVersion; +import org.apache.shardingsphere.elasticjob.restful.HandleContext; +import org.apache.shardingsphere.elasticjob.restful.Handler; +import org.apache.shardingsphere.elasticjob.restful.serializer.ResponseBodySerializer; +import org.apache.shardingsphere.elasticjob.restful.serializer.ResponseBodySerializerFactory; + +import java.lang.reflect.InvocationTargetException; + +/** + * The handler which actually executes handle method and creates HTTP response for responding. + * If an exception occurred when executing handle method, this handler would pass it to Handler named {@link ExceptionHandling}. + */ +@Sharable +public class HandleMethodExecutor extends ChannelInboundHandlerAdapter { Review comment: Add final ########## File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/pipeline/HandlerParameterDecoder.java ########## @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.elasticjob.restful.pipeline; + +import com.google.common.base.Preconditions; +import io.netty.buffer.ByteBufUtil; +import io.netty.channel.ChannelHandler.Sharable; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.handler.codec.UnsupportedMessageTypeException; +import io.netty.handler.codec.http.FullHttpRequest; +import io.netty.handler.codec.http.HttpUtil; +import io.netty.handler.codec.http.QueryStringDecoder; +import lombok.extern.slf4j.Slf4j; +import org.apache.shardingsphere.elasticjob.restful.HandleContext; +import org.apache.shardingsphere.elasticjob.restful.Handler; +import org.apache.shardingsphere.elasticjob.restful.HandlerParameter; +import org.apache.shardingsphere.elasticjob.restful.Http; +import org.apache.shardingsphere.elasticjob.restful.MappingContext; +import org.apache.shardingsphere.elasticjob.restful.PathMatcher; +import org.apache.shardingsphere.elasticjob.restful.RegexPathMatcher; +import org.apache.shardingsphere.elasticjob.restful.deserializer.RequestBodyDeserializer; +import org.apache.shardingsphere.elasticjob.restful.deserializer.RequestBodyDeserializerFactory; + +import java.text.MessageFormat; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** + * This handler is used for preparing parameters before executing handle method. + * It prepares arguments declared by {@link org.apache.shardingsphere.elasticjob.restful.annotation.Param} + * and {@link org.apache.shardingsphere.elasticjob.restful.annotation.RequestBody}, and deserializes arguments to declared type. + */ +@Slf4j +@Sharable +public class HandlerParameterDecoder extends ChannelInboundHandlerAdapter { Review comment: Add final ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org