Last active
September 28, 2016 07:35
-
-
Save jagedn/2cc530514c57dd67d3142dd87e56b135 to your computer and use it in GitHub Desktop.
Listener from cloud configuration changes and do something
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
@ConfigurationProperties(prefix="authorization") | |
class CloudConfiguration { | |
String secretKey | |
boolean dirty = true | |
@Autowired | |
SignedJwtTokenGenerator tokenGenerator | |
@EventListener | |
public void handleContextRefresh(ApplicationEvent event) { | |
if( event instanceof EnvironmentChangeEvent) { | |
dirty = event.keys.find { it == 'authorization.secretKey' } | |
} | |
if( event instanceof RefreshScopeRefreshedEvent && dirty ) { | |
println "secretKey has been updated, refresh tokenGenerator " | |
tokenGenerator.jwtSecret = secretKey | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment