code: @PostConstruct
      public void buildListener() throws RepositoryException {
          LOGGER.debug("Constructing an observer for JCR events...");
          session = getJcrSession(repository.login());
          session.getWorkspace().getObservationManager()
                  .addEventListener(this, EVENT_TYPES, "/", true, null, null, false);
          session.save();
      }
docs: Register this observer with the JCR event listeners
  
  @throws RepositoryException if repository exception occurred