@Override
  protected void onInit() throws Exception {
    super.onInit();

    if (this.evaluationContext == null) {
      this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
    }
  }
 @Override
 public final void afterPropertiesSet() {
   Assert.state(
       this.remoteDirectoryExpression != null, "'remoteDirectoryExpression' must not be null");
   if (this.evaluationContext == null) {
     this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.beanFactory);
   }
   doInit();
 }
  /**
   * Initializes the Content Enricher. Will instantiate an internal Gateway if the requestChannel is
   * set.
   */
  @Override
  protected void doInit() {
    if (this.replyChannel != null) {
      Assert.notNull(
          this.requestChannel,
          "If the replyChannel is set, then the requestChannel must not be null");
    }
    if (this.requestChannel != null) {
      this.gateway = new Gateway();
      this.gateway.setRequestChannel(requestChannel);

      if (this.requestTimeout != null) {
        this.gateway.setRequestTimeout(this.requestTimeout);
      }

      if (this.replyTimeout != null) {
        this.gateway.setReplyTimeout(this.replyTimeout);
      }

      if (replyChannel != null) {
        this.gateway.setReplyChannel(replyChannel);
      }

      if (this.getBeanFactory() != null) {
        this.gateway.setBeanFactory(this.getBeanFactory());
      }

      this.gateway.afterPropertiesSet();
    }

    if (this.sourceEvaluationContext == null) {
      this.sourceEvaluationContext =
          ExpressionUtils.createStandardEvaluationContext(this.getBeanFactory());
    }

    StandardEvaluationContext targetContext =
        ExpressionUtils.createStandardEvaluationContext(this.getBeanFactory());
    // bean resolution is NOT allowed for the target of the enrichment
    targetContext.setBeanResolver(null);
    this.targetEvaluationContext = targetContext;
  }
  @Override
  protected void onInit() throws Exception {
    super.onInit();
    Assert.state(
        !(this.discardChannelName != null && this.discardChannel != null),
        "'discardChannelName' and 'discardChannel' are mutually exclusive.");
    BeanFactory beanFactory = this.getBeanFactory();
    if (beanFactory != null) {
      if (this.outputProcessor instanceof BeanFactoryAware) {
        ((BeanFactoryAware) this.outputProcessor).setBeanFactory(beanFactory);
      }
      if (this.correlationStrategy instanceof BeanFactoryAware) {
        ((BeanFactoryAware) this.correlationStrategy).setBeanFactory(beanFactory);
      }
      if (this.releaseStrategy instanceof BeanFactoryAware) {
        ((BeanFactoryAware) this.releaseStrategy).setBeanFactory(beanFactory);
      }
    }

    if (this.discardChannel == null) {
      this.discardChannel = new NullChannel();
    }

    if (this.releasePartialSequences) {
      Assert.isInstanceOf(
          SequenceSizeReleaseStrategy.class,
          this.releaseStrategy,
          "Release strategy of type ["
              + this.releaseStrategy.getClass().getSimpleName()
              + "] cannot release partial sequences. Use the default SequenceSizeReleaseStrategy instead.");
      ((SequenceSizeReleaseStrategy) this.releaseStrategy)
          .setReleasePartialSequences(releasePartialSequences);
    }

    if (this.evaluationContext == null) {
      this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
    }

    /*
     * Disallow any further changes to the lock registry
     * (checked in the setter).
     */
    this.lockRegistrySet = true;
    this.forceReleaseProcessor = createGroupTimeoutProcessor();
  }
 @Override
 protected void onInit() throws Exception {
   this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.getBeanFactory());
   Assert.state(
       !this.mapKeyExpressionExplicitlySet
           || (this.collectionType == CollectionType.MAP
               || this.collectionType == CollectionType.PROPERTIES),
       "'mapKeyExpression' can only be set for CollectionType.MAP or CollectionType.PROPERTIES");
   if (!this.redisTemplateExplicitlySet) {
     if (!this.extractPayloadElements) {
       RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
       StringRedisSerializer serializer = new StringRedisSerializer();
       template.setKeySerializer(serializer);
       template.setHashKeySerializer(serializer);
       this.redisTemplate = template;
     }
     this.redisTemplate.setConnectionFactory(this.connectionFactory);
     this.redisTemplate.afterPropertiesSet();
   }
   this.initialized = true;
 }
  /**
   * Initializes the Content Enricher. Will instantiate an internal Gateway if the requestChannel is
   * set.
   */
  @Override
  protected void doInit() {
    Assert.state(
        !(this.requestChannelName != null && this.requestChannel != null),
        "'requestChannelName' and 'requestChannel' are mutually exclusive.");

    Assert.state(
        !(this.replyChannelName != null && this.replyChannel != null),
        "'replyChannelName' and 'replyChannel' are mutually exclusive.");

    Assert.state(
        !(this.errorChannelName != null && this.errorChannel != null),
        "'errorChannelName' and 'errorChannel' are mutually exclusive.");

    if (this.replyChannel != null || this.replyChannelName != null) {
      Assert.state(
          this.requestChannel != null || this.requestChannelName != null,
          "If the replyChannel is set, then the requestChannel must not be null");
    }
    if (this.errorChannel != null || this.errorChannelName != null) {
      Assert.state(
          this.requestChannel != null || this.requestChannelName != null,
          "If the errorChannel is set, then the requestChannel must not be null");
    }
    if (this.requestChannel != null || this.requestChannelName != null) {
      this.gateway = new Gateway();
      this.gateway.setRequestChannel(this.requestChannel);
      if (this.requestChannelName != null) {
        this.gateway.setRequestChannelName(this.requestChannelName);
      }

      if (this.requestTimeout != null) {
        this.gateway.setRequestTimeout(this.requestTimeout);
      }
      if (this.replyTimeout != null) {
        this.gateway.setReplyTimeout(this.replyTimeout);
      }

      this.gateway.setReplyChannel(replyChannel);
      if (this.replyChannelName != null) {
        this.gateway.setReplyChannelName(this.replyChannelName);
      }

      this.gateway.setErrorChannel(errorChannel);
      if (this.errorChannelName != null) {
        this.gateway.setErrorChannelName(this.errorChannelName);
      }

      if (this.getBeanFactory() != null) {
        this.gateway.setBeanFactory(this.getBeanFactory());
      }

      this.gateway.afterPropertiesSet();
    }

    if (this.sourceEvaluationContext == null) {
      this.sourceEvaluationContext =
          ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
    }

    StandardEvaluationContext targetContext =
        ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
    // bean resolution is NOT allowed for the target of the enrichment
    targetContext.setBeanResolver(null);
    this.targetEvaluationContext = targetContext;

    if (this.getBeanFactory() != null) {
      for (HeaderValueMessageProcessor<?> headerValueMessageProcessor :
          this.headerExpressions.values()) {
        if (headerValueMessageProcessor instanceof BeanFactoryAware) {
          ((BeanFactoryAware) headerValueMessageProcessor).setBeanFactory(getBeanFactory());
        }
      }
      for (HeaderValueMessageProcessor<?> headerValueMessageProcessor :
          this.nullResultHeaderExpressions.values()) {
        if (headerValueMessageProcessor instanceof BeanFactoryAware) {
          ((BeanFactoryAware) headerValueMessageProcessor).setBeanFactory(getBeanFactory());
        }
      }
    }
  }