org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver Java Examples
The following examples show how to use
org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BinderDubboConfigBinder.java From dubbo-spring-boot-project with Apache License 2.0 | 6 votes |
@Override public void bind(Map<String, Object> configurationProperties, boolean ignoreUnknownFields, boolean ignoreInvalidFields, Object configurationBean) { Iterable<PropertySource<?>> propertySources = asList(new MapPropertySource("internal", configurationProperties)); // Converts ConfigurationPropertySources Iterable<ConfigurationPropertySource> configurationPropertySources = from(propertySources); // Wrap Bindable from DubboConfig instance Bindable bindable = Bindable.ofInstance(configurationBean); Binder binder = new Binder(configurationPropertySources, new PropertySourcesPlaceholdersResolver(propertySources)); // Get BindHandler BindHandler bindHandler = getBindHandler(ignoreUnknownFields, ignoreInvalidFields); // Bind binder.bind("", bindable, bindHandler); }
Example #2
Source File: JasyptEncryptorConfigurationProperties.java From jasypt-spring-boot with MIT License | 6 votes |
public static JasyptEncryptorConfigurationProperties bindConfigProps(ConfigurableEnvironment environment) { final BindHandler handler = new IgnoreErrorsBindHandler(BindHandler.DEFAULT); final MutablePropertySources propertySources = environment.getPropertySources(); final Binder binder = new Binder(ConfigurationPropertySources.from(propertySources), new PropertySourcesPlaceholdersResolver(propertySources), ApplicationConversionService.getSharedInstance()); 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; }
Example #3
Source File: AbstractExtendedBindingProperties.java From spring-cloud-stream with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void bindToDefault(String binding) { T extendedBindingPropertiesTarget = (T) BeanUtils .instantiateClass(this.getExtendedPropertiesEntryClass()); Binder binder = new Binder( ConfigurationPropertySources .get(this.applicationContext.getEnvironment()), new PropertySourcesPlaceholdersResolver( this.applicationContext.getEnvironment()), IntegrationUtils.getConversionService( this.applicationContext.getBeanFactory()), null); binder.bind(this.getDefaultsPrefix(), Bindable.ofInstance(extendedBindingPropertiesTarget)); this.bindings.put(binding, extendedBindingPropertiesTarget); }
Example #4
Source File: FunctionalConfigurationPropertiesBinder.java From spring-fu with Apache License 2.0 | 5 votes |
public FunctionalConfigurationPropertiesBinder(ConfigurableApplicationContext context) { PropertySources propertySources = new FunctionalPropertySourcesDeducer(context).getPropertySources(); this.context = context; this.binder = new Binder(ConfigurationPropertySources.from(propertySources), new PropertySourcesPlaceholdersResolver(propertySources), null, (registry) -> context.getBeanFactory().copyRegisteredEditorsTo(registry)); }
Example #5
Source File: KafkaStreamsBinderSupportAutoConfiguration.java From spring-cloud-stream-binder-kafka with Apache License 2.0 | 5 votes |
@Bean @ConfigurationProperties(prefix = "spring.cloud.stream.kafka.streams.binder") public KafkaStreamsBinderConfigurationProperties binderConfigurationProperties( KafkaProperties kafkaProperties, ConfigurableEnvironment environment, BindingServiceProperties properties, ConfigurableApplicationContext context) throws Exception { final Map<String, BinderConfiguration> binderConfigurations = getBinderConfigurations( properties); for (Map.Entry<String, BinderConfiguration> entry : binderConfigurations .entrySet()) { final BinderConfiguration binderConfiguration = entry.getValue(); final String binderType = binderConfiguration.getBinderType(); if (binderType != null && (binderType.equals(KSTREAM_BINDER_TYPE) || binderType.equals(KTABLE_BINDER_TYPE) || binderType.equals(GLOBALKTABLE_BINDER_TYPE))) { Map<String, Object> binderProperties = new HashMap<>(); this.flatten(null, binderConfiguration.getProperties(), binderProperties); environment.getPropertySources().addFirst( new MapPropertySource(entry.getKey() + "-kafkaStreamsBinderEnv", binderProperties)); Binder binder = new Binder(ConfigurationPropertySources.get(environment), new PropertySourcesPlaceholdersResolver(environment), IntegrationUtils.getConversionService(context.getBeanFactory()), null); final Constructor<KafkaStreamsBinderConfigurationProperties> kafkaStreamsBinderConfigurationPropertiesConstructor = ReflectionUtils.accessibleConstructor(KafkaStreamsBinderConfigurationProperties.class, KafkaProperties.class); final KafkaStreamsBinderConfigurationProperties kafkaStreamsBinderConfigurationProperties = BeanUtils.instantiateClass(kafkaStreamsBinderConfigurationPropertiesConstructor, kafkaProperties); final BindResult<KafkaStreamsBinderConfigurationProperties> bind = binder.bind("spring.cloud.stream.kafka.streams.binder", Bindable.ofInstance(kafkaStreamsBinderConfigurationProperties)); context.getBeanFactory().registerSingleton( entry.getKey() + "-KafkaStreamsBinderConfigurationProperties", bind.get()); } } return new KafkaStreamsBinderConfigurationProperties(kafkaProperties); }
Example #6
Source File: RiptidePostProcessor.java From riptide with MIT License | 5 votes |
@Override public void setEnvironment(final Environment environment) { final Iterable<ConfigurationPropertySource> sources = from(((ConfigurableEnvironment) environment).getPropertySources()); final Binder binder = new Binder(sources, new PropertySourcesPlaceholdersResolver(environment)); this.properties = Defaulting.withDefaults(binder.bindOrCreate("riptide", RiptideProperties.class)); }
Example #7
Source File: BindingServiceProperties.java From spring-cloud-stream with Apache License 2.0 | 5 votes |
private void bindToDefault(String binding) { BindingProperties bindingPropertiesTarget = new BindingProperties(); Binder binder = new Binder( ConfigurationPropertySources .get(this.applicationContext.getEnvironment()), new PropertySourcesPlaceholdersResolver( this.applicationContext.getEnvironment()), IntegrationUtils.getConversionService( this.applicationContext.getBeanFactory()), null); binder.bind("spring.cloud.stream.default", Bindable.ofInstance(bindingPropertiesTarget)); this.bindings.put(binding, bindingPropertiesTarget); }
Example #8
Source File: CustomizedConfigurationPropertiesBinder.java From apollo-use-cases with Apache License 2.0 | 4 votes |
private PropertySourcesPlaceholdersResolver getPropertySourcesPlaceholdersResolver() { return new PropertySourcesPlaceholdersResolver(this.propertySources); }
Example #9
Source File: MangoConfigFactory.java From mango-spring-boot-starter with Apache License 2.0 | 4 votes |
private static PropertySourcesPlaceholdersResolver getPropertySourcesPlaceholdersResolver(PropertySources propertySources) { return new PropertySourcesPlaceholdersResolver(propertySources); }