1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.transport.jetty;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23
24 import org.eclipse.aether.RepositorySystemSession;
25 import org.eclipse.aether.repository.RemoteRepository;
26 import org.eclipse.aether.spi.connector.transport.http.ChecksumExtractor;
27 import org.eclipse.aether.spi.connector.transport.http.HttpTransporter;
28 import org.eclipse.aether.spi.connector.transport.http.HttpTransporterFactory;
29 import org.eclipse.aether.spi.io.PathProcessor;
30 import org.eclipse.aether.transfer.NoTransporterException;
31
32 import static java.util.Objects.requireNonNull;
33
34
35
36
37
38
39 @Named(JettyTransporterFactory.NAME)
40 public final class JettyTransporterFactory implements HttpTransporterFactory {
41 public static final String NAME = "jetty";
42
43 private float priority = 15.0f;
44
45 private final ChecksumExtractor checksumExtractor;
46
47 private final PathProcessor pathProcessor;
48
49 @Inject
50 public JettyTransporterFactory(ChecksumExtractor checksumExtractor, PathProcessor pathProcessor) {
51 this.checksumExtractor = requireNonNull(checksumExtractor, "checksumExtractor");
52 this.pathProcessor = requireNonNull(pathProcessor, "pathProcessor");
53 }
54
55 @Override
56 public float getPriority() {
57 return priority;
58 }
59
60 public JettyTransporterFactory setPriority(float priority) {
61 this.priority = priority;
62 return this;
63 }
64
65 @Override
66 public HttpTransporter newInstance(RepositorySystemSession session, RemoteRepository repository)
67 throws NoTransporterException {
68 requireNonNull(session, "session cannot be null");
69 requireNonNull(repository, "repository cannot be null");
70
71 if (!"http".equalsIgnoreCase(repository.getProtocol()) && !"https".equalsIgnoreCase(repository.getProtocol())) {
72 throw new NoTransporterException(repository);
73 }
74
75 return new JettyTransporter(session, repository, checksumExtractor, pathProcessor);
76 }
77 }