1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.transport.wagon;
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.Transporter;
27 import org.eclipse.aether.spi.connector.transport.TransporterFactory;
28 import org.eclipse.aether.spi.locator.Service;
29 import org.eclipse.aether.spi.locator.ServiceLocator;
30 import org.eclipse.aether.transfer.NoTransporterException;
31
32 import static java.util.Objects.requireNonNull;
33
34
35
36
37
38
39 @Named("wagon")
40 public final class WagonTransporterFactory implements TransporterFactory, Service {
41
42 private WagonProvider wagonProvider;
43
44 private WagonConfigurator wagonConfigurator;
45
46 private float priority = -1.0f;
47
48
49
50
51
52
53 @Deprecated
54 public WagonTransporterFactory() {
55
56 }
57
58 @Inject
59 public WagonTransporterFactory(WagonProvider wagonProvider, WagonConfigurator wagonConfigurator) {
60 setWagonProvider(wagonProvider);
61 setWagonConfigurator(wagonConfigurator);
62 }
63
64 @Override
65 public void initService(ServiceLocator locator) {
66 setWagonProvider(locator.getService(WagonProvider.class));
67 setWagonConfigurator(locator.getService(WagonConfigurator.class));
68 }
69
70
71
72
73
74
75
76 public WagonTransporterFactory setWagonProvider(WagonProvider wagonProvider) {
77 this.wagonProvider = wagonProvider;
78 return this;
79 }
80
81
82
83
84
85
86
87 public WagonTransporterFactory setWagonConfigurator(WagonConfigurator wagonConfigurator) {
88 this.wagonConfigurator = wagonConfigurator;
89 return this;
90 }
91
92 @Override
93 public float getPriority() {
94 return priority;
95 }
96
97
98
99
100
101
102
103 public WagonTransporterFactory setPriority(float priority) {
104 this.priority = priority;
105 return this;
106 }
107
108 @Override
109 public Transporter newInstance(RepositorySystemSession session, RemoteRepository repository)
110 throws NoTransporterException {
111 requireNonNull(session, "session cannot be null");
112 requireNonNull(repository, "repository cannot be null");
113
114 return new WagonTransporter(wagonProvider, wagonConfigurator, repository, session);
115 }
116 }