/**
   * afterPropertiesSet
   *
   * @throws java.lang.Exception if any.
   */
  @Override
  public void afterPropertiesSet() throws Exception {
    Assert.state(m_resourceService != null, "resourceService property has not been set");
    Assert.state(m_kscReportFactory != null, "kscReportFactory property has not been set");

    initTimeSpans();
  }
 @PostConstruct
 public void init() {
   System.out.println("SnmpDevice Locator 开始初始化");
   Assert.state(m_snmpDeviceService != null, "m_SnmpDeviceDao不能为空,请检查");
   Assert.state(m_domainLocator != null, "m_domainLocator不能为空,请检查");
   distruteAllSnmpDeviceNode();
 }
Example #3
0
  /** onInit */
  protected void onInit() {

    Assert.state(m_queryMgr != null, "must set the queryManager property");
    Assert.state(m_linkdConfig != null, "must set the linkdConfig property");
    Assert.state(m_scheduler != null, "must set the scheduler property");
    Assert.state(m_eventForwarder != null, "must set the eventForwarder property");

    // FIXME: circular dependency
    m_queryMgr.setLinkd(this);

    m_activepackages = new ArrayList<String>();

    // initialize the ipaddrsentevents
    m_newSuspectEventsIpAddr = new TreeSet<InetAddress>(new InetAddressComparator());
    m_newSuspectEventsIpAddr.add(addr("127.0.0.1"));
    m_newSuspectEventsIpAddr.add(addr("0.0.0.0"));

    try {
      m_nodes = m_queryMgr.getSnmpNodeList();
      m_queryMgr.updateDeletedNodes();
    } catch (SQLException e) {
      LogUtils.errorf(this, e, "SQL exception executing on database");
      throw new UndeclaredThrowableException(e);
    }

    Assert.notNull(m_nodes);
    scheduleCollection();

    LogUtils.infof(this, "init: LINKD CONFIGURATION INITIALIZED");
  }
 /** afterPropertiesSet */
 @Override
 public void afterPropertiesSet() {
   Assert.state(m_nodeDao != null, "nodeDao property has not been set");
   Assert.state(m_resourceDao != null, "resourceDao property has not been set");
   Assert.state(m_graphDao != null, "graphDao property has not been set");
   Assert.state(m_rrdDao != null, "rrdDao property has not been set");
 }
 private boolean isTap() {
   if (tap != null) {
     Assert.state(tap.getName() != null, "Tap name not provided");
     Assert.state(!tap.getGroup().equals(group), "Tap group cannot be the same as module group");
   }
   return tap != null;
 }
 private void prepareEvaluationContext(
     StandardEvaluationContext context,
     Object method,
     Class<? extends Annotation> annotationType) {
   Class<?> targetType = AopUtils.getTargetClass(this.targetObject);
   if (method instanceof Method) {
     context.registerMethodFilter(targetType, new FixedMethodFilter((Method) method));
     if (expectedType != null) {
       Assert.state(
           context
               .getTypeConverter()
               .canConvert(
                   TypeDescriptor.valueOf(((Method) method).getReturnType()),
                   TypeDescriptor.valueOf(expectedType)),
           "Cannot convert to expected type (" + expectedType + ") from " + method);
     }
   } else if (method == null || method instanceof String) {
     AnnotatedMethodFilter filter =
         new AnnotatedMethodFilter(annotationType, (String) method, this.requiresReply);
     Assert.state(
         canReturnExpectedType(filter, targetType, context.getTypeConverter()),
         "Cannot convert to expected type (" + expectedType + ") from " + method);
     context.registerMethodFilter(targetType, filter);
   }
   context.setVariable("target", targetObject);
 }
