Resource里特殊值$改成#
This commit is contained in:
@@ -8,7 +8,7 @@ package org.redkale.annotation;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @Resource(name = "$") 表示资源name采用所属对象的name <br>
|
||||
* @Resource(name = "#") 表示资源name采用所属对象的name <br>
|
||||
* @Resource(name = "@name") 表示资源对象自身的name <br>
|
||||
* @Resource(name = "@type") 表示资源对象自身的类型 <br>
|
||||
*
|
||||
@@ -20,7 +20,7 @@ import java.lang.annotation.*;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Resource {
|
||||
|
||||
public static final String PARENT_NAME = "$";
|
||||
public static final String PARENT_NAME = "#";
|
||||
|
||||
public static final String SELF_NAME = "@name";
|
||||
|
||||
@@ -39,7 +39,7 @@ public @interface Resource {
|
||||
* 资源名称 <br>
|
||||
* <blockquote><pre>
|
||||
* name规则:
|
||||
* 1: "$"有特殊含义, 表示资源本身,"$"不能单独使用
|
||||
* 1: "#"有特殊含义, 表示资源本身,"#"不能单独使用
|
||||
* 2: "@name"、"@type"有特殊含义
|
||||
* 3: 只能是字母、数字、(短横)-、(下划线)_、点(.)的组合
|
||||
* </pre></blockquote>
|
||||
|
||||
@@ -458,8 +458,8 @@ public abstract class NodeServer {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (entry.getName().contains("$")) {
|
||||
throw new RedkaleException("<name> value cannot contains '$' in " + entry.getProperty());
|
||||
if (entry.getName().contains(Resource.PARENT_NAME)) {
|
||||
throw new RedkaleException("<name> value cannot contains '" + Resource.PARENT_NAME + "' in " + entry.getProperty());
|
||||
}
|
||||
if (!entry.isEmptyGroup() && !entry.isRemote() && rpcGroups.containsGroup(entry.getGroup())) {
|
||||
throw new RedkaleException("Not found group(" + entry.getGroup() + ")");
|
||||
|
||||
@@ -52,13 +52,13 @@ public abstract class WebSocketNode implements Service {
|
||||
@RpcRemote
|
||||
protected WebSocketNode remoteNode;
|
||||
|
||||
@Resource(name = "$_sendconvert", required = false)
|
||||
@Resource(name = Resource.PARENT_NAME + "_sendconvert", required = false)
|
||||
protected Convert sendConvert;
|
||||
|
||||
//存放所有用户分布在节点上的队列信息,Set<WebSocketAddress> 为 sncpnode 的集合, key: groupid
|
||||
//集合包含 localSncpAddress
|
||||
//如果不是分布式(没有SNCP),source 将不会被用到
|
||||
@Resource(name = "$", required = false)
|
||||
@Resource(name = Resource.PARENT_NAME, required = false)
|
||||
protected CacheSource source;
|
||||
|
||||
//当前节点的本地WebSocketEngine
|
||||
|
||||
@@ -111,7 +111,7 @@ public abstract class WebSocketServlet extends HttpServlet implements Resourcabl
|
||||
@Resource(name = "$_sendconvert", required = false)
|
||||
protected Convert sendConvert;
|
||||
|
||||
@Resource(name = "$")
|
||||
@Resource(name = Resource.PARENT_NAME)
|
||||
protected WebSocketNode webSocketNode;
|
||||
|
||||
@Resource(name = RESNAME_SERVER_RESFACTORY)
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
*/
|
||||
package org.redkale.service;
|
||||
|
||||
import org.redkale.util.*;
|
||||
import org.redkale.util.AnyValue;
|
||||
|
||||
/**
|
||||
* 所有Service的实现类不得声明为final, 允许远程模式的public方法都不能声明为final。<br>
|
||||
* 注意: "$"是一个很特殊的Service.name值 。 被标记为@Resource(name = "$") 的Service的资源名与所属父Service的资源名一致。<br>
|
||||
* 注意: "#"是一个很特殊的Service.name值 。 被标记为@Resource(name = "#") 的Service的资源名与所属父Service的资源名一致。<br>
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* Service的资源类型
|
||||
|
||||
@@ -24,11 +24,11 @@ import org.redkale.convert.*;
|
||||
*
|
||||
* 依赖注入功能主类 <br>
|
||||
*
|
||||
* 如果@Resource(name = "$") 表示资源name采用所属对象的name <br>
|
||||
* 如果@Resource(name = "#") 表示资源name采用所属对象的name <br>
|
||||
* 如果没有@Resource且对象实现了Resourcable, 则会取对象的resourceName()方法值
|
||||
* <blockquote><pre>
|
||||
* name规则:
|
||||
* 1: "$"有特殊含义, 表示资源本身,"$"不能单独使用
|
||||
* 1: "#"有特殊含义, 表示资源本身,"#"不能单独使用
|
||||
* 2: "@name"、"@type"有特殊含义
|
||||
* 3: 只能是字母、数字、(短横)-、(下划线)_、点(.)的组合
|
||||
* </pre></blockquote>
|
||||
@@ -124,7 +124,7 @@ public final class ResourceFactory {
|
||||
* 检查资源名是否合法
|
||||
* <blockquote><pre>
|
||||
* name规则:
|
||||
* 1: "$"有特殊含义, 表示资源本身,"$"不能单独使用
|
||||
* 1: "#"有特殊含义, 表示资源本身,"#"不能单独使用
|
||||
* 2: "@name"、"@type"有特殊含义
|
||||
* 3: 只能是字母、数字、(短横)-、(下划线)_、点(.)的组合
|
||||
* </pre></blockquote>
|
||||
@@ -912,9 +912,19 @@ public final class ResourceFactory {
|
||||
|| classType == Float.class || classType == Double.class
|
||||
|| classType == BigInteger.class || classType == BigDecimal.class) {
|
||||
re = findEntry(rcname, String.class);
|
||||
if (re == null && rcname.startsWith("property.")) { //兼容2.8.0之前版本自动追加property.开头的配置项
|
||||
if (re == null && rcname.startsWith("${")) {
|
||||
if (rcname.charAt(rcname.length() - 1) != '}') {
|
||||
throw new ResourceInjectException("resource(type=" + field.getType().getSimpleName() + ".class, field=" + field.getName() + ", name='" + rcname + "') not endWith } ");
|
||||
}
|
||||
re = findEntry(rcname.substring(2, rcname.length() - 1), String.class);
|
||||
} else if (re == null && rcname.startsWith("property.")) { //兼容2.8.0之前版本自动追加property.开头的配置项
|
||||
re = findEntry(rcname.substring("property.".length()), String.class);
|
||||
}
|
||||
} else if (re == null && rcname.startsWith("${")) {
|
||||
if (rcname.charAt(rcname.length() - 1) != '}') {
|
||||
throw new ResourceInjectException("resource(type=" + field.getType().getSimpleName() + ".class, field=" + field.getName() + ", name='" + rcname + "') not endWith } ");
|
||||
}
|
||||
re = findEntry(rcname.substring(2, rcname.length() - 1), String.class);
|
||||
} else if (classType == String.class && rcname.startsWith("property.")) {//兼容2.8.0之前版本自动追加property.开头的配置项
|
||||
re = findEntry(rcname.substring("property.".length()), String.class);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user