Search in sources :

Example 1 with InterceptEventListener

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;
}
Also used : ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) InterceptEventListener(com.creditease.monitor.interceptframework.spi.InterceptEventListener)

Example 2 with InterceptEventListener

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());
    }
}
Also used : InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) InterceptEventListener(com.creditease.monitor.interceptframework.spi.InterceptEventListener)

Example 3 with InterceptEventListener

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();
}
Also used : InterceptSupport(com.creditease.monitor.interceptframework.InterceptSupport) ServerVendor(com.creditease.monitor.UAVServer.ServerVendor) GlobalFilterDispatchListener(com.creditease.uav.appserver.listeners.GlobalFilterDispatchListener) UAVServerJEEController(com.creditease.monitor.globalfilter.jee.UAVServerJEEController) InterceptEventListener(com.creditease.monitor.interceptframework.spi.InterceptEventListener)

Aggregations

InterceptEventListener (com.creditease.monitor.interceptframework.spi.InterceptEventListener)3 ServerVendor (com.creditease.monitor.UAVServer.ServerVendor)1 UAVServerJEEController (com.creditease.monitor.globalfilter.jee.UAVServerJEEController)1 InterceptSupport (com.creditease.monitor.interceptframework.InterceptSupport)1 InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)1 GlobalFilterDispatchListener (com.creditease.uav.appserver.listeners.GlobalFilterDispatchListener)1 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1