Package org.aspectj.lang.reflect

Examples of org.aspectj.lang.reflect.MethodSignature


        //pointcut body, should be empty
    }

    @AfterReturning(pointcut = "anyMethod() && withAttachmentAnnotation()", returning = "result")
    public void attachment(JoinPoint joinPoint, Object result) {
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        Attachment attachment = methodSignature.getMethod().getAnnotation(Attachment.class);
        String attachTitle = AllureAspectUtils.getTitle(
                attachment.value(),
                methodSignature.getName(),
                joinPoint.getThis(),
                joinPoint.getArgs()
        );

        Charset charset = AllureConfig.newInstance().getAttachmentsEncoding();
View Full Code Here


   public void retry(ProceedingJoinPoint pjp) throws Throwable {
      logger.info("retry transaction");
      int retriesLeft = 5;
      String methodName = pjp.getSignature().getName();
      MethodSignature signature = (MethodSignature) pjp.getSignature();
      Method method = signature.getMethod();
      if(method.getDeclaringClass().isInterface()){
         method = pjp.getTarget().getClass().getDeclaredMethod(methodName, method.getParameterTypes());
      }
      Annotation[] annotations = method.getDeclaredAnnotations();
      for (Annotation a : annotations) {
View Full Code Here

      this.clusterEntityMgr = clusterEntityMgr;
   }

   @Around("@annotation(com.vmware.bdd.software.mgmt.plugin.aop.PreConfiguration)")
   public Object preClusterConfiguration(ProceedingJoinPoint pjp) throws Throwable {
      MethodSignature signature = (MethodSignature) pjp.getSignature();
      Method method = signature.getMethod();
      PreConfiguration beforeConfig = AnnotationUtils.findAnnotation(method, PreConfiguration.class);
      String nameParam = beforeConfig.clusterNameParam();
      String waitingTimeParam = beforeConfig.maxWaitingTimeParam();

      String[] paramNames = signature.getParameterNames();
      Object[] args = pjp.getArgs();
      String clusterName = null;
      int maxWaitingSeconds = 120;
      for (int i = 0; i < paramNames.length; i++) {
         if (paramNames[i].equals(nameParam)) {
View Full Code Here

     */
    @Around("anyPublicMethod() && @annotation(disconfFileItem)")
    public Object decideAccess(ProceedingJoinPoint pjp,
            DisconfFileItem disconfFileItem) throws Throwable {

        MethodSignature ms = (MethodSignature) pjp.getSignature();
        Method method = ms.getMethod();

        //
        // 文件名
        //
        Class<?> cls = method.getDeclaringClass();
View Full Code Here

        };
       
        boolean isVoidReturnType = false;
        final Signature signature = pjp.getStaticPart().getSignature();
        if (signature instanceof MethodSignature) {
            final MethodSignature methodSignature = (MethodSignature) signature;
            isVoidReturnType = (methodSignature != null) ? Void.TYPE.equals(methodSignature.getReturnType()) : false;
        }
       
        RetryInterceptor interceptor = null;
        if (isVoidReturnType) {
            interceptor = new RetryInterceptorVoid(retryCallable, retryPolicy);
View Full Code Here

   * @throws Throwable
   */
  public Object intercept(ProceedingJoinPoint joinPoint) throws Throwable {

    // extract MethodSignature
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    logger.debug("Intercepted a method call on " + methodSignature.toString());

    // find the RateLimited annotation, method gets priority over class
    RateLimited annotation = methodSignature.getMethod().getAnnotation(RateLimited.class);
    if (annotation == null) {
      annotation = (RateLimited) joinPoint.getSourceLocation().getWithinType().getAnnotation(RateLimited.class);
    }

    // resolve method group name based on the methodGrouping in the annotation
    String methodGroupName = null;
    switch (annotation.methodGrouping()) {
    case GROUPED:
      methodGroupName = annotation.groupName();
      break;
    case UNGROUPED:
      methodGroupName = methodSignature.toString();
      break;
    default:
      methodGroupName = methodSignature.toString();
      break;
    }

    // get the limiter strategy chain from the spring context
    AbstractLimiterStrategy limiterStrategyChain = (AbstractLimiterStrategy) applicationContext.getBean(annotation.limiterBean());

    // generate a uuid to be used later on if rollback is required
    UUID methodInvocationUUID = UUIDGenerator.generateUUID();

    // run through the limiter strategy chain and get the conclusion
    LimiterStrategyConclusion conclusion = limiterStrategyChain.hasLimitBeenExceededChain(methodGroupName, methodInvocationUUID,
        joinPoint.getArgs());

    // if limit is not exceeded call the method and do a post invocation clean up where needed
    if (!conclusion.getHasLimitBeenExceeded()) {
      logger.trace("About to run method " + methodSignature.toString());
      try {
        Object obj = joinPoint.proceed(joinPoint.getArgs());
        logger.trace("Finished running " + methodSignature.toString());
        return obj;
      } catch (Throwable t) {
        logger.debug("Method " + methodSignature.toString() + " did not exit gracefully. " + t);
        throw t;
      } finally {
        limiterStrategyChain.postInvocationCleanupChain(methodGroupName, methodInvocationUUID, joinPoint.getArgs());
      }
    }
View Full Code Here

        final Object[] input = joinPoint.getArgs();

        final String category = clazz.getSimpleName();

        final MethodSignature ms = (MethodSignature) joinPoint.getSignature();
        Method method = ms.getMethod();

        final String event = joinPoint.getSignature().getName();

        AuditElements.Result result = null;
        Object output = null;
View Full Code Here

    private boolean isVoidReturnType(final ProceedingJoinPoint pjp) {
        boolean isVoidReturnType = false;
        final Signature signature = pjp.getStaticPart().getSignature();
        if (signature instanceof MethodSignature) {
            final MethodSignature methodSignature = (MethodSignature) signature;
            isVoidReturnType = (methodSignature != null) ? Void.TYPE.equals(methodSignature.getReturnType()) : false;
        }
        return isVoidReturnType;
    }
View Full Code Here

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Around("call(@com.amazonaws.services.simpleworkflow.flow.annotations.Asynchronous * *(..)) && @annotation(asynchronousAnnotation)")
    public Object makeAsynchronous(ProceedingJoinPoint pjp, Asynchronous asynchronousAnnotation) throws Throwable {
        final Signature signature = pjp.getStaticPart().getSignature();
        if (signature instanceof MethodSignature) {
            final MethodSignature methodSignature = (MethodSignature) signature;
            int i = 0;
            Object[] methodArguments = pjp.getArgs();
            Annotation[][] parameterAnnotations = methodSignature.getMethod().getParameterAnnotations();
            List<Promise> valueParams = new ArrayList<Promise>();
            for (final Class<?> parameterType : methodSignature.getParameterTypes()) {
                if ((isPromise(parameterType) || isPromiseArray(parameterType) || (isCollection(parameterType) && hasWaitAnnotation(parameterAnnotations[i])))
                        && !hasNoWaitAnnotation(parameterAnnotations[i])) {
                    Object param = methodArguments[i];
                    if (isPromise(parameterType)) {
                        valueParams.add((Promise) param);
View Full Code Here

    public void synchronizePointcut() {
    }

    @Around("synchronizePointcut()")
    public Object synchronizeInvocation(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        MethodSignature methodSignature = (MethodSignature) proceedingJoinPoint.getSignature();
        Method method = methodSignature.getMethod();
        Object target = proceedingJoinPoint.getTarget();
        Object[] args = proceedingJoinPoint.getArgs();
        Class<?> targetClass = AopProxyUtils.ultimateTargetClass(target);
        Synchronized annotation = getAnnotation(targetClass, method);
        Validate.notNull(annotation, "Could not find @Synchronized annotation!");
View Full Code Here

TOP

Related Classes of org.aspectj.lang.reflect.MethodSignature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.