This commit is contained in:
@@ -315,7 +315,7 @@ public abstract class NodeServer {
|
|||||||
diffGroupAddrs.forEach((k, v) -> diffGroupTransports.add(loadTransport(k, server.getProtocol(), v)));
|
diffGroupAddrs.forEach((k, v) -> diffGroupTransports.add(loadTransport(k, server.getProtocol(), v)));
|
||||||
final boolean localed = (sameGroupAddrs.isEmpty() && diffGroupAddrs.isEmpty()) || sameGroupAddrs.contains(this.sncpAddress) || type.getAnnotation(LocalService.class) != null;//本地模式
|
final boolean localed = (sameGroupAddrs.isEmpty() && diffGroupAddrs.isEmpty()) || sameGroupAddrs.contains(this.sncpAddress) || type.getAnnotation(LocalService.class) != null;//本地模式
|
||||||
if (localed && (type.isInterface() || Modifier.isAbstract(type.getModifiers()))) continue; //本地模式不能实例化接口和抽象类的Service类
|
if (localed && (type.isInterface() || Modifier.isAbstract(type.getModifiers()))) continue; //本地模式不能实例化接口和抽象类的Service类
|
||||||
final ServiceType st = type.getAnnotation(ServiceType.class);
|
final ServiceResource st = type.getAnnotation(ServiceResource.class);
|
||||||
final Class<? extends Service> resType = st == null ? type : st.value();
|
final Class<? extends Service> resType = st == null ? type : st.value();
|
||||||
if (st != null && (!isSNCP() && factory.find(entry.getName(), resType) != null)) continue;
|
if (st != null && (!isSNCP() && factory.find(entry.getName(), resType) != null)) continue;
|
||||||
ServiceWrapper wrapper;
|
ServiceWrapper wrapper;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|||||||
* 业务逻辑的Service通常有两种编写方式:
|
* 业务逻辑的Service通常有两种编写方式:
|
||||||
* 1、只写一个Service实现类。
|
* 1、只写一个Service实现类。
|
||||||
* 2、先定义业务的Service接口或抽象类,再编写具体实现类。
|
* 2、先定义业务的Service接口或抽象类,再编写具体实现类。
|
||||||
* @ServiceType用于第二种方式, 在具体实现类上需要使用@ServiceType指明资源注入的类型。
|
* @ServiceResource用于第二种方式, 在具体实现类上需要使用@ServiceResource指明资源注入的类型。
|
||||||
* </pre></blockquote>
|
* </pre></blockquote>
|
||||||
* <p>
|
* <p>
|
||||||
* 详情见: http://www.redkale.org
|
* 详情见: http://www.redkale.org
|
||||||
@@ -26,7 +26,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|||||||
@Documented
|
@Documented
|
||||||
@Target({TYPE})
|
@Target({TYPE})
|
||||||
@Retention(RUNTIME)
|
@Retention(RUNTIME)
|
||||||
public @interface ServiceType {
|
public @interface ServiceResource {
|
||||||
|
|
||||||
Class<? extends Service> value();
|
Class<? extends Service> value();
|
||||||
|
|
||||||
Reference in New Issue
Block a user