Class AbstractBinder<T,C extends ConsumerProperties,P extends ProducerProperties>

java.lang.Object
org.springframework.cloud.stream.binder.AbstractBinder<T,C,P>
Type Parameters:
T - outbound bind target class
C - consumer properties class
P - producer properties class
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, Binder<T,C,P>, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
AbstractMessageChannelBinder

public abstract class AbstractBinder<T,C extends ConsumerProperties,P extends ProducerProperties> extends Object implements org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean, Binder<T,C,P>
Base class for Binder implementations.
Author:
David Turanski, Gary Russell, Ilayaperumal Gopinathan, Mark Fisher, Marius Bogoevici, Soby Chacko, Vinicius Carvalho, Oleg Zhurakousky, Nicolas Homble
  • Field Details

    • logger

      protected final org.apache.commons.logging.Log logger
  • Constructor Details

    • AbstractBinder

      public AbstractBinder()
  • Method Details

    • applyPrefix

      public static String applyPrefix(String prefix, String name)
      For binder implementations that support a prefix, apply the prefix to the name.
      Parameters:
      prefix - the prefix.
      name - the name.
      Returns:
      name with the prefix
    • constructDLQName

      public static String constructDLQName(String name)
      For binder implementations that support dead lettering, construct the name of the dead letter entity for the underlying pipe name.
      Parameters:
      name - the name.
      Returns:
      name with DLQ suffix
    • getApplicationContext

      protected org.springframework.context.support.AbstractApplicationContext getApplicationContext()
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • getBeanFactory

      protected org.springframework.beans.factory.config.ConfigurableListableBeanFactory getBeanFactory()
    • getEvaluationContext

      protected org.springframework.expression.EvaluationContext getEvaluationContext()
    • afterPropertiesSet

      public final void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • onInit

      protected void onInit() throws Exception
      Subclasses may implement this method to perform any necessary initialization. It will be invoked from afterPropertiesSet() which is itself final.
      Throws:
      Exception - when init fails
    • bindConsumer

      public final Binding<T> bindConsumer(String name, String group, T target, C properties)
      Description copied from interface: Binder
      Bind the target component as a message consumer to the logical entity identified by the name.
      Specified by:
      bindConsumer in interface Binder<T,C extends ConsumerProperties,P extends ProducerProperties>
      Parameters:
      name - the logical identity of the message source
      group - the consumer group to which this consumer belongs - subscriptions are shared among consumers in the same group (a null or empty String, must be treated as an anonymous group that doesn't share the subscription with any other consumer)
      target - the app interface to be bound as a consumer
      properties - the consumer properties
      Returns:
      the setup binding
    • doBindConsumer

      protected abstract Binding<T> doBindConsumer(String name, String group, T inputTarget, C properties)
    • bindProducer

      public final Binding<T> bindProducer(String name, T outboundBindTarget, P properties)
      Description copied from interface: Binder
      Bind the target component as a message producer to the logical entity identified by the name.
      Specified by:
      bindProducer in interface Binder<T,C extends ConsumerProperties,P extends ProducerProperties>
      Parameters:
      name - the logical identity of the message target
      outboundBindTarget - the app interface to be bound as a producer
      properties - the producer properties
      Returns:
      the setup binding
    • doBindProducer

      protected abstract Binding<T> doBindProducer(String name, T outboundBindTarget, P properties)
    • groupedName

      protected final String groupedName(String name, String group)
      Construct a name comprised of the name and group.
      Parameters:
      name - the name.
      group - the group.
      Returns:
      the constructed name.
    • getBindingServiceProperties

      protected BindingServiceProperties getBindingServiceProperties()
      Attempts to get BindingServiceProperties from application context.
      Returns:
      instance of BindingServiceProperties or null.
    • buildRetryTemplate

      protected org.springframework.retry.support.RetryTemplate buildRetryTemplate(ConsumerProperties properties)
      Create and configure a default retry template unless one has already been provided via @Bean by an application.
      Parameters:
      properties - The properties.
      Returns:
      The retry template