Search in sources :

Example 1 with CacheFactory

use of org.xwiki.cache.CacheFactory in project xwiki-platform by xwiki.

the class DefaultLESSResourcesCacheTest method setUp.

@Before
public void setUp() throws Exception {
    cacheManager = mocker.getInstance(CacheManager.class);
    cache = mock(Cache.class);
    CacheFactory cacheFactory = mock(CacheFactory.class);
    when(cacheManager.getCacheFactory()).thenReturn(cacheFactory);
    CacheConfiguration configuration = new CacheConfiguration("lesscss.skinfiles.cache");
    when(cacheFactory.<String>newCache(eq(configuration))).thenReturn(cache);
    cacheKeyFactory = mocker.getInstance(CacheKeyFactory.class);
    LESSSkinFileResourceReference lessSkinFileResourceReference = new LESSSkinFileResourceReference("lessResource", null, null);
    when(cacheKeyFactory.getCacheKey(eq(lessSkinFileResourceReference), eq(new FSSkinReference("skin")), eq(new NamedColorThemeReference("colorTheme")), eq(true))).thenReturn("12_lessResource_4_skin_10_colorTheme");
}
Also used : NamedColorThemeReference(org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference) CacheManager(org.xwiki.cache.CacheManager) FSSkinReference(org.xwiki.lesscss.internal.skin.FSSkinReference) CacheFactory(org.xwiki.cache.CacheFactory) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) Cache(org.xwiki.cache.Cache) LESSSkinFileResourceReference(org.xwiki.lesscss.internal.resources.LESSSkinFileResourceReference) Before(org.junit.Before)

Example 2 with CacheFactory

use of org.xwiki.cache.CacheFactory in project xwiki-platform by xwiki.

the class DefaultIconSetCacheTest method setUp.

@Before
public void setUp() throws Exception {
    cacheManager = mocker.getInstance(CacheManager.class);
    entityReferenceSerializer = mocker.getInstance(new DefaultParameterizedType(null, EntityReferenceSerializer.class, String.class));
    cache = mock(Cache.class);
    CacheFactory cacheFactory = mock(CacheFactory.class);
    when(cacheManager.getCacheFactory()).thenReturn(cacheFactory);
    CacheConfiguration configuration = new CacheConfiguration("iconset");
    when(cacheFactory.<IconSet>newCache(eq(configuration))).thenReturn(cache);
}
Also used : CacheManager(org.xwiki.cache.CacheManager) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) CacheFactory(org.xwiki.cache.CacheFactory) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) Cache(org.xwiki.cache.Cache) IconSet(org.xwiki.icon.IconSet) Before(org.junit.Before)

Example 3 with CacheFactory

use of org.xwiki.cache.CacheFactory in project xwiki-platform by xwiki.

the class DefaultColorThemeCache method initialize.

@Override
public void initialize() throws InitializationException {
    try {
        // Create the cache
        CacheConfiguration configuration = new CacheConfiguration(LESS_COLOR_THEMES_CACHE_ID);
        CacheFactory cacheFactory = cacheManager.getCacheFactory();
        super.cache = cacheFactory.newCache(configuration);
        // The Color Theme only depends on colors which do not depend on the XWikiContext. So we don't handle the
        // XWikiContext in this cache.
        super.isContextHandled = false;
    } catch (ComponentLookupException | CacheException e) {
        throw new InitializationException(String.format("Failed to initialize LESS color themes cache [%s].", LESS_COLOR_THEMES_CACHE_ID), e);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) CacheFactory(org.xwiki.cache.CacheFactory) InitializationException(org.xwiki.component.phase.InitializationException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration)

Example 4 with CacheFactory

use of org.xwiki.cache.CacheFactory in project xwiki-platform by xwiki.

the class DefaultLESSResourcesCache method initialize.

@Override
public void initialize() throws InitializationException {
    try {
        CacheConfiguration configuration = new CacheConfiguration(LESS_FILES_CACHE_ID);
        CacheFactory cacheFactory = cacheManager.getCacheFactory();
        this.cache = cacheFactory.newCache(configuration);
    } catch (ComponentLookupException | CacheException e) {
        throw new InitializationException(String.format("Failed to initialize LESS skin files cache [%s].", LESS_FILES_CACHE_ID), e);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) CacheFactory(org.xwiki.cache.CacheFactory) InitializationException(org.xwiki.component.phase.InitializationException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration)

Example 5 with CacheFactory

use of org.xwiki.cache.CacheFactory in project xwiki-platform by xwiki.

the class DefaultIconSetCache method initialize.

@Override
public void initialize() throws InitializationException {
    try {
        CacheConfiguration configuration = new CacheConfiguration(ICON_SET_CACHE_ID);
        CacheFactory cacheFactory = cacheManager.getCacheFactory();
        this.cache = cacheFactory.newCache(configuration);
    } catch (ComponentLookupException | CacheException e) {
        throw new InitializationException("Failed to initialize the IconSet Cache.", e);
    }
}
Also used : CacheException(org.xwiki.cache.CacheException) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) CacheFactory(org.xwiki.cache.CacheFactory) InitializationException(org.xwiki.component.phase.InitializationException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration)

Aggregations

CacheFactory (org.xwiki.cache.CacheFactory)6 CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)6 CacheException (org.xwiki.cache.CacheException)4 InitializationException (org.xwiki.component.phase.InitializationException)4 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)3 Before (org.junit.Before)2 Cache (org.xwiki.cache.Cache)2 CacheManager (org.xwiki.cache.CacheManager)2 Test (org.junit.Test)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 IconSet (org.xwiki.icon.IconSet)1 NamedColorThemeReference (org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference)1 LESSSkinFileResourceReference (org.xwiki.lesscss.internal.resources.LESSSkinFileResourceReference)1 FSSkinReference (org.xwiki.lesscss.internal.skin.FSSkinReference)1