Search in sources :

Example 6 with DirectWithAttributesChannel

use of org.springframework.cloud.stream.messaging.DirectWithAttributesChannel in project spring-cloud-stream by spring-cloud.

the class StreamBridge method afterSingletonsInstantiated.

@Override
public void afterSingletonsInstantiated() {
    if (this.initialized) {
        return;
    }
    FunctionRegistration<Function<Object, Object>> fr = new FunctionRegistration<>(v -> v, STREAM_BRIDGE_FUNC_NAME);
    fr.getProperties().put("singleton", "false");
    Type functionType = ResolvableType.forClassWithGenerics(Function.class, Object.class, Object.class).getType();
    this.functionRegistry.register(fr.type(functionType));
    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;
}
Also used : Function(java.util.function.Function) MimeType(org.springframework.util.MimeType) ResolvableType(org.springframework.core.ResolvableType) Type(java.lang.reflect.Type) DirectWithAttributesChannel(org.springframework.cloud.stream.messaging.DirectWithAttributesChannel) FunctionRegistration(org.springframework.cloud.function.context.FunctionRegistration)

Aggregations

DirectWithAttributesChannel (org.springframework.cloud.stream.messaging.DirectWithAttributesChannel)6 Test (org.junit.Test)2 BeanCreationException (org.springframework.beans.factory.BeanCreationException)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 Binder (org.springframework.cloud.stream.binder.Binder)2 SubscribableChannel (org.springframework.messaging.SubscribableChannel)2 Type (java.lang.reflect.Type)1 Function (java.util.function.Function)1 FunctionRegistration (org.springframework.cloud.function.context.FunctionRegistration)1 BinderFactory (org.springframework.cloud.stream.binder.BinderFactory)1 ConsumerProperties (org.springframework.cloud.stream.binder.ConsumerProperties)1 DefaultPartitioningInterceptor (org.springframework.cloud.stream.binding.DefaultPartitioningInterceptor)1 BindingProperties (org.springframework.cloud.stream.config.BindingProperties)1 ResolvableType (org.springframework.core.ResolvableType)1 AbstractMessageChannel (org.springframework.integration.channel.AbstractMessageChannel)1 MessageChannel (org.springframework.messaging.MessageChannel)1 MimeType (org.springframework.util.MimeType)1