use of io.gravitee.rest.api.services.dynamicproperties.provider.http.HttpProvider in project gravitee-management-rest-api by gravitee-io.
the class DynamicPropertiesService method startDynamicProperties.
private void startDynamicProperties(ApiEntity api) {
if (api.getState() == Lifecycle.State.STARTED) {
DynamicPropertyService dynamicPropertyService = api.getServices().get(DynamicPropertyService.class);
if (dynamicPropertyService != null && dynamicPropertyService.isEnabled()) {
DynamicPropertyUpdater updater = new DynamicPropertyUpdater(api);
if (dynamicPropertyService.getProvider() == DynamicPropertyProvider.HTTP) {
HttpProvider provider = new HttpProvider(dynamicPropertyService);
provider.setVertx(vertx);
provider.setNode(node);
updater.setProvider(provider);
updater.setApiService(apiService);
logger.info("Add a scheduled task to poll dynamic properties each {}", dynamicPropertyService.getSchedule());
// Force the first refresh, and then run it periodically
updater.handle(null);
CronHandler cronHandler = new CronHandler(vertx, dynamicPropertyService.getSchedule());
cronHandler.schedule(updater);
handlers.put(api, cronHandler);
}
} else {
logger.info("Dynamic properties service is disabled for: {} [{}]", api.getName(), api.getVersion());
}
}
}
Aggregations