togglz aspect (#1743)

* togglz aspect

* formatting

* trigger travis build
This commit is contained in:
lor6
2017-04-30 11:39:11 +03:00
committed by Grzegorz Piwowarek
parent b9484b244b
commit 0735c03154
12 changed files with 325 additions and 0 deletions
@@ -0,0 +1,27 @@
package com.baeldung.toggle;
import org.apache.log4j.Logger;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class FeaturesAspect {
private static final Logger LOG = Logger.getLogger(FeaturesAspect.class);
@Around(value = "@within(featureAssociation) || @annotation(featureAssociation)")
public Object checkAspect(ProceedingJoinPoint joinPoint, FeatureAssociation featureAssociation) throws Throwable {
if (featureAssociation.value()
.isActive()) {
return joinPoint.proceed();
} else {
LOG.info("Feature " + featureAssociation.value()
.name() + " is not enabled!");
return null;
}
}
}