Search in sources :

Example 1 with JDKProxyInvokeHandler

use of com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler in project uavstack by uavorg.

the class RocketmqIT method doBefore.

public Object doBefore(Object mqClient, String methodName, Object[] args) {
    String address = getServerAddr(mqClient);
    String topic = getTopic(mqClient, methodName, args);
    String url = address + (null == topic ? "" : "/" + topic);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, url);
    params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, methodName);
    params.put(CaptureConstants.INFO_CLIENT_APPID, applicationId);
    params.put(CaptureConstants.INFO_CLIENT_TYPE, "rocketmq.client");
    if (logger.isDebugable()) {
        logger.debug("Invoke START:" + url + ",op=" + methodName, null);
    }
    // proxy the PullCallback
    if (methodName.equals("pull")) {
        PullCallback callback = null;
        if (PullCallback.class.isAssignableFrom(args[args.length - 1].getClass())) {
            callback = (PullCallback) args[args.length - 1];
        } else if (PullCallback.class.isAssignableFrom(args[args.length - 1].getClass())) {
            callback = (PullCallback) args[args.length - 2];
        }
        if (null != callback) {
            callback = JDKProxyInvokeUtil.newProxyInstance(PullCallback.class.getClassLoader(), new Class<?>[] { PullCallback.class }, new JDKProxyInvokeHandler<PullCallback>(callback, new PullCallbackProxyProcessor()));
            ccMap = UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, Monitor.CapturePhase.PRECAP, params, ccMap);
            // ivc
            ivcContext = captureInvokeChain(RocketMQPullConsumerAdapter.class, InvokeChainConstants.CapturePhase.PRECAP, params, args);
            return callback;
        }
    }
    UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, Monitor.CapturePhase.PRECAP, params);
    if (methodName.startsWith("send")) {
        // ivc
        ivcContext = captureInvokeChain(RocketMQProducerAdapter.class, InvokeChainConstants.CapturePhase.PRECAP, params, args);
    }
    return null;
}
Also used : PullCallback(com.alibaba.rocketmq.client.consumer.PullCallback) RocketMQPullConsumerAdapter(com.creditease.uav.hook.rocketmq.adapter.RocketMQPullConsumerAdapter) HashMap(java.util.HashMap) JDKProxyInvokeHandler(com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler) RocketMQProducerAdapter(com.creditease.uav.hook.rocketmq.adapter.RocketMQProducerAdapter)

Example 2 with JDKProxyInvokeHandler

use of com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler in project uavstack by uavorg.

the class ApacheAsyncHttpClientIT method doAsyncEnd.

/**
 * for async http client
 *
 * @param args
 * @return
 */
@SuppressWarnings({ "rawtypes" })
public Future doAsyncEnd(Object[] args) {
    Future f = (Future) args[0];
    f = JDKProxyInvokeUtil.newProxyInstance(HttpContext.class.getClassLoader(), new Class<?>[] { Future.class }, new JDKProxyInvokeHandler<Future>(f, new FutureProxyInvokeProcessor(ccMap4Chain)));
    return f;
}
Also used : JDKProxyInvokeHandler(com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler) Future(java.util.concurrent.Future)

Example 3 with JDKProxyInvokeHandler

use of com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler in project uavstack by uavorg.

the class JdbcDriverIT method doAsyncProxyConnection.

@SuppressWarnings("rawtypes")
public Future doAsyncProxyConnection(Object res) {
    Future f = (Future) res;
    f = JDKProxyInvokeUtil.newProxyInstance(this.getClass().getClassLoader(), new Class<?>[] { Future.class }, new JDKProxyInvokeHandler<Future>(f, new FutureProxyInvokeProcessor()));
    return f;
}
Also used : JDKProxyInvokeHandler(com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler) Future(java.util.concurrent.Future)

Example 4 with JDKProxyInvokeHandler

use of com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler in project uavstack by uavorg.

the class JaxWSCxfHookIT method create.

@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T create(T t, ClientFactoryBean clientFactoryBean) {
    Binding binding = ((BindingProvider) t).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);
    String wsdlLocation = clientFactoryBean.getAddress();
    T tProxy = JDKProxyInvokeUtil.newProxyInstance(clientFactoryBean.getServiceClass().getClassLoader(), new Class[] { clientFactoryBean.getServiceClass() }, new JDKProxyInvokeHandler<T>(t, new ClientStubProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
Also used : Binding(javax.xml.ws.Binding) Handler(javax.xml.ws.handler.Handler) JDKProxyInvokeHandler(com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler) BindingProvider(javax.xml.ws.BindingProvider)

Example 5 with JDKProxyInvokeHandler

use of com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler in project uavstack by uavorg.

the class JaxWSHookIT method getPort.

/**
 * this is for Client Stub Programming
 *
 * @param t
 * @param s
 * @param args
 * @return
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T getPort(T t, Service s, Object[] args) {
    if (JDKProxyInvokeUtil.isJDKProxy(t)) {
        return t;
    }
    Class<T> clz = null;
    if (Class.class.isAssignableFrom(args[0].getClass())) {
        clz = (Class<T>) args[0];
    } else if (Class.class.isAssignableFrom(args[1].getClass())) {
        clz = (Class<T>) args[1];
    }
    if (clz == null) {
        return t;
    }
    Binding binding = ((BindingProvider) t).getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(this.handler);
    binding.setHandlerChain(handlerChain);
    final String wsdlLocation = getServiceURL(s);
    T tProxy = JDKProxyInvokeUtil.newProxyInstance(clz.getClassLoader(), new Class[] { clz }, new JDKProxyInvokeHandler<T>(t, new ClientStubProcessor(wsdlLocation.toString(), this.handler)));
    return tProxy;
}
Also used : Binding(javax.xml.ws.Binding) SOAPHandler(javax.xml.ws.handler.soap.SOAPHandler) Handler(javax.xml.ws.handler.Handler) JDKProxyInvokeHandler(com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler) BindingProvider(javax.xml.ws.BindingProvider)

Aggregations

JDKProxyInvokeHandler (com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler)11 HashMap (java.util.HashMap)3 Binding (javax.xml.ws.Binding)3 BindingProvider (javax.xml.ws.BindingProvider)3 Handler (javax.xml.ws.handler.Handler)3 DynamicServletContextProcessor (com.creditease.monitor.jee.servlet30.DynamicServletContextProcessor)2 Future (java.util.concurrent.Future)2 ServletContext (javax.servlet.ServletContext)2 SOAPHandler (javax.xml.ws.handler.soap.SOAPHandler)2 PullCallback (com.alibaba.rocketmq.client.consumer.PullCallback)1 RocketMQProducerAdapter (com.creditease.uav.hook.rocketmq.adapter.RocketMQProducerAdapter)1 RocketMQPullConsumerAdapter (com.creditease.uav.hook.rocketmq.adapter.RocketMQPullConsumerAdapter)1 IOException (java.io.IOException)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 Map (java.util.Map)1 ServletContextEvent (javax.servlet.ServletContextEvent)1 Dispatch (javax.xml.ws.Dispatch)1 HttpException (org.apache.http.HttpException)1 HttpRequest (org.apache.http.HttpRequest)1 RequestLine (org.apache.http.RequestLine)1