This commit is contained in:
@@ -690,7 +690,7 @@ public final class Application {
|
||||
agent.init(agent.getConfig());
|
||||
this.resourceFactory.register(agent.getName(), MessageAgent.class, agent);
|
||||
this.resourceFactory.register(agent.getName(), HttpMessageClient.class, agent.getHttpMessageClient());
|
||||
this.resourceFactory.register(agent.getName(), SncpMessageClient.class, agent.getSncpMessageClient());
|
||||
//this.resourceFactory.register(agent.getName(), SncpMessageClient.class, agent.getSncpMessageClient()); //不需要给开发者使用
|
||||
}
|
||||
logger.info("MessageAgent init in " + (System.currentTimeMillis() - s) + " ms");
|
||||
|
||||
|
||||
@@ -190,6 +190,10 @@ public abstract class ClusterAgent {
|
||||
return "check-" + generateApplicationServiceId();
|
||||
}
|
||||
|
||||
protected String generateHttpServiceName(String protocol, String module, String resname) {
|
||||
return protocol.toLowerCase() + ":" + module + (resname == null || resname.isEmpty() ? "" : ("-" + resname));
|
||||
}
|
||||
|
||||
//格式: protocol:classtype-resourcename
|
||||
protected String generateServiceName(NodeServer ns, String protocol, Service service) {
|
||||
if (protocol.toLowerCase().startsWith("http")) { //HTTP使用RestService.name方式是为了与MessageClient中的module保持一致, 因为HTTP依靠的url中的module,无法知道Service类名
|
||||
|
||||
@@ -37,7 +37,7 @@ public class HttpSimpleRequestCoder implements MessageCoder<HttpSimpleRequest> {
|
||||
byte[] params = MessageCoder.getBytes(data.getParams());
|
||||
byte[] body = MessageCoder.getBytes(data.getBody());
|
||||
int count = 1 + 4 + requestURI.length + 2 + remoteAddr.length + 2 + sessionid.length
|
||||
+ 2 + contentType.length + headers.length + params.length + 4 + body.length;
|
||||
+ 2 + contentType.length + 4 + headers.length + params.length + 4 + body.length;
|
||||
byte[] bs = new byte[count];
|
||||
ByteBuffer buffer = ByteBuffer.wrap(bs);
|
||||
buffer.put((byte) (data.isRpc() ? 'T' : 'F'));
|
||||
@@ -49,6 +49,7 @@ public class HttpSimpleRequestCoder implements MessageCoder<HttpSimpleRequest> {
|
||||
if (sessionid.length > 0) buffer.put(sessionid);
|
||||
buffer.putChar((char) contentType.length);
|
||||
if (contentType.length > 0) buffer.put(contentType);
|
||||
buffer.putInt(data.getCurrentUserid());
|
||||
buffer.put(headers);
|
||||
buffer.put(params);
|
||||
buffer.putInt(body.length);
|
||||
@@ -66,6 +67,7 @@ public class HttpSimpleRequestCoder implements MessageCoder<HttpSimpleRequest> {
|
||||
req.setRemoteAddr(MessageCoder.getShortString(buffer));
|
||||
req.setSessionid(MessageCoder.getShortString(buffer));
|
||||
req.setContentType(MessageCoder.getShortString(buffer));
|
||||
req.setCurrentUserid(buffer.getInt());
|
||||
req.setHeaders(MessageCoder.getMap(buffer));
|
||||
req.setParams(MessageCoder.getMap(buffer));
|
||||
int len = buffer.getInt();
|
||||
|
||||
@@ -103,6 +103,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
if (req.getBody() != null) this.array.write(req.getBody());
|
||||
if (req.getHeaders() != null) this.headers.putAll(req.getHeaders());
|
||||
if (req.getParams() != null) this.params.putAll(req.getParams());
|
||||
if (req.getCurrentUserid() != 0) this.currentUserid = req.getCurrentUserid();
|
||||
this.contentType = req.getContentType();
|
||||
this.remoteAddr = req.getRemoteAddr();
|
||||
this.requestURI = req.getRequestURI();
|
||||
|
||||
@@ -43,14 +43,17 @@ public class HttpSimpleRequest implements java.io.Serializable {
|
||||
protected String contentType;
|
||||
|
||||
@ConvertColumn(index = 6)
|
||||
protected int currentUserid;
|
||||
|
||||
@ConvertColumn(index = 7)
|
||||
@Comment("http header信息")
|
||||
protected Map<String, String> headers;
|
||||
|
||||
@ConvertColumn(index = 7)
|
||||
@ConvertColumn(index = 8)
|
||||
@Comment("参数信息")
|
||||
protected Map<String, String> params;
|
||||
|
||||
@ConvertColumn(index = 8)
|
||||
@ConvertColumn(index = 9)
|
||||
@Comment("http body信息")
|
||||
protected byte[] body; //对应HttpRequest.array
|
||||
|
||||
@@ -92,6 +95,11 @@ public class HttpSimpleRequest implements java.io.Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpSimpleRequest currentUserid(int userid) {
|
||||
this.currentUserid = userid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpSimpleRequest removeHeader(String name) {
|
||||
if (this.headers != null) this.headers.remove(name);
|
||||
return this;
|
||||
@@ -216,6 +224,14 @@ public class HttpSimpleRequest implements java.io.Serializable {
|
||||
this.remoteAddr = remoteAddr;
|
||||
}
|
||||
|
||||
public int getCurrentUserid() {
|
||||
return currentUserid;
|
||||
}
|
||||
|
||||
public void setCurrentUserid(int currentUserid) {
|
||||
this.currentUserid = currentUserid;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user