1 changed files with 113 additions and 0 deletions
@ -0,0 +1,113 @@ |
|||||||
|
package com.fr.plugin.reset_user_passwd.PerformancePluginMonitor; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.decision.plugin.PluginControllerManager; |
||||||
|
import com.fr.event.Event; |
||||||
|
import com.fr.event.EventDispatcher; |
||||||
|
import com.fr.event.Listener; |
||||||
|
import com.fr.event.Null; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.plugin.context.PluginContext; |
||||||
|
import com.fr.plugin.context.PluginContexts; |
||||||
|
import com.fr.plugin.db.base.BasePluginDBManager; |
||||||
|
import com.fr.plugin.injectable.PluginModule; |
||||||
|
import com.fr.plugin.manage.PluginManager; |
||||||
|
import com.fr.plugin.observer.PluginEventType; |
||||||
|
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||||
|
import com.fr.plugin.reset_user_passwd.Controllers.SpringControllerHandler; |
||||||
|
import com.fr.plugin.reset_user_passwd.Controllers.TestController; |
||||||
|
import com.fr.plugin.transform.FunctionRecorder; |
||||||
|
import com.fr.stable.plugin.ExtraClassManagerProvider; |
||||||
|
import com.fr.startup.FineWebApplicationEvent; |
||||||
|
import com.fr.startup.SpringContext; |
||||||
|
import com.fr.third.springframework.context.ConfigurableApplicationContext; |
||||||
|
import com.fr.web.controller.decision.api.template.TemplateAuthResource; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
@FunctionRecorder |
||||||
|
public class MyPerformanceMonitor extends AbstractPluginLifecycleMonitor{ |
||||||
|
@Override |
||||||
|
public void afterRun(PluginContext pluginContext) { |
||||||
|
// PluginContexts.currentContext().
|
||||||
|
FineLoggerFactory.getLogger().info(PluginContexts.currentContext().getID()+"插件启动后:"); |
||||||
|
|
||||||
|
|
||||||
|
/* |
||||||
|
EventDispatcher.listen(PluginEventType.AfterRun, this.validListener); |
||||||
|
EventDispatcher.listen(PluginEventType.BeforeStop, this.invalidListener); |
||||||
|
*/ |
||||||
|
//自己来注册控制器,不通过xml配置。
|
||||||
|
// EventDispatcher.listen(FineWebApplicationEvent.AFTER_RUN, this.preRegisterListener);
|
||||||
|
//从所有插件里获取某一个扩展
|
||||||
|
/** |
||||||
|
ExtraClassManagerProvider var1 = (ExtraClassManagerProvider) PluginModule.ExtraCore.getAgent(); |
||||||
|
Set var2 = var1.getArray("DBAccessProvider"); |
||||||
|
*/ |
||||||
|
|
||||||
|
//从PluginContext来获取某一个扩展
|
||||||
|
/** |
||||||
|
Set var2 = pluginContext.getRuntime().get("DBAccessProvider"); |
||||||
|
*/ |
||||||
|
|
||||||
|
// PluginControllerManager
|
||||||
|
|
||||||
|
} |
||||||
|
/* |
||||||
|
private Listener<Null> preRegisterListener = new Listener<Null>() { |
||||||
|
public void on(Event event, Null o) { |
||||||
|
springControllerHandler.registerController(TestController.class); |
||||||
|
|
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private SpringControllerHandler springControllerHandler = new SpringControllerHandler(); |
||||||
|
private boolean isRegisted = false; |
||||||
|
private Listener<PluginContext> validListener = new Listener<PluginContext>() { |
||||||
|
public void on(Event var1, PluginContext var2) { |
||||||
|
FineLoggerFactory.getLogger().info(var2+"插件启动。。。"); |
||||||
|
// BasePluginDBManager.this.dealDynamicPluginInstall(var2);
|
||||||
|
List<PluginContext> pluginContexts = PluginManager.getContexts(); |
||||||
|
FineLoggerFactory.getLogger().info("已经启动的插件个数:"+pluginContexts.size()); |
||||||
|
boolean isAllRunning = true; |
||||||
|
for(PluginContext context : pluginContexts){ |
||||||
|
boolean isRunning = context.isRunning(); |
||||||
|
if(isRunning == false){ |
||||||
|
isAllRunning = false; |
||||||
|
} |
||||||
|
boolean isActive = context.isActive(); |
||||||
|
boolean isAvailable = context.isAvailable(); |
||||||
|
FineLoggerFactory.getLogger().info(context.getID()+",isRunning:"+isRunning+",isActive:"+isActive+",isAvailable:"+isAvailable); |
||||||
|
} |
||||||
|
|
||||||
|
if(isAllRunning == true){ |
||||||
|
FineLoggerFactory.getLogger().info("所有插件都已经运行了..."); |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
private Listener<PluginContext> invalidListener = new Listener<PluginContext>() { |
||||||
|
public void on(Event var1, PluginContext var2) { |
||||||
|
FineLoggerFactory.getLogger().info(var2+"插件停止。。。"); |
||||||
|
// BasePluginDBManager.this.dealDynamicPluginInstall(var2);
|
||||||
|
} |
||||||
|
}; |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void beforeStop(PluginContext pluginContext) { |
||||||
|
FineLoggerFactory.getLogger().info(PluginContexts.currentContext().getID()+"插件停止前:"); |
||||||
|
/* |
||||||
|
EventDispatcher.stopListen(this.validListener); |
||||||
|
EventDispatcher.stopListen(this.invalidListener); |
||||||
|
ConfigurableApplicationContext applicationContext = SpringContext.getWebApplicationContext(); |
||||||
|
if(applicationContext != null){ |
||||||
|
this.springControllerHandler.unRegisterController(TestController.class); |
||||||
|
} |
||||||
|
*/ |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue