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

File DefaultUIExtensionManager.java

 

Coverage histogram

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

Code metrics

2
8
1
1
76
35
3
0.38
8
1
3

Classes

Class Line # Actions
DefaultUIExtensionManager 41 8 0% 3 1
0.9090909490.9%
 

Contributing tests

This file is covered by 1 test. .

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.uiextension.internal;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import javax.inject.Inject;
26    import javax.inject.Named;
27    import javax.inject.Provider;
28   
29    import org.slf4j.Logger;
30    import org.xwiki.component.manager.ComponentLookupException;
31    import org.xwiki.component.manager.ComponentManager;
32    import org.xwiki.uiextension.UIExtension;
33    import org.xwiki.uiextension.UIExtensionManager;
34   
35    /**
36    * Default UIExtensionManager, retrieves all the extensions for a given extension point.
37    *
38    * @version $Id: e5b388c6c53987e7598e03fb30cc6e57ff5d169a $
39    * @since 4.3.1
40    */
 
41    public class DefaultUIExtensionManager implements UIExtensionManager
42    {
43    /**
44    * The logger to log.
45    */
46    @Inject
47    private Logger logger;
48   
49    /**
50    * We use the Context Component Manager to lookup UI Extensions registered as components.
51    * The Context Component Manager allows Extensions to be registered for a specific user, for a specific wiki or for
52    * a whole farm.
53    */
54    @Inject
55    @Named("context")
56    private Provider<ComponentManager> contextComponentManagerProvider;
57   
 
58  8422 toggle @Override
59    public List<UIExtension> get(String extensionPointId)
60    {
61  8423 List<UIExtension> extensions = new ArrayList<UIExtension>();
62   
63  8421 try {
64  8421 List<UIExtension> allExtensions = contextComponentManagerProvider.get().getInstanceList(UIExtension.class);
65  8422 for (UIExtension extension : allExtensions) {
66  67745 if (extension.getExtensionPointId().equals(extensionPointId)) {
67  1668 extensions.add(extension);
68    }
69    }
70    } catch (ComponentLookupException e) {
71  0 logger.error("Failed to lookup UIExtension instances, error: [{}]", e);
72    }
73   
74  8419 return extensions;
75    }
76    }