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

File TimedInterruptGroovyCompilationCustomizer.java

 

Coverage histogram

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

Code metrics

0
3
1
1
62
27
1
0.33
3
1
1

Classes

Class Line # Actions
TimedInterruptGroovyCompilationCustomizer 47 3 0% 1 0
1.0100%
 

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.HashMap;
23    import java.util.Map;
24   
25    import javax.inject.Inject;
26    import javax.inject.Named;
27    import javax.inject.Singleton;
28   
29    import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer;
30    import org.codehaus.groovy.control.customizers.CompilationCustomizer;
31    import org.xwiki.component.annotation.Component;
32    import org.xwiki.groovy.GroovyCompilationCustomizer;
33    import org.xwiki.groovy.TimedInterruptCustomizerConfiguration;
34   
35    import groovy.transform.TimedInterrupt;
36   
37    /**
38    * Allow interrupting Groovy scripts after a given timeout. The timeout is configurable using
39    * {@link TimedInterruptCustomizerConfiguration}.
40    *
41    * @version $Id: ae8b6c70948d72bf908a939bae5a9041bcad3b7c $
42    * @since 4.1M1
43    */
44    @Component
45    @Named("timedInterrupt")
46    @Singleton
 
47    public class TimedInterruptGroovyCompilationCustomizer implements GroovyCompilationCustomizer
48    {
49    /**
50    * Used to get the script timeout configuration parameter value.
51    */
52    @Inject
53    private TimedInterruptCustomizerConfiguration configuration;
54   
 
55  1 toggle @Override
56    public CompilationCustomizer createCustomizer()
57    {
58  1 Map<String, Object> parameters = new HashMap<String, Object>();
59  1 parameters.put("value", this.configuration.getTimeout());
60  1 return new ASTTransformationCustomizer(parameters, TimedInterrupt.class);
61    }
62    }