This commit is contained in:
Redkale
2017-05-30 17:12:51 +08:00
parent b2e73d378c
commit fa5bd95a2b
4 changed files with 8 additions and 5 deletions

View File

@@ -114,6 +114,9 @@ public final class Application {
//临时计数器 //临时计数器
CountDownLatch servicecdl; //会出现两次赋值 CountDownLatch servicecdl; //会出现两次赋值
//是否启动了WATCH协议服务
boolean watching;
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
//是否用于main方法运行 //是否用于main方法运行
private final boolean singletonrun; private final boolean singletonrun;
@@ -544,6 +547,7 @@ public final class Application {
others.add(entry); others.add(entry);
} }
} }
this.watching = !watchs.isEmpty();
//单向SNCP服务不需要对等group //单向SNCP服务不需要对等group
//if (!sncps.isEmpty() && globalNodes.isEmpty()) throw new RuntimeException("found SNCP Server node but not found <group> node info."); //if (!sncps.isEmpty() && globalNodes.isEmpty()) throw new RuntimeException("found SNCP Server node but not found <group> node info.");

View File

@@ -253,7 +253,7 @@ public final class ClassFilter<T> {
boolean rs = superClass == null || (clazz != superClass && superClass.isAssignableFrom(clazz)); boolean rs = superClass == null || (clazz != superClass && superClass.isAssignableFrom(clazz));
if (rs && this.excludeSuperClasses != null && this.excludeSuperClasses.length > 0) { if (rs && this.excludeSuperClasses != null && this.excludeSuperClasses.length > 0) {
for (Class c : this.excludeSuperClasses) { for (Class c : this.excludeSuperClasses) {
if (c != null && (clazz == c || clazz.isAssignableFrom(c))) return false; if (c != null && (clazz == c || c.isAssignableFrom(clazz))) return false;
} }
} }
return rs; return rs;

View File

@@ -8,7 +8,6 @@ package org.redkale.boot;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.file.WatchService;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -57,7 +56,7 @@ public class NodeHttpServer extends NodeServer {
@Override @Override
protected ClassFilter<Service> createServiceClassFilter() { protected ClassFilter<Service> createServiceClassFilter() {
return createClassFilter(this.sncpGroup, null, Service.class, new Class[]{WatchService.class}, Annotation.class, "services", "service"); return createClassFilter(this.sncpGroup, null, Service.class, new Class[]{org.redkale.watch.WatchService.class}, Annotation.class, "services", "service");
} }
@Override @Override

View File

@@ -9,7 +9,7 @@ import java.io.*;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.net.*; import java.net.*;
import java.nio.file.Path; import java.nio.file.*;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.function.*; import java.util.function.*;
@@ -509,7 +509,7 @@ public abstract class NodeServer {
} }
protected ClassFilter<Service> createServiceClassFilter() { protected ClassFilter<Service> createServiceClassFilter() {
return createClassFilter(this.sncpGroup, null, Service.class, null, Annotation.class, "services", "service"); return createClassFilter(this.sncpGroup, null, Service.class, (!isSNCP() || application.watching) ? null : new Class[]{org.redkale.watch.WatchService.class}, Annotation.class, "services", "service");
} }
protected ClassFilter createClassFilter(final String localGroup, Class<? extends Annotation> ref, protected ClassFilter createClassFilter(final String localGroup, Class<? extends Annotation> ref,