Package org.aspectj.lang.reflect

Examples of org.aspectj.lang.reflect.MethodSignature


   
    @Before("methodParameterWithPermissionRequired(permission, o)")
    public void enforcePermissionsOnParameter(JoinPoint joinPoint, Permission permission, Object o) throws PermissionDeniedException {
       
        //the next two lines can be replaced when this aspectj bug is closed - https://bugs.eclipse.org/bugs/show_bug.cgi?id=259416
        final MethodSignature ms = (MethodSignature)joinPoint.getSignature();
        final PermissionRequired parameterPermissionRequired = (PermissionRequired)ms.getMethod().getParameterAnnotations()[0][0];
       
        //1) check if we should allow DBA access
        if(((parameterPermissionRequired.user() & IS_DBA) == IS_DBA) && permission.isCurrentSubjectDBA()) {
            return;
        }
View Full Code Here


public class LogDebugInterceptor {
    @SuppressWarnings("finally")
    protected Method getMethod(JoinPoint jp) {
        Method invoked = null;
        try {
            final MethodSignature met = (MethodSignature) jp.getSignature();
            invoked = jp.getSourceLocation().getWithinType().getMethod(
                    met.getMethod().getName(),
                    met.getMethod().getParameterTypes());
        } catch (NoSuchMethodException e) {
            final Logger logger = this.getLog(jp);
            logger.debug("invoked: " + invoked);
        } finally {
            final Logger logger = this.getLog(jp);
View Full Code Here

        SourceLocation sl = mock(SourceLocation.class);
        when(sl.getFileName()).thenReturn("Test.java");
        when(sl.getLine()).thenReturn(100);
        when(sl.getWithinType()).thenReturn(this.getClass());
        when(staticPart.getSourceLocation()).thenReturn(sl);
        MethodSignature msig = mock(MethodSignature.class);
        when(staticPart.getSignature()).thenReturn(msig);
        when(jp.getStaticPart()).thenReturn(staticPart);

        // Db
        Operation op = MongoDbOperationCollectionAspect.aspectOf().createOperation(jp);
View Full Code Here

        try {
            StringBuilder sb = new StringBuilder(httpMethod).append(" ");
            final Path classPathAnnotation = pjp.getTarget().getClass().getAnnotation(Path.class);
            if (classPathAnnotation!=null)
                sb.append(classPathAnnotation.value());
            MethodSignature signature = (MethodSignature) pjp.getSignature();
            Method method = signature.getMethod();
            final Path methodPathAnnotation = method.getAnnotation(Path.class);
            if (methodPathAnnotation!=null)
                sb.append(methodPathAnnotation.value());
            NewRelic.setTransactionName(null, sb.toString());
        } catch (Throwable t) {
View Full Code Here

  //Match any public methods in a class annotated with @AutoValidating
  @Around("execution(public * *(..)) && @within(de.gmorling.methodvalidation.spring.AutoValidating)")
  public Object validateMethodInvocation(ProceedingJoinPoint pjp) throws Throwable {
    Object result;
    MethodSignature signature = (MethodSignature) pjp.getSignature();
    MethodValidator methodValidator = validator.unwrap( MethodValidator.class );

    Set<MethodConstraintViolation<Object>> parametersViolations = methodValidator.validateParameters(
        pjp.getTarget(), signature.getMethod(), pjp.getArgs()
    );
    if ( !parametersViolations.isEmpty() ) {
      throw new MethodConstraintViolationException( parametersViolations );
    }

    result =  pjp.proceed(); //Execute the method

    Set<MethodConstraintViolation<Object>> returnValueViolations = methodValidator.validateReturnValue(
        pjp.getTarget(), signature.getMethod(), result
    );
    if ( !returnValueViolations.isEmpty() ) {
      throw new MethodConstraintViolationException( returnValueViolations );
    }

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

    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

    return response;
  }

  private void executeResponseValidation(ProceedingJoinPoint pjp, Object response) {
    MethodSignature sig = (MethodSignature) pjp.getSignature();
    Method method = sig.getMethod();

    BeanValidator validator = null;
    for (Annotation respAnnotatioin : method.getDeclaredAnnotations()) {
      if (respAnnotatioin.annotationType().isAssignableFrom(NotNull.class)
          || (respAnnotatioin.annotationType().isAssignableFrom(Valid.class) && response != null)) {
View Full Code Here

    }
  }

  private void executeParamValidation(ProceedingJoinPoint pjp) {
    Object[] args = pjp.getArgs();
    MethodSignature sig = (MethodSignature) pjp.getSignature();
    Method method = sig.getMethod();
    Annotation[][] allParamAnnotations = method.getParameterAnnotations();

    BeanValidator validator = null;
    for (int paramIdx = 0; paramIdx < allParamAnnotations.length; paramIdx++) {
      Annotation[] paramAnnotations = allParamAnnotations[paramIdx];
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.