This commit is contained in:
wentch
2015-12-24 09:38:45 +08:00
parent 9f6b4bde8a
commit e879135f33
2 changed files with 87 additions and 79 deletions

View File

@@ -99,7 +99,8 @@ public abstract class Sncp {
}
public static boolean isRemote(Service service) {
return service.getClass().getName().startsWith(REMOTEPREFIX);
SncpDyn dyn = service.getClass().getAnnotation(SncpDyn.class);
return dyn != null && dyn.remote();
}
/**
@@ -120,6 +121,7 @@ public abstract class Sncp {
* }
* }
*
* @SncpDyn
* public final class _DynLocalTestService extends TestService{
*
* @Resource
@@ -214,6 +216,7 @@ public abstract class Sncp {
cw.visit(V1_8, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, supDynName, null);
{
av0 = cw.visitAnnotation(sncpDynDesc, true);
av0.visit("remote", Boolean.FALSE);
av0.visitEnd();
}
if (hasMultiRun) {
@@ -346,6 +349,7 @@ public abstract class Sncp {
}
}
av0 = mv.visitAnnotation(sncpDynDesc, true);
av0.visit("remote", Boolean.FALSE);
av0.visit("index", index);
av0.visitEnd();
Label l1 = new Label();
@@ -762,6 +766,7 @@ public abstract class Sncp {
}
/**
* @SncpDyn(remote = true)
* public final class _DynRemoteTestService extends TestService{
*
* @Resource
@@ -861,6 +866,7 @@ public abstract class Sncp {
cw.visit(V1_8, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, supDynName, null);
{
av0 = cw.visitAnnotation(sncpDynDesc, true);
av0.visit("remote", Boolean.TRUE);
av0.visitEnd();
}
{

View File

@@ -11,8 +11,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* 修饰由SNCP协议动态生成的class、和method
* 本地模式动态生成的_DynLocalXXXService类、其带有@MultiRun方法均会打上@SncpDyn 的注解
* 远程模式动态生成的_DynRemoteXXXService类会打上@SncpDyn 的注解
* 本地模式动态生成的_DynLocalXXXService类、其带有@MultiRun方法均会打上@SncpDyn(remote = false, index=N) 的注解
* 远程模式动态生成的_DynRemoteXXXService类会打上@SncpDyn(remote = true) 的注解
*
* @see http://www.redkale.org
* @author zhangjx
@@ -23,5 +23,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
public @interface SncpDyn {
int index() default 0; //排列顺序, 一般用于Method
boolean remote();
int index() default 0; //排列顺序, 主要用于Method
}