use of org.aspectj.lang.reflect.MethodSignature in project bamboobsc by billchen198318.
the class ServiceScriptExpressionProcessAspect method logicServiceProcess.
@Around(AspectConstants.LOGIC_SERVICE_PACKAGE)
public Object logicServiceProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable {
Annotation[] annotations = pjp.getTarget().getClass().getAnnotations();
MethodSignature signature = (MethodSignature) pjp.getSignature();
if (annotations == null || annotations.length < 1) {
return pjp.proceed();
}
String beanId = AspectConstants.getServiceId(annotations);
/**
* 如果是Hession proxy 代理, 讓 remote-server 端處理, 這裡如果是client端就不需要, 要不然會倍加工兩次, remote-server一次, client端一次
*/
if (GreenStepHessianUtils.isEnableCallRemote() && GreenStepHessianUtils.isProxyServiceId(beanId)) {
return pjp.proceed();
}
if (StringUtils.isBlank(beanId)) {
return pjp.proceed();
}
if (!ServiceScriptExpressionUtils.needProcess(beanId, signature.getMethod().getName(), Constants.getSystem())) {
return pjp.proceed();
}
Method method = signature.getMethod();
ServiceScriptExpressionUtils.processBefore(beanId, signature.getMethod(), Constants.getSystem(), pjp);
Object obj = pjp.proceed();
ServiceScriptExpressionUtils.processAfter(beanId, method, Constants.getSystem(), obj, pjp);
return obj;
}
use of org.aspectj.lang.reflect.MethodSignature in project paascloud-master by paascloud.
the class MqConsumerStoreAspect method getAnnotation.
private MqConsumerStore getAnnotation(JoinPoint joinPoint) {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
return method.getAnnotation(MqConsumerStore.class);
}
use of org.aspectj.lang.reflect.MethodSignature in project Hystrix by Netflix.
the class AopUtils method getMethodFromTarget.
/**
* Gets a {@link Method} object from target object (not proxy class).
*
* @param joinPoint the {@link JoinPoint}
* @return a {@link Method} object or null if method doesn't exist or if the signature at a join point
* isn't sub-type of {@link MethodSignature}
*/
public static Method getMethodFromTarget(JoinPoint joinPoint) {
Method method = null;
if (joinPoint.getSignature() instanceof MethodSignature) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
method = getDeclaredMethod(joinPoint.getTarget().getClass(), signature.getName(), getParameterTypes(joinPoint));
}
return method;
}
use of org.aspectj.lang.reflect.MethodSignature in project incubator-servicecomb-java-chassis by apache.
the class ZipkinSpanAspect method advise.
@Around("execution(@org.apache.servicecomb.tracing.Span * *(..)) && @annotation(spanAnnotation)")
public Object advise(ProceedingJoinPoint joinPoint, Span spanAnnotation) throws Throwable {
String spanName = spanAnnotation.spanName();
String callPath = spanAnnotation.callPath();
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
LOG.debug("Generating zipkin span for method {}", method.toString());
if ("".equals(spanName)) {
spanName = method.getName();
}
if ("".equals(callPath)) {
callPath = method.toString();
}
return adviser.invoke(spanName, callPath, joinPoint::proceed);
}
use of org.aspectj.lang.reflect.MethodSignature in project Corgi by kevinYin.
the class AdminLoggerAspect method getJointPointParam.
/**
* 获取连接点对应方法的请求参数列表(参数名-参数值)
*
* @param jp
* - 切面连接点
* @return
* @throws IllegalAccessException
* @throws IllegalArgumentException
*/
public static Map<String, Object> getJointPointParam(JoinPoint jp) throws IllegalArgumentException, IllegalAccessException {
MethodSignature ms = (MethodSignature) jp.getSignature();
Method method = ms.getMethod();
List<Class<?>> paramTypes = Arrays.asList(method.getParameterTypes());
List<String> paramNames = getMethodParamNames(method);
Object[] args = jp.getArgs();
int size = paramNames.size();
int length = args.length;
Map<String, Object> params = new HashMap<String, Object>();
for (int i = 0; i < size && i < length; i++) {
Class<?> clazz = paramTypes.get(i);
String name = paramNames.get(i);
Object value = args[i];
if (isJavaClass(clazz)) {
params.put(name, value);
} else {
if ((value instanceof HttpServletResponse)) {
continue;
}
Map<String, Object> param = getClassAttrValueMap(clazz, name, value);
params.putAll(param);
}
}
return params;
}
Aggregations