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 Summary

    Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement

    org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.springframework.expression.Expression
     

    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(org.springframework.expression.Expression queryExpression)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
     
    protected org.springframework.data.mongodb.core.query.Query
     
    protected org.springframework.data.mongodb.core.query.Update
     
    org.springframework.context.ApplicationContext
     
    protected org.springframework.data.mongodb.core.query.Query
     
    org.springframework.expression.Expression
     
     
    org.springframework.data.mongodb.core.convert.MongoConverter
     
    org.springframework.expression.Expression
     
    protected org.springframework.data.util.Pair<String,Object>
     
    boolean
     
    protected boolean
     
    protected void
     
    void
    setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
     
    void
    setCollectionNameExpression(org.springframework.expression.Expression collectionNameExpression)
    Set the SpEL Expression that should resolve to a collection name used by the Query.
    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(org.springframework.data.mongodb.core.convert.MongoConverter mongoConverter)
    Provide a custom MongoConverter used to assist in deserialization data read from MongoDb.
    void
    setUpdateExpression(org.springframework.expression.Expression updateExpression)
    Specify an optional update 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

      protected final org.springframework.expression.Expression queryExpression
  • Constructor Details

    • AbstractMongoDbMessageSource

      protected AbstractMongoDbMessageSource(org.springframework.expression.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(org.springframework.expression.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(org.springframework.data.mongodb.core.convert.MongoConverter mongoConverter)
      Provide a custom MongoConverter used to assist in deserialization data read from MongoDb.
      Parameters:
      mongoConverter - The mongo converter.
    • setUpdateExpression

      public void setUpdateExpression(org.springframework.expression.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(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • getCollectionNameExpression

      public org.springframework.expression.Expression getCollectionNameExpression()
    • getMongoConverter

      public org.springframework.data.mongodb.core.convert.MongoConverter getMongoConverter()
    • getEntityClass

      public Class<?> getEntityClass()
    • isExpectSingleResult

      public boolean isExpectSingleResult()
    • getUpdateExpression

      public org.springframework.expression.Expression getUpdateExpression()
    • getApplicationContext

      public org.springframework.context.ApplicationContext getApplicationContext()
    • setInitialized

      protected void setInitialized(boolean initialized)
    • isInitialized

      protected boolean isInitialized()
    • onInit

      protected void onInit()
      Overrides:
      onInit in class org.springframework.integration.util.AbstractExpressionEvaluator
    • evaluateQueryExpression

      protected org.springframework.data.mongodb.core.query.Query evaluateQueryExpression()
    • evaluateCollectionNameExpression

      protected String evaluateCollectionNameExpression()
    • getByIdInQuery

      protected org.springframework.data.mongodb.core.query.Query getByIdInQuery(Collection<?> entities)
    • idForEntity

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

      @Nullable protected org.springframework.data.mongodb.core.query.Update evaluateUpdateExpression()