Service 增加 stop 方法
This commit is contained in:
@@ -827,9 +827,11 @@ public final class Rest {
|
||||
if (Modifier.isStatic(method.getModifiers())) continue;
|
||||
if (method.isSynthetic()) continue;
|
||||
if (EXCLUDERMETHODS.contains(method.getName())) continue;
|
||||
if ("init".equals(method.getName())) continue;
|
||||
if ("destroy".equals(method.getName())) continue;
|
||||
if ("version".equals(method.getName())) continue;
|
||||
if (method.getParameterCount() == 1 && method.getParameterTypes()[0] == AnyValue.class) {
|
||||
if ("init".equals(method.getName())) continue;
|
||||
if ("stop".equals(method.getName())) continue;
|
||||
if ("destroy".equals(method.getName())) continue;
|
||||
}
|
||||
if (controller == null) continue;
|
||||
|
||||
RestMapping[] mappings = method.getAnnotationsByType(RestMapping.class);
|
||||
|
||||
@@ -688,6 +688,12 @@ public abstract class Sncp {
|
||||
mv.visitMaxs(0, 2);
|
||||
mv.visitEnd();
|
||||
}
|
||||
{ //stop
|
||||
mv = new MethodDebugVisitor(cw.visitMethod(ACC_PUBLIC, "stop", "(" + anyValueDesc + ")V", null, null));
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0, 2);
|
||||
mv.visitEnd();
|
||||
}
|
||||
{ //destroy
|
||||
mv = new MethodDebugVisitor(cw.visitMethod(ACC_PUBLIC, "destroy", "(" + anyValueDesc + ")V", null, null));
|
||||
mv.visitInsn(RETURN);
|
||||
|
||||
@@ -183,9 +183,11 @@ public final class SncpClient {
|
||||
if (method.getName().equals("getClass") || method.getName().equals("toString")) continue;
|
||||
if (method.getName().equals("equals") || method.getName().equals("hashCode")) continue;
|
||||
if (method.getName().equals("notify") || method.getName().equals("notifyAll") || method.getName().equals("wait")) continue;
|
||||
if (method.getName().equals("init") || method.getName().equals("destroy")) continue;
|
||||
//if (method.getName().equals("version") || method.getName().equals("name")) continue;
|
||||
if (method.getParameterCount() == 1 && method.getParameterTypes()[0] == AnyValue.class) {
|
||||
if (method.getName().equals("init") || method.getName().equals("stop") || method.getName().equals("destroy")) continue;
|
||||
}
|
||||
//if (onlySncpDyn && method.getAnnotation(SncpDyn.class) == null) continue;
|
||||
|
||||
DLong actionid = Sncp.hash(method);
|
||||
Method old = actionids.get(actionid);
|
||||
if (old != null) {
|
||||
|
||||
@@ -63,8 +63,10 @@ public final class SncpDynServlet extends SncpServlet {
|
||||
if (method.getName().equals("getClass") || method.getName().equals("toString")) continue;
|
||||
if (method.getName().equals("equals") || method.getName().equals("hashCode")) continue;
|
||||
if (method.getName().equals("notify") || method.getName().equals("notifyAll") || method.getName().equals("wait")) continue;
|
||||
if (method.getName().equals("init") || method.getName().equals("destroy")) continue;
|
||||
//if (method.getName().equals("version") || method.getName().equals("name")) continue;
|
||||
if (method.getParameterCount() == 1 && method.getParameterTypes()[0] == AnyValue.class) {
|
||||
if (method.getName().equals("init") || method.getName().equals("stop") || method.getName().equals("destroy")) continue;
|
||||
}
|
||||
|
||||
final DLong actionid = Sncp.hash(method);
|
||||
SncpServletAction action = SncpServletAction.create(service, actionid, method);
|
||||
action.convert = convert;
|
||||
|
||||
@@ -46,6 +46,18 @@ public interface Service {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 进程退出前会进行stop动作
|
||||
* 远程模式下该方法会重载成空方法
|
||||
*
|
||||
* @param config 配置参数
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
default void stop(AnyValue config) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 进程退出时,调用Service销毁
|
||||
* 远程模式下该方法会重载成空方法
|
||||
|
||||
Reference in New Issue
Block a user