ing
This commit is contained in:
parent
9566810bf5
commit
14a7e47e3a
|
@ -4,6 +4,7 @@ package com.loafle.overflow.container;
|
||||||
* Container
|
* Container
|
||||||
*/
|
*/
|
||||||
public class 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";
|
||||||
|
|
||||||
}
|
}
|
|
@ -12,9 +12,11 @@ import com.loafle.commons.rpc.registry.RPCRegistry;
|
||||||
import com.loafle.commons.rpc.registry.pojo.POJORPCRegistry;
|
import com.loafle.commons.rpc.registry.pojo.POJORPCRegistry;
|
||||||
import com.loafle.commons.server.Server;
|
import com.loafle.commons.server.Server;
|
||||||
import com.loafle.commons.server.socket.handler.codec.SocketServerProtocolHandler;
|
import com.loafle.commons.server.socket.handler.codec.SocketServerProtocolHandler;
|
||||||
|
import com.loafle.overflow.container.Container;
|
||||||
import com.loafle.overflow.container.server.handler.RPCServerHandler;
|
import com.loafle.overflow.container.server.handler.RPCServerHandler;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@ -34,22 +36,26 @@ import io.netty.handler.logging.LoggingHandler;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class ContainerConfiguration {
|
public class ContainerConfiguration {
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@Qualifier(Container.PIPELINE_CHANNEL_HANDLERS)
|
||||||
private List<ChannelHandler> pipelineChannelHandlers;
|
private List<ChannelHandler> pipelineChannelHandlers;
|
||||||
|
|
||||||
@Autowired
|
@Autowired(required=false)
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
|
|
||||||
@Bean
|
@Bean()
|
||||||
|
@Qualifier(Server.CHANNEL_CLASS)
|
||||||
public Class<? extends ServerChannel> channelClass() {
|
public Class<? extends ServerChannel> channelClass() {
|
||||||
return NioServerSocketChannel.class;
|
return NioServerSocketChannel.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@Qualifier(Server.CHANNEL_OPTIONS)
|
||||||
public List<Server.ChannelOptionItem<?>> channelOptions() {
|
public List<Server.ChannelOptionItem<?>> channelOptions() {
|
||||||
return Arrays.asList(new Server.ChannelOptionItem<>(ChannelOption.SO_BACKLOG, 100));
|
return Arrays.asList(new Server.ChannelOptionItem<>(ChannelOption.SO_BACKLOG, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@Qualifier(Server.CHANNEL_HANDLER)
|
||||||
public ChannelHandler channelHandler() {
|
public ChannelHandler channelHandler() {
|
||||||
return new LoggingHandler(LogLevel.INFO);
|
return new LoggingHandler(LogLevel.INFO);
|
||||||
}
|
}
|
||||||
|
@ -69,6 +75,7 @@ public class ContainerConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@Qualifier(Server.CHANNEL_INITIALIZER)
|
||||||
public ChannelInitializer<?> channelInitializer() {
|
public ChannelInitializer<?> channelInitializer() {
|
||||||
return new ChannelInitializer<SocketChannel>() {
|
return new ChannelInitializer<SocketChannel>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -84,6 +91,7 @@ public class ContainerConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@Qualifier(Server.SOCKET_ADDRESS)
|
||||||
public SocketAddress address() {
|
public SocketAddress address() {
|
||||||
return new InetSocketAddress("127.0.0.1", 60000);
|
return new InetSocketAddress("127.0.0.1", 60000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class CrawlerService implements Service {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SensorConfigService sensorConfigService;
|
private SensorConfigService sensorConfigService;
|
||||||
|
|
||||||
@Resource(name=Container.CONTAINER_CRAWLERS)
|
@Resource(name=Container.CRAWLERS)
|
||||||
private Map<String, Crawler> crawlers;
|
private Map<String, Crawler> crawlers;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user