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:
- org.springframework.beans.factory.Aware,- org.springframework.beans.factory.BeanFactoryAware,- org.springframework.beans.factory.BeanNameAware,- org.springframework.beans.factory.DisposableBean,- org.springframework.beans.factory.InitializingBean,- org.springframework.context.ApplicationContextAware,- org.springframework.integration.core.MessageSource<T>,- org.springframework.integration.IntegrationPattern,- org.springframework.integration.support.context.NamedComponent,- org.springframework.integration.support.management.IntegrationInboundManagement,- org.springframework.integration.support.management.IntegrationManagement
- Direct Known Subclasses:
- MongoDbMessageSource,- ReactiveMongoDbMessageSource
public abstract class AbstractMongoDbMessageSource<T>
extends org.springframework.integration.endpoint.AbstractMessageSource<T>
implements org.springframework.context.ApplicationContextAware
An 
AbstractMessageSource extension for common MongoDB sources options and support methods.- Since:
- 5.5
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementorg.springframework.integration.support.management.IntegrationManagement.ManagementOverrides
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final org.springframework.expression.ExpressionFields inherited from class org.springframework.integration.util.AbstractExpressionEvaluatorEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractMongoDbMessageSource(org.springframework.expression.Expression queryExpression) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected Stringprotected org.springframework.data.mongodb.core.query.Queryprotected org.springframework.data.mongodb.core.query.Updateorg.springframework.context.ApplicationContextprotected org.springframework.data.mongodb.core.query.QuerygetByIdInQuery(Collection<?> entities) org.springframework.expression.ExpressionClass<?>org.springframework.data.mongodb.core.convert.MongoConverterorg.springframework.expression.ExpressionidForEntity(Object entity) booleanprotected booleanprotected voidonInit()voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetCollectionNameExpression(org.springframework.expression.Expression collectionNameExpression) Set the SpELExpressionthat should resolve to a collection name used by theQuery.voidsetEntityClass(Class<?> entityClass) Set the type of the entityClass that will be passed to the find MongoDb template operation.voidsetExpectSingleResult(boolean expectSingleResult) Manage which find* method to invoke.protected voidsetInitialized(boolean initialized) voidsetMongoConverter(org.springframework.data.mongodb.core.convert.MongoConverter mongoConverter) Provide a customMongoConverterused to assist in deserialization data read from MongoDb.voidsetUpdateExpression(org.springframework.expression.Expression updateExpression) Specify an optionalupdatefor just polled records from the collection.Methods inherited from class org.springframework.integration.endpoint.AbstractMessageSourcebuildMessage, destroy, doReceive, getBeanName, getComponentName, getManagedName, getManagedType, getOverrides, isLoggingEnabled, receive, registerMetricsCaptor, setBeanName, setHeaderExpressions, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from class org.springframework.integration.util.AbstractExpressionEvaluatorafterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, setBeanFactory, setConversionServiceMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAs, isObserved, registerObservationRegistryMethods inherited from interface org.springframework.integration.core.MessageSourcegetIntegrationPatternTypeMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetComponentType
- 
Field Details- 
queryExpressionprotected final org.springframework.expression.Expression queryExpression
 
- 
- 
Constructor Details- 
AbstractMongoDbMessageSourceprotected AbstractMongoDbMessageSource(org.springframework.expression.Expression queryExpression) 
 
- 
- 
Method Details- 
setEntityClassSet the type of the entityClass that will be passed to the find MongoDb template operation. Default isDBObject.- Parameters:
- entityClass- The entity class.
 
- 
setExpectSingleResultpublic 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 returnedMessagewill be the returned target Object of type identified byentityClassinstead of a List.- Parameters:
- expectSingleResult- true if a single result is expected.
 
- 
setCollectionNameExpressionpublic void setCollectionNameExpression(org.springframework.expression.Expression collectionNameExpression) Set the SpELExpressionthat should resolve to a collection name used by theQuery. The resulting collection name will be included in theMongoHeaders.COLLECTION_NAMEheader.- Parameters:
- collectionNameExpression- The collection name expression.
 
- 
setMongoConverterpublic void setMongoConverter(org.springframework.data.mongodb.core.convert.MongoConverter mongoConverter) Provide a customMongoConverterused to assist in deserialization data read from MongoDb.- Parameters:
- mongoConverter- The mongo converter.
 
- 
setUpdateExpressionpublic void setUpdateExpression(org.springframework.expression.Expression updateExpression) Specify an optionalupdatefor just polled records from the collection.- Parameters:
- updateExpression- SpEL expression for an- UpdateDefinition.
- Since:
- 5.5
 
- 
setApplicationContextpublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
- setApplicationContextin interface- org.springframework.context.ApplicationContextAware
- Throws:
- org.springframework.beans.BeansException
 
- 
getCollectionNameExpressionpublic org.springframework.expression.Expression getCollectionNameExpression()
- 
getMongoConverterpublic org.springframework.data.mongodb.core.convert.MongoConverter getMongoConverter()
- 
getEntityClass
- 
isExpectSingleResultpublic boolean isExpectSingleResult()
- 
getUpdateExpressionpublic org.springframework.expression.Expression getUpdateExpression()
- 
getApplicationContextpublic org.springframework.context.ApplicationContext getApplicationContext()
- 
setInitializedprotected void setInitialized(boolean initialized) 
- 
isInitializedprotected boolean isInitialized()
- 
onInitprotected void onInit()- Overrides:
- onInitin class- org.springframework.integration.util.AbstractExpressionEvaluator
 
- 
evaluateQueryExpressionprotected org.springframework.data.mongodb.core.query.Query evaluateQueryExpression()
- 
evaluateCollectionNameExpression
- 
getByIdInQuery
- 
idForEntity
- 
evaluateUpdateExpression@Nullable protected org.springframework.data.mongodb.core.query.Update evaluateUpdateExpression()
 
-