This commit is contained in:
@@ -737,6 +737,7 @@ public final class Application {
|
|||||||
Class clazz = classLoader.loadClass(listenClass);
|
Class clazz = classLoader.loadClass(listenClass);
|
||||||
if (RestDyncListener.class.isAssignableFrom(clazz)) {
|
if (RestDyncListener.class.isAssignableFrom(clazz)) {
|
||||||
RestDyncListener listener = (RestDyncListener) clazz.getDeclaredConstructor().newInstance();
|
RestDyncListener listener = (RestDyncListener) clazz.getDeclaredConstructor().newInstance();
|
||||||
|
listener.init(config);
|
||||||
this.restListeners.add(listener);
|
this.restListeners.add(listener);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -917,6 +918,9 @@ public final class Application {
|
|||||||
//if (!singletonrun) signalHandle();
|
//if (!singletonrun) signalHandle();
|
||||||
//if (!singletonrun) clearPersistData();
|
//if (!singletonrun) clearPersistData();
|
||||||
logger.info(this.getClass().getSimpleName() + " started in " + (System.currentTimeMillis() - startTime) + " ms\r\n");
|
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();
|
if (!singletonrun) this.serversLatch.await();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
package org.redkale.net.http;
|
package org.redkale.net.http;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import org.redkale.boot.Application;
|
||||||
import org.redkale.service.Service;
|
import org.redkale.service.Service;
|
||||||
|
import org.redkale.util.AnyValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application进程启动后动态创建RestServlet时调用 <br>
|
* Application进程启动后动态创建RestServlet时调用 <br>
|
||||||
@@ -20,6 +22,31 @@ import org.redkale.service.Service;
|
|||||||
*/
|
*/
|
||||||
public interface RestDyncListener {
|
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,
|
public void invoke(final ClassLoader classLoader, final Class baseServletType,
|
||||||
final Class<? extends Service> serviceType, final Method method);
|
final Class<? extends Service> serviceType, final Method method);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user