1 package org.eclipse.aether.connector.basic;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import javax.inject.Inject;
23 import javax.inject.Named;
24
25 import org.eclipse.aether.RepositorySystemSession;
26 import org.eclipse.aether.repository.RemoteRepository;
27 import org.eclipse.aether.spi.connector.RepositoryConnector;
28 import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
29 import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider;
30 import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider;
31 import org.eclipse.aether.spi.connector.transport.TransporterProvider;
32 import org.eclipse.aether.spi.io.FileProcessor;
33 import org.eclipse.aether.spi.locator.Service;
34 import org.eclipse.aether.spi.locator.ServiceLocator;
35 import org.eclipse.aether.spi.log.Logger;
36 import org.eclipse.aether.spi.log.LoggerFactory;
37 import org.eclipse.aether.spi.log.NullLoggerFactory;
38 import org.eclipse.aether.transfer.NoRepositoryConnectorException;
39
40
41
42
43
44
45 @Named( "basic" )
46 public final class BasicRepositoryConnectorFactory
47 implements RepositoryConnectorFactory, Service
48 {
49
50 private Logger logger = NullLoggerFactory.LOGGER;
51
52 private TransporterProvider transporterProvider;
53
54 private RepositoryLayoutProvider layoutProvider;
55
56 private ChecksumPolicyProvider checksumPolicyProvider;
57
58 private FileProcessor fileProcessor;
59
60 private float priority;
61
62
63
64
65
66
67 public BasicRepositoryConnectorFactory()
68 {
69
70 }
71
72 @Inject
73 BasicRepositoryConnectorFactory( TransporterProvider transporterProvider, RepositoryLayoutProvider layoutProvider,
74 ChecksumPolicyProvider checksumPolicyProvider, FileProcessor fileProcessor,
75 LoggerFactory loggerFactory )
76 {
77 setTransporterProvider( transporterProvider );
78 setRepositoryLayoutProvider( layoutProvider );
79 setChecksumPolicyProvider( checksumPolicyProvider );
80 setFileProcessor( fileProcessor );
81 setLoggerFactory( loggerFactory );
82 }
83
84 public void initService( ServiceLocator locator )
85 {
86 setLoggerFactory( locator.getService( LoggerFactory.class ) );
87 setTransporterProvider( locator.getService( TransporterProvider.class ) );
88 setRepositoryLayoutProvider( locator.getService( RepositoryLayoutProvider.class ) );
89 setChecksumPolicyProvider( locator.getService( ChecksumPolicyProvider.class ) );
90 setFileProcessor( locator.getService( FileProcessor.class ) );
91 }
92
93
94
95
96
97
98
99 public BasicRepositoryConnectorFactory setLoggerFactory( LoggerFactory loggerFactory )
100 {
101 this.logger = NullLoggerFactory.getSafeLogger( loggerFactory, BasicRepositoryConnector.class );
102 return this;
103 }
104
105
106
107
108
109
110
111 public BasicRepositoryConnectorFactory setTransporterProvider( TransporterProvider transporterProvider )
112 {
113 if ( transporterProvider == null )
114 {
115 throw new IllegalArgumentException( "transporter provider has not been specified" );
116 }
117 this.transporterProvider = transporterProvider;
118 return this;
119 }
120
121
122
123
124
125
126
127 public BasicRepositoryConnectorFactory setRepositoryLayoutProvider( RepositoryLayoutProvider layoutProvider )
128 {
129 if ( layoutProvider == null )
130 {
131 throw new IllegalArgumentException( "repository layout provider has not been specified" );
132 }
133 this.layoutProvider = layoutProvider;
134 return this;
135 }
136
137
138
139
140
141
142
143 public BasicRepositoryConnectorFactory setChecksumPolicyProvider( ChecksumPolicyProvider checksumPolicyProvider )
144 {
145 if ( checksumPolicyProvider == null )
146 {
147 throw new IllegalArgumentException( "checksum policy provider has not been specified" );
148 }
149 this.checksumPolicyProvider = checksumPolicyProvider;
150 return this;
151 }
152
153
154
155
156
157
158
159 public BasicRepositoryConnectorFactory setFileProcessor( FileProcessor fileProcessor )
160 {
161 if ( fileProcessor == null )
162 {
163 throw new IllegalArgumentException( "file processor has not been specified" );
164 }
165 this.fileProcessor = fileProcessor;
166 return this;
167 }
168
169 public float getPriority()
170 {
171 return priority;
172 }
173
174
175
176
177
178
179
180 public BasicRepositoryConnectorFactory setPriority( float priority )
181 {
182 this.priority = priority;
183 return this;
184 }
185
186 public RepositoryConnector newInstance( RepositorySystemSession session, RemoteRepository repository )
187 throws NoRepositoryConnectorException
188 {
189 return new BasicRepositoryConnector( session, repository, transporterProvider, layoutProvider,
190 checksumPolicyProvider, fileProcessor, logger );
191 }
192
193 }