Example #7
0
  /** Get/allocate spaceNeeded entries for the designated float-based attribute */
  private int getFloatSpace(int attrId, int spaceNeeded) {
    int sequence =
        AttrDefinitionMgr.getAttrIndex(attrId); // this should be unique across all attributes

    if (sequence < indicesPlusOne.size()) {
      int indexPlusOne = indicesPlusOne.getQuick(sequence);
      if (indexPlusOne > 0) {
        Assert.state(
            getLength(attrId) == spaceNeeded,
            "getLength = "
                + getLength(attrId)
                + ", requested = "
                + spaceNeeded); // dumbo check to ensure not asking for diff size
        return indexPlusOne - 1;
      }
    } else {
      padSpace(indicesPlusOne, sequence);
    }

    // okay, it's not been allocated so ...
    int index = nextFloatsIndex;
    nextFloatsIndex += spaceNeeded;

    indicesPlusOne.set(sequence, index + 1);

    // Add to list of attrIds for iterator
    Assert.state(attrIds.contains(attrId) == false);
    attrIds.add(attrId);

    setLength(sequence, spaceNeeded);

    syncToStore(); // we sync here as we've modified
    return index;
  }
  /**
   * afterPropertiesSet
   *
   * @throws java.lang.Exception if any.
   */
  @Override
  public void afterPropertiesSet() throws Exception {
    Assert.state(
        m_configResource != null, "property configResource must be set to a non-null value");
    Assert.state(m_localServer != null, "property localServer must be set to a non-null value");
    Assert.state(m_verifyServer != null, "property verifyServer must be set to a non-null value");

    loadConfig();
  }
