Search in sources :

Example 6 with MethodSignature

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;
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) Around(org.aspectj.lang.annotation.Around)

Example 7 with MethodSignature

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);
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) Method(java.lang.reflect.Method)

Example 8 with MethodSignature

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;
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) Method(java.lang.reflect.Method)

Example 9 with MethodSignature

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);
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) Method(java.lang.reflect.Method) Around(org.aspectj.lang.annotation.Around)

Example 10 with MethodSignature

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;
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) HttpServletResponse(javax.servlet.http.HttpServletResponse) Method(java.lang.reflect.Method) JoinPoint(org.aspectj.lang.JoinPoint)

Aggregations

MethodSignature (org.aspectj.lang.reflect.MethodSignature)116 Method (java.lang.reflect.Method)95 Around (org.aspectj.lang.annotation.Around)43 JoinPoint (org.aspectj.lang.JoinPoint)30 AccessDeniedException (org.springframework.security.access.AccessDeniedException)26 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)25 Test (org.junit.Test)25 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)24 SecurityUserWrapper (org.finra.herd.model.dto.SecurityUserWrapper)22 ApplicationUser (org.finra.herd.model.dto.ApplicationUser)21 NamespaceAuthorization (org.finra.herd.model.api.xml.NamespaceAuthorization)14 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)13 Signature (org.aspectj.lang.Signature)13 Annotation (java.lang.annotation.Annotation)10 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)2 List (java.util.List)2 Tick (mysh.util.Tick)2 Ignite (org.apache.ignite.Ignite)2