Я попытался создать класс, реализующий условие и, следовательно, метод match(), который позволил бы мне выполнить необходима проверка и установите для вывода соответствующее логическое значение, включив или отключив его.
Код: Выделить всё
@Aspect
@Component
@Conditional(AuthFilterCondition.class)
public class AuthTokenFilter {
@Before("@annotation(org.company.annotations.ValidateAuthToken)")
public void doBefore(JoinPoint joinPoint) {
System.out.println("Loading auth token filter");
}
}
Код: Выделить всё
public class AuthFilterCondition implements Condition {
private static final String IS_AUTH_FILTER_FEATURE_ENABLED = "org.company.load.auth.filter";
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
return (context.getEnvironment().getProperty(IS_AUTH_FILTER_FEATURE_ENABLED).equalsIgnoreCase("true"));
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... -executing
Мобильная версия