1
2
3
4
5
6
7
8
9
10 package org.eclipse.jgit.lib;
11
12 import java.util.Iterator;
13 import java.util.ServiceConfigurationError;
14 import java.util.ServiceLoader;
15
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19
20
21
22
23
24 public abstract class GpgSignatureVerifierFactory {
25
26 private static final Logger LOG = LoggerFactory
27 .getLogger(GpgSignatureVerifierFactory.class);
28
29 private static volatile GpgSignatureVerifierFactory defaultFactory = loadDefault();
30
31 private static GpgSignatureVerifierFactory loadDefault() {
32 try {
33 ServiceLoader<GpgSignatureVerifierFactory> loader = ServiceLoader
34 .load(GpgSignatureVerifierFactory.class);
35 Iterator<GpgSignatureVerifierFactory> iter = loader.iterator();
36 if (iter.hasNext()) {
37 return iter.next();
38 }
39 } catch (ServiceConfigurationError e) {
40 LOG.error(e.getMessage(), e);
41 }
42 return null;
43 }
44
45
46
47
48
49
50 public static GpgSignatureVerifierFactory getDefault() {
51 return defaultFactory;
52 }
53
54
55
56
57
58
59
60 public static void setDefault(GpgSignatureVerifierFactory factory) {
61 defaultFactory = factory;
62 }
63
64
65
66
67
68
69 public abstract GpgSignatureVerifier getVerifier();
70
71 }