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

File DefaultGroovyConfiguration.java

 

Coverage histogram

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

Code metrics

2
10
2
1
95
48
4
0.4
5
2
2

Classes

Class Line # Actions
DefaultGroovyConfiguration 45 10 0% 4 1
0.928571492.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.groovy.internal;
21   
22    import java.util.ArrayList;
23    import java.util.Collections;
24    import java.util.List;
25   
26    import javax.inject.Inject;
27    import javax.inject.Singleton;
28   
29    import org.codehaus.groovy.control.customizers.CompilationCustomizer;
30    import org.slf4j.Logger;
31    import org.xwiki.component.annotation.Component;
32    import org.xwiki.component.manager.ComponentManager;
33    import org.xwiki.configuration.ConfigurationSource;
34    import org.xwiki.groovy.GroovyCompilationCustomizer;
35    import org.xwiki.groovy.GroovyConfiguration;
36   
37    /**
38    * Default configuration implementation for the Groovy module, especially the list of Groovy Compilation Customizers.
39    *
40    * @version $Id: e29ad24d091c99fa7999578fa980e3e201b9ff2f $
41    * @since 4.1M1
42    */
43    @Component
44    @Singleton
 
45    public class DefaultGroovyConfiguration implements GroovyConfiguration
46    {
47    /**
48    * Prefix for configuration keys for the Groovy module.
49    */
50    private static final String PREFIX = "groovy.";
51   
52    /**
53    * Defines from where to read the configuration data.
54    */
55    @Inject
56    private ConfigurationSource configuration;
57   
58    /**
59    * The logger to log.
60    */
61    @Inject
62    private Logger logger;
63   
64    /**
65    * Used to get Compilation Customizer implementations to use.
66    */
67    @Inject
68    private ComponentManager componentManager;
69   
 
70  197 toggle @Override
71    public List<String> getCompilationCustomizerNames()
72    {
73  197 return this.configuration.getProperty(PREFIX + "compilationCustomizers", Collections.<String>emptyList());
74    }
75   
 
76  95 toggle @Override
77    public List<CompilationCustomizer> getCompilationCustomizers()
78    {
79  95 List<CompilationCustomizer> customizers = new ArrayList<CompilationCustomizer>();
80  95 for (String customizerName : getCompilationCustomizerNames()) {
81  6 try {
82  6 GroovyCompilationCustomizer customizer =
83    this.componentManager.getInstance(GroovyCompilationCustomizer.class, customizerName);
84  6 CompilationCustomizer compilationCustomizer = customizer.createCustomizer();
85  6 if (compilationCustomizer != null) {
86  4 customizers.add(compilationCustomizer);
87    }
88    } catch (Exception e) {
89    // Just don't use the customizer but log the error
90  0 this.logger.warn("Failed to create the Groovy Compilation Customizer named [{}]", customizerName, e);
91    }
92    }
93  95 return customizers;
94    }
95    }