1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.supplier;
20
21 import java.util.HashMap;
22 import java.util.HashSet;
23 import java.util.Map;
24 import java.util.function.Supplier;
25
26 import org.apache.maven.model.building.DefaultModelBuilderFactory;
27 import org.apache.maven.model.building.ModelBuilder;
28 import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader;
29 import org.apache.maven.repository.internal.DefaultModelCacheFactory;
30 import org.apache.maven.repository.internal.DefaultVersionRangeResolver;
31 import org.apache.maven.repository.internal.DefaultVersionResolver;
32 import org.apache.maven.repository.internal.ModelCacheFactory;
33 import org.apache.maven.repository.internal.PluginsMetadataGeneratorFactory;
34 import org.apache.maven.repository.internal.SnapshotMetadataGeneratorFactory;
35 import org.apache.maven.repository.internal.VersionsMetadataGeneratorFactory;
36 import org.eclipse.aether.RepositoryListener;
37 import org.eclipse.aether.RepositorySystem;
38 import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
39 import org.eclipse.aether.impl.ArtifactDescriptorReader;
40 import org.eclipse.aether.impl.ArtifactResolver;
41 import org.eclipse.aether.impl.DependencyCollector;
42 import org.eclipse.aether.impl.Deployer;
43 import org.eclipse.aether.impl.Installer;
44 import org.eclipse.aether.impl.LocalRepositoryProvider;
45 import org.eclipse.aether.impl.MetadataGeneratorFactory;
46 import org.eclipse.aether.impl.MetadataResolver;
47 import org.eclipse.aether.impl.OfflineController;
48 import org.eclipse.aether.impl.RemoteRepositoryFilterManager;
49 import org.eclipse.aether.impl.RemoteRepositoryManager;
50 import org.eclipse.aether.impl.RepositoryConnectorProvider;
51 import org.eclipse.aether.impl.RepositoryEventDispatcher;
52 import org.eclipse.aether.impl.RepositorySystemLifecycle;
53 import org.eclipse.aether.impl.UpdateCheckManager;
54 import org.eclipse.aether.impl.UpdatePolicyAnalyzer;
55 import org.eclipse.aether.impl.VersionRangeResolver;
56 import org.eclipse.aether.impl.VersionResolver;
57 import org.eclipse.aether.internal.impl.DefaultArtifactResolver;
58 import org.eclipse.aether.internal.impl.DefaultChecksumPolicyProvider;
59 import org.eclipse.aether.internal.impl.DefaultDeployer;
60 import org.eclipse.aether.internal.impl.DefaultFileProcessor;
61 import org.eclipse.aether.internal.impl.DefaultInstaller;
62 import org.eclipse.aether.internal.impl.DefaultLocalPathComposer;
63 import org.eclipse.aether.internal.impl.DefaultLocalPathPrefixComposerFactory;
64 import org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider;
65 import org.eclipse.aether.internal.impl.DefaultMetadataResolver;
66 import org.eclipse.aether.internal.impl.DefaultOfflineController;
67 import org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager;
68 import org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider;
69 import org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher;
70 import org.eclipse.aether.internal.impl.DefaultRepositoryLayoutProvider;
71 import org.eclipse.aether.internal.impl.DefaultRepositorySystem;
72 import org.eclipse.aether.internal.impl.DefaultRepositorySystemLifecycle;
73 import org.eclipse.aether.internal.impl.DefaultTrackingFileManager;
74 import org.eclipse.aether.internal.impl.DefaultTransporterProvider;
75 import org.eclipse.aether.internal.impl.DefaultUpdateCheckManager;
76 import org.eclipse.aether.internal.impl.DefaultUpdatePolicyAnalyzer;
77 import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory;
78 import org.eclipse.aether.internal.impl.LocalPathComposer;
79 import org.eclipse.aether.internal.impl.LocalPathPrefixComposerFactory;
80 import org.eclipse.aether.internal.impl.Maven2RepositoryLayoutFactory;
81 import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
82 import org.eclipse.aether.internal.impl.TrackingFileManager;
83 import org.eclipse.aether.internal.impl.checksum.DefaultChecksumAlgorithmFactorySelector;
84 import org.eclipse.aether.internal.impl.checksum.Md5ChecksumAlgorithmFactory;
85 import org.eclipse.aether.internal.impl.checksum.Sha1ChecksumAlgorithmFactory;
86 import org.eclipse.aether.internal.impl.checksum.Sha256ChecksumAlgorithmFactory;
87 import org.eclipse.aether.internal.impl.checksum.Sha512ChecksumAlgorithmFactory;
88 import org.eclipse.aether.internal.impl.checksum.SparseDirectoryTrustedChecksumsSource;
89 import org.eclipse.aether.internal.impl.checksum.SummaryFileTrustedChecksumsSource;
90 import org.eclipse.aether.internal.impl.checksum.TrustedToProvidedChecksumsSourceAdapter;
91 import org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector;
92 import org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate;
93 import org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector;
94 import org.eclipse.aether.internal.impl.collect.df.DfDependencyCollector;
95 import org.eclipse.aether.internal.impl.filter.DefaultRemoteRepositoryFilterManager;
96 import org.eclipse.aether.internal.impl.filter.GroupIdRemoteRepositoryFilterSource;
97 import org.eclipse.aether.internal.impl.filter.PrefixesRemoteRepositoryFilterSource;
98 import org.eclipse.aether.internal.impl.resolution.TrustedChecksumsArtifactResolverPostProcessor;
99 import org.eclipse.aether.internal.impl.synccontext.DefaultSyncContextFactory;
100 import org.eclipse.aether.internal.impl.synccontext.named.NameMapper;
101 import org.eclipse.aether.internal.impl.synccontext.named.NameMappers;
102 import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactory;
103 import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactoryImpl;
104 import org.eclipse.aether.named.NamedLockFactory;
105 import org.eclipse.aether.named.providers.FileLockNamedLockFactory;
106 import org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory;
107 import org.eclipse.aether.named.providers.LocalSemaphoreNamedLockFactory;
108 import org.eclipse.aether.named.providers.NoopNamedLockFactory;
109 import org.eclipse.aether.spi.checksums.ProvidedChecksumsSource;
110 import org.eclipse.aether.spi.checksums.TrustedChecksumsSource;
111 import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
112 import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory;
113 import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactorySelector;
114 import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider;
115 import org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilterSource;
116 import org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory;
117 import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider;
118 import org.eclipse.aether.spi.connector.transport.TransporterFactory;
119 import org.eclipse.aether.spi.connector.transport.TransporterProvider;
120 import org.eclipse.aether.spi.io.FileProcessor;
121 import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory;
122 import org.eclipse.aether.spi.resolution.ArtifactResolverPostProcessor;
123 import org.eclipse.aether.spi.synccontext.SyncContextFactory;
124 import org.eclipse.aether.transport.file.FileTransporterFactory;
125 import org.eclipse.aether.transport.http.ChecksumExtractor;
126 import org.eclipse.aether.transport.http.HttpTransporterFactory;
127 import org.eclipse.aether.transport.http.Nexus2ChecksumExtractor;
128 import org.eclipse.aether.transport.http.XChecksumChecksumExtractor;
129
130
131
132
133
134
135
136
137
138 public class RepositorySystemSupplier implements Supplier<RepositorySystem> {
139 protected FileProcessor getFileProcessor() {
140 return new DefaultFileProcessor();
141 }
142
143 protected TrackingFileManager getTrackingFileManager() {
144 return new DefaultTrackingFileManager();
145 }
146
147 protected LocalPathComposer getLocalPathComposer() {
148 return new DefaultLocalPathComposer();
149 }
150
151 protected LocalPathPrefixComposerFactory getLocalPathPrefixComposerFactory() {
152 return new DefaultLocalPathPrefixComposerFactory();
153 }
154
155 protected RepositorySystemLifecycle getRepositorySystemLifecycle() {
156 return new DefaultRepositorySystemLifecycle();
157 }
158
159 protected OfflineController getOfflineController() {
160 return new DefaultOfflineController();
161 }
162
163 protected UpdatePolicyAnalyzer getUpdatePolicyAnalyzer() {
164 return new DefaultUpdatePolicyAnalyzer();
165 }
166
167 protected ChecksumPolicyProvider getChecksumPolicyProvider() {
168 return new DefaultChecksumPolicyProvider();
169 }
170
171 protected UpdateCheckManager getUpdateCheckManager(
172 TrackingFileManager trackingFileManager, UpdatePolicyAnalyzer updatePolicyAnalyzer) {
173 return new DefaultUpdateCheckManager(trackingFileManager, updatePolicyAnalyzer);
174 }
175
176 protected Map<String, NamedLockFactory> getNamedLockFactories() {
177 HashMap<String, NamedLockFactory> result = new HashMap<>();
178 result.put(NoopNamedLockFactory.NAME, new NoopNamedLockFactory());
179 result.put(LocalReadWriteLockNamedLockFactory.NAME, new LocalReadWriteLockNamedLockFactory());
180 result.put(LocalSemaphoreNamedLockFactory.NAME, new LocalSemaphoreNamedLockFactory());
181 result.put(FileLockNamedLockFactory.NAME, new FileLockNamedLockFactory());
182 return result;
183 }
184
185 protected Map<String, NameMapper> getNameMappers() {
186 HashMap<String, NameMapper> result = new HashMap<>();
187 result.put(NameMappers.STATIC_NAME, NameMappers.staticNameMapper());
188 result.put(NameMappers.GAV_NAME, NameMappers.gavNameMapper());
189 result.put(NameMappers.DISCRIMINATING_NAME, NameMappers.discriminatingNameMapper());
190 result.put(NameMappers.FILE_GAV_NAME, NameMappers.fileGavNameMapper());
191 result.put(NameMappers.FILE_HGAV_NAME, NameMappers.fileHashingGavNameMapper());
192 return result;
193 }
194
195 protected NamedLockFactoryAdapterFactory getNamedLockFactoryAdapterFactory(
196 Map<String, NamedLockFactory> namedLockFactories,
197 Map<String, NameMapper> nameMappers,
198 RepositorySystemLifecycle repositorySystemLifecycle) {
199 return new NamedLockFactoryAdapterFactoryImpl(namedLockFactories, nameMappers, repositorySystemLifecycle);
200 }
201
202 protected SyncContextFactory getSyncContextFactory(NamedLockFactoryAdapterFactory namedLockFactoryAdapterFactory) {
203 return new DefaultSyncContextFactory(namedLockFactoryAdapterFactory);
204 }
205
206 protected Map<String, ChecksumAlgorithmFactory> getChecksumAlgorithmFactories() {
207 HashMap<String, ChecksumAlgorithmFactory> result = new HashMap<>();
208 result.put(Sha512ChecksumAlgorithmFactory.NAME, new Sha512ChecksumAlgorithmFactory());
209 result.put(Sha256ChecksumAlgorithmFactory.NAME, new Sha256ChecksumAlgorithmFactory());
210 result.put(Sha1ChecksumAlgorithmFactory.NAME, new Sha1ChecksumAlgorithmFactory());
211 result.put(Md5ChecksumAlgorithmFactory.NAME, new Md5ChecksumAlgorithmFactory());
212 return result;
213 }
214
215 protected ChecksumAlgorithmFactorySelector getChecksumAlgorithmFactorySelector(
216 Map<String, ChecksumAlgorithmFactory> checksumAlgorithmFactories) {
217 return new DefaultChecksumAlgorithmFactorySelector(checksumAlgorithmFactories);
218 }
219
220 protected Map<String, RepositoryLayoutFactory> getRepositoryLayoutFactories(
221 ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector) {
222 HashMap<String, RepositoryLayoutFactory> result = new HashMap<>();
223 result.put(
224 Maven2RepositoryLayoutFactory.NAME,
225 new Maven2RepositoryLayoutFactory(checksumAlgorithmFactorySelector));
226 return result;
227 }
228
229 protected RepositoryLayoutProvider getRepositoryLayoutProvider(
230 Map<String, RepositoryLayoutFactory> repositoryLayoutFactories) {
231 return new DefaultRepositoryLayoutProvider(new HashSet<>(repositoryLayoutFactories.values()));
232 }
233
234 protected LocalRepositoryProvider getLocalRepositoryProvider(
235 LocalPathComposer localPathComposer,
236 TrackingFileManager trackingFileManager,
237 LocalPathPrefixComposerFactory localPathPrefixComposerFactory) {
238 HashSet<LocalRepositoryManagerFactory> localRepositoryProviders = new HashSet<>(2);
239 localRepositoryProviders.add(new SimpleLocalRepositoryManagerFactory(localPathComposer));
240 localRepositoryProviders.add(new EnhancedLocalRepositoryManagerFactory(
241 localPathComposer, trackingFileManager, localPathPrefixComposerFactory));
242 return new DefaultLocalRepositoryProvider(localRepositoryProviders);
243 }
244
245 protected RemoteRepositoryManager getRemoteRepositoryManager(
246 UpdatePolicyAnalyzer updatePolicyAnalyzer, ChecksumPolicyProvider checksumPolicyProvider) {
247 return new DefaultRemoteRepositoryManager(updatePolicyAnalyzer, checksumPolicyProvider);
248 }
249
250 protected Map<String, RemoteRepositoryFilterSource> getRemoteRepositoryFilterSources(
251 RepositorySystemLifecycle repositorySystemLifecycle, RepositoryLayoutProvider repositoryLayoutProvider) {
252 HashMap<String, RemoteRepositoryFilterSource> result = new HashMap<>();
253 result.put(
254 GroupIdRemoteRepositoryFilterSource.NAME,
255 new GroupIdRemoteRepositoryFilterSource(repositorySystemLifecycle));
256 result.put(
257 PrefixesRemoteRepositoryFilterSource.NAME,
258 new PrefixesRemoteRepositoryFilterSource(repositoryLayoutProvider));
259 return result;
260 }
261
262 protected RemoteRepositoryFilterManager getRemoteRepositoryFilterManager(
263 Map<String, RemoteRepositoryFilterSource> remoteRepositoryFilterSources) {
264 return new DefaultRemoteRepositoryFilterManager(remoteRepositoryFilterSources);
265 }
266
267 protected Map<String, RepositoryListener> getRepositoryListeners() {
268 return new HashMap<>();
269 }
270
271 protected RepositoryEventDispatcher getRepositoryEventDispatcher(
272 Map<String, RepositoryListener> repositoryListeners) {
273 return new DefaultRepositoryEventDispatcher(new HashSet<>(repositoryListeners.values()));
274 }
275
276 protected Map<String, TrustedChecksumsSource> getTrustedChecksumsSources(
277 FileProcessor fileProcessor,
278 LocalPathComposer localPathComposer,
279 RepositorySystemLifecycle repositorySystemLifecycle) {
280 HashMap<String, TrustedChecksumsSource> result = new HashMap<>();
281 result.put(
282 SparseDirectoryTrustedChecksumsSource.NAME,
283 new SparseDirectoryTrustedChecksumsSource(fileProcessor, localPathComposer));
284 result.put(
285 SummaryFileTrustedChecksumsSource.NAME,
286 new SummaryFileTrustedChecksumsSource(localPathComposer, repositorySystemLifecycle));
287 return result;
288 }
289
290 protected Map<String, ProvidedChecksumsSource> getProvidedChecksumsSources(
291 Map<String, TrustedChecksumsSource> trustedChecksumsSources) {
292 HashMap<String, ProvidedChecksumsSource> result = new HashMap<>();
293 result.put(
294 TrustedToProvidedChecksumsSourceAdapter.NAME,
295 new TrustedToProvidedChecksumsSourceAdapter(trustedChecksumsSources));
296 return result;
297 }
298
299 protected Map<String, ChecksumExtractor> getChecksumExtractors() {
300 HashMap<String, ChecksumExtractor> result = new HashMap<>();
301 result.put(Nexus2ChecksumExtractor.NAME, new Nexus2ChecksumExtractor());
302 result.put(XChecksumChecksumExtractor.NAME, new XChecksumChecksumExtractor());
303 return result;
304 }
305
306 protected Map<String, TransporterFactory> getTransporterFactories(Map<String, ChecksumExtractor> extractors) {
307 HashMap<String, TransporterFactory> result = new HashMap<>();
308 result.put(FileTransporterFactory.NAME, new FileTransporterFactory());
309 result.put(HttpTransporterFactory.NAME, new HttpTransporterFactory(extractors));
310 return result;
311 }
312
313 protected TransporterProvider getTransporterProvider(Map<String, TransporterFactory> transporterFactories) {
314 return new DefaultTransporterProvider(new HashSet<>(transporterFactories.values()));
315 }
316
317 protected BasicRepositoryConnectorFactory getBasicRepositoryConnectorFactory(
318 TransporterProvider transporterProvider,
319 RepositoryLayoutProvider repositoryLayoutProvider,
320 ChecksumPolicyProvider checksumPolicyProvider,
321 FileProcessor fileProcessor,
322 Map<String, ProvidedChecksumsSource> providedChecksumsSources) {
323 return new BasicRepositoryConnectorFactory(
324 transporterProvider,
325 repositoryLayoutProvider,
326 checksumPolicyProvider,
327 fileProcessor,
328 providedChecksumsSources);
329 }
330
331 protected Map<String, RepositoryConnectorFactory> getRepositoryConnectorFactories(
332 BasicRepositoryConnectorFactory basicRepositoryConnectorFactory) {
333 HashMap<String, RepositoryConnectorFactory> result = new HashMap<>();
334 result.put(BasicRepositoryConnectorFactory.NAME, basicRepositoryConnectorFactory);
335 return result;
336 }
337
338 protected RepositoryConnectorProvider getRepositoryConnectorProvider(
339 Map<String, RepositoryConnectorFactory> repositoryConnectorFactories,
340 RemoteRepositoryFilterManager remoteRepositoryFilterManager) {
341 return new DefaultRepositoryConnectorProvider(
342 new HashSet<>(repositoryConnectorFactories.values()), remoteRepositoryFilterManager);
343 }
344
345 protected Installer getInstaller(
346 FileProcessor fileProcessor,
347 RepositoryEventDispatcher repositoryEventDispatcher,
348 Map<String, MetadataGeneratorFactory> metadataGeneratorFactories,
349 SyncContextFactory syncContextFactory) {
350 return new DefaultInstaller(
351 fileProcessor,
352 repositoryEventDispatcher,
353 new HashSet<>(metadataGeneratorFactories.values()),
354 syncContextFactory);
355 }
356
357 @SuppressWarnings("checkstyle:parameternumber")
358 protected Deployer getDeployer(
359 FileProcessor fileProcessor,
360 RepositoryEventDispatcher repositoryEventDispatcher,
361 RepositoryConnectorProvider repositoryConnectorProvider,
362 RemoteRepositoryManager remoteRepositoryManager,
363 UpdateCheckManager updateCheckManager,
364 Map<String, MetadataGeneratorFactory> metadataGeneratorFactories,
365 SyncContextFactory syncContextFactory,
366 OfflineController offlineController) {
367 return new DefaultDeployer(
368 fileProcessor,
369 repositoryEventDispatcher,
370 repositoryConnectorProvider,
371 remoteRepositoryManager,
372 updateCheckManager,
373 new HashSet<>(metadataGeneratorFactories.values()),
374 syncContextFactory,
375 offlineController);
376 }
377
378 protected Map<String, DependencyCollectorDelegate> getDependencyCollectorDelegates(
379 RemoteRepositoryManager remoteRepositoryManager,
380 ArtifactDescriptorReader artifactDescriptorReader,
381 VersionRangeResolver versionRangeResolver) {
382 HashMap<String, DependencyCollectorDelegate> result = new HashMap<>();
383 result.put(
384 DfDependencyCollector.NAME,
385 new DfDependencyCollector(remoteRepositoryManager, artifactDescriptorReader, versionRangeResolver));
386 result.put(
387 BfDependencyCollector.NAME,
388 new BfDependencyCollector(remoteRepositoryManager, artifactDescriptorReader, versionRangeResolver));
389 return result;
390 }
391
392 protected DependencyCollector getDependencyCollector(
393 Map<String, DependencyCollectorDelegate> dependencyCollectorDelegates) {
394 return new DefaultDependencyCollector(dependencyCollectorDelegates);
395 }
396
397 protected Map<String, ArtifactResolverPostProcessor> getArtifactResolverPostProcessors(
398 ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector,
399 Map<String, TrustedChecksumsSource> trustedChecksumsSources) {
400 HashMap<String, ArtifactResolverPostProcessor> result = new HashMap<>();
401 result.put(
402 TrustedChecksumsArtifactResolverPostProcessor.NAME,
403 new TrustedChecksumsArtifactResolverPostProcessor(
404 checksumAlgorithmFactorySelector, trustedChecksumsSources));
405 return result;
406 }
407
408 @SuppressWarnings("checkstyle:parameternumber")
409 protected ArtifactResolver getArtifactResolver(
410 FileProcessor fileProcessor,
411 RepositoryEventDispatcher repositoryEventDispatcher,
412 VersionResolver versionResolver,
413 UpdateCheckManager updateCheckManager,
414 RepositoryConnectorProvider repositoryConnectorProvider,
415 RemoteRepositoryManager remoteRepositoryManager,
416 SyncContextFactory syncContextFactory,
417 OfflineController offlineController,
418 Map<String, ArtifactResolverPostProcessor> artifactResolverPostProcessors,
419 RemoteRepositoryFilterManager remoteRepositoryFilterManager) {
420 return new DefaultArtifactResolver(
421 fileProcessor,
422 repositoryEventDispatcher,
423 versionResolver,
424 updateCheckManager,
425 repositoryConnectorProvider,
426 remoteRepositoryManager,
427 syncContextFactory,
428 offlineController,
429 artifactResolverPostProcessors,
430 remoteRepositoryFilterManager);
431 }
432
433 protected MetadataResolver getMetadataResolver(
434 RepositoryEventDispatcher repositoryEventDispatcher,
435 UpdateCheckManager updateCheckManager,
436 RepositoryConnectorProvider repositoryConnectorProvider,
437 RemoteRepositoryManager remoteRepositoryManager,
438 SyncContextFactory syncContextFactory,
439 OfflineController offlineController,
440 RemoteRepositoryFilterManager remoteRepositoryFilterManager) {
441 return new DefaultMetadataResolver(
442 repositoryEventDispatcher,
443 updateCheckManager,
444 repositoryConnectorProvider,
445 remoteRepositoryManager,
446 syncContextFactory,
447 offlineController,
448 remoteRepositoryFilterManager);
449 }
450
451
452
453 protected Map<String, MetadataGeneratorFactory> getMetadataGeneratorFactories() {
454
455 HashMap<String, MetadataGeneratorFactory> result = new HashMap<>();
456
457 result.put("plugins", new PluginsMetadataGeneratorFactory());
458 result.put("versions", new VersionsMetadataGeneratorFactory());
459 result.put("snapshot", new SnapshotMetadataGeneratorFactory());
460 return result;
461 }
462
463 protected ArtifactDescriptorReader getArtifactDescriptorReader(
464 RemoteRepositoryManager remoteRepositoryManager,
465 VersionResolver versionResolver,
466 VersionRangeResolver versionRangeResolver,
467 ArtifactResolver artifactResolver,
468 ModelBuilder modelBuilder,
469 RepositoryEventDispatcher repositoryEventDispatcher,
470 ModelCacheFactory modelCacheFactory) {
471
472 DefaultArtifactDescriptorReader result = new DefaultArtifactDescriptorReader();
473 result.setRemoteRepositoryManager(remoteRepositoryManager);
474 result.setVersionResolver(versionResolver);
475 result.setVersionRangeResolver(versionRangeResolver);
476 result.setArtifactResolver(artifactResolver);
477 result.setModelBuilder(modelBuilder);
478 result.setRepositoryEventDispatcher(repositoryEventDispatcher);
479 result.setModelCacheFactory(modelCacheFactory);
480 return result;
481 }
482
483 protected VersionResolver getVersionResolver(
484 MetadataResolver metadataResolver,
485 SyncContextFactory syncContextFactory,
486 RepositoryEventDispatcher repositoryEventDispatcher) {
487
488 DefaultVersionResolver result = new DefaultVersionResolver();
489 result.setMetadataResolver(metadataResolver);
490 result.setSyncContextFactory(syncContextFactory);
491 result.setRepositoryEventDispatcher(repositoryEventDispatcher);
492 return result;
493 }
494
495 protected VersionRangeResolver getVersionRangeResolver(
496 MetadataResolver metadataResolver,
497 SyncContextFactory syncContextFactory,
498 RepositoryEventDispatcher repositoryEventDispatcher) {
499
500 DefaultVersionRangeResolver result = new DefaultVersionRangeResolver();
501 result.setMetadataResolver(metadataResolver);
502 result.setSyncContextFactory(syncContextFactory);
503 result.setRepositoryEventDispatcher(repositoryEventDispatcher);
504 return result;
505 }
506
507 protected ModelBuilder getModelBuilder() {
508
509 return new DefaultModelBuilderFactory().newInstance();
510 }
511
512 protected ModelCacheFactory getModelCacheFactory() {
513
514 return new DefaultModelCacheFactory();
515 }
516
517 @Override
518 public RepositorySystem get() {
519 FileProcessor fileProcessor = getFileProcessor();
520 TrackingFileManager trackingFileManager = getTrackingFileManager();
521 LocalPathComposer localPathComposer = getLocalPathComposer();
522 LocalPathPrefixComposerFactory localPathPrefixComposerFactory = getLocalPathPrefixComposerFactory();
523 RepositorySystemLifecycle repositorySystemLifecycle = getRepositorySystemLifecycle();
524 OfflineController offlineController = getOfflineController();
525 UpdatePolicyAnalyzer updatePolicyAnalyzer = getUpdatePolicyAnalyzer();
526 ChecksumPolicyProvider checksumPolicyProvider = getChecksumPolicyProvider();
527
528 UpdateCheckManager updateCheckManager = getUpdateCheckManager(trackingFileManager, updatePolicyAnalyzer);
529
530 Map<String, NamedLockFactory> namedLockFactories = getNamedLockFactories();
531 Map<String, NameMapper> nameMappers = getNameMappers();
532 NamedLockFactoryAdapterFactory namedLockFactoryAdapterFactory =
533 getNamedLockFactoryAdapterFactory(namedLockFactories, nameMappers, repositorySystemLifecycle);
534 SyncContextFactory syncContextFactory = getSyncContextFactory(namedLockFactoryAdapterFactory);
535
536 Map<String, ChecksumAlgorithmFactory> checksumAlgorithmFactories = getChecksumAlgorithmFactories();
537 ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector =
538 getChecksumAlgorithmFactorySelector(checksumAlgorithmFactories);
539
540 Map<String, RepositoryLayoutFactory> repositoryLayoutFactories =
541 getRepositoryLayoutFactories(checksumAlgorithmFactorySelector);
542 RepositoryLayoutProvider repositoryLayoutProvider = getRepositoryLayoutProvider(repositoryLayoutFactories);
543
544 LocalRepositoryProvider localRepositoryProvider =
545 getLocalRepositoryProvider(localPathComposer, trackingFileManager, localPathPrefixComposerFactory);
546
547 RemoteRepositoryManager remoteRepositoryManager =
548 getRemoteRepositoryManager(updatePolicyAnalyzer, checksumPolicyProvider);
549 Map<String, RemoteRepositoryFilterSource> remoteRepositoryFilterSources =
550 getRemoteRepositoryFilterSources(repositorySystemLifecycle, repositoryLayoutProvider);
551 RemoteRepositoryFilterManager remoteRepositoryFilterManager =
552 getRemoteRepositoryFilterManager(remoteRepositoryFilterSources);
553
554 Map<String, RepositoryListener> repositoryListeners = getRepositoryListeners();
555 RepositoryEventDispatcher repositoryEventDispatcher = getRepositoryEventDispatcher(repositoryListeners);
556
557 Map<String, TrustedChecksumsSource> trustedChecksumsSources =
558 getTrustedChecksumsSources(fileProcessor, localPathComposer, repositorySystemLifecycle);
559 Map<String, ProvidedChecksumsSource> providedChecksumsSources =
560 getProvidedChecksumsSources(trustedChecksumsSources);
561
562 Map<String, ChecksumExtractor> checksumExtractors = getChecksumExtractors();
563 Map<String, TransporterFactory> transporterFactories = getTransporterFactories(checksumExtractors);
564 TransporterProvider transporterProvider = getTransporterProvider(transporterFactories);
565
566 BasicRepositoryConnectorFactory basic = getBasicRepositoryConnectorFactory(
567 transporterProvider,
568 repositoryLayoutProvider,
569 checksumPolicyProvider,
570 fileProcessor,
571 providedChecksumsSources);
572 Map<String, RepositoryConnectorFactory> repositoryConnectorFactories = getRepositoryConnectorFactories(basic);
573 RepositoryConnectorProvider repositoryConnectorProvider =
574 getRepositoryConnectorProvider(repositoryConnectorFactories, remoteRepositoryFilterManager);
575
576 Map<String, MetadataGeneratorFactory> metadataGeneratorFactories = getMetadataGeneratorFactories();
577
578 Installer installer =
579 getInstaller(fileProcessor, repositoryEventDispatcher, metadataGeneratorFactories, syncContextFactory);
580 Deployer deployer = getDeployer(
581 fileProcessor,
582 repositoryEventDispatcher,
583 repositoryConnectorProvider,
584 remoteRepositoryManager,
585 updateCheckManager,
586 metadataGeneratorFactories,
587 syncContextFactory,
588 offlineController);
589
590 MetadataResolver metadataResolver = getMetadataResolver(
591 repositoryEventDispatcher,
592 updateCheckManager,
593 repositoryConnectorProvider,
594 remoteRepositoryManager,
595 syncContextFactory,
596 offlineController,
597 remoteRepositoryFilterManager);
598
599 VersionResolver versionResolver =
600 getVersionResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher);
601 VersionRangeResolver versionRangeResolver =
602 getVersionRangeResolver(metadataResolver, syncContextFactory, repositoryEventDispatcher);
603
604 Map<String, ArtifactResolverPostProcessor> artifactResolverPostProcessors =
605 getArtifactResolverPostProcessors(checksumAlgorithmFactorySelector, trustedChecksumsSources);
606 ArtifactResolver artifactResolver = getArtifactResolver(
607 fileProcessor,
608 repositoryEventDispatcher,
609 versionResolver,
610 updateCheckManager,
611 repositoryConnectorProvider,
612 remoteRepositoryManager,
613 syncContextFactory,
614 offlineController,
615 artifactResolverPostProcessors,
616 remoteRepositoryFilterManager);
617
618 ModelBuilder modelBuilder = getModelBuilder();
619 ModelCacheFactory modelCacheFactory = getModelCacheFactory();
620
621 ArtifactDescriptorReader artifactDescriptorReader = getArtifactDescriptorReader(
622 remoteRepositoryManager,
623 versionResolver,
624 versionRangeResolver,
625 artifactResolver,
626 modelBuilder,
627 repositoryEventDispatcher,
628 modelCacheFactory);
629
630 Map<String, DependencyCollectorDelegate> dependencyCollectorDelegates = getDependencyCollectorDelegates(
631 remoteRepositoryManager, artifactDescriptorReader, versionRangeResolver);
632 DependencyCollector dependencyCollector = getDependencyCollector(dependencyCollectorDelegates);
633
634 return new DefaultRepositorySystem(
635 versionResolver,
636 versionRangeResolver,
637 artifactResolver,
638 metadataResolver,
639 artifactDescriptorReader,
640 dependencyCollector,
641 installer,
642 deployer,
643 localRepositoryProvider,
644 syncContextFactory,
645 remoteRepositoryManager,
646 repositorySystemLifecycle);
647 }
648 }