/**
   * Initialize the supplied provider.
   *
   * @param provider the provider; may not be null
   * @throws RepositoryException if there is a problem initializing the provider
   */
  protected void doInitialize(IndexProvider provider) throws RepositoryException {

    // Set the execution context instance ...
    Reflection.setValue(provider, "context", repository.context());

    // Set the environment
    Reflection.setValue(provider, "environment", repository.environment());

    provider.initialize();

    // If successful, call the 'postInitialize' method reflectively (due to inability to call
    // directly) ...
    Method postInitialize = Reflection.findMethod(IndexProvider.class, "postInitialize");
    Reflection.invokeAccessibly(provider, postInitialize, new Object[] {});

    if (logger.isDebugEnabled()) {
      logger.debug(
          "Successfully initialized index provider '{0}' in repository '{1}'",
          provider.getName(), repository.name());
    }
  }