use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class SpringBootTomcatPlusIT method onSpringBeanRegist.
/**
* springboot load beans before web container start, hook opr should be done before beanRegist in case of duplicate
* definition ,so we define SPRING_BEAN_REGIST event to trigger hook
*/
public void onSpringBeanRegist(Object... args) {
if (!isWebServerContext(args[0])) {
return;
}
String contextPath = (String) args[1];
if (contextPath == null || "/".equals(contextPath)) {
contextPath = "";
}
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.SPRING_BEAN_REGIST);
context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader());
context.put(InterceptConstants.CONTEXTPATH, contextPath);
context.put(InterceptConstants.BASEPATH, "");
iSupport.doIntercept(context);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class SpringBootTomcatPlusIT method onServletStop.
/**
* onServletStop
*
* @param args
*/
@Override
public void onServletStop(Object... args) {
StandardWrapper sw = (StandardWrapper) args[0];
Servlet servlet = (Servlet) args[1];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY);
context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
/**
* NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do
* anything on this we may use its webappclassloader's parent as the classloader
*/
context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent());
context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath());
iSupport.doIntercept(context);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class SpringBootTomcatPlusIT method startServer.
/**
* startUAVServer
*/
public void startServer(String port, String contextPath, String appName, Object arg) {
if (!isWebServerContext(arg)) {
return;
}
// integrate Tomcat log
UAVServer.instance().setLog(new TomcatLog("MonitorServer"));
// start Monitor Server when server starts
UAVServer.instance().start(new Object[] { UAVServer.ServerVendor.SPRINGBOOT });
// set appid
setAppid(contextPath);
// set the connector port
UAVServer.instance().putServerInfo(CaptureConstants.INFO_APPSERVER_LISTEN_PORT, DataConvertHelper.toInt(port, 8080));
InterceptSupport iSupport = InterceptSupport.instance();
// this context will be transmited from springboot mainThread to webcontainerInit thread then back to mainThread
InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_STARTED);
context.put(InterceptConstants.APPNAME, appName);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class SpringBootTomcatPlusIT method onServletStart.
/**
* onServletStart
*
* @param args
*/
@Override
public void onServletStart(Object... args) {
StandardWrapper sw = (StandardWrapper) args[0];
Servlet servlet = (Servlet) args[1];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT);
context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
/**
* NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do
* anything on this we may use its webappclassloader's parent as the classloader
*/
context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent());
context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath());
iSupport.doIntercept(context);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class TomcatPlusIT method onServletStart.
/**
* onServletStart
*
* @param args
*/
public void onServletStart(Object... args) {
StandardWrapper sw = (StandardWrapper) args[0];
Servlet servlet = (Servlet) args[1];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT);
context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader());
context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath());
iSupport.doIntercept(context);
}
Aggregations