Spring AOP: Around Advice: Zugriff auf Annotation

aze

Bekanntes Mitglied
Hi

Ich habe folgenden Code:

Java:
import org.apache.commons.lang.ArrayUtils;

import org.aspectj.lang.ProceedingJoinPoint;

import org.aspectj.lang.annotation.Around;

import org.aspectj.lang.annotation.Aspect;





@Aspect

public class SecurityAdvice

{



	

	

	

	@Around("execution(@Deny * (@SafetyCritical *).*(..))")

	public Object translateExceptionsDeny(ProceedingJoinPoint pjp /*,Deny deny*/ ) throws Throwable

	{

		Account account = (Account) pjp.getArgs()[0];

		

		/*if (ArrayUtils.contains(deny.value(), account.getRole()))

		{

			throw new IllegalAccessException("");

		}*/

		return pjp.proceed();

		

	}



	@Around("execution(@Allow * (@SafetyCritical *).*(..))")

	public Object translateExceptionsAllow(ProceedingJoinPoint pjp/*, Allow allow*/) throws Throwable

	{

		Account account = (Account) pjp.getArgs()[0];

		/*if (!ArrayUtils.contains(allow.value(), account.getRole()))

		{

			throw new IllegalAccessException("");

		}*/

		return pjp.proceed();

	}

}

Nun möchte ich den auskommentierten Code ausführen.Es kommt folgender Fehler:

Java:
error at ::0 formal unbound in pointcut

wie kann ich innerhalb der Methoden auf die Annotation zugreifen ?
 
Hi

icjh habe es. Der Code war schon korrekt . Die Namen der Annotationen müssen aber klein geschrieben werden. Also @annotation(deny) statt @annotation(Deny).
 

Zurück
Oben