This commit is contained in:
Redkale
2019-01-08 12:46:20 +08:00
parent 4a36244294
commit e69a120965
2 changed files with 6 additions and 5 deletions

View File

@@ -672,7 +672,6 @@ public final class Application {
final List<AnyValue> others = new ArrayList<>();
final List<AnyValue> watchs = new ArrayList<>();
for (final AnyValue entry : entrys) {
if (singletonrun) ((DefaultAnyValue) entry).setValue("red" + "kale-singleton-serviceclass", config.getValue("red" + "kale-singleton-serviceclass"));
if (entry.getValue("protocol", "").toUpperCase().startsWith("SNCP")) {
sncps.add(entry);
} else if (entry.getValue("protocol", "").toUpperCase().startsWith("WATCH")) {
@@ -820,7 +819,7 @@ public final class Application {
public static <T extends Service> T singleton(String name, Class<T> serviceClass) throws Exception {
if (serviceClass == null) throw new IllegalArgumentException("serviceClass is null");
final Application application = Application.create(true);
((DefaultAnyValue) application.config).setValue("red" + "kale-singleton-serviceclass", serviceClass.getName());
System.setProperty("red" + "kale-singleton-serviceclass", serviceClass.getName());
application.init();
application.start();
for (NodeServer server : application.servers) {

View File

@@ -155,7 +155,7 @@ public abstract class NodeServer {
ClassFilter<Service> serviceFilter = createServiceClassFilter();
if (application.singletonrun) { //singleton模式下只加载指定的Service
final String ssc = config == null ? null : config.getValue("red" + "kale-singleton-serviceclass");
final String ssc = System.getProperty("red" + "kale-singleton-serviceclass");
if (ssc != null) serviceFilter.setExpectPredicate(c -> !ssc.equals(c));
}
ClassFilter<Filter> filterFilter = createFilterClassFilter();
@@ -164,7 +164,7 @@ public abstract class NodeServer {
long s = System.currentTimeMillis();
ClassFilter.Loader.load(application.getHome(), serverConf.getValue("excludelibs", "").split(";"), serviceFilter, filterFilter, servletFilter, otherFilter);
long e = System.currentTimeMillis() - s;
logger.info(this.getClass().getSimpleName() + " load filter class in " + e + " ms");
if (!application.singletonrun) logger.info(this.getClass().getSimpleName() + " load filter class in " + e + " ms");
loadService(serviceFilter, otherFilter); //必须在servlet之前
if (!application.singletonrun) { //非singleton模式下才加载Filter、Servlet
loadFilter(filterFilter, otherFilter);
@@ -515,7 +515,9 @@ public abstract class NodeServer {
}
sb.append(threadName).append("All Services load cost " + (System.currentTimeMillis() - starts) + " ms" + LINE_SEPARATOR);
}
if (sb != null && sb.length() > 0) logger.log(Level.INFO, sb.toString());
if (!application.singletonrun) {
if (sb != null && sb.length() > 0) logger.log(Level.INFO, sb.toString());
}
}
private void calcMaxLength(Service y) { //计算toString中的长度