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

File ContextRootComponentManager.java

 

Coverage histogram

../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

0
3
5
1
90
48
5
1.67
0.6
5
1

Classes

Class Line # Actions
ContextRootComponentManager 46 3 0% 5 2
0.7575%
 

Contributing tests

This file is covered by 26 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.descriptor.ComponentDescriptor;
28    import org.xwiki.component.internal.multi.DelegateComponentManager;
29    import org.xwiki.component.manager.ComponentEventManager;
30    import org.xwiki.component.manager.ComponentManager;
31    import org.xwiki.component.manager.ComponentRepositoryException;
32    import org.xwiki.component.phase.Initializable;
33    import org.xwiki.component.phase.InitializationException;
34   
35    /**
36    * Read in the context component manager and write in the root component manager. Mostly used for retro compatibility
37    * purpose.
38    *
39    * @version $Id: 5891146fd4082f67b62cf95b208b2d2033d67bf6 $
40    * @since 6.4.1
41    * @since 6.2.6
42    */
43    @Component
44    @Named("context/root")
45    @Singleton
 
46    public class ContextRootComponentManager extends DelegateComponentManager implements Initializable
47    {
48    @Inject
49    @Named("context")
50    private ComponentManager userComponentManager;
51   
52    @Inject
53    @Named("root")
54    private ComponentManager rootComponentManager;
55   
 
56  90 toggle @Override
57    public void initialize() throws InitializationException
58    {
59    // The first Component Manager in the lookup chain is the user Component Manager (i.e. components registered
60    // for the current user).
61  90 setComponentManager(this.userComponentManager);
62    }
63   
64    // Make the Context Component Manager "read-only". Writes should be done against specific Component Managers.
65   
 
66  1 toggle @Override
67    public <T> void registerComponent(ComponentDescriptor<T> componentDescriptor, T componentInstance)
68    throws ComponentRepositoryException
69    {
70  1 this.rootComponentManager.registerComponent(componentDescriptor, componentInstance);
71    }
72   
 
73  1 toggle @Override
74    public <T> void registerComponent(ComponentDescriptor<T> componentDescriptor) throws ComponentRepositoryException
75    {
76  1 this.rootComponentManager.registerComponent(componentDescriptor);
77    }
78   
 
79  0 toggle @Override
80    public void setComponentEventManager(ComponentEventManager eventManager)
81    {
82    // do nothing
83    }
84   
 
85  0 toggle @Override
86    public void setParent(ComponentManager parentComponentManager)
87    {
88    // do nothing
89    }
90    }