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

File EmbeddableComponentManagerFactory.java

 

Coverage histogram

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

Code metrics

0
5
2
1
67
27
2
0.4
2.5
2
1

Classes

Class Line # Actions
EmbeddableComponentManagerFactory 39 5 0% 2 2
0.7142857371.4%
 

Contributing tests

This file is covered by 17 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.embed;
21   
22    import javax.inject.Inject;
23    import javax.inject.Singleton;
24   
25    import org.xwiki.component.annotation.Component;
26    import org.xwiki.component.embed.EmbeddableComponentManager;
27    import org.xwiki.component.internal.multi.ComponentManagerFactory;
28    import org.xwiki.component.manager.ComponentManager;
29   
30    /**
31    * Create Component Manager implementation based on the Embeddable Component Manager (i.e. a simple implementation of
32    * {@link ComponentManager} to be used when using some XWiki modules standalone).
33    *
34    * @version $Id: 5263d3fbe387837273b4668481d1f12842e35fc2 $
35    * @since 3.3M2
36    */
37    @Component
38    @Singleton
 
39    public class EmbeddableComponentManagerFactory implements ComponentManagerFactory
40    {
41    /**
42    * The Root Component Manager used to get access to the set Component Event Manager that we set by default for newly
43    * created Component Managers.
44    */
45    @Inject
46    private ComponentManager rootComponentManager;
47   
 
48  0 toggle @Override
49    public ComponentManager createComponentManager(ComponentManager parentComponentManager)
50    {
51  0 return createComponentManager(null, parentComponentManager);
52    }
53   
 
54  102 toggle @Override
55    public ComponentManager createComponentManager(String namespace, ComponentManager parentComponentManager)
56    {
57  102 ComponentManager cm = new EmbeddableComponentManager(namespace);
58   
59    // Set the parent
60  102 cm.setParent(parentComponentManager);
61   
62    // Make sure the Event Manager is set so that events can be sent
63  102 cm.setComponentEventManager(this.rootComponentManager.getComponentEventManager());
64   
65  102 return cm;
66    }
67    }