Example #9
0
 /** afterPropertiesSet */
 public void afterPropertiesSet() {
   Assert.state(m_jdbcTemplate != null, "property jdbcTemplate must be set to a non-null value");
   Assert.state(m_capsdConfig != null, "property capsdConfig must be set to a non-null value");
   Assert.state(
       m_opennmsServerConfig != null,
       "property opennmsServerConfig must be set to a non-null value");
   Assert.state(m_pollerConfig != null, "property pollerConfig must be set to a non-null value");
   Assert.state(
       m_collectdConfig != null, "property collectdConfig must be set to a non-null value");
 }
 @Override
 protected void doInit() {
   Assert.state(
       exchangeNameExpression == null || exchangeName == null,
       "Either an exchangeName or an exchangeNameExpression can be provided, but not both");
   BeanFactory beanFactory = this.getBeanFactory();
   if (this.exchangeNameExpression != null) {
     this.exchangeNameGenerator =
         new ExpressionEvaluatingMessageProcessor<String>(
             this.exchangeNameExpression, String.class);
     if (beanFactory != null) {
       this.exchangeNameGenerator.setBeanFactory(beanFactory);
     }
   }
   Assert.state(
       routingKeyExpression == null || routingKey == null,
       "Either a routingKey or a routingKeyExpression can be provided, but not both");
   if (this.routingKeyExpression != null) {
     this.routingKeyGenerator =
         new ExpressionEvaluatingMessageProcessor<String>(this.routingKeyExpression, String.class);
     if (beanFactory != null) {
       this.routingKeyGenerator.setBeanFactory(beanFactory);
     }
   }
   if (this.confirmCorrelationExpression != null) {
     this.correlationDataGenerator =
         new ExpressionEvaluatingMessageProcessor<Object>(
             this.confirmCorrelationExpression, Object.class);
     Assert.isInstanceOf(
         RabbitTemplate.class,
         this.amqpTemplate,
         "RabbitTemplate implementation is required for publisher confirms");
     ((RabbitTemplate) this.amqpTemplate).setConfirmCallback(this);
     if (beanFactory != null) {
       this.correlationDataGenerator.setBeanFactory(beanFactory);
     }
   } else {
     NullChannel nullChannel = extractTypeIfPossible(this.confirmAckChannel, NullChannel.class);
     Assert.state(
         this.confirmAckChannel == null || nullChannel != null,
         "A 'confirmCorrelationExpression' is required when specifying a 'confirmAckChannel'");
     nullChannel = extractTypeIfPossible(this.confirmNackChannel, NullChannel.class);
     Assert.state(
         this.confirmNackChannel == null || nullChannel != null,
         "A 'confirmCorrelationExpression' is required when specifying a 'confirmNackChannel'");
   }
   if (this.returnChannel != null) {
     Assert.isInstanceOf(
         RabbitTemplate.class,
         this.amqpTemplate,
         "RabbitTemplate implementation is required for publisher confirms");
     ((RabbitTemplate) this.amqpTemplate).setReturnCallback(this);
   }
 }
 /**
  * afterPropertiesSet
  *
  * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
  */
 @Override
 public void afterPropertiesSet() {
   Assert.state(
       m_delegatedVisitor != null, "property delegatedVisitor must be set to a non-null value");
   Assert.state(
       m_resourceAttributeKey != null,
       "property resourceAttributeKey must be set to a non-null value");
   Assert.state(
       m_resourceAttributeValueMatch != null,
       "property resourceAttributeValueMatch must be set to a non-null value");
 }
 @PostConstruct
 public void checkLocationExists() {
   if (this.properties.isCheckLocation()) {
     Assert.state(
         !this.properties.getLocations().isEmpty(), "Migration script locations not configured");
     boolean exists = hasAtLeastOneLocation();
     Assert.state(
         exists,
         "Cannot find migrations location in: "
             + this.properties.getLocations()
             + " (please add migrations or check your Flyway configuration)");
   }
 }
 /**
  * Create a new chunk oriented tasklet with reader, writer and processor as provided.
  *
  * @see org.springframework.batch.core.step.builder.SimpleStepBuilder#createTasklet()
  */
 @Override
 protected Tasklet createTasklet() {
   Assert.state(getReader() != null, "ItemReader must be provided");
   Assert.state(
       getProcessor() != null || getWriter() != null,
       "ItemWriter or ItemProcessor must be provided");
   addSpecialExceptions();
   registerSkipListeners();
   FaultTolerantChunkProvider<I> chunkProvider = createChunkProvider();
   FaultTolerantChunkProcessor<I, O> chunkProcessor = createChunkProcessor();
   ChunkOrientedTasklet<I> tasklet = new ChunkOrientedTasklet<I>(chunkProvider, chunkProcessor);
   tasklet.setBuffering(!isReaderTransactionalQueue());
   return tasklet;
 }
  /**
   * Rename a file or folder.
   *
   * @param from the source to rename, this will be a complete reference to a file or folder
   * @param to the destination name, this will be a complete reference to the new name (including
   *     path)
   * @param overwrite <tt>true</tt> if any existing destination should be overwritten. If this
   *     parameter is <tt>false</tt> a unique name should be generated based on <tt>to</tt>.
   * @return the name of the new file (excluding the path)
   */
  public String renameFile(
      @ParamName(name = "from") String from,
      @ParamName(name = "to") String to,
      @ParamName(name = "overwrite") boolean overwrite) {

    Resource source = getResource(from, Resource.class);

    ResourcePath destination = new ResourcePath().get(to);
    Folder destinationFolder = getResource(destination.getParent().toString(), Folder.class);
    Assert.state(
        destinationFolder.exists(),
        "The destination folder '" + destinationFolder + "' does not exist");

    String destinationName = destination.getName();
    if (destinationFolder.hasExisting(destinationName) && !overwrite) {
      destinationName = generateUniqueNumberedFileName(destinationFolder, destinationName);
    }

    Resource renamed = source;
    if (!destinationFolder.equals(renamed.getParent())) {
      renamed = renamed.moveTo(destinationFolder);
    }
    if (!renamed.getName().equals(destinationName)) {
      renamed = renamed.rename(destinationName);
    }
    return renamed.getName();
  }
  @SuppressWarnings("unchecked")
  public void afterPropertiesSet() throws Exception {

    Assert.state(yaml != null, "Yaml document should not be null");

    Validator validator = Validation.buildDefaultValidatorFactory().getValidator();

    try {
      logger.trace("Yaml document is\n" + yaml);
      configuration = (T) (new Yaml(constructor)).load(yaml);
      Set<ConstraintViolation<T>> errors = validator.validate(configuration);

      if (!errors.isEmpty()) {
        logger.error("YAML configuration failed validation");
        for (ConstraintViolation<?> error : errors) {
          logger.error(error.getPropertyPath() + ": " + error.getMessage());
        }
        if (exceptionIfInvalid) {
          @SuppressWarnings("rawtypes")
          ConstraintViolationException summary = new ConstraintViolationException((Set) errors);
          throw summary;
        }
      }
    } catch (YAMLException e) {
      if (exceptionIfInvalid) {
        throw e;
      }
      logger.error("Failed to load YAML validation bean. Your YAML file may be invalid.", e);
    }
  }
 public SockJsMessageCodec getMessageCodec() {
   Assert.state(
       this.messageCodec != null,
       "A SockJsMessageCodec is required but not available: "
           + "Add Jackson 2 to the classpath, or configure a custom SockJsMessageCodec.");
   return this.messageCodec;
 }
  public JobInstance createJobInstance(String jobName, final JobParameters jobParameters) {
    Assert.notNull(jobName, "Job name must not be null.");
    Assert.notNull(jobParameters, "JobParameters must not be null.");

    Assert.state(
        getJobInstance(jobName, jobParameters) == null, "JobInstance must not already exist");

    Long jobId = getNextId(JobInstance.class.getSimpleName(), mongoTemplate);

    JobInstance jobInstance = new JobInstance(jobId, jobName);

    jobInstance.incrementVersion();

    Map<String, JobParameter> jobParams = jobParameters.getParameters();
    Map<String, Object> paramMap = new HashMap<String, Object>(jobParams.size());
    for (Map.Entry<String, JobParameter> entry : jobParams.entrySet()) {
      paramMap.put(
          entry.getKey().replaceAll(DOT_STRING, DOT_ESCAPE_STRING), entry.getValue().getValue());
    }
    getCollection()
        .save(
            start()
                .add(JOB_INSTANCE_ID_KEY, jobId)
                .add(JOB_NAME_KEY, jobName)
                .add(JOB_KEY_KEY, createJobKey(jobParameters))
                .add(VERSION_KEY, jobInstance.getVersion())
                .add(JOB_PARAMETERS_KEY, new BasicDBObject(paramMap))
                .get());
    return jobInstance;
  }
 @Override
 public void applyPromotion(final Owner owner, final Bonus bonus) {
   final Account account = accountService.findAccountByOwner(owner);
   Assert.state(account != null, "account doesn't exist");
   final double updatedBalance = account.getBalance() + bonus.getBonusAmount();
   accountService.updateAccountBalance(account, updatedBalance);
 }
 @Override
 public void afterPropertiesSet() throws Exception {
   Assert.state(
       getUri() != null,
       "You need to configure a uri for the subversion repository (e.g. 'http://example.com/svn/')");
   resolveRelativeFileUri();
 }
 protected final SubProtocolHandler findProtocolHandler(WebSocketSession session) {
   String protocol = null;
   try {
     protocol = session.getAcceptedProtocol();
   } catch (Exception ex) {
     // Shouldn't happen
     logger.error(
         "Failed to obtain session.getAcceptedProtocol(). Will use the "
             + "default protocol handler (if configured).",
         ex);
   }
   SubProtocolHandler handler;
   if (!StringUtils.isEmpty(protocol)) {
     handler = this.protocolHandlerLookup.get(protocol);
     Assert.state(
         handler != null, "No handler for '" + protocol + "' among " + this.protocolHandlerLookup);
   } else {
     if (this.defaultProtocolHandler != null) {
       handler = this.defaultProtocolHandler;
     } else if (this.protocolHandlers.size() == 1) {
       handler = this.protocolHandlers.iterator().next();
     } else {
       throw new IllegalStateException(
           "Multiple protocol handlers configured and "
               + "no protocol was negotiated. Consider configuring a default SubProtocolHandler.");
     }
   }
   return handler;
 }
