Minor cleanup and javadocs

This commit is contained in:
Oleg Zhurakousky
2020-12-02 08:47:04 +01:00
parent 306da4248a
commit 0cdcc46f57
5 changed files with 20 additions and 16 deletions

View File

@@ -32,6 +32,8 @@ import org.springframework.messaging.support.GenericMessage;
/**
* Message builder which is aware of Cloud Event semantics.
* It provides type-safe setters for v1.0 Cloud Event attributes while
* supporting any version by exposing a convenient {@link #setHeader(String, Object)} method.
*
* @author Oleg Zhurakousky
* @since 3.1
@@ -106,11 +108,6 @@ public final class CloudEventMessageBuilder<T> {
return this;
}
public CloudEventMessageBuilder<T> copyHeaders(Map<String, Object> headers) {
this.headers.putAll(headers);
return this;
}
public CloudEventMessageBuilder<T> setTime(OffsetTime time) {
this.headers.put(CloudEventMessageUtils.TIME, time);
return this;
@@ -126,6 +123,11 @@ public final class CloudEventMessageBuilder<T> {
return this;
}
public CloudEventMessageBuilder<T> copyHeaders(Map<String, Object> headers) {
this.headers.putAll(headers);
return this;
}
/**
* Returns a snapshot of the headers {@link Map} at the time this method is called.
* The returned Map is read-only.
@@ -168,8 +170,6 @@ public final class CloudEventMessageBuilder<T> {
String stringId = this.headers.get(CloudEventMessageUtils.ID).toString();
try {
id = UUID.fromString(stringId);
System.out.println(stringId);
System.out.println(id.toString());
}
catch (Exception e) {
logger.info("Provided Cloud Event 'id' is not compatible with Message 'id' which is UUID, "

View File

@@ -17,12 +17,16 @@
package org.springframework.cloud.function.cloudevent;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.cloud.function.core.FunctionInvocationHelper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
/**
* Configuration class with components relevant to Cloud Events support.
*
* @author Oleg Zhurakousky
* @since 3.1
@@ -32,13 +36,15 @@ class CloudEventsFunctionExtensionConfiguration {
@Bean
@ConditionalOnMissingClass("io.cloudevents.CloudEvent")
public CloudEventsFunctionInvocationHelper nativeFunctionInvocationHelper(@Nullable CloudEventHeaderEnricher cloudEventHeadersProvider) {
@ConditionalOnMissingBean
public FunctionInvocationHelper<Message<?>> nativeFunctionInvocationHelper(@Nullable CloudEventHeaderEnricher cloudEventHeadersProvider) {
return new CloudEventsFunctionInvocationHelper(cloudEventHeadersProvider);
}
@Bean
@ConditionalOnClass(name = "io.cloudevents.CloudEvent")
public CloudEventsFunctionInvocationHelper sdkFunctionInvocationHelper() {
@ConditionalOnMissingBean
public FunctionInvocationHelper<Message<?>> sdkFunctionInvocationHelper() {
// TODO you may need SDKs header provider
return null;
}

View File

@@ -89,7 +89,10 @@ class CloudEventsFunctionInvocationHelper implements FunctionInvocationHelper<Me
}
private String determineOutputPrefix(Message<?> input) {
//TODO rework to actually figure out where output goes instead of relying on input
/*
* TODO rework to actually figure out where output goes instead of relying on input
* In streams we can overrode and access output binding, ect.
*/
return CloudEventMessageUtils.determinePrefixToUse(input.getHeaders());
}

View File

@@ -328,12 +328,6 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
*/
private Function<Object, Message> enhancer;
// private BiFunction<Message<?>, Object, Message<?>> outputMessageHeaderEnricher;
//
// void setOutputMessageHeaderEnricher(BiFunction<Message<?>, Object, Message<?>> outputMessageHeaderEnricher) {
// this.outputMessageHeaderEnricher = outputMessageHeaderEnricher;
// }
FunctionInvocationWrapper(FunctionInvocationWrapper function) {
this.target = function.target;
this.inputType = function.inputType;