ing
This commit is contained in:
parent
cabbe71a80
commit
37cac2b0d3
|
@ -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";
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user