code: public void createRepository(RepositoryEntry rEntry) throws RepositoryConfigurationException, RepositoryException
     {
        // Need privileges to manage repository.
        SecurityManager security = System.getSecurityManager();
        if (security != null)
        {
           security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
        }
  
        if (repositoryContainers.containsKey(rEntry.getName()))
        {
           throw new RepositoryConfigurationException("Repository container " + rEntry.getName() + " already started");
        }
  
        final RepositoryContainer repositoryContainer =
           new RepositoryContainer(parentContainer, rEntry, addNamespacesPlugins);
  
        // Storing and starting the repository container under
        // key=repository_name
        try
        {
           if (repositoryContainers.putIfAbsent(rEntry.getName(), repositoryContainer) == null)
           {
              SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
              {
                 public Void run()
                 {
                    repositoryContainer.start();
                    return null;
                 }
              });
           }
           else
           {
              throw new RepositoryConfigurationException("Repository container " + rEntry.getName() + " already started");
           }
        }
        catch (Throwable t) //NOSONAR
        {
           repositoryContainers.remove(rEntry.getName());
  
           throw new RepositoryConfigurationException("Repository container " + rEntry.getName() + " was not started.", t);
        }
  
        if (!config.getRepositoryConfigurations().contains(rEntry))
        {
           config.getRepositoryConfigurations().add(rEntry);
        }
  
        registerNodeTypes(rEntry.getName());
  
        // turn on Repository ONLINE
        ManageableRepository mr =
           (ManageableRepository)repositoryContainer.getComponentInstanceOfType(ManageableRepository.class);
        mr.setState(ManageableRepository.ONLINE);
     }
docs: Create repository. <br>
  Init worksapces for initial start or them load from persistence. <br>
  Add namespaces and nodetypes from service plugins.