Prefix function names with spring-

* Add `spring-` prefix to function names

Fixes: #9

This commit renames each sub-module in the common, consumer, function
and supplier groups with a prefix of `spring-`.

* Update README.adoc links to new prefixed names
This commit is contained in:
Chris Bono
2024-01-02 13:07:00 -06:00
committed by GitHub
parent b9a3e59074
commit 84e732da08
596 changed files with 146 additions and 147 deletions

View File

@@ -0,0 +1,71 @@
/*
* Copyright 2020-2022 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 org.springframework.cloud.fn.header.enricher;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.function.Function;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.integration.transformer.HeaderEnricher;
import org.springframework.integration.transformer.support.ExpressionEvaluatingHeaderValueMessageProcessor;
import org.springframework.messaging.Message;
/**
* @author Gary Russell
* @author Christian Tzolov
* @author Soby Chacko
* @author Artem Bilan
*/
@AutoConfiguration
@EnableConfigurationProperties(HeaderEnricherFunctionProperties.class)
@ConditionalOnProperty(prefix = "header.enricher", value = "headers")
public class HeaderEnricherFunctionConfiguration {
@Autowired
private HeaderEnricherFunctionProperties properties;
@Bean
public Function<Message<?>, Message<?>> headerEnricherFunction(HeaderEnricher headerEnricher) {
return headerEnricher::transform;
}
@Bean
public HeaderEnricher headerEnricher(BeanFactory beanFactory) {
Map<String, ExpressionEvaluatingHeaderValueMessageProcessor<?>> headersToAdd = new HashMap<>();
Properties props = this.properties.getHeaders();
Enumeration<?> enumeration = props.propertyNames();
while (enumeration.hasMoreElements()) {
String propertyName = (String) enumeration.nextElement();
ExpressionEvaluatingHeaderValueMessageProcessor<?> headerValueMessageProcessor =
new ExpressionEvaluatingHeaderValueMessageProcessor<>(props.getProperty(propertyName), null);
headerValueMessageProcessor.setBeanFactory(beanFactory);
headersToAdd.put(propertyName, headerValueMessageProcessor);
}
HeaderEnricher headerEnricher = new HeaderEnricher(headersToAdd);
headerEnricher.setDefaultOverwrite(this.properties.isOverwrite());
return headerEnricher;
}
}

View File

@@ -0,0 +1,65 @@
/*
* 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 org.springframework.cloud.fn.header.enricher;
import java.util.Properties;
import jakarta.validation.constraints.NotNull;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
/**
* Configuration properties for the Header Enricher Processor application.
*
* @author Gary Russell
* @author Artem Bilan
* @author Soby Chacko
*/
@ConfigurationProperties("header.enricher")
@Validated
public class HeaderEnricherFunctionProperties {
/**
* \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.
*/
private boolean overwrite = false;
@NotNull
public Properties getHeaders() {
return this.headers;
}
public void setHeaders(Properties headers) {
this.headers = headers;
}
public boolean isOverwrite() {
return this.overwrite;
}
public void setOverwrite(boolean overwrite) {
this.overwrite = overwrite;
}
}

View File

@@ -0,0 +1 @@
org.springframework.cloud.fn.header.enricher.HeaderEnricherFunctionConfiguration