ing
This commit is contained in:
parent
cabbe71a80
commit
37cac2b0d3
|
@ -4,6 +4,7 @@ package com.loafle.overflow.container;
|
||||||
* Container
|
* Container
|
||||||
*/
|
*/
|
||||||
public class Container {
|
public class Container {
|
||||||
|
public static final String PIDFILE_PATH = "CONTAINER_PIDFILE_PATH";
|
||||||
public static final String CRAWLERS = "CONTAINER_CRAWLERS";
|
public static final String CRAWLERS = "CONTAINER_CRAWLERS";
|
||||||
public static final String PIPELINE_CHANNEL_HANDLERS = "CONTAINER_PIPELINE_CHANNEL_HANDLERS";
|
public static final String PIPELINE_CHANNEL_HANDLERS = "CONTAINER_PIPELINE_CHANNEL_HANDLERS";
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ import io.netty.handler.logging.LoggingHandler;
|
||||||
@ComponentScan(basePackages = { "com.loafle.overflow" })
|
@ComponentScan(basePackages = { "com.loafle.overflow" })
|
||||||
@PropertySource({ "classpath:netty.properties" })
|
@PropertySource({ "classpath:netty.properties" })
|
||||||
public class ContainerConfiguration {
|
public class ContainerConfiguration {
|
||||||
@Autowired
|
@Autowired(required = false)
|
||||||
@Qualifier(Container.PIPELINE_CHANNEL_HANDLERS)
|
@Qualifier(Container.PIPELINE_CHANNEL_HANDLERS)
|
||||||
private List<ChannelHandler> pipelineChannelHandlers;
|
private List<ChannelHandler> pipelineChannelHandlers;
|
||||||
|
|
||||||
|
@ -83,10 +83,12 @@ public class ContainerConfiguration {
|
||||||
ChannelPipeline cp = ch.pipeline();
|
ChannelPipeline cp = ch.pipeline();
|
||||||
cp.addLast(new SocketServerProtocolHandler(true));
|
cp.addLast(new SocketServerProtocolHandler(true));
|
||||||
cp.addLast(new RPCServerHandler());
|
cp.addLast(new RPCServerHandler());
|
||||||
|
if (null != pipelineChannelHandlers) {
|
||||||
for (ChannelHandler channelHandler : pipelineChannelHandlers) {
|
for (ChannelHandler channelHandler : pipelineChannelHandlers) {
|
||||||
cp.addLast(channelHandler);
|
cp.addLast(channelHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@ import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
import com.loafle.commons.server.Server;
|
import com.loafle.commons.server.Server;
|
||||||
|
import com.loafle.overflow.container.Container;
|
||||||
|
|
||||||
import io.netty.bootstrap.ServerBootstrap;
|
import io.netty.bootstrap.ServerBootstrap;
|
||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelFuture;
|
||||||
|
@ -13,6 +16,7 @@ import io.netty.channel.ChannelFuture;
|
||||||
* ContainerServer
|
* ContainerServer
|
||||||
*/
|
*/
|
||||||
public class ContainerServer extends Server {
|
public class ContainerServer extends Server {
|
||||||
|
@Resource(name=Container.PIDFILE_PATH)
|
||||||
private String pidFilePath;
|
private String pidFilePath;
|
||||||
|
|
||||||
private int portNumber;
|
private int portNumber;
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class Service implements InitializingBean, ApplicationContextAware {
|
||||||
}
|
}
|
||||||
|
|
||||||
services.forEach((name, bean) -> {
|
services.forEach((name, bean) -> {
|
||||||
logger.debug("bean %s", bean.getClass().getName());
|
logger.debug("bean {}", bean.getClass().getName());
|
||||||
try {
|
try {
|
||||||
this.rpcRegistry.registerService(bean, bean.getClass(), name);
|
this.rpcRegistry.registerService(bean, bean.getClass(), name);
|
||||||
} catch (RPCException e) {
|
} catch (RPCException e) {
|
||||||
|
@ -49,5 +49,4 @@ public class Service implements InitializingBean, ApplicationContextAware {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user