Class AbstractMongoDbMessageSource<T>
java.lang.Object
org.springframework.integration.util.AbstractExpressionEvaluator
org.springframework.integration.endpoint.AbstractMessageSource<T>
org.springframework.integration.mongodb.inbound.AbstractMongoDbMessageSource<T>
- Type Parameters:
T
- The payload type.
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,MessageSource<T>
,IntegrationPattern
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
- Direct Known Subclasses:
MongoDbMessageSource
,ReactiveMongoDbMessageSource
public abstract class AbstractMongoDbMessageSource<T> extends AbstractMessageSource<T> implements ApplicationContextAware
An
AbstractMessageSource
extension for common MongoDB sources options and support methods.- Since:
- 5.5
- Author:
- Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields Modifier and Type Field Description protected Expression
queryExpression
Fields inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractMongoDbMessageSource(Expression queryExpression)
-
Method Summary
Modifier and Type Method Description protected String
evaluateCollectionNameExpression()
protected Query
evaluateQueryExpression()
protected Update
evaluateUpdateExpression()
ApplicationContext
getApplicationContext()
protected Query
getByIdInQuery(Collection<?> entities)
Expression
getCollectionNameExpression()
Class<?>
getEntityClass()
MongoConverter
getMongoConverter()
Expression
getUpdateExpression()
protected org.springframework.data.util.Pair<String,Object>
idForEntity(Object entity)
boolean
isExpectSingleResult()
protected boolean
isInitialized()
protected void
onInit()
void
setApplicationContext(ApplicationContext applicationContext)
void
setCollectionNameExpression(Expression collectionNameExpression)
Set the SpELExpression
that should resolve to a collection name used by theQuery
.void
setEntityClass(Class<?> entityClass)
Allow you to set the type of the entityClass that will be passed to theReactiveMongoTemplate.find(Query, Class)
orReactiveMongoTemplate.findOne(Query, Class)
method.void
setExpectSingleResult(boolean expectSingleResult)
Allow you to manage which find* method to invoke onReactiveMongoTemplate
.protected void
setInitialized(boolean initialized)
void
setMongoConverter(MongoConverter mongoConverter)
Allow you to provide a customMongoConverter
used to assist in deserialization data read from MongoDb.void
setUpdateExpression(Expression updateExpression)
Specify an optionalupdate
for just polled records from the collection.Methods inherited from class org.springframework.integration.endpoint.AbstractMessageSource
buildMessage, destroy, doReceive, getBeanName, getComponentName, getManagedName, getManagedType, getOverrides, isLoggingEnabled, receive, registerMetricsCaptor, setBeanName, setHeaderExpressions, setLoggingEnabled, setManagedName, setManagedType
Methods inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
afterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, setBeanFactory, setConversionService
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods inherited from interface org.springframework.integration.core.MessageSource
getIntegrationPatternType
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getComponentType
-
Field Details
-
Constructor Details
-
Method Details
-
setEntityClass
Allow you to set the type of the entityClass that will be passed to theReactiveMongoTemplate.find(Query, Class)
orReactiveMongoTemplate.findOne(Query, Class)
method. Default isDBObject
.- Parameters:
entityClass
- The entity class.
-
setExpectSingleResult
public void setExpectSingleResult(boolean expectSingleResult)Allow you to manage which find* method to invoke onReactiveMongoTemplate
. Default is 'false', which means theAbstractMessageSource.receive()
method will use theReactiveMongoTemplate.find(Query, Class)
method. If set to 'true',AbstractMessageSource.receive()
will useReactiveMongoTemplate.findOne(Query, Class)
, and the payload of the returnedMessage
will be the returned target Object of type identified byentityClass
instead of a List.- Parameters:
expectSingleResult
- true if a single result is expected.
-
setCollectionNameExpression
Set the SpELExpression
that should resolve to a collection name used by theQuery
. The resulting collection name will be included in theMongoHeaders.COLLECTION_NAME
header.- Parameters:
collectionNameExpression
- The collection name expression.
-
setMongoConverter
Allow you to provide a customMongoConverter
used to assist in deserialization data read from MongoDb. Only allowed if this instance was constructed with aReactiveMongoDatabaseFactory
.- Parameters:
mongoConverter
- The mongo converter.
-
setUpdateExpression
Specify an optionalupdate
for just polled records from the collection.- Parameters:
updateExpression
- SpEL expression for anUpdateDefinition
.- Since:
- 5.5
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-
getCollectionNameExpression
-
getMongoConverter
-
getEntityClass
-
isExpectSingleResult
public boolean isExpectSingleResult() -
getUpdateExpression
-
getApplicationContext
-
setInitialized
protected void setInitialized(boolean initialized) -
isInitialized
protected boolean isInitialized() -
onInit
protected void onInit()- Overrides:
onInit
in classAbstractExpressionEvaluator
-
evaluateQueryExpression
-
evaluateCollectionNameExpression
-
getByIdInQuery
-
idForEntity
-
evaluateUpdateExpression
-