Search in sources :

Example 1 with RepositoryConfig

use of org.apache.jackrabbit.jcr2spi.config.RepositoryConfig in project jackrabbit by apache.

the class RepositoryFactoryImplTest method testGetRepositoryFromRepositoryConfig.

public void testGetRepositoryFromRepositoryConfig() throws RepositoryException {
    Map<String, RepositoryConfig> parameters = Collections.singletonMap("org.apache.jackrabbit.jcr2spi.RepositoryConfig", RepositoryConfigImpl.INSTANCE);
    Repository repo = factory.getRepository(parameters);
    assertNotNull(repo);
}
Also used : RepositoryConfig(org.apache.jackrabbit.jcr2spi.config.RepositoryConfig) Repository(javax.jcr.Repository)

Example 2 with RepositoryConfig

use of org.apache.jackrabbit.jcr2spi.config.RepositoryConfig in project jackrabbit by apache.

the class Jcr2spiRepositoryFactory method getRepository.

/**
     * <p>Creates a SPI based <code>Repository</code> instance based on the
     * <code>parameters</code> passed.</p>
     *
     * <p>If the {@link #PARAM_REPOSITORY_SERVICE_FACTORY} parameter is set,
     * the specified {@link RepositoryServiceFactory} is used to create the
     * {@link RepositoryService} instance. All parameters are passed to
     * {@link RepositoryServiceFactory#createRepositoryService(Map)}.</p>
     *
     * <p>If the {@link #PARAM_REPOSITORY_CONFIG} parameter is set, the
     * specified {@link RepositoryConfig} instance is used to create the
     * repository.</p>
     *
     * <p>If both parameters are set, the latter takes precedence and the
     * former is ignores.</p>
     *
     * <p>The known SPI implementations and its <code>RepositoryServiceFactory</code>s are:
     * <ul>
     * <li>SPI2DAVex (see jackrabbit-spi2dav module): <code>Spi2davRepositoryServiceFactory</code></li>
     * <li>SPI2DAV (see jackrabbit-spi2dav module): <code>Spi2davexRepositoryServiceFactory</code></li>
     * <li>SPI2JCR (see jackrabbit-spi2jcr module) <code>Spi2jcrRepositoryServiceFactory</code></li>
     * </ul>
     * <p>
     * NOTE: If the <code>parameters</code> map contains an
     * {@link #PARAM_LOG_WRITER_PROVIDER} entry the
     * {@link org.apache.jackrabbit.spi.RepositoryService RepositoryService} obtained
     * from the configuration is wrapped by a SPI logger. See the
     * {@link org.apache.jackrabbit.spi.commons.logging.SpiLoggerFactory SpiLoggerFactory}
     * for details.
     *
     * @see RepositoryFactory#getRepository(java.util.Map)
     */
public Repository getRepository(@SuppressWarnings("unchecked") Map parameters) throws RepositoryException {
    RepositoryServiceFactory serviceFactory = getServiceFactory(parameters);
    Object configParam = parameters.get(PARAM_REPOSITORY_CONFIG);
    if (serviceFactory == null && configParam == null) {
        return null;
    }
    RepositoryConfig config;
    if (configParam instanceof RepositoryConfig) {
        config = (RepositoryConfig) configParam;
        if (serviceFactory != null) {
            log.warn("Ignoring {} since {} was specified", PARAM_REPOSITORY_SERVICE_FACTORY, PARAM_REPOSITORY_CONFIG);
        }
    } else {
        if (serviceFactory == null) {
            return null;
        } else {
            config = new RepositoryConfigImpl(serviceFactory, parameters);
        }
    }
    config = SpiLoggerConfig.wrap(config, parameters);
    return RepositoryImpl.create(config);
}
Also used : RepositoryConfig(org.apache.jackrabbit.jcr2spi.config.RepositoryConfig) RepositoryServiceFactory(org.apache.jackrabbit.spi.RepositoryServiceFactory)

Aggregations

RepositoryConfig (org.apache.jackrabbit.jcr2spi.config.RepositoryConfig)2 Repository (javax.jcr.Repository)1 RepositoryServiceFactory (org.apache.jackrabbit.spi.RepositoryServiceFactory)1