use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.
the class TomcatPlusIT method onAppStarting.
/**
* onAppStarting
*
* @param args
*/
public void onAppStarting(Object... args) {
// release the left contexts
StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_INIT);
StandardInterceptContextHelper.releaseContext(Event.WEBCONTAINER_RESOURCE_CREATE);
StandardContext sc = (StandardContext) args[0];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT);
context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader());
context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
context.put(InterceptConstants.CONTEXTPATH, ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true));
context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true));
ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true);
context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
getBasePath(context, sContext);
iSupport.doIntercept(context);
}
use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.
the class TomcatPlusIT method onAppStart.
/**
* onAppStart
*
* @param args
*/
public void onAppStart(Object... args) {
StandardContext sc = (StandardContext) args[0];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STARTED);
context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader());
context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
context.put(InterceptConstants.CONTEXTPATH, ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true));
context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true));
ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true);
context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
getBasePath(context, sContext);
iSupport.doIntercept(context);
}
use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.
the class TomcatPlusIT method onResourceCreate.
/**
* on Resource Create
*/
public Object onResourceCreate(Object... args) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
/**
* after tomcat8, tomcat use ParallelWebappClassLoader instead of WebappClassLoader as it's webapp's
* classloader, both of them are extends WebappClassLoaderBase
*/
Class<?> cls = cl.loadClass("org.apache.catalina.loader.WebappClassLoaderBase");
if (!cls.isAssignableFrom(cl.getClass())) {
return args[0];
}
} catch (ClassNotFoundException e) {
/**
* before tomcat7.0.64(include), WebappClassLoaderBase doesn't exist
*/
if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) {
return args[0];
}
}
/**
* for Application Starting's Resource Create
*/
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE, false);
if (context == null) {
return args[0];
}
StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ);
if (sc == null) {
return args[0];
}
context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader());
context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
context.put(InterceptConstants.CONTEXTPATH, ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true));
context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true));
ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true);
context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
getBasePath(context, sContext);
context.put(InterceptConstants.RESOURCEOBJ, args[0]);
context.put(InterceptConstants.RESOURCECFG, args[1]);
iSupport.doIntercept(context);
InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE);
ic.put(InterceptConstants.CONTEXTOBJ, sc);
return context.get(InterceptConstants.RESOURCEOBJ);
}
use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.
the class TomcatPlusIT method onAppStop.
/**
* onAppStop
*
* @param args
*/
public void onAppStop(Object... args) {
StandardContext sc = (StandardContext) args[0];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STOPPED);
context.put(InterceptConstants.WEBAPPLOADER, sc.getLoader().getClassLoader());
context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
context.put(InterceptConstants.CONTEXTPATH, ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true));
context.put(InterceptConstants.APPNAME, ReflectionHelper.getField(StandardContext.class, sc, "displayName", true));
ServletContext sContext = (ServletContext) ReflectionHelper.getField(StandardContext.class, sc, "context", true);
context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
getBasePath(context, sContext);
iSupport.doIntercept(context);
}
use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.
the class JettyPlusIT method onAppStart.
/**
* onAppStart
*
* @param args
*/
public void onAppStart(Object... args) {
WebAppContext sc = getWebAppContext(args);
if (sc == null) {
return;
}
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STARTED);
context.put(InterceptConstants.WEBAPPLOADER, sc.getClassLoader());
context.put(InterceptConstants.WEBWORKDIR, sc.getServletContext().getRealPath(""));
context.put(InterceptConstants.CONTEXTPATH, sc.getContextPath());
context.put(InterceptConstants.APPNAME, sc.getDisplayName());
ServletContext sContext = sc.getServletContext();
context.put(InterceptConstants.SERVLET_CONTEXT, sContext);
getBasePath(context, sContext);
iSupport.doIntercept(context);
// GlobalFilter
sc.addFilter("com.creditease.monitor.jee.filters.GlobalFilter", "/*", EnumSet.of(DispatcherType.REQUEST));
}
Aggregations