use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class JettyPlusIT method onAppInit.
/**
* onAppInit
*
* @param args
*/
public void onAppInit(Object... args) {
App sc = (App) args[0];
InterceptSupport iSupport = InterceptSupport.instance();
InterceptContext ic = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_INIT);
InterceptContext ic2 = iSupport.getThreadLocalContext(Event.WEBCONTAINER_RESOURCE_CREATE);
/**
* NOTE: onAppInit, we put the Context Object into threadlocal, then all other later process for
* PRE_WEBCONTAINER_INIT, which can get the object, as not everywhere we can get the object
*
* for example, the DataSource related injection
*/
ic.put(InterceptConstants.CONTEXTOBJ, sc);
ic2.put(InterceptConstants.CONTEXTOBJ, sc);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext 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));
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class MybatisHookProxy method InsertInterceptToClients.
private void InsertInterceptToClients(HookContext context, ClassLoader webapploader) {
if (isHookEventDone("InsertInterceptToClients")) {
return;
}
InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT);
String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH);
String basePath = (String) ic.get(InterceptConstants.BASEPATH);
appid = MonitorServerUtil.getApplicationId(contextPath, basePath);
dpInstall.setTargetClassLoader(webapploader);
dpInstall.installProxy("org.apache.ibatis.datasource.pooled.PooledDataSource", new String[] { "com.creditease.uav.hook.jdbc.pools.mybatis.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("setUrl".equals(m.getName())) {
dpInstall.defineLocalVal(m, "mObj", MybatisIT.class);
m.insertBefore("{mObj=new MybatisIT(\"" + id + "\",this);}");
}
}
}, false);
// release loader
dpInstall.releaseTargetClassLoader();
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class RabbitmqHookProxy method InsertInterceptToClients.
public void InsertInterceptToClients(HookContext context, ClassLoader webapploader) {
if (isHookEventDone("InsertInterceptToClients")) {
return;
}
InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT);
String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH);
String basePath = (String) ic.get(InterceptConstants.BASEPATH);
final String appid = MonitorServerUtil.getApplicationId(contextPath, basePath);
doInstallDProxy(webapploader, appid);
}
use of com.creditease.monitor.interceptframework.spi.InterceptContext in project uavstack by uavorg.
the class ComponentProfileHandler method getDynInfoForWebService.
@SuppressWarnings("unchecked")
private void getDynInfoForWebService(String componentClassName, ProfileElementInstance inst, ProfileContext context, Map<String, Class<?>> annoAvailableClasses, FastClasspathScanner fcs) {
if (!componentClassName.equals("javax.jws.WebService")) {
return;
}
Class<?> annoClass = annoAvailableClasses.get(componentClassName);
if (null == annoClass) {
return;
}
List<String> coms = fcs.getNamesOfClassesWithAnnotation(annoClass);
if (null == coms || coms.isEmpty()) {
return;
}
// construct data "dyn" for webservice
InterceptContext ic = context.get(InterceptContext.class);
List<WebServiceProfileInfo> wsli = (ArrayList<WebServiceProfileInfo>) ic.get("webservice.profile.info");
if (wsli == null || wsli.isEmpty()) {
return;
}
for (WebServiceProfileInfo wslinfo : wsli) {
String url = wslinfo.getUrl();
String clazz = (wslinfo.getImpl() instanceof String) ? (String) wslinfo.getImpl() : wslinfo.getImpl().getClass().getName();
if (coms.contains(clazz)) {
Map<String, Object> dynInfos = new LinkedHashMap<String, Object>();
Map<String, Object> info = (Map<String, Object>) inst.getValues().get(clazz);
dynInfos.put("url", url);
dynInfos.put("className", clazz);
info.put("dyn", dynInfos);
inst.getValues().put(clazz, info);
}
}
}
Aggregations