Example #21
0
 /** Obtain a lazily initializted CachedIntrospectionResults instance for the wrapped object. */
 private CachedIntrospectionResults getCachedIntrospectionResults() {
   Assert.state(this.object != null, "BeanWrapper does not hold a bean instance");
   if (this.cachedIntrospectionResults == null) {
     this.cachedIntrospectionResults = CachedIntrospectionResults.forClass(getWrappedClass());
   }
   return this.cachedIntrospectionResults;
 }
 @Override
 public void execute(Runnable task, long startTimeout) {
   Assert.state(this.workManager != null, "No WorkManager specified");
   Work work = new DelegatingWork(task);
   try {
     if (this.blockUntilCompleted) {
       if (startTimeout != TIMEOUT_INDEFINITE || this.workListener != null) {
         this.workManager.doWork(work, startTimeout, null, this.workListener);
       } else {
         this.workManager.doWork(work);
       }
     } else if (this.blockUntilStarted) {
       if (startTimeout != TIMEOUT_INDEFINITE || this.workListener != null) {
         this.workManager.startWork(work, startTimeout, null, this.workListener);
       } else {
         this.workManager.startWork(work);
       }
     } else {
       if (startTimeout != TIMEOUT_INDEFINITE || this.workListener != null) {
         this.workManager.scheduleWork(work, startTimeout, null, this.workListener);
       } else {
         this.workManager.scheduleWork(work);
       }
     }
   } catch (WorkRejectedException ex) {
     if (WorkException.START_TIMED_OUT.equals(ex.getErrorCode())) {
       throw new TaskTimeoutException(
           "JCA WorkManager rejected task because of timeout: " + task, ex);
     } else {
       throw new TaskRejectedException("JCA WorkManager rejected task: " + task, ex);
     }
   } catch (WorkException ex) {
     throw new SchedulingException("Could not schedule task on JCA WorkManager", ex);
   }
 }
