Example usage for org.springframework.messaging MessageChannel getClass

List of usage examples for org.springframework.messaging MessageChannel getClass

Introduction

In this page you can find the example usage for org.springframework.messaging MessageChannel getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.springframework.cloud.stream.binding.MessageConverterConfigurer.java

/**
 * Setup data-type and message converters for the given message channel.
 *
 * @param channel message channel to set the data-type and message converters
 * @param channelName the channel name// www  .  jav a 2  s.  co  m
 * @param inbound inbound (i.e., "input") or outbound channel
 */
private void configureMessageChannel(MessageChannel channel, String channelName, boolean inbound) {
    Assert.isAssignable(AbstractMessageChannel.class, channel.getClass());
    AbstractMessageChannel messageChannel = (AbstractMessageChannel) channel;
    BindingProperties bindingProperties = this.bindingServiceProperties.getBindingProperties(channelName);
    String contentType = bindingProperties.getContentType();
    ProducerProperties producerProperties = bindingProperties.getProducer();
    if (!inbound && producerProperties != null && producerProperties.isPartitioned()) {
        messageChannel.addInterceptor(new PartitioningInterceptor(bindingProperties,
                getPartitionKeyExtractorStrategy(producerProperties),
                getPartitionSelectorStrategy(producerProperties)));
    }

    ConsumerProperties consumerProperties = bindingProperties.getConsumer();
    if (this.isNativeEncodingNotSet(producerProperties, consumerProperties, inbound)) {
        if (inbound) {
            messageChannel.addInterceptor(new InboundContentTypeConvertingInterceptor(contentType,
                    this.compositeMessageConverterFactory));
        } else {
            messageChannel.addInterceptor(new OutboundContentTypeConvertingInterceptor(contentType,
                    this.compositeMessageConverterFactory.getMessageConverterForAllRegistered()));
        }
    }
}