use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.
the class MSCPPlusIT method onAppStarting.
/**
* onAppStarting
*
* @param args
*/
public void onAppStarting() {
IConfigurationManager cm = ConfigurationManager.getInstance();
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT);
context.put(InterceptConstants.WEBAPPLOADER, this.getClass().getClassLoader());
context.put(InterceptConstants.WEBWORKDIR, cm.getContext(IConfigurationManager.ROOT));
context.put(InterceptConstants.CONTEXTPATH, "");
context.put(InterceptConstants.APPNAME, cm.getContext(IConfigurationManager.NODEAPPID));
context.put(InterceptConstants.BASEPATH, "/" + cm.getContext(IConfigurationManager.NODEAPPID));
iSupport.doIntercept(context);
}
use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.
the class MSCPPlusIT method onAppStart.
/**
* onAppStart
*
* @param args
*/
public void onAppStart() {
// String featureName = (String) args[0];
IConfigurationManager cm = ConfigurationManager.getInstance();
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_STARTED);
context.put(InterceptConstants.WEBAPPLOADER, this.getClass().getClassLoader());
context.put(InterceptConstants.WEBWORKDIR, cm.getContext(IConfigurationManager.ROOT));
context.put(InterceptConstants.CONTEXTPATH, "");
context.put(InterceptConstants.APPNAME, cm.getContext(IConfigurationManager.NODEAPPID));
context.put(InterceptConstants.BASEPATH, "/" + cm.getContext(IConfigurationManager.NODEAPPID));
iSupport.doIntercept(context);
}
use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.
the class SpringBootTomcatPlusIT method onResourceInit.
@Override
public void onResourceInit(Object... args) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (!WebappClassLoader.class.isAssignableFrom(cl.getClass())) {
return;
}
/**
* for Application Starting's Resource Init
*/
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT);
StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ);
/**
* 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, sc.getLoader().getClassLoader().getParent());
context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true);
context.put(InterceptConstants.CONTEXTPATH, contextPath);
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);
String basePath = sContext.getRealPath("");
/*
* NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process
*/
if (basePath == null) {
basePath = "";
} else if (basePath.lastIndexOf("/") == (basePath.length() - 1) || basePath.lastIndexOf("\\") == (basePath.length() - 1)) {
basePath = basePath.substring(0, basePath.length() - 1);
}
context.put(InterceptConstants.BASEPATH, basePath);
iSupport.doIntercept(context);
}
use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.
the class SpringBootTomcatPlusIT method onAppStarting.
/**
* onAppStarting
*
* @param args
*/
@Override
public void onAppStarting(Object... args) {
StandardContext sc = (StandardContext) args[0];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext context = iSupport.createInterceptContext(Event.WEBCONTAINER_INIT);
/**
* 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, sc.getLoader().getClassLoader().getParent());
context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true);
context.put(InterceptConstants.CONTEXTPATH, contextPath);
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);
String basePath = sContext.getRealPath("");
/*
* NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process
*/
if (basePath == null) {
basePath = "";
} else if (basePath.lastIndexOf("/") == (basePath.length() - 1) || basePath.lastIndexOf("\\") == (basePath.length() - 1)) {
basePath = basePath.substring(0, basePath.length() - 1);
}
context.put(InterceptConstants.BASEPATH, basePath);
iSupport.doIntercept(context);
}
use of com.creditease.monitor.interceptframework.InterceptSupport in project uavstack by uavorg.
the class SpringBootTomcatPlusIT method onResourceCreate.
@Override
public Object onResourceCreate(Object... args) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
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);
StandardContext sc = (StandardContext) context.get(InterceptConstants.CONTEXTOBJ);
/**
* 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, sc.getLoader().getClassLoader().getParent());
context.put(InterceptConstants.WEBWORKDIR, sc.getWorkPath());
String contextPath = (String) ReflectionHelper.getField(StandardContext.class, sc, "encodedPath", true);
context.put(InterceptConstants.CONTEXTPATH, contextPath);
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);
String basePath = sContext.getRealPath("");
/*
* NOTE: springboot couldn't get the basePath through method "getRealPath", temporary process
*/
if (basePath == null) {
basePath = "";
} else if (basePath.lastIndexOf("/") == (basePath.length() - 1) || basePath.lastIndexOf("\\") == (basePath.length() - 1)) {
basePath = basePath.substring(0, basePath.length() - 1);
}
context.put(InterceptConstants.BASEPATH, basePath);
context.put(InterceptConstants.RESOURCEOBJ, args[0]);
context.put(InterceptConstants.RESOURCECFG, args[1]);
iSupport.doIntercept(context);
return context.get(InterceptConstants.RESOURCEOBJ);
}
Aggregations