Small cleanup in StreamBridge

Remove redundant injection of FunctionRegistry since it is the same as FunctionCatalog
This commit is contained in:
Oleg Zhurakousky
2022-08-29 16:51:42 +02:00
parent 644224802b
commit 3fc3097852
2 changed files with 5 additions and 15 deletions

View File

@@ -137,10 +137,10 @@ public class FunctionConfiguration {
private final static String SOURCE_PROPERY = "spring.cloud.stream.source";
@Bean
public StreamBridge streamBridgeUtils(FunctionCatalog functionCatalog, FunctionRegistry functionRegistry,
public StreamBridge streamBridgeUtils(FunctionCatalog functionCatalog,
BindingServiceProperties bindingServiceProperties, ConfigurableApplicationContext applicationContext,
@Nullable NewDestinationBindingCallback callback) {
return new StreamBridge(functionCatalog, functionRegistry, bindingServiceProperties, applicationContext, callback);
return new StreamBridge(functionCatalog, bindingServiceProperties, applicationContext, callback);
}
@Bean

View File

@@ -82,8 +82,6 @@ public final class StreamBridge implements SmartInitializingSingleton {
private final FunctionCatalog functionCatalog;
private final FunctionRegistry functionRegistry;
private final NewDestinationBindingCallback destinationBindingCallback;
private BindingServiceProperties bindingServiceProperties;
@@ -101,17 +99,14 @@ public final class StreamBridge implements SmartInitializingSingleton {
/**
*
* @param functionCatalog instance of {@link FunctionCatalog}
* @param functionRegistry instance of {@link FunctionRegistry}
* @param bindingServiceProperties instance of {@link BindingServiceProperties}
* @param applicationContext instance of {@link ConfigurableApplicationContext}
*/
@SuppressWarnings("serial")
StreamBridge(FunctionCatalog functionCatalog, FunctionRegistry functionRegistry,
BindingServiceProperties bindingServiceProperties, ConfigurableApplicationContext applicationContext,
@Nullable NewDestinationBindingCallback destinationBindingCallback) {
StreamBridge(FunctionCatalog functionCatalog, BindingServiceProperties bindingServiceProperties,
ConfigurableApplicationContext applicationContext, @Nullable NewDestinationBindingCallback destinationBindingCallback) {
this.bindingService = applicationContext.getBean(BindingService.class);
this.functionCatalog = functionCatalog;
this.functionRegistry = functionRegistry;
this.applicationContext = applicationContext;
this.bindingServiceProperties = bindingServiceProperties;
this.destinationBindingCallback = destinationBindingCallback;
@@ -257,13 +252,8 @@ public final class StreamBridge implements SmartInitializingSingleton {
}
FunctionRegistration<Function<Object, Object>> fr = new FunctionRegistration<>(v -> v, STREAM_BRIDGE_FUNC_NAME);
fr.getProperties().put("singleton", "false");
this.functionRegistry.register(fr.type(FunctionType.from(Object.class).to(Object.class).message()));
((FunctionRegistry) this.functionCatalog).register(fr.type(FunctionType.from(Object.class).to(Object.class).message()));
Map<String, DirectWithAttributesChannel> channels = applicationContext.getBeansOfType(DirectWithAttributesChannel.class);
// for (Entry<String, DirectWithAttributesChannel> channelEntry : channels.entrySet()) {
// if (channelEntry.getValue().getAttribute("type").equals("output")) {
// this.channelCache.put(channelEntry.getKey(), channelEntry.getValue());
// }
// }
this.initialized = true;
}