1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.connector.basic;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23
24 import java.util.Map;
25
26 import org.eclipse.aether.RepositorySystemSession;
27 import org.eclipse.aether.repository.RemoteRepository;
28 import org.eclipse.aether.spi.checksums.ProvidedChecksumsSource;
29 import org.eclipse.aether.spi.connector.RepositoryConnector;
30 import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
31 import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider;
32 import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider;
33 import org.eclipse.aether.spi.connector.transport.TransporterProvider;
34 import org.eclipse.aether.spi.io.ChecksumProcessor;
35 import org.eclipse.aether.transfer.NoRepositoryConnectorException;
36
37 import static java.util.Objects.requireNonNull;
38
39
40
41
42
43
44 @Named(BasicRepositoryConnectorFactory.NAME)
45 public final class BasicRepositoryConnectorFactory implements RepositoryConnectorFactory {
46 public static final String NAME = "basic";
47 private final TransporterProvider transporterProvider;
48
49 private final RepositoryLayoutProvider layoutProvider;
50
51 private final ChecksumPolicyProvider checksumPolicyProvider;
52
53 private final ChecksumProcessor checksumProcessor;
54
55 private final Map<String, ProvidedChecksumsSource> providedChecksumsSources;
56
57 private float priority;
58
59 @Inject
60 public BasicRepositoryConnectorFactory(
61 TransporterProvider transporterProvider,
62 RepositoryLayoutProvider layoutProvider,
63 ChecksumPolicyProvider checksumPolicyProvider,
64 ChecksumProcessor checksumProcessor,
65 Map<String, ProvidedChecksumsSource> providedChecksumsSources) {
66 this.transporterProvider = requireNonNull(transporterProvider, "transporter provider cannot be null");
67 this.layoutProvider = requireNonNull(layoutProvider, "repository layout provider cannot be null");
68 this.checksumPolicyProvider = requireNonNull(checksumPolicyProvider, "checksum policy provider cannot be null");
69 this.checksumProcessor = requireNonNull(checksumProcessor, "checksum processor cannot be null");
70 this.providedChecksumsSources =
71 requireNonNull(providedChecksumsSources, "provided checksum sources cannot be null");
72 }
73
74 @Override
75 public float getPriority() {
76 return priority;
77 }
78
79
80
81
82
83
84
85 public BasicRepositoryConnectorFactory setPriority(float priority) {
86 this.priority = priority;
87 return this;
88 }
89
90 @Override
91 public RepositoryConnector newInstance(RepositorySystemSession session, RemoteRepository repository)
92 throws NoRepositoryConnectorException {
93 requireNonNull(session, "session cannot be null");
94 requireNonNull(repository, "repository cannot be null");
95
96 return new BasicRepositoryConnector(
97 session,
98 repository,
99 transporterProvider,
100 layoutProvider,
101 checksumPolicyProvider,
102 checksumProcessor,
103 providedChecksumsSources);
104 }
105 }