use of com.creditease.monitor.UAVServer.ServerVendor in project uavstack by uavorg.
the class GlobalFilterDispatchListener method handleEvent.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void handleEvent(InterceptContext context) {
UAVServer.ServerVendor vendor = (ServerVendor) UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR);
Object httpReq = context.get(InterceptConstants.HTTPREQUEST);
Object httpResp = context.get(InterceptConstants.HTTPRESPONSE);
String url = null;
/**
* MSCP
*/
if (vendor == ServerVendor.MSCP) {
// TODO
} else /**
* JEE Application uses HttpServletRequest
*/
{
StringBuffer urlSB = (StringBuffer) ReflectionHelper.invoke("javax.servlet.http.HttpServletRequest", httpReq, "getRequestURL", null, null);
if (urlSB != null) {
url = urlSB.toString();
}
}
if (url == null) {
return;
}
if (MonitorServerUtil.isIncludeMonitorURL(url) == false) {
return;
}
/**
* NOTE: 目前的机制下,执行可能分为几种情况:
*
* 1. 执行1个BaseGlobalFilterHandler,就终止Handler Chain,也终止Filter
* Chain,则该handler的isBlockHandlerChain和isBlockFilterChain都为true
*
* 2. 执行多个BaseGlobalFilterHandler(contextPath有重合或叠加),才终止Handler Chain,但不终止Filter
* Chain,最后一个BaseGlobalFilterHandler的isBlockHandlerChain为true,
* 所有的BaseGlobalFilterHandler的isBlockFilterChain为false
*
* 3. 执行多个BaseGlobalFilterHandler(contextPath有重合或叠加),才终止Handler Chain,,也终止Filter
* Chain,最后一个BaseGlobalFilterHandler的isBlockHandlerChain为true,
* 其中任何一个BaseGlobalFilterHandler的isBlockFilterChain为true
*
* 所以要注意,BaseGlobalFilterHandler的执行顺序与注册的顺序有关
*/
boolean isBlockFilterChain = false;
for (AbsGlobalFilterHandler handler : handlers) {
String contextPath = handler.getContext();
if (url.indexOf(contextPath) > -1) {
try {
handler.handle(httpReq, httpResp, context);
} catch (Exception e) {
logger.error("GlobalFilterDispatchListener Handler[" + handler.getClass().getName() + "] runs FAIL: url=" + url, e);
}
if (handler.isBlockFilterChain() == true) {
isBlockFilterChain = true;
}
if (handler.isBlockHandlerChain() == true) {
break;
}
}
}
if (isBlockFilterChain == true) {
context.put(InterceptConstants.STOPREQUEST, new Object());
}
}
use of com.creditease.monitor.UAVServer.ServerVendor 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();
}
use of com.creditease.monitor.UAVServer.ServerVendor in project uavstack by uavorg.
the class HttpJEEJVMObserver method doRequest.
@Override
protected void doRequest(HttpServletRequest request, HttpServletResponse response, InterceptContext ic) {
String action = request.getParameter("action");
if (action.equalsIgnoreCase("ping")) {
ServerVendor sv = (UAVServer.ServerVendor) UAVServer.instance().getServerInfo(CaptureConstants.INFO_APPSERVER_VENDOR);
this.writeResponseBody(response, sv.toString(), HttpServletResponse.SC_OK);
} else if (action.equalsIgnoreCase("getSystemPro")) {
System.setProperty("proc.ext.pid", JVMToolHelper.getCurrentProcId());
this.writeResponseBody(response, JSONHelper.toString(System.getProperties()), HttpServletResponse.SC_OK);
}
}
Aggregations