private LocElasticJobProperties resolverJobProperties() { try { return Binder.get(environment) .bind("loc.elasticjob", Bindable.of(LocElasticJobProperties.class)) .orElseThrow( () -> new FatalBeanException("Could not bind DataSourceSettings properties")); } catch (Exception e) { //ignore log.error("Could not bind job properties, error message is {}", e.getMessage(), e); throw new FatalBeanException("Could not bind job properties", e); } }
protected <T> T resolverSetting(Class<T> clazz, MutablePropertySources propertySources) { return new Binder(ConfigurationPropertySources.from(propertySources)) .bind("loc", Bindable.of(clazz)) .orElseThrow(() -> new FatalBeanException("Could not bind properties")); } }
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { String prefix = (String) attribute(metadata, "prefix"); Class<?> value = (Class<?>) attribute(metadata, "value"); ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment(); try { new Binder(ConfigurationPropertySources.from(environment.getPropertySources())) .bind(prefix, Bindable.of(value)) .orElseThrow( () -> new FatalBeanException("Could not bind DataSourceSettings properties")); return new ConditionOutcome(true, String.format("Map property [%s] is not empty", prefix)); } catch (Exception e) { //ignore } return new ConditionOutcome(false, String.format("Map property [%s] is empty", prefix)); }