Class 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
  • Field Details

    • queryExpression

      protected final Expression queryExpression
  • Constructor Details

    • AbstractMongoDbMessageSource

      protected AbstractMongoDbMessageSource(Expression queryExpression)
  • Method Details

    • setEntityClass

      public void setEntityClass(Class<?> entityClass)
      Set the type of the entityClass that will be passed to the find MongoDb template operation. Default is DBObject.
      Parameters:
      entityClass - The entity class.
    • setExpectSingleResult

      public void setExpectSingleResult(boolean expectSingleResult)
      Manage which find* method to invoke. Default is 'false', which means the AbstractMessageSource.receive() method will use the find() method. If set to 'true', AbstractMessageSource.receive() will use findOne(Query, Class), and the payload of the returned Message will be the returned target Object of type identified by entityClass instead of a List.
      Parameters:
      expectSingleResult - true if a single result is expected.
    • setCollectionNameExpression

      public void setCollectionNameExpression(Expression collectionNameExpression)
      Set the SpEL Expression that should resolve to a collection name used by the Query. The resulting collection name will be included in the MongoHeaders.COLLECTION_NAME header.
      Parameters:
      collectionNameExpression - The collection name expression.
    • setMongoConverter

      public void setMongoConverter(MongoConverter mongoConverter)
      Provide a custom MongoConverter used to assist in deserialization data read from MongoDb.
      Parameters:
      mongoConverter - The mongo converter.
    • setUpdateExpression

      public void setUpdateExpression(Expression updateExpression)
      Specify an optional update for just polled records from the collection.
      Parameters:
      updateExpression - SpEL expression for an UpdateDefinition.
      Since:
      5.5
    • setApplicationContext

      public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
      Specified by:
      setApplicationContext in interface ApplicationContextAware
      Throws:
      BeansException
    • getCollectionNameExpression

      public Expression getCollectionNameExpression()
    • getMongoConverter

      public MongoConverter getMongoConverter()
    • getEntityClass

      public Class<?> getEntityClass()
    • isExpectSingleResult

      public boolean isExpectSingleResult()
    • getUpdateExpression

      public Expression getUpdateExpression()
    • getApplicationContext

      public ApplicationContext getApplicationContext()
    • setInitialized

      protected void setInitialized(boolean initialized)
    • isInitialized

      protected boolean isInitialized()
    • onInit

      protected void onInit()
      Overrides:
      onInit in class AbstractExpressionEvaluator
    • evaluateQueryExpression

      protected Query evaluateQueryExpression()
    • evaluateCollectionNameExpression

      protected String evaluateCollectionNameExpression()
    • getByIdInQuery

      protected Query getByIdInQuery(Collection<?> entities)
    • idForEntity

      protected org.springframework.data.util.Pair<String,Object> idForEntity(Object entity)
    • evaluateUpdateExpression

      @Nullable protected Update evaluateUpdateExpression()