use of com.creditease.monitor.interceptframework.spi.InterceptEventListener in project uavstack by uavorg.
the class InterceptSupport method newInstance.
private InterceptEventListener newInstance(String lClassName) {
InterceptEventListener listener = null;
try {
Class<?> lClass = null;
List<ClassLoader> cls = new ArrayList<ClassLoader>();
if (this.contextClassLoader != null) {
cls.add(this.contextClassLoader);
}
cls.add(Thread.currentThread().getContextClassLoader());
cls.add(this.getClass().getClassLoader());
lClass = tryLoadClass(lClassName, lClass, cls);
if (lClass == null) {
log.error("InterceptEventListener[" + lClassName + "] is loaded FAIL", null);
return listener;
}
Object inst = lClass.newInstance();
listener = InterceptEventListener.class.cast(inst);
} catch (Exception e) {
// ignore
}
return listener;
}
use of com.creditease.monitor.interceptframework.spi.InterceptEventListener in project uavstack by uavorg.
the class InterceptSupport method doIntercept.
public void doIntercept(InterceptContext context) {
InterceptContext threadLocalContext = StandardInterceptContextHelper.getContext(context.getEvent(), false);
mergeContext(threadLocalContext, context);
for (InterceptEventListener listener : listeners) {
if (listener.isEventListener(context.getEvent())) {
doHandleEvent(context, listener);
}
}
if (threadLocalContext != null) {
StandardInterceptContextHelper.releaseContext(context.getEvent());
}
}
use of com.creditease.monitor.interceptframework.spi.InterceptEventListener in project uavstack by uavorg.
the class InterceptFrameworkSupportor method start.
@Override
public void start() {
String listenersString = System.getProperty("com.creditease.uav.interceptlisteners");
if (null == listenersString) {
return;
}
String[] defaultListeners = listenersString.split(",");
// Step 1: install intercept listeners
InterceptSupport is = InterceptSupport.instance();
for (String listenerClass : defaultListeners) {
InterceptEventListener listener = is.createInterceptEventListener(listenerClass);
if (listener != null) {
if (this.logger.isLogEnabled()) {
this.logger.info("InterceptEventListener[" + listenerClass + "] load SUCCESS");
}
is.addEventListener(listener);
}
}
// Step 2: register UAVServerController
ServerVendor vendor = (ServerVendor) UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR);
GlobalFilterDispatchListener listener = (GlobalFilterDispatchListener) InterceptSupport.instance().getEventListener(GlobalFilterDispatchListener.class);
// MSCP
if (vendor == ServerVendor.MSCP) {
// TODO
} else // JEE
{
listener.registerHandler(new UAVServerJEEController("UAVServerJEEController"));
}
// init MonitorUrlFilterMgr
MonitorUrlFilterMgr.getInstance().init();
}
Aggregations