This commit is contained in:
@@ -69,7 +69,7 @@ public abstract class WebSocketServlet extends HttpServlet {
|
|||||||
|
|
||||||
public final void preInit(HttpContext context, AnyValue conf) {
|
public final void preInit(HttpContext context, AnyValue conf) {
|
||||||
InetSocketAddress addr = context.getServerAddress();
|
InetSocketAddress addr = context.getServerAddress();
|
||||||
this.engine = new WebSocketEngine(addr.getHostString() + ":" + addr.getPort() + "-[" + name() + "]", this.node, logger);
|
this.engine = new WebSocketEngine(addr.getHostString() + ":" + addr.getPort() + "-[" + getResourceName() + "]", this.node, logger);
|
||||||
if (this.node == null) this.node = createWebSocketNode();
|
if (this.node == null) this.node = createWebSocketNode();
|
||||||
if (this.node == null) {
|
if (this.node == null) {
|
||||||
this.node = new WebSocketNodeService();
|
this.node = new WebSocketNodeService();
|
||||||
@@ -86,7 +86,7 @@ public abstract class WebSocketServlet extends HttpServlet {
|
|||||||
engine.close();
|
engine.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String name() {
|
public String getResourceName() {
|
||||||
return this.getClass().getSimpleName().replace("Servlet", "").replace("WebSocket", "").toLowerCase();
|
return this.getClass().getSimpleName().replace("Servlet", "").replace("WebSocket", "").toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public final class SncpClient {
|
|||||||
this.remote = remote;
|
this.remote = remote;
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.serviceClass = serviceClass;
|
this.serviceClass = serviceClass;
|
||||||
this.serviceversion = service.version();
|
this.serviceversion = 0;
|
||||||
this.clientAddress = clientAddress;
|
this.clientAddress = clientAddress;
|
||||||
this.name = serviceName;
|
this.name = serviceName;
|
||||||
this.serviceid = Sncp.hash(serviceType.getName() + ':' + serviceName);
|
this.serviceid = Sncp.hash(serviceType.getName() + ':' + serviceName);
|
||||||
@@ -216,7 +216,7 @@ public final class SncpClient {
|
|||||||
if (method.getName().equals("equals") || method.getName().equals("hashCode")) continue;
|
if (method.getName().equals("equals") || method.getName().equals("hashCode")) continue;
|
||||||
if (method.getName().equals("notify") || method.getName().equals("notifyAll") || method.getName().equals("wait")) continue;
|
if (method.getName().equals("notify") || method.getName().equals("notifyAll") || method.getName().equals("wait")) continue;
|
||||||
if (method.getName().equals("init") || method.getName().equals("destroy")) continue;
|
if (method.getName().equals("init") || method.getName().equals("destroy")) continue;
|
||||||
if (method.getName().equals("version") || method.getName().equals("name")) continue;
|
//if (method.getName().equals("version") || method.getName().equals("name")) continue;
|
||||||
//if (onlySncpDyn && method.getAnnotation(SncpDyn.class) == null) continue;
|
//if (onlySncpDyn && method.getAnnotation(SncpDyn.class) == null) continue;
|
||||||
DLong actionid = Sncp.hash(method);
|
DLong actionid = Sncp.hash(method);
|
||||||
Method old = actionids.get(actionid);
|
Method old = actionids.get(actionid);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public final class SncpDynServlet extends SncpServlet {
|
|||||||
if (method.getName().equals("equals") || method.getName().equals("hashCode")) continue;
|
if (method.getName().equals("equals") || method.getName().equals("hashCode")) continue;
|
||||||
if (method.getName().equals("notify") || method.getName().equals("notifyAll") || method.getName().equals("wait")) continue;
|
if (method.getName().equals("notify") || method.getName().equals("notifyAll") || method.getName().equals("wait")) continue;
|
||||||
if (method.getName().equals("init") || method.getName().equals("destroy")) continue;
|
if (method.getName().equals("init") || method.getName().equals("destroy")) continue;
|
||||||
if (method.getName().equals("version") || method.getName().equals("name")) continue;
|
//if (method.getName().equals("version") || method.getName().equals("name")) continue;
|
||||||
final DLong actionid = Sncp.hash(method);
|
final DLong actionid = Sncp.hash(method);
|
||||||
SncpServletAction action = SncpServletAction.create(service, actionid, method);
|
SncpServletAction action = SncpServletAction.create(service, actionid, method);
|
||||||
action.convert = convert;
|
action.convert = convert;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ package org.redkale.service;
|
|||||||
import org.redkale.util.*;
|
import org.redkale.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所有Service的实现类不得声明为final, 允许远程模式的public方法都不能声明为final。
|
* 所有Service的实现类不得声明为final, 允许远程模式的public方法都不能声明为final。<br>
|
||||||
* 注意: "$"是一个很特殊的Service.name值 。 被标记为@Resource(name = "$") 的Service的资源名与所属父Service的资源名一致。
|
* 注意: "$"是一个很特殊的Service.name值 。 被标记为@Resource(name = "$") 的Service的资源名与所属父Service的资源名一致。<br>
|
||||||
*
|
*
|
||||||
* <blockquote><pre>
|
* <blockquote><pre>
|
||||||
* Service的资源类型
|
* Service的资源类型
|
||||||
@@ -59,14 +59,4 @@ public interface Service {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Service的接口版本号
|
|
||||||
* <b>注: public方法的参数或返回类型或参数类型内部变更后改值必须进行改变</b>
|
|
||||||
*
|
|
||||||
* @return 接口版本号
|
|
||||||
*/
|
|
||||||
default int version() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,13 @@ import java.util.regex.Pattern;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果Resource(name = "$") 表示资源name采用所属对象的name
|
* 如果@Resource(name = "$") 表示资源name采用所属对象的name <br>
|
||||||
|
* 如果没有@Resource 则会取对象的getResourceName()方法值(若存在)
|
||||||
|
* <blockquote><pre>
|
||||||
* name规则:
|
* name规则:
|
||||||
* 1: "$"有特殊含义, 不能表示"$"资源本身
|
* 1: "$"有特殊含义, 不能表示"$"资源本身
|
||||||
* 2: 只能是字母、数字、(短横)-、(下划线)_、点(.)的组合
|
* 2: 只能是字母、数字、(短横)-、(下划线)_、点(.)的组合
|
||||||
|
* </pre></blockquote>
|
||||||
* <p>
|
* <p>
|
||||||
* 详情见: https://redkale.org
|
* 详情见: https://redkale.org
|
||||||
*
|
*
|
||||||
@@ -323,13 +326,13 @@ public final class ResourceFactory {
|
|||||||
try {
|
try {
|
||||||
Resource res = src.getClass().getAnnotation(Resource.class);
|
Resource res = src.getClass().getAnnotation(Resource.class);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
String srcname = (String) src.getClass().getMethod("name").invoke(src);
|
String srcname = (String) src.getClass().getMethod("getResourceName").invoke(src);
|
||||||
tname = tname.replace(RESOURCE_PARENT_NAME, srcname);
|
tname = tname.replace(RESOURCE_PARENT_NAME, srcname);
|
||||||
} else {
|
} else {
|
||||||
tname = res.name();
|
tname = res.name();
|
||||||
}
|
}
|
||||||
} catch (Exception e) { // 获取src中的name()方法的值, 异常则忽略
|
} catch (Exception e) { // 获取src中的name()方法的值, 异常则忽略
|
||||||
logger.log(Level.SEVERE, src.getClass().getName() + " not found @Resource on Class or [public String name()] method", e);
|
logger.log(Level.SEVERE, src.getClass().getName() + " not found @Resource on Class or [public String getResourceName()] method", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String rcname = tname;
|
final String rcname = tname;
|
||||||
|
|||||||
Reference in New Issue
Block a user