Skip to content

Instantly share code, notes, and snippets.

@hlassiege
Created July 1, 2014 16:21
Show Gist options
  • Save hlassiege/b1bc3810e2ac3fd7d8a4 to your computer and use it in GitHub Desktop.
Save hlassiege/b1bc3810e2ac3fd7d8a4 to your computer and use it in GitHub Desktop.
Conditional
public class HopSearchEnabledCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
PropertyResolver resolver = conditionContext.getEnvironment();
// renvoie toujours null, les propriétés ne sont jamais résolus
return "true".equalsIgnoreCase(resolver.getProperty("hopsearch.enabled"));
}
}
@Service
@Conditional(HopSearchDisabledCondition.class)
public class MockHopSearch {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment