private PropertySourcesPlaceholdersResolver getPropertySourcesPlaceholdersResolver() { return new PropertySourcesPlaceholdersResolver(this.propertySources); }
public PropertySourcesPlaceholdersResolver(Environment environment) { this(getSources(environment), null); }
@Override protected String resolvePlaceholder(String placeholder) { String value = super.resolvePlaceholder(placeholder); if (value == null) { return null; } return (String) this.sanitizer.sanitize(placeholder, value); }
/** * Create a new {@link Binder} instance from the specified environment. * @param environment the environment source (must have attached * {@link ConfigurationPropertySources}) * @return a {@link Binder} instance */ public static Binder get(Environment environment) { return new Binder(ConfigurationPropertySources.get(environment), new PropertySourcesPlaceholdersResolver(environment)); }
Loader(ConfigurableEnvironment environment, ResourceLoader resourceLoader) { this.environment = environment; this.placeholdersResolver = new PropertySourcesPlaceholdersResolver( this.environment); this.resourceLoader = (resourceLoader != null) ? resourceLoader : new DefaultResourceLoader(); this.propertySourceLoaders = SpringFactoriesLoader.loadFactories( PropertySourceLoader.class, getClass().getClassLoader()); }
@Override public <C extends AbstractConfig> void bind(String prefix, C dubboConfig) { Iterable<PropertySource<?>> propertySources = getPropertySources(); // Converts ConfigurationPropertySources Iterable<ConfigurationPropertySource> configurationPropertySources = from(propertySources); // Wrap Bindable from DubboConfig instance Bindable<C> bindable = Bindable.ofInstance(dubboConfig); Binder binder = new Binder(configurationPropertySources, new PropertySourcesPlaceholdersResolver(propertySources)); // Get BindHandler BindHandler bindHandler = getBindHandler(); // Bind binder.bind(prefix, bindable, bindHandler); }
@Bean(name = CONFIG_SINGLETON) public Singleton<JasyptEncryptorConfigurationProperties> configProps( @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") final EnvCopy envCopy, final ConfigurableBeanFactory bf) { return new Singleton<>(() -> { final BindHandler handler = new IgnoreErrorsBindHandler(BindHandler.DEFAULT); final MutablePropertySources propertySources = envCopy.get().getPropertySources(); final Binder binder = new Binder(ConfigurationPropertySources.from(propertySources), new PropertySourcesPlaceholdersResolver(propertySources), ApplicationConversionService.getSharedInstance(), bf::copyRegisteredEditorsTo); final JasyptEncryptorConfigurationProperties config = new JasyptEncryptorConfigurationProperties(); final ResolvableType type = ResolvableType.forClass(JasyptEncryptorConfigurationProperties.class); final Annotation annotation = AnnotationUtils.findAnnotation(JasyptEncryptorConfigurationProperties.class, ConfigurationProperties.class); final Annotation[] annotations = new Annotation[] {annotation}; final Bindable<?> target = Bindable.of(type).withExistingValue(config).withAnnotations(annotations); binder.bind("jasypt.encryptor", target, handler); return config; }); }
private PropertySourcesPlaceholdersResolver getPropertySourcesPlaceholdersResolver() { return new PropertySourcesPlaceholdersResolver(this.propertySources); }
@SuppressWarnings("unchecked") private void bindToDefault(String binding) { T extendedBindingPropertiesTarget = (T) BeanUtils.instantiateClass(this.getExtendedPropertiesEntryClass()); Binder binder = new Binder(ConfigurationPropertySources.get(applicationContext.getEnvironment()), new PropertySourcesPlaceholdersResolver(applicationContext.getEnvironment()), IntegrationUtils.getConversionService(applicationContext.getBeanFactory()), null); binder.bind(this.getDefaultsPrefix(), Bindable.ofInstance(extendedBindingPropertiesTarget)); this.bindings.put(binding, extendedBindingPropertiesTarget); } }
private void bindToDefault(String binding) { BindingProperties bindingPropertiesTarget = new BindingProperties(); Binder binder = new Binder(ConfigurationPropertySources.get(applicationContext.getEnvironment()), new PropertySourcesPlaceholdersResolver(applicationContext.getEnvironment()), IntegrationUtils.getConversionService(applicationContext.getBeanFactory()), null); binder.bind("spring.cloud.stream.default", Bindable.ofInstance(bindingPropertiesTarget)); this.bindings.put(binding, bindingPropertiesTarget); } }
@Override public <C extends AbstractConfig> void bind(String prefix, C dubboConfig) { Iterable<PropertySource<?>> propertySources = getPropertySources(); // Converts ConfigurationPropertySources Iterable<ConfigurationPropertySource> configurationPropertySources = from(propertySources); // Wrap Bindable from DubboConfig instance Bindable<C> bindable = Bindable.ofInstance(dubboConfig); Binder binder = new Binder(configurationPropertySources, new PropertySourcesPlaceholdersResolver(propertySources)); // Get BindHandler BindHandler bindHandler = getBindHandler(); // Bind binder.bind(prefix, bindable, bindHandler); }
public FunctionalConfigurationPropertiesBinder(ConfigurableApplicationContext context) { this.context = context; this.propertySources = new PropertySourcesDeducer(context).getPropertySources(); this.binder = new Binder(ConfigurationPropertySources.from(propertySources), new PropertySourcesPlaceholdersResolver(this.propertySources), new ConversionServiceDeducer(context).getConversionService(), (registry) -> context.getBeanFactory().copyRegisteredEditorsTo(registry)); }
@Bean(name = CONFIG_SINGLETON) public Singleton<JasyptEncryptorConfigurationProperties> configProps( @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") final EnvCopy envCopy, final ConfigurableBeanFactory bf) { return new Singleton<>(() -> { final BindHandler handler = new IgnoreErrorsBindHandler(BindHandler.DEFAULT); final MutablePropertySources propertySources = envCopy.get().getPropertySources(); final Binder binder = new Binder(ConfigurationPropertySources.from(propertySources), new PropertySourcesPlaceholdersResolver(propertySources), ApplicationConversionService.getSharedInstance(), bf::copyRegisteredEditorsTo); final JasyptEncryptorConfigurationProperties config = new JasyptEncryptorConfigurationProperties(); final ResolvableType type = ResolvableType.forClass(JasyptEncryptorConfigurationProperties.class); final Annotation annotation = AnnotationUtils.findAnnotation(JasyptEncryptorConfigurationProperties.class, ConfigurationProperties.class); final Annotation[] annotations = new Annotation[] {annotation}; final Bindable<?> target = Bindable.of(type).withExistingValue(config).withAnnotations(annotations); binder.bind("jasypt.encryptor", target, handler); return config; }); }