1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package packagefile.scriptServiceJarExtension.internal.script

File GreeterScriptService.java

 

Coverage histogram

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

Code metrics

0
5
2
1
82
32
3
0.6
2.5
2
1.5

Classes

Class Line # Actions
GreeterScriptService 40 5 0% 3 1
0.8571428785.7%
 

Contributing tests

No tests hitting this source file were found.

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 packagefile.scriptServiceJarExtension.internal.script;
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.manager.ComponentLookupException;
28    import org.xwiki.component.manager.ComponentManager;
29    import org.xwiki.script.service.ScriptService;
30   
31    import packagefile.scriptServiceJarExtension.Greeter;
32   
33    /**
34    * Script service for {@link Greeter}.
35    */
36    //It is a static registration but it's a generated jar
37    @Component(staticRegistration = false)
38    @Named("greeter")
39    @Singleton
 
40    public class GreeterScriptService implements ScriptService
41    {
42    /**
43    * The greeter.
44    */
45    @Inject
46    private Greeter greeter;
47   
48    /**
49    * The component manager, used to perform dynamic component lookups.
50    */
51    @Inject
52    private ComponentManager componentManager;
53   
54    /**
55    * Greets the specified person.
56    *
57    * @param name the name of the person to greet
58    * @return the greet message
59    */
 
60  2 toggle public String greet(String name)
61    {
62    // Test component injection.
63  2 return greeter.greet(name);
64    }
65   
66    /**
67    * Greets the specified person.
68    *
69    * @param name the name of the person to greet
70    * @return the greet message
71    */
 
72  2 toggle public String greet(String name, String hint)
73    {
74  2 try {
75    // Test dynamic component lookup.
76  2 Greeter greeter = componentManager.getInstance(Greeter.class, hint);
77  2 return greeter.greet(name);
78    } catch (ComponentLookupException e) {
79  0 return null;
80    }
81    }
82    }