去掉ServiceWrapper
This commit is contained in:
@@ -41,29 +41,29 @@ public class ABMainService implements Service {
|
||||
factory.register(JsonConvert.root());
|
||||
factory.register(BsonConvert.root());
|
||||
//------------------------ 初始化 CService ------------------------------------
|
||||
CService cservice = Sncp.createLocalService("", null, ResourceFactory.root(), CService.class, new InetSocketAddress("127.0.0.1", 5577), null, null);
|
||||
CService cservice = Sncp.createLocalService("", null, ResourceFactory.root(), CService.class, new InetSocketAddress("127.0.0.1", 5577), "", new HashSet<>(), (AnyValue) null, null, null);
|
||||
SncpServer cserver = new SncpServer();
|
||||
cserver.getLogger().setLevel(Level.WARNING);
|
||||
cserver.addSncpServlet(new ServiceWrapper(cservice, "", "", new HashSet<>(), null));
|
||||
cserver.addSncpServlet(cservice);
|
||||
cserver.init(DefaultAnyValue.create("port", 5577));
|
||||
cserver.start();
|
||||
|
||||
//------------------------ 初始化 BCService ------------------------------------
|
||||
final Transport bctransport = new Transport("", WatchFactory.root(), "", newBufferPool(), newChannelGroup(), null, Utility.ofSet(new InetSocketAddress("127.0.0.1", 5577)));
|
||||
BCService bcservice = Sncp.createLocalService("", null, ResourceFactory.root(), BCService.class, new InetSocketAddress("127.0.0.1", 5588), bctransport, null);
|
||||
CService remoteCService = Sncp.createRemoteService("", null, CService.class, new InetSocketAddress("127.0.0.1", 5588), bctransport);
|
||||
BCService bcservice = Sncp.createLocalService("", null, ResourceFactory.root(), BCService.class, new InetSocketAddress("127.0.0.1", 5588), "", new HashSet<>(), (AnyValue) null, bctransport, null);
|
||||
CService remoteCService = Sncp.createRemoteService("", null, CService.class, new InetSocketAddress("127.0.0.1", 5588), "", new HashSet<>(), (AnyValue) null, bctransport);
|
||||
factory.inject(remoteCService);
|
||||
factory.register("", remoteCService);
|
||||
SncpServer bcserver = new SncpServer();
|
||||
bcserver.getLogger().setLevel(Level.WARNING);
|
||||
bcserver.addSncpServlet(new ServiceWrapper(bcservice, "", "", new HashSet<>(), null));
|
||||
bcserver.addSncpServlet(bcservice);
|
||||
bcserver.init(DefaultAnyValue.create("port", 5588));
|
||||
bcserver.start();
|
||||
|
||||
//------------------------ 初始化 ABMainService ------------------------------------
|
||||
final Transport abtransport = new Transport("", WatchFactory.root(), "", newBufferPool(), newChannelGroup(), null, Utility.ofSet(new InetSocketAddress("127.0.0.1", 5588)));
|
||||
ABMainService service = Sncp.createLocalService("", null, ResourceFactory.root(), ABMainService.class, new InetSocketAddress("127.0.0.1", 5599), bctransport, null);
|
||||
BCService remoteBCService = Sncp.createRemoteService("", null, BCService.class, new InetSocketAddress("127.0.0.1", 5599), abtransport);
|
||||
ABMainService service = Sncp.createLocalService("", null, ResourceFactory.root(), ABMainService.class, new InetSocketAddress("127.0.0.1", 5599), "", new HashSet<>(), (AnyValue) null, bctransport, null);
|
||||
BCService remoteBCService = Sncp.createRemoteService("", null, BCService.class, new InetSocketAddress("127.0.0.1", 5599), "", new HashSet<>(), (AnyValue) null, abtransport);
|
||||
factory.inject(remoteBCService);
|
||||
factory.register("", remoteBCService);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
package org.redkale.test.service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import org.redkale.net.sncp.*;
|
||||
import org.redkale.service.Service;
|
||||
import org.redkale.util.*;
|
||||
@@ -26,7 +25,7 @@ public class TestService implements Service {
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
SncpServer cserver = new SncpServer();
|
||||
cserver.addSncpServlet(new ServiceWrapper(new TestService(), "", "", new HashSet<>(), null));
|
||||
cserver.addSncpServlet(new TestService());
|
||||
cserver.init(AnyValue.DefaultAnyValue.create("port", 5577));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class SncpTest {
|
||||
if (port2 > 0) set.add(new InetSocketAddress(myhost, port2));
|
||||
//String name, WatchFactory, ObjectPool<ByteBuffer>, AsynchronousChannelGroup, InetSocketAddress clientAddress, Collection<InetSocketAddress>
|
||||
final Transport transport = new Transport("", WatchFactory.root(), "", newBufferPool(), newChannelGroup(), null, set);
|
||||
final SncpTestIService service = Sncp.createRemoteService(serviceName, null, SncpTestIService.class, null, transport);
|
||||
final SncpTestIService service = Sncp.createSimpleRemoteService(serviceName, SncpTestIService.class, addr, transport);
|
||||
ResourceFactory.root().inject(service);
|
||||
|
||||
// SncpTestBean bean = new SncpTestBean();
|
||||
@@ -159,9 +159,9 @@ public class SncpTest {
|
||||
if (port2 > 0) set.add(new InetSocketAddress(myhost, port2));
|
||||
//String name, WatchFactory, ObjectPool<ByteBuffer>, AsynchronousChannelGroup, InetSocketAddress clientAddress, Collection<InetSocketAddress>
|
||||
final Transport transport = new Transport("", WatchFactory.root(), "", newBufferPool(), newChannelGroup(), null, set);
|
||||
SncpTestIService service = Sncp.createLocalService("", null, ResourceFactory.root(), SncpTestServiceImpl.class, addr, transport, null);
|
||||
SncpTestIService service = Sncp.createSimpleLocalService("", SncpTestServiceImpl.class, addr, transport);
|
||||
ResourceFactory.root().inject(service);
|
||||
server.addSncpServlet(new ServiceWrapper(service, "", "", new HashSet<>(), null));
|
||||
server.addSncpServlet(service);
|
||||
System.out.println(service);
|
||||
AnyValue.DefaultAnyValue conf = new AnyValue.DefaultAnyValue();
|
||||
conf.addValue("host", "0.0.0.0");
|
||||
@@ -193,8 +193,8 @@ public class SncpTest {
|
||||
set.add(new InetSocketAddress(myhost, port));
|
||||
//String name, WatchFactory, ObjectPool<ByteBuffer>, AsynchronousChannelGroup, InetSocketAddress clientAddress, Collection<InetSocketAddress>
|
||||
final Transport transport = new Transport("", WatchFactory.root(), "", newBufferPool(), newChannelGroup(), null, set);
|
||||
Service service = Sncp.createLocalService("", null, ResourceFactory.root(), SncpTestServiceImpl.class, addr, transport, null);
|
||||
server.addSncpServlet(new ServiceWrapper(service, "", "", new HashSet<>(), null));
|
||||
Service service = Sncp.createSimpleLocalService("", SncpTestServiceImpl.class, addr, transport);
|
||||
server.addSncpServlet(service);
|
||||
AnyValue.DefaultAnyValue conf = new AnyValue.DefaultAnyValue();
|
||||
conf.addValue("host", "0.0.0.0");
|
||||
conf.addValue("port", "" + port2);
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.redkale.test.sncp;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.redkale.net.sncp.*;
|
||||
import org.redkale.service.*;
|
||||
@@ -97,7 +98,7 @@ public class SncpTestServiceImpl implements SncpTestIService {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Service service = Sncp.createLocalService("", null, ResourceFactory.root(), SncpTestServiceImpl.class, new InetSocketAddress("127.0.0.1", 7070), null, null);
|
||||
Service service = Sncp.createLocalService("", null, ResourceFactory.root(), SncpTestServiceImpl.class, new InetSocketAddress("127.0.0.1", 7070), "", new HashSet<>(), (AnyValue) null, null, null);
|
||||
for (Method method : service.getClass().getDeclaredMethods()) {
|
||||
System.out.println(method);
|
||||
}
|
||||
@@ -106,7 +107,7 @@ public class SncpTestServiceImpl implements SncpTestIService {
|
||||
System.out.println(method);
|
||||
}
|
||||
System.out.println("-----------------------------------");
|
||||
service = Sncp.createRemoteService("", null, SncpTestServiceImpl.class, new InetSocketAddress("127.0.0.1", 7070), null);
|
||||
service = Sncp.createSimpleRemoteService("", SncpTestServiceImpl.class, new InetSocketAddress("127.0.0.1", 7070), null);
|
||||
for (Method method : service.getClass().getDeclaredMethods()) {
|
||||
System.out.println(method);
|
||||
}
|
||||
@@ -115,7 +116,7 @@ public class SncpTestServiceImpl implements SncpTestIService {
|
||||
System.out.println(method);
|
||||
}
|
||||
System.out.println("-----------------------------------");
|
||||
service = Sncp.createRemoteService("", null, SncpTestIService.class, new InetSocketAddress("127.0.0.1", 7070), null);
|
||||
service = Sncp.createSimpleRemoteService("", SncpTestIService.class, new InetSocketAddress("127.0.0.1", 7070), null);
|
||||
for (Method method : service.getClass().getDeclaredMethods()) {
|
||||
System.out.println(method);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user