From aec69d29730a147f538ce3b61747ab3c79cc646a Mon Sep 17 00:00:00 2001 From: Redkale <22250530@qq.com> Date: Wed, 24 Aug 2016 22:27:27 +0800 Subject: [PATCH] --- src/org/redkale/boot/Application.java | 4 ++-- src/org/redkale/boot/NodeSncpServer.java | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/org/redkale/boot/Application.java b/src/org/redkale/boot/Application.java index 511c48fe2..2e3be8378 100644 --- a/src/org/redkale/boot/Application.java +++ b/src/org/redkale/boot/Application.java @@ -464,8 +464,8 @@ public final class Application { final String protocol = serconf.getValue("protocol", "").replaceFirst("\\..+", "").toUpperCase(); NodeServer server = null; if ("SNCP".equals(protocol)) { - server = new NodeSncpServer(Application.this, serconf); - } else if ("HTTP".equals(protocol)) { + server = NodeSncpServer.createNodeServer(Application.this, serconf); + } else if ("HTTP".equalsIgnoreCase(protocol)) { server = new NodeHttpServer(Application.this, serconf); } else { if (!inited.get()) { diff --git a/src/org/redkale/boot/NodeSncpServer.java b/src/org/redkale/boot/NodeSncpServer.java index 1cc7824cc..bbe796266 100644 --- a/src/org/redkale/boot/NodeSncpServer.java +++ b/src/org/redkale/boot/NodeSncpServer.java @@ -24,12 +24,19 @@ public final class NodeSncpServer extends NodeServer { private final SncpServer sncpServer; - public NodeSncpServer(Application application, AnyValue serconf) { + private NodeSncpServer(Application application, AnyValue serconf) { super(application, createServer(application, serconf)); this.sncpServer = (SncpServer) this.server; this.consumer = sncpServer == null ? null : x -> sncpServer.addService(x); } + public static NodeServer createNodeServer(Application application, AnyValue serconf) { + if (serconf != null && serconf.getAnyValue("rest") != null) { + return new NodeHttpServer(application, serconf); + } + return new NodeSncpServer(application, serconf); + } + private static Server createServer(Application application, AnyValue serconf) { return new SncpServer(application.getStartTime(), application.getWatchFactory()); }