Fix conditions for custom AWS runtime
Conflicts: spring-cloud-function-samples/function-sample-aws-custom/pom.xml
This commit is contained in:
committed by
Oleg Zhurakousky
parent
1de8526b7a
commit
5e3111bf80
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user