Search in sources :

Example 1 with ResourceResolverTypeAdapter

use of org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter in project sling by apache.

the class MockSling method newResourceResolverFactory.

/**
     * Creates new sling resource resolver factory instance.
     * @param type Type of underlying repository.
     * @param bundleContext Bundle context
     * @return Resource resolver factory instance
     */
public static ResourceResolverFactory newResourceResolverFactory(final ResourceResolverType type, final BundleContext bundleContext) {
    ResourceResolverTypeAdapter adapter = getResourceResolverTypeAdapter(type);
    ResourceResolverFactory factory = adapter.newResourceResolverFactory();
    if (factory == null) {
        SlingRepository repository = adapter.newSlingRepository();
        factory = ResourceResolverFactoryInitializer.setUp(repository, bundleContext, type.getNodeTypeMode());
    } else {
        bundleContext.registerService(ResourceResolverFactory.class.getName(), factory, null);
    }
    return factory;
}
Also used : SlingRepository(org.apache.sling.jcr.api.SlingRepository) ResourceResolverTypeAdapter(org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter) ResourceResolverFactory(org.apache.sling.api.resource.ResourceResolverFactory)

Aggregations

ResourceResolverFactory (org.apache.sling.api.resource.ResourceResolverFactory)1 SlingRepository (org.apache.sling.jcr.api.SlingRepository)1 ResourceResolverTypeAdapter (org.apache.sling.testing.mock.sling.spi.ResourceResolverTypeAdapter)1