Skip to content

Instantly share code, notes, and snippets.

@nattaphonjeamjit
Created April 8, 2018 16:42
Show Gist options
  • Save nattaphonjeamjit/653130f23fe22845b2878f371eb0b1aa to your computer and use it in GitHub Desktop.
Save nattaphonjeamjit/653130f23fe22845b2878f371eb0b1aa to your computer and use it in GitHub Desktop.
@Aspect
@Component
public class FeaturesAspect {
private static final Logger LOG = Logger.getLogger(FeaturesAspect.class);
@Around(value = "@within(featureSwitch) || @annotation(featureSwitch)")
public Object checkAspect(ProceedingJoinPoint joinPoint, FeatureSwitch featureSwitch) throws Throwable {
if (featureSwitch.value().isActive()) {
LOG.info("Feature " + featureSwitch.value().name() + " is Open");
return joinPoint.proceed();
} else {
LOG.info("Feature " + featureSwitch.value().name() + " is Close");
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment