diff --git a/src/org/redkale/boot/Application.java b/src/org/redkale/boot/Application.java index da7ff2458..277cd1149 100644 --- a/src/org/redkale/boot/Application.java +++ b/src/org/redkale/boot/Application.java @@ -737,6 +737,7 @@ public final class Application { Class clazz = classLoader.loadClass(listenClass); if (RestDyncListener.class.isAssignableFrom(clazz)) { RestDyncListener listener = (RestDyncListener) clazz.getDeclaredConstructor().newInstance(); + listener.init(config); this.restListeners.add(listener); continue; } @@ -917,6 +918,9 @@ public final class Application { //if (!singletonrun) signalHandle(); //if (!singletonrun) clearPersistData(); logger.info(this.getClass().getSimpleName() + " started in " + (System.currentTimeMillis() - startTime) + " ms\r\n"); + for (RestDyncListener listener : this.restListeners) { + listener.postApplicationStarted(this); + } if (!singletonrun) this.serversLatch.await(); } diff --git a/src/org/redkale/net/http/RestDyncListener.java b/src/org/redkale/net/http/RestDyncListener.java index 5414d82a2..0dbb07ffe 100644 --- a/src/org/redkale/net/http/RestDyncListener.java +++ b/src/org/redkale/net/http/RestDyncListener.java @@ -6,7 +6,9 @@ package org.redkale.net.http; import java.lang.reflect.Method; +import org.redkale.boot.Application; import org.redkale.service.Service; +import org.redkale.util.AnyValue; /** * Application进程启动后动态创建RestServlet时调用
@@ -20,6 +22,31 @@ import org.redkale.service.Service; */ public interface RestDyncListener { + /** + * 初始化方法 + * + * @param config 配置参数 + */ + default void init(AnyValue config) { + + } + + /** + * Application 初始化完所有Server后调用 + * + * @param application Application + */ + default void postApplicationStarted(Application application) { + } + + /** + * 动态生成RestMapping方法后调用 + * + * @param classLoader ClassLoader + * @param baseServletType Rest的Servlet基类 + * @param serviceType Service类 + * @param method Service的RestMapping方法 + */ public void invoke(final ClassLoader classLoader, final Class baseServletType, final Class serviceType, final Method method); }