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 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
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
protected Query
protected Update
protected Query
getByIdInQuery
(Collection<?> entities) Class<?>
idForEntity
(Object entity) boolean
protected boolean
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) Set the type of the entityClass that will be passed to the find MongoDb template operation.void
setExpectSingleResult
(boolean expectSingleResult) Manage which find* method to invoke.protected void
setInitialized
(boolean initialized) void
setMongoConverter
(MongoConverter mongoConverter) 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, isObserved, registerObservationRegistry
Methods inherited from interface org.springframework.integration.core.MessageSource
getIntegrationPatternType
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getComponentType
-
Field Details
-
queryExpression
-
-
Constructor Details
-
AbstractMongoDbMessageSource
-
-
Method Details
-
setEntityClass
Set the type of the entityClass that will be passed to the find MongoDb template operation. Default isDBObject
.- Parameters:
entityClass
- The entity class.
-
setExpectSingleResult
public void setExpectSingleResult(boolean expectSingleResult) Manage which find* method to invoke. Default is 'false', which means theAbstractMessageSource.receive()
method will use thefind()
method. If set to 'true',AbstractMessageSource.receive()
will usefindOne(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
Provide a customMongoConverter
used to assist in deserialization data read from MongoDb.- 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
-