This commit is contained in:
wentch
2015-12-16 10:18:38 +08:00
parent 8ccd5de549
commit 34f4eba615
4 changed files with 9 additions and 7 deletions

View File

@@ -117,7 +117,7 @@ public final class SncpClient {
protected final Consumer<Runnable> executor;
public SncpClient(final String serviceName, final Consumer<Runnable> executor, final long serviceid0, boolean remote, final Class serviceClass,
public SncpClient(final String serviceName, final Consumer<Runnable> executor, final long serviceid, boolean remote, final Class serviceClass,
boolean onlySncpDyn, final InetSocketAddress clientAddress, final HashSet<String> groups) {
if (serviceName.length() > 10) throw new RuntimeException(serviceClass + " @Resource name(" + serviceName + ") too long , must less 11");
this.remote = remote;
@@ -128,10 +128,10 @@ public final class SncpClient {
//if (subLocalClass != null && !serviceClass.isAssignableFrom(subLocalClass)) throw new RuntimeException(subLocalClass + " is not " + serviceClass + " sub class ");
this.name = serviceName;
this.nameid = Sncp.hash(serviceName);
this.serviceid = serviceid0 > 0 ? serviceid0 : Sncp.hash(serviceClass);
this.serviceid = serviceid;
final List<SncpAction> methodens = new ArrayList<>();
//------------------------------------------------------------------------------
for (java.lang.reflect.Method method : parseMethod(serviceClass, onlySncpDyn)) {
for (java.lang.reflect.Method method : parseMethod(serviceClass, onlySncpDyn)) { //远程模式下onlySncpDyn = false
SncpAction en = new SncpAction(method, Sncp.hash(method));
methodens.add(en);
}
@@ -161,7 +161,7 @@ public final class SncpClient {
+ ", groups = " + groups + ", actions.size = " + actions.length + ")";
}
public static List<Method> parseMethod(final Class serviceClass, boolean onlySncpDyn) {
public static List<Method> parseMethod(final Class serviceClass, boolean onlySncpDyn) { //远程模式下onlySncpDyn = false
final List<Method> list = new ArrayList<>();
final List<Method> multis = new ArrayList<>();
final Map<DLong, Method> actionids = new HashMap<>();

View File

@@ -11,6 +11,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 修饰由SNCP协议动态生成的class、和method
* 本地模式动态生成的_DynLocalXXXService类、其带有@MultiRun方法均会打上@SncpDyn 的注解
* 远程模式动态生成的_DynRemoteXXXService类会打上@SncpDyn 的注解
*
* @see http://www.redkale.org
* @author zhangjx

View File

@@ -44,10 +44,10 @@ public final class SncpDynServlet extends SncpServlet {
private Supplier<ByteBuffer> bufferSupplier;
public SncpDynServlet(final BsonConvert convert, final String serviceName, final Service service, final AnyValue conf) {
public SncpDynServlet(final BsonConvert convert, final String serviceName, final Class<? extends Service> type, final Service service, final AnyValue conf) {
this.conf = conf;
this.serviceName = serviceName;
this.type = (Class<? extends Service>) service.getClass().getSuperclass();
this.type = type;
this.nameid = Sncp.hash(serviceName);
this.serviceid = Sncp.hash(type);
Set<DLong> actionids = new HashSet<>();

View File

@@ -35,7 +35,7 @@ public final class SncpServer extends Server {
}
public void addService(ServiceWrapper entry) {
((SncpPrepareServlet) this.prepare).addSncpServlet(new SncpDynServlet(BsonFactory.root().getConvert(), entry.getName(), entry.getService(), entry.getConf()));
((SncpPrepareServlet) this.prepare).addSncpServlet(new SncpDynServlet(BsonFactory.root().getConvert(), entry.getName(), entry.getType(), entry.getService(), entry.getConf()));
}
public List<SncpServlet> getSncpServlets() {