use of com.shulie.instrument.simulator.api.reflect.ReflectException in project LinkAgent by shulieTech.
the class MapperBuilderAssistantUseNewCacheInterceptor method doAfter.
@Override
public void doAfter(Advice advice) {
String currentNamespace = null;
try {
currentNamespace = Reflect.on(advice.getTarget()).get(MybatisConstants.DYNAMIC_FIELD_CURRENT_NAMESPACE);
} catch (ReflectException e) {
currentNamespace = manager.getDynamicField(advice.getTarget(), MybatisConstants.DYNAMIC_FIELD_CURRENT_NAMESPACE);
}
Object[] args = advice.getParameterArray();
Class<? extends Cache> typeClass = (Class<? extends Cache>) args[0];
Class<? extends Cache> evictionClass = (Class<? extends Cache>) args[1];
Long flushInterval = (Long) args[2];
Integer size = (Integer) args[3];
boolean readWrite = (Boolean) args[4];
boolean blocking = (Boolean) args[5];
Properties props = (Properties) args[6];
Cache ptCache = initPtCache(Pradar.CLUSTER_TEST_PREFIX + currentNamespace, typeClass, evictionClass, flushInterval, size, readWrite, blocking, props);
MybatisConstants.currentName2PtCacheMap.put(currentNamespace, ptCache);
}
use of com.shulie.instrument.simulator.api.reflect.ReflectException in project LinkAgent by shulieTech.
the class BurlapServletServiceInterceptor 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);
BurlapServlet burlapServlet = (BurlapServlet) target;
BurlapSkeleton hessianSkeleton = null;
try {
hessianSkeleton = Reflect.on(burlapServlet).get(HessianConstants.DYNAMIC_FIELD_SKELETON);
} catch (ReflectException e) {
}
Object[] result = getMethodArgs(request.getInputStream(), hessianSkeleton);
Object[] arguments = (Object[]) result[1];
if (method == null) {
method = (String) result[0];
}
Class<?> clazz = null;
try {
clazz = Reflect.on(burlapServlet).get(HessianConstants.DYNAMIC_FIELD_TYPE);
} catch (ReflectException e) {
}
SpanRecord spanRecord = new SpanRecord();
spanRecord.setService(clazz == null ? null : clazz.getName());
spanRecord.setMethod(method);
spanRecord.setRequest(arguments);
spanRecord.setPort(request.getRemotePort());
return spanRecord;
}
use of com.shulie.instrument.simulator.api.reflect.ReflectException in project LinkAgent by shulieTech.
the class BurlapServletServiceInterceptor method getMethodArgs.
public Object[] getMethodArgs(InputStream is, BurlapSkeleton burlapSkeleton) {
try {
BurlapInput in = new BurlapInput(is);
HessianInputFactory.HeaderType header = _inputFactory.readHeader(is);
while ((in.readHeader()) != null) {
in.readObject();
}
String methodName = in.readMethod();
int argLength = in.readMethodArgLength();
Method method = null;
try {
Map map = Reflect.on(burlapSkeleton).get(HessianConstants.DYNAMIC_FIELD_METHOD_MAP);
method = (Method) map.get(methodName + "__" + argLength);
} catch (ReflectException e) {
}
if (method != null) {
} else if ("_hessian_getAttribute".equals(methodName)) {
String attrName = in.readString();
in.completeCall();
} else if (method == null) {
}
Class<?>[] args = method.getParameterTypes();
if (argLength != args.length && argLength >= 0) {
return null;
}
Object[] values = new Object[args.length];
for (int i = 0; i < args.length; i++) {
values[i] = in.readObject(args[i]);
}
in.completeCall();
return new Object[] { methodName, args };
} catch (IOException e) {
return EMPTY_ARGS;
}
}
use of com.shulie.instrument.simulator.api.reflect.ReflectException in project LinkAgent by shulieTech.
the class HessianServiceExporterHandleRequestInterceptor method getMethodArgs.
public Object[] getMethodArgs(InputStream is, SerializerFactory serializerFactory, HessianSkeleton hessianSkeleton) {
try {
InputStream isToUse = is;
if (!isToUse.markSupported()) {
isToUse = new BufferedInputStream(isToUse);
isToUse.mark(1);
}
int code = isToUse.read();
int major;
int minor;
AbstractHessianInput in;
AbstractHessianOutput out;
if (code == 'H') {
// Hessian 2.0 stream
major = isToUse.read();
minor = isToUse.read();
if (major != 0x02) {
throw new IOException("Version " + major + "." + minor + " is not understood");
}
in = new Hessian2Input(isToUse);
in.readCall();
} else if (code == 'C') {
// Hessian 2.0 call... for some reason not handled in HessianServlet!
isToUse.reset();
in = new Hessian2Input(isToUse);
in.readCall();
} else if (code == 'c') {
// Hessian 1.0 call
major = isToUse.read();
minor = isToUse.read();
in = new HessianInput(isToUse);
} else {
throw new IOException("Expected 'H'/'C' (Hessian 2.0) or 'c' (Hessian 1.0) in hessian input at " + code);
}
in.setSerializerFactory(serializerFactory);
in.skipOptionalCall();
while ((in.readHeader()) != null) {
in.readObject();
}
String methodName = in.readMethod();
int argLength = in.readMethodArgLength();
Method method = null;
if (hessianSkeleton != null) {
try {
Map map = Reflect.on(hessianSkeleton).get(HessianConstants.DYNAMIC_FIELD_METHOD_MAP);
method = (Method) map.get(methodName + "__" + argLength);
} catch (ReflectException e) {
}
}
if ("_hessian_getAttribute".equals(methodName)) {
String attrName = in.readString();
in.completeCall();
return new Object[] { "_hessian_getAttribute", new Object[0] };
}
Class<?>[] args = method == null ? null : method.getParameterTypes();
if (args == null || (argLength != args.length && argLength >= 0)) {
return EMPTY_ARGS;
}
Object[] values = new Object[args.length];
for (int i = 0; i < args.length; i++) {
values[i] = in.readObject(args[i]);
}
in.completeCall();
return new Object[] { methodName, args };
} catch (IOException e) {
return EMPTY_ARGS;
}
}
use of com.shulie.instrument.simulator.api.reflect.ReflectException in project LinkAgent by shulieTech.
the class HessianServletServiceInterceptor 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);
HessianServlet hessianServlet = (HessianServlet) target;
String objectId = request.getParameter("id");
if (objectId == null) {
objectId = request.getParameter("ejbid");
}
HessianSkeleton hessianSkeleton = null;
try {
hessianSkeleton = Reflect.on(hessianServlet).get(HessianConstants.DYNAMIC_FIELD_OBJECT_SKELETON);
} catch (ReflectException e) {
try {
hessianSkeleton = Reflect.on(hessianServlet).get(HessianConstants.DYNAMIC_FIELD_HOME_SKELETON);
} catch (ReflectException reflectException) {
}
}
Object[] result = getMethodArgs(request.getInputStream(), hessianServlet.getSerializerFactory(), hessianSkeleton);
Object[] arguments = (Object[]) result[1];
if (method == null) {
method = (String) result[0];
}
Class<?> clazz = hessianServlet.getAPIClass();
SpanRecord spanRecord = new SpanRecord();
spanRecord.setService(clazz.getName());
spanRecord.setMethod(method);
spanRecord.setRequest(arguments);
return spanRecord;
}
Aggregations