use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class GlobalFilter method inteceptResponse.
private void inteceptResponse(InterceptSupport iSupport, InterceptContext context) {
InterceptContext respContext = iSupport.createInterceptContext(Event.GLOBAL_FILTER_RESPONSE);
respContext.putAll(context.getAll());
iSupport.doIntercept(respContext);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class WebServiceListenerIT method obtainWsInfo.
public void obtainWsInfo(Object address, Object impl) {
InterceptContext ic = InterceptSupport.instance().getThreadLocalContext(Event.WEBCONTAINER_STARTED);
@SuppressWarnings("unchecked") List<WebServiceProfileInfo> list = (ArrayList<WebServiceProfileInfo>) ic.get("webservice.profile.info");
if (null == list) {
list = new ArrayList<WebServiceProfileInfo>();
ic.put("webservice.profile.info", list);
}
setWsInfo(list, address, impl);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class HookFactory method stopHook.
/**
* stop application framework hook
*
* @param webapploader
* @param proxyClass
* @param cntx
*/
public void stopHook(ClassLoader webapploader, String proxyClass, HookContext cntx, boolean shouldRemove) {
try {
if (log.isLogEnabled()) {
log.info("STOP hookproxy[" + proxyClass + "] ");
}
InterceptContext context = (InterceptContext) cntx.get(HookConstants.INTERCEPTCONTEXT);
String contextPath = (String) context.get(InterceptConstants.CONTEXTPATH);
String proxyKey = getHookProxyKey(contextPath, proxyClass);
HookProxy proxy = (!shouldRemove) ? hooks.get(proxyKey) : hooks.remove(proxyKey);
if (proxy == null) {
if (log.isDebugable()) {
log.debug("no hookproxy[" + proxyClass + "] should be STOP", null);
}
return;
}
// run stop hookproxy
proxy.stop(cntx, webapploader);
if (log.isDebugable()) {
log.debug("STOP hookproxy[" + proxyClass + "] END", null);
}
} catch (Exception e) {
log.error("STOP hookproxy[" + proxyClass + "] FAIL. ", e);
return;
}
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class MSCPProfileHandler method doProfiling.
@Override
public void doProfiling(ProfileElement elem, ProfileContext context) {
UAVServer.ServerVendor sv = (UAVServer.ServerVendor) UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR);
// only support MSCP Application
if (sv != UAVServer.ServerVendor.MSCP) {
return;
}
if (!ProfileConstants.PROELEM_COMPONENT.equals(elem.getElemId())) {
return;
}
InterceptContext ic = context.get(InterceptContext.class);
if (ic == null) {
this.logger.warn("Profile:Annotation FAILs as No InterceptContext available", null);
return;
}
/**
* 1. get webappclassloader
*/
ClassLoader webappclsLoader = (ClassLoader) ic.get(InterceptConstants.WEBAPPLOADER);
if (null == webappclsLoader) {
this.logger.warn("Profile:JARS FAILs as No webappclsLoader available", null);
return;
}
Collection<ClassLoader> clList = ConfigurationManager.getInstance().getFeatureClassLoader();
clList.add(webappclsLoader);
ClassLoader[] allcl = new ClassLoader[clList.size()];
allcl = clList.toArray(allcl);
/**
* 2. see what kind of components we could get via annotations or interface or parentClass
*/
FastClasspathScanner fcs = new FastClasspathScanner(allcl, "com.creditease.uav", "com.creditease.agent", "org.uavstack");
fcs.scan();
/**
* 3. get MSCPServlets profile info
*/
InterceptContext itContext = context.get(InterceptContext.class);
String appRootPath = (String) itContext.get(InterceptConstants.BASEPATH);
String appName = (String) itContext.get(InterceptConstants.APPNAME);
for (String componentClassName : componentClassMap.keySet()) {
// set the instance id = simple name of the annotation class
ProfileElementInstance inst = elem.getInstance(componentClassName);
ComponentProcessor cp = componentClassMap.get(componentClassName);
cp.handle(componentClassName, appName, inst, fcs);
}
/**
* 4. load application info
*/
loadAppInfo(elem, appRootPath, appName);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext 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);
}
Aggregations