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

File DefaultJobProgressManager.java

 

Coverage histogram

../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

2
19
13
1
138
94
14
0.74
1.46
13
1.08

Classes

Class Line # Actions
DefaultJobProgressManager 45 19 0% 14 15
0.558823555.9%
 

Contributing tests

This file is covered by 127 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.job.internal;
21   
22    import java.util.concurrent.Callable;
23   
24    import javax.inject.Inject;
25    import javax.inject.Singleton;
26   
27    import org.xwiki.component.annotation.Component;
28    import org.xwiki.job.event.status.EndStepProgressEvent;
29    import org.xwiki.job.event.status.JobProgressManager;
30    import org.xwiki.job.event.status.PopLevelProgressEvent;
31    import org.xwiki.job.event.status.PushLevelProgressEvent;
32    import org.xwiki.job.event.status.StartStepProgressEvent;
33    import org.xwiki.job.event.status.StepProgressEvent;
34    import org.xwiki.logging.Message;
35    import org.xwiki.observation.ObservationManager;
36   
37    /**
38    * Default implementation of {@link JobProgressManager}.
39    *
40    * @version $Id: 5ef7c236e2af934ffec5f7f67adbbb9a54733fac $
41    * @since 6.1M1
42    */
43    @Component
44    @Singleton
 
45    public class DefaultJobProgressManager implements JobProgressManager
46    {
47    @Inject
48    private ObservationManager observationManager;
49   
 
50  0 toggle @Override
51    public void pushLevelProgress(Object source)
52    {
53  0 this.observationManager.notify(new PushLevelProgressEvent(), source);
54    }
55   
 
56  38465 toggle @Override
57    public void pushLevelProgress(int steps, Object source)
58    {
59  38467 this.observationManager.notify(new PushLevelProgressEvent(steps), source);
60    }
61   
 
62  0 toggle @Override
63    @Deprecated
64    public void stepPropress(Object source)
65    {
66  0 this.observationManager.notify(StepProgressEvent.INSTANCE, source);
67    }
68   
 
69  4748 toggle @Override
70    public void startStep(Object source)
71    {
72  4748 startStep(source, (Message) null);
73    }
74   
 
75  106017 toggle @Override
76    public void startStep(Object source, String name)
77    {
78  106024 startStep(source, toMessage(name));
79    }
80   
 
81  226952 toggle @Override
82    public void startStep(Object source, Message message)
83    {
84  226964 this.observationManager.notify(StartStepProgressEvent.INSTANCE, source, message);
85    }
86   
 
87  116217 toggle @Override
88    public void startStep(Object source, String translationKey, String message, Object... arguments)
89    {
90  116214 startStep(source, toMessage(translationKey, message, arguments));
91    }
92   
 
93  120235 toggle @Override
94    public void endStep(Object source)
95    {
96  120234 this.observationManager.notify(EndStepProgressEvent.INSTANCE, source);
97    }
98   
 
99  28820 toggle @Override
100    public void popLevelProgress(Object source)
101    {
102  28820 this.observationManager.notify(PopLevelProgressEvent.INSTANCE, source);
103    }
104   
 
105  0 toggle @Override
106    public <T> T call(Callable<T> task, Object source) throws Exception
107    {
108  0 pushLevelProgress(source);
109   
110  0 try {
111  0 return task.call();
112    } finally {
113  0 popLevelProgress(source);
114    }
115    }
116   
 
117  0 toggle @Override
118    public <T> T call(Callable<T> task, int steps, Object source) throws Exception
119    {
120  0 pushLevelProgress(steps, source);
121   
122  0 try {
123  0 return task.call();
124    } finally {
125  0 popLevelProgress(source);
126    }
127    }
128   
 
129  106026 toggle private Message toMessage(String name)
130    {
131  106008 return name != null ? new Message(name) : null;
132    }
133   
 
134  116209 toggle private Message toMessage(String translationKey, String message, Object[] arguments)
135    {
136  116209 return new Message(translationKey, message, arguments);
137    }
138    }