Search in sources :

Example 1 with HessianServiceExporter

use of org.springframework.remoting.caucho.HessianServiceExporter in project LinkAgent by shulieTech.

the class HessianServiceExporterHandleRequestInterceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    Object target = advice.getTarget();
    if (args == null || args.length == 0) {
        return null;
    }
    if (!(args[0] instanceof HttpServletRequest)) {
        if (Pradar.isClusterTest()) {
            throw new PressureMeasureError("hessian servlet trace err! can't cast to HttpServletRequest");
        }
        return null;
    }
    WrapperRequest request = (WrapperRequest) args[0];
    if (!request.getMethod().equals("POST") && !request.getMethod().equals("post")) {
        return null;
    }
    String method = request.getHeader(HessianConstants.METHOD_HEADER);
    if (method != null && isSkip(method)) {
        return null;
    }
    HessianServiceExporter serviceExporter = (HessianServiceExporter) target;
    HessianSkeleton hessianSkeleton = null;
    try {
        hessianSkeleton = Reflect.on(serviceExporter).get(HessianConstants.DYNAMIC_FIELD_OBJECT_SKELETON);
    } catch (ReflectException e) {
    }
    SerializerFactory serializerFactory = null;
    try {
        serializerFactory = Reflect.on(serviceExporter).get(HessianConstants.DYNAMIC_FIELD_SERIALIZER_FACTORY);
    } catch (ReflectException e) {
    }
    Object[] result = getMethodArgs(request.getInputStream(), serializerFactory, hessianSkeleton);
    Object[] arguments = (Object[]) result[1];
    if (method == null) {
        method = (String) result[0];
    }
    Class<?> clazz = serviceExporter.getServiceInterface();
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setService(clazz.getName());
    spanRecord.setMethod(method);
    spanRecord.setRequest(arguments);
    return spanRecord;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) WrapperRequest(com.pamirs.attach.plugin.hessian.common.WrapperRequest) HessianSkeleton(com.caucho.hessian.server.HessianSkeleton) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException) HessianServiceExporter(org.springframework.remoting.caucho.HessianServiceExporter)

Example 2 with HessianServiceExporter

use of org.springframework.remoting.caucho.HessianServiceExporter in project tutorials by eugenp.

the class Server method hessianService.

@Bean(name = "/booking")
RemoteExporter hessianService(CabBookingService service) {
    HessianServiceExporter exporter = new HessianServiceExporter();
    exporter.setService(bookingService());
    exporter.setServiceInterface(CabBookingService.class);
    return exporter;
}
Also used : HessianServiceExporter(org.springframework.remoting.caucho.HessianServiceExporter) Bean(org.springframework.context.annotation.Bean)

Aggregations

HessianServiceExporter (org.springframework.remoting.caucho.HessianServiceExporter)2 HessianSkeleton (com.caucho.hessian.server.HessianSkeleton)1 WrapperRequest (com.pamirs.attach.plugin.hessian.common.WrapperRequest)1 PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)1 SpanRecord (com.pamirs.pradar.interceptor.SpanRecord)1 ReflectException (com.shulie.instrument.simulator.api.reflect.ReflectException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Bean (org.springframework.context.annotation.Bean)1