Search in sources :

Example 1 with AbstractBaseHttpServComponent

use of com.creditease.agent.spi.AbstractBaseHttpServComponent in project uavstack by uavorg.

the class HBClientDefaultHandler method getServiceURLs.

/**
 * get the node's http service url
 *
 * @return
 */
@SuppressWarnings("rawtypes")
private Map<String, String> getServiceURLs() {
    Set<Object> components = this.getConfigManager().getComponents();
    Map<String, String> services = new LinkedHashMap<String, String>();
    for (Object comp : components) {
        if (!AbstractBaseHttpServComponent.class.isAssignableFrom(comp.getClass())) {
            continue;
        }
        AbstractBaseHttpServComponent asc = (AbstractBaseHttpServComponent) comp;
        String compid = asc.getFeature() + "-" + asc.getName();
        String httpRootURL = asc.getHttpRootURL();
        List handlers = asc.getHandlers();
        for (Object handler : handlers) {
            if (!AbstractHttpHandler.class.isAssignableFrom(handler.getClass())) {
                continue;
            }
            AbstractHttpHandler abshandler = (AbstractHttpHandler) handler;
            String serviceId = compid + "-" + abshandler.getContextPath();
            String serviceHttpURL = httpRootURL + abshandler.getContextPath();
            services.put(serviceId, serviceHttpURL);
        }
    }
    return services;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) AbstractBaseHttpServComponent(com.creditease.agent.spi.AbstractBaseHttpServComponent) AbstractHttpHandler(com.creditease.agent.spi.AbstractHttpHandler)

Example 2 with AbstractBaseHttpServComponent

use of com.creditease.agent.spi.AbstractBaseHttpServComponent in project uavstack by uavorg.

the class MSCPPlusIT method onServiceEnd.

/**
 * onServiceEnd
 *
 * @param args
 */
@SuppressWarnings("rawtypes")
public void onServiceEnd(Object... args) {
    AbstractBaseHttpServComponent abhsc = (AbstractBaseHttpServComponent) args[0];
    HttpMessage message = (HttpMessage) args[1];
    String reqURL = abhsc.getHttpRootURL() + message.getContextPath();
    Map<String, Object> params = new HashMap<String, Object>();
    try {
        params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_REQUEST_URL, reqURL);
    } catch (Exception e) {
    }
    try {
        params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_SERVLET, reqURL);
    } catch (Exception e) {
    }
    try {
        params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT, "");
    } catch (Exception e) {
    }
    try {
        params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CONTEXT_REALPATH, "/" + System.getProperty("JAppID"));
    } catch (Exception e) {
    }
    try {
        params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_RESPONSECODE, message.getResponseCode());
    } catch (Exception e) {
    }
    try {
        params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_FORWARDADDR, message.getHeader("X-Forwarded-For"));
    } catch (Exception e) {
    }
    try {
        params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_LISTENPORT, System.getProperty("JAppOperPort"));
    } catch (Exception e) {
    }
    try {
        params.put(CaptureConstants.INFO_APPSERVER_CLIENT_USRAGENT, message.getHeader("User-Agent"));
    } catch (Exception e) {
    }
    try {
        params.put(CaptureConstants.INFO_APPSERVER_UAVCLIENT_TAG, message.getHeader("UAV-Client-Src"));
    } catch (Exception e) {
    }
    try {
        params.put(CaptureConstants.INFO_APPSERVER_PROXY_HOST, message.getHeader("Host"));
    } catch (Exception e) {
    }
    try {
        params.put(CaptureConstants.INFO_APPSERVER_CONNECTOR_CLIENTADDR, message.getClientAddress());
    } catch (Exception e) {
    }
    UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_SERVER_CONNECTOR, Monitor.CapturePhase.DOCAP, params);
}
Also used : HashMap(java.util.HashMap) HttpMessage(com.creditease.agent.spi.HttpMessage) AbstractBaseHttpServComponent(com.creditease.agent.spi.AbstractBaseHttpServComponent)

Aggregations

AbstractBaseHttpServComponent (com.creditease.agent.spi.AbstractBaseHttpServComponent)2 AbstractHttpHandler (com.creditease.agent.spi.AbstractHttpHandler)1 HttpMessage (com.creditease.agent.spi.HttpMessage)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1