1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.transport.http;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23
24 import java.util.Collections;
25 import java.util.HashMap;
26 import java.util.Map;
27
28 import org.eclipse.aether.RepositorySystemSession;
29 import org.eclipse.aether.repository.RemoteRepository;
30 import org.eclipse.aether.spi.connector.transport.Transporter;
31 import org.eclipse.aether.spi.connector.transport.TransporterFactory;
32 import org.eclipse.aether.transfer.NoTransporterException;
33
34 import static java.util.Objects.requireNonNull;
35
36
37
38
39
40 @Named("http")
41 public final class HttpTransporterFactory implements TransporterFactory {
42 private static Map<String, ChecksumExtractor> getManuallyCreatedExtractors() {
43 HashMap<String, ChecksumExtractor> map = new HashMap<>();
44 map.put(Nexus2ChecksumExtractor.NAME, new Nexus2ChecksumExtractor());
45 map.put(XChecksumChecksumExtractor.NAME, new XChecksumChecksumExtractor());
46 return Collections.unmodifiableMap(map);
47 }
48
49 private float priority = 5.0f;
50
51 private final Map<String, ChecksumExtractor> extractors;
52
53
54
55
56 @Deprecated
57 public HttpTransporterFactory() {
58 this(getManuallyCreatedExtractors());
59 }
60
61
62
63
64
65
66 @Inject
67 public HttpTransporterFactory(Map<String, ChecksumExtractor> extractors) {
68 this.extractors = requireNonNull(extractors);
69 }
70
71 @Override
72 public float getPriority() {
73 return priority;
74 }
75
76
77
78
79
80
81
82 public HttpTransporterFactory setPriority(float priority) {
83 this.priority = priority;
84 return this;
85 }
86
87 @Override
88 public Transporter newInstance(RepositorySystemSession session, RemoteRepository repository)
89 throws NoTransporterException {
90 requireNonNull(session, "session cannot be null");
91 requireNonNull(repository, "repository cannot be null");
92
93 return new HttpTransporter(extractors, repository, session);
94 }
95 }