code: public boolean addRepository(final ArchiveRepository archiveRepository, final int pollInterval, TimeUnit timeUnit, boolean waitForInitialPoll) {
          if (pollInterval <= 0) {
              throw new IllegalArgumentException("invalid pollInterval " + pollInterval);
          }
          Objects.requireNonNull(timeUnit, "timeUnit");
          RepositoryPollerContext pollerContext = new RepositoryPollerContext();
          RepositoryPollerContext oldContext = repositoryContexts.putIfAbsent(archiveRepository, pollerContext);
          if (oldContext != null) {
              return false;
          }
          final CountDownLatch initialPollLatch = new CountDownLatch(1);
          ScheduledFuture<?> future = pollerThreadPool.scheduleWithFixedDelay(new Runnable() {
              public void run() {
                  try {
                      pollRepository(archiveRepository);
                      initialPollLatch.countDown();
                  } catch (Throwable t) {
                      // should never happen
                      logger.error("Excecution exception on poll" , t);
                  }
              }
          }, 0, pollInterval, timeUnit);
          pollerContext.future = future;
          if (waitForInitialPoll) {
              try {
                  initialPollLatch.await();
              } catch (Exception e) {
                  // should never happen
                  logger.error("Excecution exception on poll" , e);
              }
          }
          return true;
      }
docs: Add a repository and schedule polling
  @param archiveRepository repository to scan
  @param pollInterval how often this repository should be scanned
  @param timeUnit unit of the pollInterval param
  @param waitForInitialPoll whether or not to block until the initial poll is complete
  @return true if the repository was added. false if it already exists