List of usage examples for org.aspectj.lang.reflect PerClauseKind PERCFLOW
PerClauseKind PERCFLOW
To view the source code for org.aspectj.lang.reflect PerClauseKind PERCFLOW.
Click Source Link
From source file:org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.java
License:Apache License
@Override public void validate(Class<?> aspectClass) throws AopConfigException { // If the parent has the annotation and isn't abstract it's an error if (aspectClass.getSuperclass().getAnnotation(Aspect.class) != null && !Modifier.isAbstract(aspectClass.getSuperclass().getModifiers())) { throw new AopConfigException("[" + aspectClass.getName() + "] cannot extend concrete aspect [" + aspectClass.getSuperclass().getName() + "]"); }//from w ww . j a va 2s .co m AjType<?> ajType = AjTypeSystem.getAjType(aspectClass); if (!ajType.isAspect()) { throw new NotAnAtAspectException(aspectClass); } if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOW) { throw new AopConfigException(aspectClass.getName() + " uses percflow instantiation model: " + "This is not supported in Spring AOP."); } if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOWBELOW) { throw new AopConfigException(aspectClass.getName() + " uses percflowbelow instantiation model: " + "This is not supported in Spring AOP."); } }
From source file:org.springframework.ide.eclipse.aop.core.internal.model.builder.AnnotationAspectDefinitionBuilder.java
License:Open Source License
private boolean validateAspect(String className) throws Throwable { ClassReader classReader = getClassReader(className); if (classReader == null) { return false; }//from w ww . ja v a 2 s . c om AspectAnnotationVisitor v = new AspectAnnotationVisitor(); classReader.accept(v, 0); if (!v.getClassInfo().hasAspectAnnotation()) { return false; } else { // we know it's an aspect, but we don't know whether it is an // @AspectJ aspect or a code style aspect. // This is an *unclean* test whilst waiting for AspectJ to // provide us with something better for (String m : v.getClassInfo().getMethodNames()) { if (m.startsWith(AJC_MAGIC)) { // must be a code style aspect return false; } } // validate supported instantiation models if (v.getClassInfo().getAspectAnnotation().getValue() != null) { if (v.getClassInfo().getAspectAnnotation().getValue().toUpperCase() .equals(PerClauseKind.PERCFLOW.toString())) { return false; } if (v.getClassInfo().getAspectAnnotation().getValue().toUpperCase().toString() .equals(PerClauseKind.PERCFLOWBELOW.toString())) { return false; } } // check if super class is Aspect as well and abstract if (v.getClassInfo().getSuperType() != null) { classReader = getClassReader(v.getClassInfo().getSuperType()); if (classReader == null) { return false; } AspectAnnotationVisitor sv = new AspectAnnotationVisitor(); classReader.accept(sv, 0); if (sv.getClassInfo().getAspectAnnotation() != null && !((sv.getClassInfo().getModifier() & Opcodes.ACC_ABSTRACT) != 0)) { return false; } } return true; } }