docs: private static synchronized JcrRepository getRepository( String configFileName,
                                                               String repositoryName,
                                                               final Context nameCtx,
                                                               final Name jndiName )
          throws IOException, RepositoryException, NamingException {
  
          if (!StringUtil.isBlank(repositoryName)) {
              // Make sure the engine is running ...
              ENGINE.start();
  
              // See if we can shortcut the process by using the name ...
              try {
                  JcrRepository repository = ENGINE.getRepository(repositoryName);
                  switch (repository.getState()) {
                      case STARTING:
                      case RUNNING:
                          return repository;
                      default:
                          LOG.error(JcrI18n.repositoryIsNotRunningOrHasBeenShutDown, repositoryName);
                          return null;
                  }
              } catch (NoSuchRepositoryException e) {
                  if (configFileName == null) {
                      // No configuration file given, so we can't do anything ...
                      throw e;
                  }
                  // Nothing found, so continue ...
              }
          }
  
          RepositoryConfiguration config = RepositoryConfiguration.read(configFileName);
          if (repositoryName == null) {
              repositoryName = config.getName();
          } else if (!repositoryName.equals(config.getName())) {
              LOG.warn(JcrI18n.repositoryNameDoesNotMatchConfigurationName, repositoryName, config.getName(), configFileName);
          }
  
          // Try to deploy and start the repository ...
          ENGINE.start();
          JcrRepository repository = ENGINE.deploy(config);
          try {
              ENGINE.startRepository(repository.getName()).get();
          } catch (InterruptedException e) {
              Thread.interrupted();
              throw new RepositoryException(e);
          } catch (ExecutionException e) {
              throw new RepositoryException(e.getCause());
          }
  
          // Register the JNDI listener, to shut down the repository when removed from JNDI ...
          if (nameCtx instanceof EventContext) {
              registerNamingListener((EventContext)nameCtx, jndiName);
          }
  
          return repository;
      }