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 classC
- consumer properties classP
- 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 forBinder
implementations.- Author:
- David Turanski, Gary Russell, Ilayaperumal Gopinathan, Mark Fisher, Marius Bogoevici, Soby Chacko, Vinicius Carvalho, Oleg Zhurakousky, Nicolas Homble
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.Log
logger
-
Constructor Summary
Constructors Constructor Description AbstractBinder()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
static String
applyPrefix(String prefix, String name)
For binder implementations that support a prefix, apply the prefix to the name.Binding<T>
bindConsumer(String name, String group, T target, C properties)
Bind the target component as a message consumer to the logical entity identified by the name.Binding<T>
bindProducer(String name, T outboundBindTarget, P properties)
Bind the target component as a message producer to the logical entity identified by the name.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.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.protected abstract Binding<T>
doBindConsumer(String name, String group, T inputTarget, C properties)
protected abstract Binding<T>
doBindProducer(String name, T outboundBindTarget, P properties)
protected org.springframework.context.support.AbstractApplicationContext
getApplicationContext()
protected org.springframework.beans.factory.config.ConfigurableListableBeanFactory
getBeanFactory()
protected org.springframework.expression.EvaluationContext
getEvaluationContext()
protected String
groupedName(String name, String group)
Construct a name comprised of the name and group.protected void
onInit()
Subclasses may implement this method to perform any necessary initialization.void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
-
-
Method Detail
-
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 interfaceorg.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 interfaceorg.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 fromafterPropertiesSet()
which is itselffinal
.- 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 interfaceBinder<T,C extends ConsumerProperties,P extends ProducerProperties>
- Parameters:
name
- the logical identity of the message sourcegroup
- the consumer group to which this consumer belongs - subscriptions are shared among consumers in the same group (anull
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 consumerproperties
- 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 interfaceBinder<T,C extends ConsumerProperties,P extends ProducerProperties>
- Parameters:
name
- the logical identity of the message targetoutboundBindTarget
- the app interface to be bound as a producerproperties
- 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.
-
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
-
-