1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.lesscss.internal.cache

File DefaultColorThemeCache.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

0
6
1
1
66
29
2
0.33
6
1
2

Classes

Class Line # Actions
DefaultColorThemeCache 41 6 0% 2 1
0.8571428785.7%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.lesscss.internal.cache;
21   
22    import javax.inject.Singleton;
23   
24    import org.xwiki.cache.CacheException;
25    import org.xwiki.cache.CacheFactory;
26    import org.xwiki.cache.config.CacheConfiguration;
27    import org.xwiki.component.annotation.Component;
28    import org.xwiki.component.manager.ComponentLookupException;
29    import org.xwiki.component.phase.Initializable;
30    import org.xwiki.component.phase.InitializationException;
31    import org.xwiki.lesscss.internal.colortheme.ColorTheme;
32   
33    /**
34    * Default implementation for {@link org.xwiki.lesscss.internal.cache.ColorThemeCache}.
35    *
36    * @since 6.4M2
37    * @version $Id: f29464b608db1a2dd2eee493ce90a41955ff57f0 $
38    */
39    @Component
40    @Singleton
 
41    public class DefaultColorThemeCache extends AbstractCache<ColorTheme> implements ColorThemeCache, Initializable
42    {
43    /**
44    * Id of the cache for generated CSS.
45    */
46    public static final String LESS_COLOR_THEMES_CACHE_ID = "lesscss.colortheme.cache";
47   
 
48  60 toggle @Override
49    public void initialize() throws InitializationException
50    {
51  60 try {
52    // Create the cache
53  60 CacheConfiguration configuration = new CacheConfiguration(LESS_COLOR_THEMES_CACHE_ID);
54  60 CacheFactory cacheFactory = cacheManager.getCacheFactory();
55  60 super.cache = cacheFactory.newCache(configuration);
56   
57    // The Color Theme only depends on colors which do not depend on the XWikiContext. So we don't handle the
58    // XWikiContext in this cache.
59  60 super.isContextHandled = false;
60   
61    } catch (ComponentLookupException | CacheException e) {
62  0 throw new InitializationException(
63    String.format("Failed to initialize LESS color themes cache [%s].", LESS_COLOR_THEMES_CACHE_ID), e);
64    }
65    }
66    }