Example #23
0
  @Override
  public void afterPropertiesSet() throws Exception {
    // Check the signing and verification keys match
    if (signer instanceof RsaSigner) {
      RsaVerifier verifier;
      try {
        verifier = new RsaVerifier(verifierKey);
      } catch (Exception e) {
        logger.warn("Unable to create an RSA verifier from verifierKey");
        return;
      }

      byte[] test = "test".getBytes();
      try {
        verifier.verify(test, signer.sign(test));
        logger.info("Signing and verification RSA keys match");
      } catch (InvalidSignatureException e) {
        logger.error("Signing and verification RSA keys do not match");
      }
    } else {
      // Avoid a race condition where verifier is set after signer to a different (possibly
      // incompatible value)
      Assert.state(
          this.signingKey == this.verifierKey,
          "For MAC signing you do not need to specify the verifier key separately, and if you do it must match the signing key");
    }
  }
 protected WebApplicationContext createRootApplicationContext(ServletContext servletContext) {
   SpringApplicationBuilder builder = new SpringApplicationBuilder();
   builder.main(getClass());
   ApplicationContext parent = getExistingRootWebApplicationContext(servletContext);
   if (parent != null) {
     this.logger.info("Root context already created (using as parent).");
     servletContext.setAttribute(
         WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, null);
     builder.initializers(new ParentContextApplicationContextInitializer(parent));
   }
   builder.initializers(new ServletContextApplicationContextInitializer(servletContext));
   builder.contextClass(AnnotationConfigEmbeddedWebApplicationContext.class);
   builder = configure(builder);
   SpringApplication application = builder.build();
   if (application.getSources().isEmpty()
       && AnnotationUtils.findAnnotation(getClass(), Configuration.class) != null) {
     application.getSources().add(getClass());
   }
   Assert.state(
       application.getSources().size() > 0,
       "No SpringApplication sources have been defined. Either override the "
           + "configure method or add an @Configuration annotation");
   // Ensure error pages are registered
   application.getSources().add(ErrorPageFilter.class);
   return run(application);
 }
 @Override
 @SuppressWarnings({"unchecked", "rawtypes"})
 protected Tasklet createTasklet() {
   Assert.state(getReader() != null, "ItemReader must be provided");
   Assert.state(
       getProcessor() != null || getWriter() != null,
       "ItemWriter or ItemProcessor must be provided");
   RepeatOperations repeatOperations = createRepeatOperations();
   ChunkProvider<I> chunkProvider = new JsrChunkProvider<I>();
   JsrChunkProcessor<I, O> chunkProcessor =
       new JsrChunkProcessor(getReader(), getProcessor(), getWriter(), repeatOperations);
   chunkProcessor.setListeners(new ArrayList<StepListener>(getItemListeners()));
   ChunkOrientedTasklet<I> tasklet = new ChunkOrientedTasklet<I>(chunkProvider, chunkProcessor);
   tasklet.setBuffering(!isReaderTransactionalQueue());
   return tasklet;
 }
  /**
   * Get a {@link PagingQueryProvider} instance using the provided properties and appropriate for
   * the given database type.
   *
   * @see FactoryBean#getObject()
   */
  @Override
  public PagingQueryProvider getObject() throws Exception {

    DatabaseType type;
    try {
      type =
          databaseType != null
              ? DatabaseType.valueOf(databaseType.toUpperCase())
              : DatabaseType.fromMetaData(dataSource);
    } catch (MetaDataAccessException e) {
      throw new IllegalArgumentException(
          "Could not inspect meta data for database type.  You have to supply it explicitly.", e);
    }

    AbstractSqlPagingQueryProvider provider = providers.get(type);
    Assert.state(
        provider != null,
        "Should not happen: missing PagingQueryProvider for DatabaseType=" + type);

    provider.setFromClause(fromClause);
    provider.setWhereClause(whereClause);
    provider.setSortKeys(sortKeys);
    if (StringUtils.hasText(selectClause)) {
      provider.setSelectClause(selectClause);
    }
    if (StringUtils.hasText(groupClause)) {
      provider.setGroupClause(groupClause);
    }

    provider.init(dataSource);

    return provider;
  }
  /**
   * Will extract the payload from the Message and store it in the collection identified by the key
   * (which may be determined by an expression). The type of collection is specified by the {@link
   * #collectionType} property. The default CollectionType is LIST.
   *
   * <p>The rules for storing the payload are:
   *
   * <p><b>LIST/SET</b> If the payload is of type Collection and {@link #extractPayloadElements} is
   * 'true' (default), the payload will be added using the addAll() method. If {@link
   * #extractPayloadElements} is set to 'false', then regardless of the payload type, the payload
   * will be added using add().
   *
   * <p><b>ZSET</b> In addition to the rules described for LIST/SET, ZSET allows 'score' information
   * to be provided. The score can be provided using the {@link RedisHeaders#ZSET_SCORE} message
   * header when the payload is not a Map, or by sending a Map as the payload where each Map 'key'
   * is a value to be saved and each corresponding Map 'value' is the score assigned to it. If
   * {@link #extractPayloadElements} is set to 'false' the map will be stored as a single entry. If
   * the 'score' can not be determined, the default value (1) will be used.
   *
   * <p><b>MAP/PROPERTIES</b> You can also add items to a Map or Properties based store. If the
   * payload itself is of type Map or Properties, it can be stored either as a batch or single item
   * following the same rules as described above for other collection types. If the payload itself
   * needs to be stored as a value of the map/property then the map key must be specified via the
   * mapKeyExpression (default {@link RedisHeaders#MAP_KEY} Message header).
   */
  @SuppressWarnings("unchecked")
  @Override
  protected void handleMessageInternal(Message<?> message) throws Exception {
    String key = this.keyExpression.getValue(this.evaluationContext, message, String.class);
    Assert.hasText(
        key,
        "Failed to determine a key for the Redis store using expression: "
            + this.keyExpression.getExpressionString());

    RedisStore store = this.createStoreView(key);

    Assert.state(
        this.initialized,
        "handler not initialized - afterPropertiesSet() must be called before the first use");
    try {
      if (collectionType == CollectionType.ZSET) {
        this.writeToZset((RedisZSet<Object>) store, message);
      } else if (collectionType == CollectionType.SET) {
        this.writeToSet((RedisSet<Object>) store, message);
      } else if (collectionType == CollectionType.LIST) {
        this.writeToList((RedisList<Object>) store, message);
      } else if (collectionType == CollectionType.MAP) {
        this.writeToMap((RedisMap<Object, Object>) store, message);
      } else if (collectionType == CollectionType.PROPERTIES) {
        this.writeToProperties((RedisProperties) store, message);
      }
    } catch (Exception e) {
      throw new MessageHandlingException(
          message, "Failed to store Message data in Redis collection", e);
    }
  }
 /**
  * Internal version of getPropertyDescriptor: Returns null if not found rather than throwing an
  * exception.
  */
 protected PropertyDescriptor getPropertyDescriptorInternal(String propertyName)
     throws BeansException {
   Assert.state(this.object != null, "BeanWrapper does not hold a bean instance");
   BeanWrapperImpl nestedBw = getBeanWrapperForPropertyPath(propertyName);
   return nestedBw.cachedIntrospectionResults.getPropertyDescriptor(
       getFinalPath(nestedBw, propertyName));
 }
 @SuppressWarnings("unchecked")
 protected AbstractEndpoint doCreateEndpoint(
     MessageHandler handler, MessageChannel inputChannel, List<Annotation> annotations) {
   AbstractEndpoint endpoint;
   if (inputChannel instanceof PollableChannel) {
     PollingConsumer pollingConsumer =
         new PollingConsumer((PollableChannel) inputChannel, handler);
     configurePollingEndpoint(pollingConsumer, annotations);
     endpoint = pollingConsumer;
   } else {
     Poller[] pollers =
         MessagingAnnotationUtils.resolveAttribute(annotations, "poller", Poller[].class);
     Assert.state(
         ObjectUtils.isEmpty(pollers),
         "A '@Poller' should not be specified for Annotation-based "
             + "endpoint, since '"
             + inputChannel
             + "' is a SubscribableChannel (not pollable).");
     if (inputChannel instanceof Publisher) {
       Subscriber<Message<?>> subscriber;
       if (handler instanceof Subscriber) {
         subscriber = (Subscriber<Message<?>>) handler;
       } else {
         // TODO errorConsumer, completeConsumer
         DirectProcessor<Message<?>> directProcessor = DirectProcessor.create();
         directProcessor.doOnNext(handler::handleMessage);
         subscriber = directProcessor;
       }
       endpoint = new ReactiveConsumer(inputChannel, subscriber);
     } else {
       endpoint = new EventDrivenConsumer((SubscribableChannel) inputChannel, handler);
     }
   }
   return endpoint;
 }
  public void afterPropertiesSet() throws Exception {
    // Check the signing and verification keys match
    if (signer instanceof RsaSigner) {
      RsaVerifier verifier;
      try {
        verifier = new RsaVerifier(verifierKey);
      } catch (Exception e) {
        logger.warn("Unable to create an RSA verifier from verifierKey");
        return;
      }

      byte[] test = "test".getBytes();
      try {
        verifier.verify(test, signer.sign(test));
        logger.info("Signing and verification RSA keys match");
      } catch (InvalidSignatureException e) {
        logger.error("Signing and verification RSA keys do not match");
      }
    } else {
      // Avoid a race condition where setters are called in the wrong order. Use of == is
      // intentional.
      Assert.state(
          this.signingKey == this.verifierKey,
          "For MAC signing you do not need to specify the verifier key separately, and if you do it must match the signing key");
    }
    SignatureVerifier verifier = new MacSigner(verifierKey);
    try {
      verifier = new RsaVerifier(verifierKey);
    } catch (Exception e) {
      logger.warn("Unable to create an RSA verifier from verifierKey");
    }
    this.verifier = verifier;
  }