ing
This commit is contained in:
parent
fca686637a
commit
bf5a8a7ec4
|
@ -5,6 +5,7 @@ package com.loafle.overflow.container;
|
|||
*/
|
||||
public class Container {
|
||||
public static final String PORT_NUMBER = "CONTAINER_PORT_NUMBER";
|
||||
public static final String CHANNEL_HANDLERS = "CONTAINER_CHANNEL_HANDLERS";
|
||||
public static final String CRAWLERS = "CONTAINER_CRAWLERS";
|
||||
public static final String SERVICES = "CONTAINER_SERVICES";
|
||||
public static final String RPC_CLIENT_CODEC = "CONTAINER_RPC_CLIENT_CODEC";
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.loafle.overflow.container.configuration;
|
|||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -11,11 +13,13 @@ import com.loafle.commons.rpc.protocol.RPCClientCodec;
|
|||
import com.loafle.commons.rpc.protocol.json.JSONRPCClientCodec;
|
||||
import com.loafle.commons.rpc.registry.RPCRegistry;
|
||||
import com.loafle.commons.server.websocket.client.Client;
|
||||
import com.loafle.overflow.config.container.ContainerProtocol;
|
||||
import com.loafle.overflow.container.Container;
|
||||
import com.loafle.overflow.container.client.handler.RPCClientHandler;
|
||||
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
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.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
@ -38,6 +42,10 @@ public class ContainerConfiguration {
|
|||
@Autowired()
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Autowired(required=false)
|
||||
@Qualifier(Container.CHANNEL_HANDLERS)
|
||||
private List<ChannelHandler> extraChannelHandlers;
|
||||
|
||||
@Bean(Client.CHANNEL_CLASS)
|
||||
public Class<? extends Channel> channelClass() {
|
||||
return NioSocketChannel.class;
|
||||
|
@ -45,7 +53,17 @@ public class ContainerConfiguration {
|
|||
|
||||
@Bean(Client.CHANNEL_HANDLERS)
|
||||
public List<ChannelHandler> channelHandlers() {
|
||||
return Arrays.asList(new RPCClientHandler());
|
||||
List<ChannelHandler> chs = Arrays.asList(new RPCClientHandler());
|
||||
if (null != this.extraChannelHandlers) {
|
||||
chs.addAll(this.extraChannelHandlers);
|
||||
}
|
||||
|
||||
return chs;
|
||||
}
|
||||
|
||||
@Bean(Client.SERVER_URI)
|
||||
public URI probeURI() throws URISyntaxException {
|
||||
return new URI(String.format("ws://127.0.0.1:%d%s", portNumber, ContainerProtocol.HTTPEntry_Container));
|
||||
}
|
||||
|
||||
@Bean(Container.RPC_CLIENT_CODEC)
|
||||
|
@ -58,8 +76,4 @@ public class ContainerConfiguration {
|
|||
return new RPCRegistry();
|
||||
}
|
||||
|
||||
@Bean(Client.SOCKET_ADDRESS)
|
||||
public SocketAddress address() {
|
||||
return new InetSocketAddress("127.0.0.1", portNumber);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user