格式化
This commit is contained in:
@@ -5,9 +5,6 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.reflect.*;
|
||||
@@ -17,6 +14,8 @@ import java.util.function.*;
|
||||
import java.util.logging.*;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.asm.*;
|
||||
import static org.redkale.asm.ClassWriter.COMPUTE_FRAMES;
|
||||
import static org.redkale.asm.Opcodes.*;
|
||||
import org.redkale.boot.*;
|
||||
import org.redkale.net.*;
|
||||
import org.redkale.util.*;
|
||||
@@ -36,16 +35,22 @@ public class HttpServlet extends Servlet<HttpContext, HttpRequest, HttpResponse>
|
||||
// @Deprecated(since = "2.8.0")
|
||||
// public static final int RET_METHOD_ERROR = 1200_0002;
|
||||
//
|
||||
String _actionSimpleMappingUrl; // 只给HttpActionServlet使用,_actionSimpleMappingUrl不能包含正则表达式,比如: /json、/createRecord,
|
||||
|
||||
// 只给HttpActionServlet使用,_actionSimpleMappingUrl不能包含正则表达式,比如: /json、/createRecord,
|
||||
// 不能是/user/**
|
||||
String _actionSimpleMappingUrl;
|
||||
|
||||
String _prefix = ""; // 当前HttpServlet的path前缀
|
||||
// 当前HttpServlet的path前缀
|
||||
String _prefix = "";
|
||||
|
||||
String _reqtopic; // 根据RestService+MQ生成的值 @since 2.5.0
|
||||
// 根据RestService+MQ生成的值 @since 2.5.0
|
||||
String _reqtopic;
|
||||
|
||||
HashMap<String, ActionEntry> _actionmap; // Rest生成时赋值, 字段名Rest有用到
|
||||
// Rest生成时赋值, 字段名Rest有用到
|
||||
HashMap<String, ActionEntry> _actionmap;
|
||||
|
||||
private Map.Entry<String, ActionEntry>[] mappings; // 字段名Rest有用到
|
||||
// 字段名Rest有用到
|
||||
private Map.Entry<String, ActionEntry>[] mappings;
|
||||
|
||||
// 这里不能直接使用HttpServlet,会造成死循环初始化HttpServlet
|
||||
private final Servlet<HttpContext, HttpRequest, HttpResponse> authSuccessServlet =
|
||||
@@ -114,8 +119,6 @@ public class HttpServlet extends Servlet<HttpContext, HttpRequest, HttpResponse>
|
||||
if (request.actionEntry != null) {
|
||||
ActionEntry entry = request.actionEntry;
|
||||
if (!entry.checkMethod(request.getMethod())) {
|
||||
// response.finishJson(new RetResult(RET_METHOD_ERROR, "Method(" + request.getMethod() + ")
|
||||
// Error"));
|
||||
finish405(request, response);
|
||||
return;
|
||||
}
|
||||
@@ -134,8 +137,6 @@ public class HttpServlet extends Servlet<HttpContext, HttpRequest, HttpResponse>
|
||||
if (request.getRequestPath().startsWith(en.getKey())) {
|
||||
ActionEntry entry = en.getValue();
|
||||
if (!entry.checkMethod(request.getMethod())) {
|
||||
// response.finishJson(new RetResult(RET_METHOD_ERROR, "Method(" + request.getMethod() +
|
||||
// ") Error"));
|
||||
finish405(request, response);
|
||||
return;
|
||||
}
|
||||
@@ -153,8 +154,6 @@ public class HttpServlet extends Servlet<HttpContext, HttpRequest, HttpResponse>
|
||||
}
|
||||
}
|
||||
finish404(request, response);
|
||||
// throw new IOException(this.getClass().getName() + " not found method for URI(" +
|
||||
// request.getRequestPath() + ")");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -330,7 +329,6 @@ public class HttpServlet extends Servlet<HttpContext, HttpRequest, HttpResponse>
|
||||
NonBlocking non = method.getAnnotation(NonBlocking.class);
|
||||
exeNonBlocking = non != null && non.value();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} while ((clz = clz.getSuperclass()) != HttpServlet.class);
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.logging.*;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.*;
|
||||
import org.redkale.annotation.Comment;
|
||||
import org.redkale.annotation.Nonnull;
|
||||
import org.redkale.convert.Convert;
|
||||
import org.redkale.net.AsyncConnection;
|
||||
import org.redkale.net.http.WebSocketPacket.FrameType;
|
||||
@@ -88,41 +89,65 @@ public abstract class WebSocket<G extends Serializable, T> {
|
||||
@Comment("WebSocket将延迟发送")
|
||||
public static final int RETCODE_DELAYSEND = 1 << 9; // 512
|
||||
|
||||
WebSocketEngine _engine; // 不可能为空
|
||||
// 不可能为空
|
||||
@Nonnull
|
||||
WebSocketEngine _engine;
|
||||
|
||||
WebSocketReadHandler _readHandler;
|
||||
|
||||
WebSocketWriteHandler _writeHandler;
|
||||
|
||||
InetSocketAddress _sncpAddress; // 分布式下不可为空
|
||||
// 分布式下不可为空
|
||||
InetSocketAddress _sncpAddress;
|
||||
|
||||
AsyncConnection _channel; // 不可能为空
|
||||
// 不可能为空
|
||||
@Nonnull
|
||||
AsyncConnection _channel;
|
||||
|
||||
String _sessionid; // 不可能为空
|
||||
// 不可能为空
|
||||
@Nonnull
|
||||
String _sessionid;
|
||||
|
||||
G _userid; // 不可能为空
|
||||
// 不可能为空
|
||||
@Nonnull
|
||||
G _userid;
|
||||
|
||||
SocketAddress _remoteAddress; // 不可能为空
|
||||
// 不可能为空
|
||||
@Nonnull
|
||||
SocketAddress _remoteAddress;
|
||||
|
||||
String _remoteAddr; // 不可能为空
|
||||
// 不可能为空
|
||||
@Nonnull
|
||||
String _remoteAddr;
|
||||
|
||||
Convert _textConvert; // 不可能为空
|
||||
// 不可能为空
|
||||
@Nonnull
|
||||
Convert _textConvert;
|
||||
|
||||
Convert _binaryConvert; // 可能为空
|
||||
// 不可能为空
|
||||
@Nonnull
|
||||
Convert _binaryConvert;
|
||||
|
||||
Convert _sendConvert; // 不可能为空
|
||||
// 不可能为空
|
||||
@Nonnull
|
||||
Convert _sendConvert;
|
||||
|
||||
java.lang.reflect.Type _messageRestType; // 不可能为空
|
||||
// 不可能为空
|
||||
@Nonnull
|
||||
java.lang.reflect.Type _messageRestType;
|
||||
|
||||
Deflater deflater; // 压缩
|
||||
// 压缩
|
||||
Deflater deflater;
|
||||
|
||||
Inflater inflater; // 解压
|
||||
// 解压
|
||||
Inflater inflater;
|
||||
|
||||
long createTime = System.currentTimeMillis();
|
||||
|
||||
List<WebSocketPacket> delayPackets;
|
||||
|
||||
private Map<String, Object> attributes = new HashMap<>(); // 非线程安全
|
||||
// 非线程安全
|
||||
private Map<String, Object> attributes = new HashMap<>();
|
||||
|
||||
private long lastPingTime;
|
||||
|
||||
@@ -130,7 +155,8 @@ public abstract class WebSocket<G extends Serializable, T> {
|
||||
|
||||
long lastSendTime;
|
||||
|
||||
boolean initiateClosed; // 收到客户端发送的CLOSE消息
|
||||
// 收到客户端发送的CLOSE消息
|
||||
boolean initiateClosed;
|
||||
|
||||
private final AtomicBoolean closed = new AtomicBoolean();
|
||||
|
||||
|
||||
@@ -81,10 +81,11 @@ public abstract class WebSocketServlet extends HttpServlet implements Resourcabl
|
||||
private final ObjectPool<ByteArray> byteArrayPool =
|
||||
ObjectPool.createSafePool(1000, () -> new ByteArray(), null, ByteArray::recycle);
|
||||
|
||||
protected Type messageRestType; // RestWebSocket时会被修改
|
||||
// RestWebSocket时会被修改
|
||||
protected Type messageRestType;
|
||||
|
||||
// 同RestWebSocket.single
|
||||
protected boolean single = true; // 是否单用户单连接
|
||||
// 同RestWebSocket.single,是否单用户单连接
|
||||
protected boolean single = true;
|
||||
|
||||
// 同RestWebSocket.liveinterval
|
||||
protected int liveinterval = DEFAILT_LIVEINTERVAL;
|
||||
|
||||
@@ -22,14 +22,17 @@ public class SncpRpcGroup {
|
||||
|
||||
protected final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
// 地址
|
||||
@ConvertColumn(index = 1)
|
||||
protected String name; // 地址
|
||||
protected String name;
|
||||
|
||||
// 协议 取值范围: TCP、UDP
|
||||
@ConvertColumn(index = 2)
|
||||
protected String protocol; // 协议 取值范围: TCP、UDP
|
||||
protected String protocol;
|
||||
|
||||
// 地址列表, 对应 resources->group->node节点信息
|
||||
@ConvertColumn(index = 3)
|
||||
protected Set<InetSocketAddress> addresses; // 地址列表, 对应 resources->group->node节点信息
|
||||
protected Set<InetSocketAddress> addresses;
|
||||
|
||||
public SncpRpcGroup() {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user