Coverage Summary for Class: ProfilerFactory (co.rsk.metrics.profilers)
Class |
Class, %
|
Method, %
|
Line, %
|
ProfilerFactory |
100%
(1/1)
|
75%
(3/4)
|
77.8%
(7/9)
|
1 package co.rsk.metrics.profilers;
2
3
4 import co.rsk.metrics.profilers.impl.DummyProfiler;
5
6
7 /**
8 * ProfilerFactory is used to get the configured Profiler instance.
9 * Only one profiler can be defined, once a profiler is set, it cannot be changed.
10 * If a profiler isn't configured, the DummyProfiler will be set upon the first request for the instance.
11 */
12 public final class ProfilerFactory {
13
14 private static volatile Profiler instance = null;
15
16 private ProfilerFactory(){
17 super();
18 }
19
20 public static synchronized void configure(Profiler profiler){
21 if(instance == null){
22 instance = profiler;
23 }
24 }
25
26 public static Profiler getInstance(){
27 if(instance == null){
28 configure(new DummyProfiler());
29 }
30
31 return instance;
32 }
33 }