改造Transport的构造函数,便于TransportFactory统一管理

This commit is contained in:
Redkale
2017-11-02 19:04:55 +08:00
parent e559379294
commit ad2a3f0d54
6 changed files with 39 additions and 13 deletions

View File

@@ -37,7 +37,7 @@ public class ABMainService implements Service {
final int abport = 8888;
ResourceFactory resFactory = ResourceFactory.root();
ExecutorService executor = Executors.newSingleThreadExecutor();
final TransportFactory transFactory = new TransportFactory(executor, newBufferPool(), newChannelGroup());
final TransportFactory transFactory = TransportFactory.create(executor, newBufferPool(), newChannelGroup());
transFactory.addGroupInfo("g77", new InetSocketAddress("127.0.0.1", 5577));
transFactory.addGroupInfo("g88", new InetSocketAddress("127.0.0.1", 5588));
transFactory.addGroupInfo("g99", new InetSocketAddress("127.0.0.1", 5599));

View File

@@ -79,7 +79,7 @@ public class SncpTest {
Set<InetSocketAddress> set = new LinkedHashSet<>();
set.add(addr);
if (port2 > 0) set.add(new InetSocketAddress(myhost, port2));
final TransportFactory transFactory = new TransportFactory(Executors.newSingleThreadExecutor(), newBufferPool(), newChannelGroup());
final TransportFactory transFactory = TransportFactory.create(Executors.newSingleThreadExecutor(), newBufferPool(), newChannelGroup());
transFactory.addGroupInfo("client", set);
final SncpTestIService service = Sncp.createSimpleRemoteService(SncpTestIService.class, transFactory, addr, "client");
ResourceFactory.root().inject(service);
@@ -156,7 +156,7 @@ public class SncpTest {
SncpServer server = new SncpServer();
Set<InetSocketAddress> set = new LinkedHashSet<>();
if (port2 > 0) set.add(new InetSocketAddress(myhost, port2));
final TransportFactory transFactory = new TransportFactory(Executors.newSingleThreadExecutor(), newBufferPool(), newChannelGroup());
final TransportFactory transFactory = TransportFactory.create(Executors.newSingleThreadExecutor(), newBufferPool(), newChannelGroup());
transFactory.addGroupInfo("server", set);
SncpTestIService service = Sncp.createSimpleLocalService(SncpTestServiceImpl.class, transFactory, addr, "server");
ResourceFactory.root().inject(service);
@@ -191,7 +191,7 @@ public class SncpTest {
Set<InetSocketAddress> set = new LinkedHashSet<>();
set.add(new InetSocketAddress(myhost, port));
final TransportFactory transFactory = new TransportFactory(Executors.newSingleThreadExecutor(), newBufferPool(), newChannelGroup());
final TransportFactory transFactory = TransportFactory.create(Executors.newSingleThreadExecutor(), newBufferPool(), newChannelGroup());
transFactory.addGroupInfo("server", set);
Service service = Sncp.createSimpleLocalService(SncpTestServiceImpl.class, transFactory, addr, "server");
server.addSncpServlet(service);

View File

@@ -100,7 +100,7 @@ public class SncpTestServiceImpl implements SncpTestIService {
public static void main(String[] args) throws Exception {
final TransportFactory transFactory = new TransportFactory(Executors.newSingleThreadExecutor(), newBufferPool(), newChannelGroup());
final TransportFactory transFactory = TransportFactory.create(Executors.newSingleThreadExecutor(), newBufferPool(), newChannelGroup());
transFactory.addGroupInfo("g70", new InetSocketAddress("127.0.0.1", 7070));
Service service = Sncp.createSimpleLocalService(SncpTestServiceImpl.class, transFactory, new InetSocketAddress("127.0.0.1", 7070), "g70");