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

File AbstractWrapperSkinExtension.java

 

Coverage histogram

../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
6
4
1
79
35
4
0.67
1.5
4
1

Classes

Class Line # Actions
AbstractWrapperSkinExtension 41 6 0% 4 0
1.0100%
 

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.skinx;
21   
22    import java.util.Map;
23   
24    import javax.inject.Inject;
25   
26    import org.xwiki.component.descriptor.ComponentDescriptor;
27    import org.xwiki.context.Execution;
28   
29    import com.xpn.xwiki.XWiki;
30    import com.xpn.xwiki.XWikiContext;
31    import com.xpn.xwiki.plugin.skinx.SkinExtensionPluginApi;
32   
33    /**
34    * The abstract implementation of the wrapper around the skinx plugins. Provides the mechanism needed to grab the skin
35    * extensions plugins and call the {@code use} methods on them, subclasses only need to provide the name of the skin
36    * extension through their {@link SkinExtension} role hint.
37    *
38    * @version $Id: 018cd3601ee2bb38d41b7e48835f070e562d7d49 $
39    * @since 1.20
40    */
 
41    public abstract class AbstractWrapperSkinExtension implements SkinExtension
42    {
43    /** Execution context handler, needed for accessing the XWikiContext. */
44    @Inject
45    private Execution execution;
46   
47    @Inject
48    private ComponentDescriptor<SkinExtension> descriptor;
49   
 
50  18 toggle @Override
51    public void use(String resource)
52    {
53  18 getSkinExtensionPluginApi().use(resource);
54    }
55   
 
56  2 toggle @Override
57    public void use(String resource, Map<String, Object> parameters)
58    {
59  2 getSkinExtensionPluginApi().use(resource, parameters);
60    }
61   
62    /**
63    * @return the {@link SkinExtensionPluginApi} in the running wiki
64    */
 
65  20 toggle private SkinExtensionPluginApi getSkinExtensionPluginApi()
66    {
67  20 XWikiContext xwikiContext = (XWikiContext) execution.getContext().getProperty("xwikicontext");
68  20 XWiki wiki = xwikiContext.getWiki();
69  20 return (SkinExtensionPluginApi) wiki.getPluginApi(getName(), xwikiContext);
70    }
71   
72    /**
73    * @return the name of the skin extension (e.g. ssx, jsfx, etc) to wrap
74    */
 
75  20 toggle public String getName()
76    {
77  20 return this.descriptor.getRoleHint();
78    }
79    }