This commit is contained in:
crusader 2018-04-24 19:38:25 +09:00
parent 9566810bf5
commit 14a7e47e3a
3 changed files with 14 additions and 5 deletions

View File

@ -4,6 +4,7 @@ package com.loafle.overflow.container;
* Container
*/
public class Container {
public static final String CONTAINER_CRAWLERS = "CONTAINER_CRAWLERS";
public static final String CRAWLERS = "CONTAINER_CRAWLERS";
public static final String PIPELINE_CHANNEL_HANDLERS = "CONTAINER_PIPELINE_CHANNEL_HANDLERS";
}

View File

@ -12,9 +12,11 @@ import com.loafle.commons.rpc.registry.RPCRegistry;
import com.loafle.commons.rpc.registry.pojo.POJORPCRegistry;
import com.loafle.commons.server.Server;
import com.loafle.commons.server.socket.handler.codec.SocketServerProtocolHandler;
import com.loafle.overflow.container.Container;
import com.loafle.overflow.container.server.handler.RPCServerHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -34,22 +36,26 @@ import io.netty.handler.logging.LoggingHandler;
@Configuration
public class ContainerConfiguration {
@Autowired
@Qualifier(Container.PIPELINE_CHANNEL_HANDLERS)
private List<ChannelHandler> pipelineChannelHandlers;
@Autowired
@Autowired(required=false)
private Gson gson;
@Bean
@Bean()
@Qualifier(Server.CHANNEL_CLASS)
public Class<? extends ServerChannel> channelClass() {
return NioServerSocketChannel.class;
}
@Bean
@Qualifier(Server.CHANNEL_OPTIONS)
public List<Server.ChannelOptionItem<?>> channelOptions() {
return Arrays.asList(new Server.ChannelOptionItem<>(ChannelOption.SO_BACKLOG, 100));
}
@Bean
@Qualifier(Server.CHANNEL_HANDLER)
public ChannelHandler channelHandler() {
return new LoggingHandler(LogLevel.INFO);
}
@ -69,6 +75,7 @@ public class ContainerConfiguration {
}
@Bean
@Qualifier(Server.CHANNEL_INITIALIZER)
public ChannelInitializer<?> channelInitializer() {
return new ChannelInitializer<SocketChannel>() {
@Override
@ -84,6 +91,7 @@ public class ContainerConfiguration {
}
@Bean
@Qualifier(Server.SOCKET_ADDRESS)
public SocketAddress address() {
return new InetSocketAddress("127.0.0.1", 60000);
}

View File

@ -25,7 +25,7 @@ public class CrawlerService implements Service {
@Autowired
private SensorConfigService sensorConfigService;
@Resource(name=Container.CONTAINER_CRAWLERS)
@Resource(name=Container.CRAWLERS)
private Map<String, Crawler> crawlers;
@Override