This commit is contained in:
crusader 2018-04-24 20:34:41 +09:00
parent cabbe71a80
commit 37cac2b0d3
4 changed files with 13 additions and 7 deletions

View File

@ -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";

View File

@ -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<ChannelHandler> 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);
}
}
}
};

View File

@ -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;

View File

@ -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 {
}
});
}
}