Fix conditions for custom AWS runtime

Conflicts:
	spring-cloud-function-samples/function-sample-aws-custom/pom.xml
This commit is contained in:
Dave Syer
2019-07-08 14:46:28 +01:00
committed by Oleg Zhurakousky
parent 1de8526b7a
commit 5e3111bf80
4 changed files with 34 additions and 57 deletions

View File

@@ -32,7 +32,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@AutoConfigureBefore(FunctionExporterAutoConfiguration.class)
@ConditionalOnClass(DestinationResolver.class)
@ConditionalOnProperty(prefix = "spring.cloud.function.web.export", name = "enabled", matchIfMissing = true)
@ConditionalOnProperty(prefix = "spring.cloud.function.web.export", name = "enabled", matchIfMissing = false)
public class CustomRuntimeAutoConfiguration {
@Bean

View File

@@ -27,25 +27,21 @@ import org.springframework.core.annotation.Order;
* @author Dave Syer
*/
@Order(0)
public class CustomRuntimeInitializer
implements ApplicationContextInitializer<GenericApplicationContext> {
public class CustomRuntimeInitializer implements ApplicationContextInitializer<GenericApplicationContext> {
@Override
public void initialize(GenericApplicationContext context) {
Boolean enabled = context.getEnvironment()
.getProperty("spring.cloud.function.web.export.enabled", Boolean.class);
if (enabled != null) {
Boolean enabled = context.getEnvironment().getProperty("spring.cloud.function.web.export.enabled",
Boolean.class);
if (enabled == null || !enabled) {
return;
}
if (ContextFunctionCatalogInitializer.enabled && context.getEnvironment()
.getProperty("spring.functional.enabled", Boolean.class, false)) {
if (context.getBeanFactory().getBeanNamesForType(DestinationResolver.class,
false, false).length == 0) {
context.registerBean(LambdaDestinationResolver.class,
() -> new LambdaDestinationResolver());
if (ContextFunctionCatalogInitializer.enabled
&& context.getEnvironment().getProperty("spring.functional.enabled", Boolean.class, false)) {
if (context.getBeanFactory().getBeanNamesForType(DestinationResolver.class, false, false).length == 0) {
context.registerBean(LambdaDestinationResolver.class, () -> new LambdaDestinationResolver());
}
context.registerBean(CommandLineRunner.class,
() -> args -> CustomRuntimeAutoConfiguration.background());
context.registerBean(CommandLineRunner.class, () -> args -> CustomRuntimeAutoConfiguration.background());
}
}