1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.component.internal

File WikiComponentManager.java

 

Coverage histogram

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

Code metrics

4
6
4
1
100
44
6
1
1.5
4
1.5

Classes

Class Line # Actions
WikiComponentManager 46 6 0% 6 1
0.928571492.9%
 

Contributing tests

This file is covered by 200 tests. .

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.component.internal;
21   
22    import javax.inject.Inject;
23    import javax.inject.Named;
24    import javax.inject.Singleton;
25   
26    import org.xwiki.component.annotation.Component;
27    import org.xwiki.component.manager.ComponentManager;
28    import org.xwiki.component.phase.Initializable;
29    import org.xwiki.component.phase.InitializationException;
30    import org.xwiki.model.namespace.WikiNamespace;
31    import org.xwiki.model.reference.EntityReference;
32    import org.xwiki.model.reference.WikiReference;
33    import org.xwiki.wiki.descriptor.WikiDescriptorManager;
34   
35    /**
36    * Proxy Component Manager that creates and queries individual Component Managers specific to the current wiki in the
37    * Execution Context. These Component Managers are created on the fly the first time a component is registered for the
38    * current wiki.
39    *
40    * @version $Id: 29902c671d6cd5bcf02c8bb13d65e2c714d2f24e $
41    * @since 2.1RC1
42    */
43    @Component
44    @Named(WikiNamespace.TYPE)
45    @Singleton
 
46    public class WikiComponentManager extends AbstractEntityComponentManager implements Initializable
47    {
48    /**
49    * The prefix of wiki namespace.
50    *
51    * @since 8.4RC1
52    */
53    public static final String NAMESPACE_PREFIX = WikiNamespace.TYPE + ':';
54   
55    @Inject
56    private WikiDescriptorManager wikis;
57   
58    /**
59    * The Component Manager to be used as parent when a component is not found in the current Component Manager.
60    */
61    @Inject
62    private ComponentManager rootComponentManager;
63   
 
64  45541077 toggle private String getCurrentWiki()
65    {
66  45542351 return this.wikis.getCurrentWikiId();
67    }
68   
 
69  45196090 toggle @Override
70    protected EntityReference getCurrentReference()
71    {
72  45200245 String currentWikiId = getCurrentWiki();
73   
74  45202552 return currentWikiId != null ? new WikiReference(currentWikiId) : null;
75    }
76   
77    /**
78    * {@inheritDoc}
79    * <p>
80    * Override default implementation with one much better for performances.
81    * </p>
82    *
83    * @see org.xwiki.component.internal.AbstractEntityComponentManager#getKey()
84    */
 
85  338519 toggle @Override
86    protected String getKey()
87    {
88  338595 String wiki = getCurrentWiki();
89   
90  338595 return wiki != null ? NAMESPACE_PREFIX + wiki : null;
91    }
92   
 
93  289 toggle @Override
94    public void initialize() throws InitializationException
95    {
96    // Set the parent to the Root Component Manager since if a component isn't found for a particular wiki
97    // we want to check if it's available in the Root Component Manager.
98  289 setInternalParent(this.rootComponentManager);
99    }
100    }