Add composite function support for the sources

This commit is contained in:
David Turanski
2020-06-15 11:31:08 -04:00
committed by Soby Chacko
parent 92b2fc2f39
commit d56525b27a
8 changed files with 50 additions and 4 deletions

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.fn.filter.FilterFunctionConfiguration

View File

@@ -24,6 +24,7 @@ import java.util.function.Function;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -39,6 +40,7 @@ import org.springframework.messaging.Message;
*/
@Configuration
@EnableConfigurationProperties(HeaderEnricherFunctionProperties.class)
@ConditionalOnProperty(prefix = "header.enricher", value = "headers")
public class HeaderEnricherFunctionConfiguration {
@Autowired

View File

@@ -16,7 +16,6 @@
package org.springframework.cloud.fn.header.enricher;
import java.util.Properties;
import javax.validation.constraints.NotNull;
@@ -36,13 +35,13 @@ import org.springframework.validation.annotation.Validated;
public class HeaderEnricherFunctionProperties {
/**
* \n separated properties representing headers in which values are SpEL expressions,
* e.g foo='bar' \n baz=payload.baz.
* \n separated properties representing headers in which values are SpEL expressions, e.g
* foo='bar' \n baz=payload.baz.
*/
private Properties headers;
/**
* set to true to overwrite any existing message headers.
* set to true to overwrite any existing message headers.
*/
private boolean overwrite = false;

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.fn.header.enricher.HeaderEnricherFunctionConfiguration

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2020-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package functions;
import java.util.function.Function;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
/**
* Wrap a POJO as a message.
*
*/
// TODO: Remove when https://github.com/spring-cloud/spring-cloud-function/issues/550 is
// resolved.
public class ToMessage implements Function<Object, Message<?>> {
@Override
public Message<?> apply(Object o) {
return MessageBuilder.withPayload(o).build();
}
}

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.fn.spel.SpelFunctionConfiguration

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.fn.splitter.SplitterFunctionConfiguration

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.cloud.fn.task.launch.request.TaskLaunchRequestFunctionConfiguration