From 37cac2b0d33ff45deba3e921b7011d2342b5efdc Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 24 Apr 2018 20:34:41 +0900 Subject: [PATCH] ing --- .../com/loafle/overflow/container/Container.java | 1 + .../configuration/ContainerConfiguration.java | 12 +++++++----- .../overflow/container/server/ContainerServer.java | 4 ++++ .../loafle/overflow/container/service/Service.java | 3 +-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/loafle/overflow/container/Container.java b/src/main/java/com/loafle/overflow/container/Container.java index 16960ac..506bc32 100644 --- a/src/main/java/com/loafle/overflow/container/Container.java +++ b/src/main/java/com/loafle/overflow/container/Container.java @@ -4,6 +4,7 @@ package com.loafle.overflow.container; * Container */ public class Container { + public static final String PIDFILE_PATH = "CONTAINER_PIDFILE_PATH"; public static final String CRAWLERS = "CONTAINER_CRAWLERS"; public static final String PIPELINE_CHANNEL_HANDLERS = "CONTAINER_PIPELINE_CHANNEL_HANDLERS"; diff --git a/src/main/java/com/loafle/overflow/container/configuration/ContainerConfiguration.java b/src/main/java/com/loafle/overflow/container/configuration/ContainerConfiguration.java index 948786b..5c79186 100644 --- a/src/main/java/com/loafle/overflow/container/configuration/ContainerConfiguration.java +++ b/src/main/java/com/loafle/overflow/container/configuration/ContainerConfiguration.java @@ -37,13 +37,13 @@ import io.netty.handler.logging.LoggingHandler; */ @Configuration @ComponentScan(basePackages = { "com.loafle.overflow" }) -@PropertySource({ "classpath:netty.properties"}) +@PropertySource({ "classpath:netty.properties" }) public class ContainerConfiguration { - @Autowired + @Autowired(required = false) @Qualifier(Container.PIPELINE_CHANNEL_HANDLERS) private List pipelineChannelHandlers; - @Autowired(required=false) + @Autowired(required = false) private Gson gson; @Bean(Server.CHANNEL_CLASS) @@ -83,8 +83,10 @@ public class ContainerConfiguration { ChannelPipeline cp = ch.pipeline(); cp.addLast(new SocketServerProtocolHandler(true)); cp.addLast(new RPCServerHandler()); - for (ChannelHandler channelHandler : pipelineChannelHandlers) { - cp.addLast(channelHandler); + if (null != pipelineChannelHandlers) { + for (ChannelHandler channelHandler : pipelineChannelHandlers) { + cp.addLast(channelHandler); + } } } }; diff --git a/src/main/java/com/loafle/overflow/container/server/ContainerServer.java b/src/main/java/com/loafle/overflow/container/server/ContainerServer.java index b7d3a3f..57e2be7 100644 --- a/src/main/java/com/loafle/overflow/container/server/ContainerServer.java +++ b/src/main/java/com/loafle/overflow/container/server/ContainerServer.java @@ -4,7 +4,10 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import javax.annotation.Resource; + import com.loafle.commons.server.Server; +import com.loafle.overflow.container.Container; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelFuture; @@ -13,6 +16,7 @@ import io.netty.channel.ChannelFuture; * ContainerServer */ public class ContainerServer extends Server { + @Resource(name=Container.PIDFILE_PATH) private String pidFilePath; private int portNumber; diff --git a/src/main/java/com/loafle/overflow/container/service/Service.java b/src/main/java/com/loafle/overflow/container/service/Service.java index 283010d..e7cdce7 100644 --- a/src/main/java/com/loafle/overflow/container/service/Service.java +++ b/src/main/java/com/loafle/overflow/container/service/Service.java @@ -41,7 +41,7 @@ public class Service implements InitializingBean, ApplicationContextAware { } services.forEach((name, bean) -> { - logger.debug("bean %s", bean.getClass().getName()); + logger.debug("bean {}", bean.getClass().getName()); try { this.rpcRegistry.registerService(bean, bean.getClass(), name); } catch (RPCException e) { @@ -49,5 +49,4 @@ public class Service implements InitializingBean, ApplicationContextAware { } }); } - } \ No newline at end of file