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.Map;
23 import java.util.concurrent.atomic.AtomicBoolean;
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.*;
58 import org.eclipse.aether.internal.impl.checksum.DefaultChecksumAlgorithmFactorySelector;
59 import org.eclipse.aether.internal.impl.checksum.Md5ChecksumAlgorithmFactory;
60 import org.eclipse.aether.internal.impl.checksum.Sha1ChecksumAlgorithmFactory;
61 import org.eclipse.aether.internal.impl.checksum.Sha256ChecksumAlgorithmFactory;
62 import org.eclipse.aether.internal.impl.checksum.Sha512ChecksumAlgorithmFactory;
63 import org.eclipse.aether.internal.impl.checksum.SparseDirectoryTrustedChecksumsSource;
64 import org.eclipse.aether.internal.impl.checksum.SummaryFileTrustedChecksumsSource;
65 import org.eclipse.aether.internal.impl.checksum.TrustedToProvidedChecksumsSourceAdapter;
66 import org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector;
67 import org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate;
68 import org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector;
69 import org.eclipse.aether.internal.impl.collect.df.DfDependencyCollector;
70 import org.eclipse.aether.internal.impl.filter.DefaultRemoteRepositoryFilterManager;
71 import org.eclipse.aether.internal.impl.filter.GroupIdRemoteRepositoryFilterSource;
72 import org.eclipse.aether.internal.impl.filter.PrefixesRemoteRepositoryFilterSource;
73 import org.eclipse.aether.internal.impl.resolution.TrustedChecksumsArtifactResolverPostProcessor;
74 import org.eclipse.aether.internal.impl.synccontext.DefaultSyncContextFactory;
75 import org.eclipse.aether.internal.impl.synccontext.named.NameMapper;
76 import org.eclipse.aether.internal.impl.synccontext.named.NameMappers;
77 import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactory;
78 import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapterFactoryImpl;
79 import org.eclipse.aether.internal.impl.transport.http.DefaultChecksumExtractor;
80 import org.eclipse.aether.internal.impl.transport.http.Nx2ChecksumExtractor;
81 import org.eclipse.aether.internal.impl.transport.http.XChecksumExtractor;
82 import org.eclipse.aether.named.NamedLockFactory;
83 import org.eclipse.aether.named.providers.FileLockNamedLockFactory;
84 import org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory;
85 import org.eclipse.aether.named.providers.LocalSemaphoreNamedLockFactory;
86 import org.eclipse.aether.named.providers.NoopNamedLockFactory;
87 import org.eclipse.aether.spi.artifact.ArtifactPredicateFactory;
88 import org.eclipse.aether.spi.artifact.decorator.ArtifactDecoratorFactory;
89 import org.eclipse.aether.spi.artifact.generator.ArtifactGeneratorFactory;
90 import org.eclipse.aether.spi.checksums.ProvidedChecksumsSource;
91 import org.eclipse.aether.spi.checksums.TrustedChecksumsSource;
92 import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
93 import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactory;
94 import org.eclipse.aether.spi.connector.checksum.ChecksumAlgorithmFactorySelector;
95 import org.eclipse.aether.spi.connector.checksum.ChecksumPolicyProvider;
96 import org.eclipse.aether.spi.connector.filter.RemoteRepositoryFilterSource;
97 import org.eclipse.aether.spi.connector.layout.RepositoryLayoutFactory;
98 import org.eclipse.aether.spi.connector.layout.RepositoryLayoutProvider;
99 import org.eclipse.aether.spi.connector.transport.TransporterFactory;
100 import org.eclipse.aether.spi.connector.transport.TransporterProvider;
101 import org.eclipse.aether.spi.connector.transport.http.ChecksumExtractor;
102 import org.eclipse.aether.spi.connector.transport.http.ChecksumExtractorStrategy;
103 import org.eclipse.aether.spi.io.ChecksumProcessor;
104 import org.eclipse.aether.spi.io.PathProcessor;
105 import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory;
106 import org.eclipse.aether.spi.resolution.ArtifactResolverPostProcessor;
107 import org.eclipse.aether.spi.synccontext.SyncContextFactory;
108 import org.eclipse.aether.transport.apache.ApacheTransporterFactory;
109 import org.eclipse.aether.transport.file.FileTransporterFactory;
110 import org.eclipse.aether.util.version.GenericVersionScheme;
111 import org.eclipse.aether.version.VersionScheme;
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136 public class RepositorySystemSupplier implements Supplier<RepositorySystem> {
137 private final AtomicBoolean closed = new AtomicBoolean(false);
138
139 public RepositorySystemSupplier() {}
140
141 private void checkClosed() {
142 if (closed.get()) {
143 throw new IllegalStateException("Supplier is closed");
144 }
145 }
146
147 private PathProcessor pathProcessor;
148
149 public final PathProcessor getPathProcessor() {
150 checkClosed();
151 if (pathProcessor == null) {
152 pathProcessor = createPathProcessor();
153 }
154 return pathProcessor;
155 }
156
157 protected PathProcessor createPathProcessor() {
158 return new DefaultPathProcessor();
159 }
160
161 private ChecksumProcessor checksumProcessor;
162
163 public final ChecksumProcessor getChecksumProcessor() {
164 checkClosed();
165 if (checksumProcessor == null) {
166 checksumProcessor = createChecksumProcessor();
167 }
168 return checksumProcessor;
169 }
170
171 protected ChecksumProcessor createChecksumProcessor() {
172 return new DefaultChecksumProcessor(getPathProcessor());
173 }
174
175 private TrackingFileManager trackingFileManager;
176
177 public final TrackingFileManager getTrackingFileManager() {
178 checkClosed();
179 if (trackingFileManager == null) {
180 trackingFileManager = createTrackingFileManager();
181 }
182 return trackingFileManager;
183 }
184
185 protected TrackingFileManager createTrackingFileManager() {
186 return new DefaultTrackingFileManager();
187 }
188
189 private LocalPathComposer localPathComposer;
190
191 public final LocalPathComposer getLocalPathComposer() {
192 checkClosed();
193 if (localPathComposer == null) {
194 localPathComposer = createLocalPathComposer();
195 }
196 return localPathComposer;
197 }
198
199 protected LocalPathComposer createLocalPathComposer() {
200 return new DefaultLocalPathComposer();
201 }
202
203 private LocalPathPrefixComposerFactory localPathPrefixComposerFactory;
204
205 public final LocalPathPrefixComposerFactory getLocalPathPrefixComposerFactory() {
206 checkClosed();
207 if (localPathPrefixComposerFactory == null) {
208 localPathPrefixComposerFactory = createLocalPathPrefixComposerFactory();
209 }
210 return localPathPrefixComposerFactory;
211 }
212
213 protected LocalPathPrefixComposerFactory createLocalPathPrefixComposerFactory() {
214 return new DefaultLocalPathPrefixComposerFactory();
215 }
216
217 private RepositorySystemLifecycle repositorySystemLifecycle;
218
219 public final RepositorySystemLifecycle getRepositorySystemLifecycle() {
220 checkClosed();
221 if (repositorySystemLifecycle == null) {
222 repositorySystemLifecycle = createRepositorySystemLifecycle();
223 repositorySystemLifecycle.addOnSystemEndedHandler(() -> closed.set(true));
224 }
225 return repositorySystemLifecycle;
226 }
227
228 protected RepositorySystemLifecycle createRepositorySystemLifecycle() {
229 return new DefaultRepositorySystemLifecycle();
230 }
231
232 private OfflineController offlineController;
233
234 public final OfflineController getOfflineController() {
235 checkClosed();
236 if (offlineController == null) {
237 offlineController = createOfflineController();
238 }
239 return offlineController;
240 }
241
242 protected OfflineController createOfflineController() {
243 return new DefaultOfflineController();
244 }
245
246 private UpdatePolicyAnalyzer updatePolicyAnalyzer;
247
248 public final UpdatePolicyAnalyzer getUpdatePolicyAnalyzer() {
249 checkClosed();
250 if (updatePolicyAnalyzer == null) {
251 updatePolicyAnalyzer = createUpdatePolicyAnalyzer();
252 }
253 return updatePolicyAnalyzer;
254 }
255
256 protected UpdatePolicyAnalyzer createUpdatePolicyAnalyzer() {
257 return new DefaultUpdatePolicyAnalyzer();
258 }
259
260 private ChecksumPolicyProvider checksumPolicyProvider;
261
262 public final ChecksumPolicyProvider getChecksumPolicyProvider() {
263 checkClosed();
264 if (checksumPolicyProvider == null) {
265 checksumPolicyProvider = createChecksumPolicyProvider();
266 }
267 return checksumPolicyProvider;
268 }
269
270 protected ChecksumPolicyProvider createChecksumPolicyProvider() {
271 return new DefaultChecksumPolicyProvider();
272 }
273
274 private UpdateCheckManager updateCheckManager;
275
276 public final UpdateCheckManager getUpdateCheckManager() {
277 checkClosed();
278 if (updateCheckManager == null) {
279 updateCheckManager = createUpdateCheckManager();
280 }
281 return updateCheckManager;
282 }
283
284 protected UpdateCheckManager createUpdateCheckManager() {
285 return new DefaultUpdateCheckManager(getTrackingFileManager(), getUpdatePolicyAnalyzer(), getPathProcessor());
286 }
287
288 private Map<String, NamedLockFactory> namedLockFactories;
289
290 public final Map<String, NamedLockFactory> getNamedLockFactories() {
291 checkClosed();
292 if (namedLockFactories == null) {
293 namedLockFactories = createNamedLockFactories();
294 }
295 return namedLockFactories;
296 }
297
298 protected Map<String, NamedLockFactory> createNamedLockFactories() {
299 HashMap<String, NamedLockFactory> result = new HashMap<>();
300 result.put(NoopNamedLockFactory.NAME, new NoopNamedLockFactory());
301 result.put(LocalReadWriteLockNamedLockFactory.NAME, new LocalReadWriteLockNamedLockFactory());
302 result.put(LocalSemaphoreNamedLockFactory.NAME, new LocalSemaphoreNamedLockFactory());
303 result.put(FileLockNamedLockFactory.NAME, new FileLockNamedLockFactory());
304 return result;
305 }
306
307 private Map<String, NameMapper> nameMappers;
308
309 public final Map<String, NameMapper> getNameMappers() {
310 checkClosed();
311 if (nameMappers == null) {
312 nameMappers = createNameMappers();
313 }
314 return nameMappers;
315 }
316
317 protected Map<String, NameMapper> createNameMappers() {
318 HashMap<String, NameMapper> result = new HashMap<>();
319 result.put(NameMappers.STATIC_NAME, NameMappers.staticNameMapper());
320 result.put(NameMappers.GAV_NAME, NameMappers.gavNameMapper());
321 result.put(NameMappers.DISCRIMINATING_NAME, NameMappers.discriminatingNameMapper());
322 result.put(NameMappers.FILE_GAV_NAME, NameMappers.fileGavNameMapper());
323 result.put(NameMappers.FILE_HGAV_NAME, NameMappers.fileHashingGavNameMapper());
324 return result;
325 }
326
327 private NamedLockFactoryAdapterFactory namedLockFactoryAdapterFactory;
328
329 public final NamedLockFactoryAdapterFactory getNamedLockFactoryAdapterFactory() {
330 checkClosed();
331 if (namedLockFactoryAdapterFactory == null) {
332 namedLockFactoryAdapterFactory = createNamedLockFactoryAdapterFactory();
333 }
334 return namedLockFactoryAdapterFactory;
335 }
336
337 protected NamedLockFactoryAdapterFactory createNamedLockFactoryAdapterFactory() {
338 return new NamedLockFactoryAdapterFactoryImpl(
339 getNamedLockFactories(), getNameMappers(), getRepositorySystemLifecycle());
340 }
341
342 private SyncContextFactory syncContextFactory;
343
344 public final SyncContextFactory getSyncContextFactory() {
345 checkClosed();
346 if (syncContextFactory == null) {
347 syncContextFactory = createSyncContextFactory();
348 }
349 return syncContextFactory;
350 }
351
352 protected SyncContextFactory createSyncContextFactory() {
353 return new DefaultSyncContextFactory(getNamedLockFactoryAdapterFactory());
354 }
355
356 private Map<String, ChecksumAlgorithmFactory> checksumAlgorithmFactories;
357
358 public final Map<String, ChecksumAlgorithmFactory> getChecksumAlgorithmFactories() {
359 checkClosed();
360 if (checksumAlgorithmFactories == null) {
361 checksumAlgorithmFactories = createChecksumAlgorithmFactories();
362 }
363 return checksumAlgorithmFactories;
364 }
365
366 protected Map<String, ChecksumAlgorithmFactory> createChecksumAlgorithmFactories() {
367 HashMap<String, ChecksumAlgorithmFactory> result = new HashMap<>();
368 result.put(Sha512ChecksumAlgorithmFactory.NAME, new Sha512ChecksumAlgorithmFactory());
369 result.put(Sha256ChecksumAlgorithmFactory.NAME, new Sha256ChecksumAlgorithmFactory());
370 result.put(Sha1ChecksumAlgorithmFactory.NAME, new Sha1ChecksumAlgorithmFactory());
371 result.put(Md5ChecksumAlgorithmFactory.NAME, new Md5ChecksumAlgorithmFactory());
372 return result;
373 }
374
375 private ChecksumAlgorithmFactorySelector checksumAlgorithmFactorySelector;
376
377 public final ChecksumAlgorithmFactorySelector getChecksumAlgorithmFactorySelector() {
378 checkClosed();
379 if (checksumAlgorithmFactorySelector == null) {
380 checksumAlgorithmFactorySelector = createChecksumAlgorithmFactorySelector();
381 }
382 return checksumAlgorithmFactorySelector;
383 }
384
385 protected ChecksumAlgorithmFactorySelector createChecksumAlgorithmFactorySelector() {
386 return new DefaultChecksumAlgorithmFactorySelector(getChecksumAlgorithmFactories());
387 }
388
389 private ArtifactPredicateFactory artifactPredicateFactory;
390
391 public final ArtifactPredicateFactory getArtifactPredicateFactory() {
392 checkClosed();
393 if (artifactPredicateFactory == null) {
394 artifactPredicateFactory = createArtifactPredicateFactory();
395 }
396 return artifactPredicateFactory;
397 }
398
399 protected ArtifactPredicateFactory createArtifactPredicateFactory() {
400 return new DefaultArtifactPredicateFactory(getChecksumAlgorithmFactorySelector());
401 }
402
403 private Map<String, RepositoryLayoutFactory> repositoryLayoutFactories;
404
405 public final Map<String, RepositoryLayoutFactory> getRepositoryLayoutFactories() {
406 checkClosed();
407 if (repositoryLayoutFactories == null) {
408 repositoryLayoutFactories = createRepositoryLayoutFactories();
409 }
410 return repositoryLayoutFactories;
411 }
412
413 protected Map<String, RepositoryLayoutFactory> createRepositoryLayoutFactories() {
414 HashMap<String, RepositoryLayoutFactory> result = new HashMap<>();
415 result.put(
416 Maven2RepositoryLayoutFactory.NAME,
417 new Maven2RepositoryLayoutFactory(
418 getChecksumAlgorithmFactorySelector(), getArtifactPredicateFactory()));
419 return result;
420 }
421
422 private RepositoryLayoutProvider repositoryLayoutProvider;
423
424 public final RepositoryLayoutProvider getRepositoryLayoutProvider() {
425 checkClosed();
426 if (repositoryLayoutProvider == null) {
427 repositoryLayoutProvider = createRepositoryLayoutProvider();
428 }
429 return repositoryLayoutProvider;
430 }
431
432 protected RepositoryLayoutProvider createRepositoryLayoutProvider() {
433 return new DefaultRepositoryLayoutProvider(getRepositoryLayoutFactories());
434 }
435
436 private LocalRepositoryProvider localRepositoryProvider;
437
438 public final LocalRepositoryProvider getLocalRepositoryProvider() {
439 checkClosed();
440 if (localRepositoryProvider == null) {
441 localRepositoryProvider = createLocalRepositoryProvider();
442 }
443 return localRepositoryProvider;
444 }
445
446 protected LocalRepositoryProvider createLocalRepositoryProvider() {
447 LocalPathComposer localPathComposer = getLocalPathComposer();
448 HashMap<String, LocalRepositoryManagerFactory> localRepositoryProviders = new HashMap<>(2);
449 localRepositoryProviders.put(
450 SimpleLocalRepositoryManagerFactory.NAME, new SimpleLocalRepositoryManagerFactory(localPathComposer));
451 localRepositoryProviders.put(
452 EnhancedLocalRepositoryManagerFactory.NAME,
453 new EnhancedLocalRepositoryManagerFactory(
454 localPathComposer, getTrackingFileManager(), getLocalPathPrefixComposerFactory()));
455 return new DefaultLocalRepositoryProvider(localRepositoryProviders);
456 }
457
458 private RemoteRepositoryManager remoteRepositoryManager;
459
460 public final RemoteRepositoryManager getRemoteRepositoryManager() {
461 checkClosed();
462 if (remoteRepositoryManager == null) {
463 remoteRepositoryManager = createRemoteRepositoryManager();
464 }
465 return remoteRepositoryManager;
466 }
467
468 protected RemoteRepositoryManager createRemoteRepositoryManager() {
469 return new DefaultRemoteRepositoryManager(getUpdatePolicyAnalyzer(), getChecksumPolicyProvider());
470 }
471
472 private Map<String, RemoteRepositoryFilterSource> remoteRepositoryFilterSources;
473
474 public final Map<String, RemoteRepositoryFilterSource> getRemoteRepositoryFilterSources() {
475 checkClosed();
476 if (remoteRepositoryFilterSources == null) {
477 remoteRepositoryFilterSources = createRemoteRepositoryFilterSources();
478 }
479 return remoteRepositoryFilterSources;
480 }
481
482 protected Map<String, RemoteRepositoryFilterSource> createRemoteRepositoryFilterSources() {
483 HashMap<String, RemoteRepositoryFilterSource> result = new HashMap<>();
484 result.put(
485 GroupIdRemoteRepositoryFilterSource.NAME,
486 new GroupIdRemoteRepositoryFilterSource(getRepositorySystemLifecycle()));
487 result.put(
488 PrefixesRemoteRepositoryFilterSource.NAME,
489 new PrefixesRemoteRepositoryFilterSource(getRepositoryLayoutProvider()));
490 return result;
491 }
492
493 private RemoteRepositoryFilterManager remoteRepositoryFilterManager;
494
495 public final RemoteRepositoryFilterManager getRemoteRepositoryFilterManager() {
496 checkClosed();
497 if (remoteRepositoryFilterManager == null) {
498 remoteRepositoryFilterManager = createRemoteRepositoryFilterManager();
499 }
500 return remoteRepositoryFilterManager;
501 }
502
503 protected RemoteRepositoryFilterManager createRemoteRepositoryFilterManager() {
504 return new DefaultRemoteRepositoryFilterManager(getRemoteRepositoryFilterSources());
505 }
506
507 private Map<String, RepositoryListener> repositoryListeners;
508
509 public final Map<String, RepositoryListener> getRepositoryListeners() {
510 checkClosed();
511 if (repositoryListeners == null) {
512 repositoryListeners = createRepositoryListeners();
513 }
514 return repositoryListeners;
515 }
516
517 protected Map<String, RepositoryListener> createRepositoryListeners() {
518 return new HashMap<>();
519 }
520
521 private RepositoryEventDispatcher repositoryEventDispatcher;
522
523 public final RepositoryEventDispatcher getRepositoryEventDispatcher() {
524 checkClosed();
525 if (repositoryEventDispatcher == null) {
526 repositoryEventDispatcher = createRepositoryEventDispatcher();
527 }
528 return repositoryEventDispatcher;
529 }
530
531 protected RepositoryEventDispatcher createRepositoryEventDispatcher() {
532 return new DefaultRepositoryEventDispatcher(getRepositoryListeners());
533 }
534
535 private Map<String, TrustedChecksumsSource> trustedChecksumsSources;
536
537 public final Map<String, TrustedChecksumsSource> getTrustedChecksumsSources() {
538 checkClosed();
539 if (trustedChecksumsSources == null) {
540 trustedChecksumsSources = createTrustedChecksumsSources();
541 }
542 return trustedChecksumsSources;
543 }
544
545 protected Map<String, TrustedChecksumsSource> createTrustedChecksumsSources() {
546 HashMap<String, TrustedChecksumsSource> result = new HashMap<>();
547 result.put(
548 SparseDirectoryTrustedChecksumsSource.NAME,
549 new SparseDirectoryTrustedChecksumsSource(getChecksumProcessor(), getLocalPathComposer()));
550 result.put(
551 SummaryFileTrustedChecksumsSource.NAME,
552 new SummaryFileTrustedChecksumsSource(getLocalPathComposer(), getRepositorySystemLifecycle()));
553 return result;
554 }
555
556 private Map<String, ProvidedChecksumsSource> providedChecksumsSources;
557
558 public final Map<String, ProvidedChecksumsSource> getProvidedChecksumsSources() {
559 checkClosed();
560 if (providedChecksumsSources == null) {
561 providedChecksumsSources = createProvidedChecksumsSources();
562 }
563 return providedChecksumsSources;
564 }
565
566 protected Map<String, ProvidedChecksumsSource> createProvidedChecksumsSources() {
567 HashMap<String, ProvidedChecksumsSource> result = new HashMap<>();
568 result.put(
569 TrustedToProvidedChecksumsSourceAdapter.NAME,
570 new TrustedToProvidedChecksumsSourceAdapter(getTrustedChecksumsSources()));
571 return result;
572 }
573
574 private Map<String, ChecksumExtractorStrategy> checksumExtractorStrategies;
575
576 public final Map<String, ChecksumExtractorStrategy> getChecksumExtractorStrategies() {
577 checkClosed();
578 if (checksumExtractorStrategies == null) {
579 checksumExtractorStrategies = createChecksumExtractorStrategies();
580 }
581 return checksumExtractorStrategies;
582 }
583
584 protected Map<String, ChecksumExtractorStrategy> createChecksumExtractorStrategies() {
585 HashMap<String, ChecksumExtractorStrategy> result = new HashMap<>();
586 result.put(XChecksumExtractor.NAME, new XChecksumExtractor());
587 result.put(Nx2ChecksumExtractor.NAME, new Nx2ChecksumExtractor());
588 return result;
589 }
590
591 private ChecksumExtractor checksumExtractor;
592
593 public final ChecksumExtractor getChecksumExtractor() {
594 checkClosed();
595 if (checksumExtractor == null) {
596 checksumExtractor = createChecksumExtractor();
597 }
598 return checksumExtractor;
599 }
600
601 protected ChecksumExtractor createChecksumExtractor() {
602 return new DefaultChecksumExtractor(getChecksumExtractorStrategies());
603 }
604
605 private Map<String, TransporterFactory> transporterFactories;
606
607 public final Map<String, TransporterFactory> getTransporterFactories() {
608 checkClosed();
609 if (transporterFactories == null) {
610 transporterFactories = createTransporterFactories();
611 }
612 return transporterFactories;
613 }
614
615 protected Map<String, TransporterFactory> createTransporterFactories() {
616 HashMap<String, TransporterFactory> result = new HashMap<>();
617 result.put(FileTransporterFactory.NAME, new FileTransporterFactory());
618 result.put(
619 ApacheTransporterFactory.NAME,
620 new ApacheTransporterFactory(getChecksumExtractor(), getPathProcessor()));
621 return result;
622 }
623
624 private TransporterProvider transporterProvider;
625
626 public final TransporterProvider getTransporterProvider() {
627 checkClosed();
628 if (transporterProvider == null) {
629 transporterProvider = createTransporterProvider();
630 }
631 return transporterProvider;
632 }
633
634 protected TransporterProvider createTransporterProvider() {
635 return new DefaultTransporterProvider(getTransporterFactories());
636 }
637
638 private BasicRepositoryConnectorFactory basicRepositoryConnectorFactory;
639
640 public final BasicRepositoryConnectorFactory getBasicRepositoryConnectorFactory() {
641 checkClosed();
642 if (basicRepositoryConnectorFactory == null) {
643 basicRepositoryConnectorFactory = createBasicRepositoryConnectorFactory();
644 }
645 return basicRepositoryConnectorFactory;
646 }
647
648 protected BasicRepositoryConnectorFactory createBasicRepositoryConnectorFactory() {
649 return new BasicRepositoryConnectorFactory(
650 getTransporterProvider(),
651 getRepositoryLayoutProvider(),
652 getChecksumPolicyProvider(),
653 getChecksumProcessor(),
654 getProvidedChecksumsSources());
655 }
656
657 private Map<String, RepositoryConnectorFactory> repositoryConnectorFactories;
658
659 public final Map<String, RepositoryConnectorFactory> getRepositoryConnectorFactories() {
660 checkClosed();
661 if (repositoryConnectorFactories == null) {
662 repositoryConnectorFactories = createRepositoryConnectorFactories();
663 }
664 return repositoryConnectorFactories;
665 }
666
667 protected Map<String, RepositoryConnectorFactory> createRepositoryConnectorFactories() {
668 HashMap<String, RepositoryConnectorFactory> result = new HashMap<>();
669 result.put(BasicRepositoryConnectorFactory.NAME, getBasicRepositoryConnectorFactory());
670 return result;
671 }
672
673 private RepositoryConnectorProvider repositoryConnectorProvider;
674
675 public final RepositoryConnectorProvider getRepositoryConnectorProvider() {
676 checkClosed();
677 if (repositoryConnectorProvider == null) {
678 repositoryConnectorProvider = createRepositoryConnectorProvider();
679 }
680 return repositoryConnectorProvider;
681 }
682
683 protected RepositoryConnectorProvider createRepositoryConnectorProvider() {
684 return new DefaultRepositoryConnectorProvider(
685 getRepositoryConnectorFactories(), getRemoteRepositoryFilterManager());
686 }
687
688 private Installer installer;
689
690 public final Installer getInstaller() {
691 checkClosed();
692 if (installer == null) {
693 installer = createInstaller();
694 }
695 return installer;
696 }
697
698 protected Installer createInstaller() {
699 return new DefaultInstaller(
700 getPathProcessor(),
701 getRepositoryEventDispatcher(),
702 getArtifactGeneratorFactories(),
703 getMetadataGeneratorFactories(),
704 getSyncContextFactory());
705 }
706
707 private Deployer deployer;
708
709 public final Deployer getDeployer() {
710 checkClosed();
711 if (deployer == null) {
712 deployer = createDeployer();
713 }
714 return deployer;
715 }
716
717 protected Deployer createDeployer() {
718 return new DefaultDeployer(
719 getPathProcessor(),
720 getRepositoryEventDispatcher(),
721 getRepositoryConnectorProvider(),
722 getRemoteRepositoryManager(),
723 getUpdateCheckManager(),
724 getArtifactGeneratorFactories(),
725 getMetadataGeneratorFactories(),
726 getSyncContextFactory(),
727 getOfflineController());
728 }
729
730 private Map<String, DependencyCollectorDelegate> dependencyCollectorDelegates;
731
732 public final Map<String, DependencyCollectorDelegate> getDependencyCollectorDelegates() {
733 checkClosed();
734 if (dependencyCollectorDelegates == null) {
735 dependencyCollectorDelegates = createDependencyCollectorDelegates();
736 }
737 return dependencyCollectorDelegates;
738 }
739
740 protected Map<String, DependencyCollectorDelegate> createDependencyCollectorDelegates() {
741 RemoteRepositoryManager remoteRepositoryManager = getRemoteRepositoryManager();
742 ArtifactDescriptorReader artifactDescriptorReader = getArtifactDescriptorReader();
743 VersionRangeResolver versionRangeResolver = getVersionRangeResolver();
744 HashMap<String, DependencyCollectorDelegate> result = new HashMap<>();
745 result.put(
746 DfDependencyCollector.NAME,
747 new DfDependencyCollector(
748 remoteRepositoryManager,
749 artifactDescriptorReader,
750 versionRangeResolver,
751 getArtifactDecoratorFactories()));
752 result.put(
753 BfDependencyCollector.NAME,
754 new BfDependencyCollector(
755 remoteRepositoryManager,
756 artifactDescriptorReader,
757 versionRangeResolver,
758 getArtifactDecoratorFactories()));
759 return result;
760 }
761
762 private DependencyCollector dependencyCollector;
763
764 public final DependencyCollector getDependencyCollector() {
765 checkClosed();
766 if (dependencyCollector == null) {
767 dependencyCollector = createDependencyCollector();
768 }
769 return dependencyCollector;
770 }
771
772 protected DependencyCollector createDependencyCollector() {
773 return new DefaultDependencyCollector(getDependencyCollectorDelegates());
774 }
775
776 private Map<String, ArtifactResolverPostProcessor> artifactResolverPostProcessors;
777
778 public final Map<String, ArtifactResolverPostProcessor> getArtifactResolverPostProcessors() {
779 checkClosed();
780 if (artifactResolverPostProcessors == null) {
781 artifactResolverPostProcessors = createArtifactResolverPostProcessors();
782 }
783 return artifactResolverPostProcessors;
784 }
785
786 protected Map<String, ArtifactResolverPostProcessor> createArtifactResolverPostProcessors() {
787 HashMap<String, ArtifactResolverPostProcessor> result = new HashMap<>();
788 result.put(
789 TrustedChecksumsArtifactResolverPostProcessor.NAME,
790 new TrustedChecksumsArtifactResolverPostProcessor(
791 getChecksumAlgorithmFactorySelector(), getTrustedChecksumsSources()));
792 return result;
793 }
794
795 private ArtifactResolver artifactResolver;
796
797 public final ArtifactResolver getArtifactResolver() {
798 checkClosed();
799 if (artifactResolver == null) {
800 artifactResolver = createArtifactResolver();
801 }
802 return artifactResolver;
803 }
804
805 protected ArtifactResolver createArtifactResolver() {
806 return new DefaultArtifactResolver(
807 getPathProcessor(),
808 getRepositoryEventDispatcher(),
809 getVersionResolver(),
810 getUpdateCheckManager(),
811 getRepositoryConnectorProvider(),
812 getRemoteRepositoryManager(),
813 getSyncContextFactory(),
814 getOfflineController(),
815 getArtifactResolverPostProcessors(),
816 getRemoteRepositoryFilterManager());
817 }
818
819 private MetadataResolver metadataResolver;
820
821 public final MetadataResolver getMetadataResolver() {
822 checkClosed();
823 if (metadataResolver == null) {
824 metadataResolver = createMetadataResolver();
825 }
826 return metadataResolver;
827 }
828
829 protected MetadataResolver createMetadataResolver() {
830 return new DefaultMetadataResolver(
831 getRepositoryEventDispatcher(),
832 getUpdateCheckManager(),
833 getRepositoryConnectorProvider(),
834 getRemoteRepositoryManager(),
835 getSyncContextFactory(),
836 getOfflineController(),
837 getRemoteRepositoryFilterManager(),
838 getPathProcessor());
839 }
840
841 private VersionScheme versionScheme;
842
843 public final VersionScheme getVersionScheme() {
844 checkClosed();
845 if (versionScheme == null) {
846 versionScheme = createVersionScheme();
847 }
848 return versionScheme;
849 }
850
851 protected VersionScheme createVersionScheme() {
852 return new GenericVersionScheme();
853 }
854
855 private Map<String, ArtifactGeneratorFactory> artifactGeneratorFactories;
856
857 public final Map<String, ArtifactGeneratorFactory> getArtifactGeneratorFactories() {
858 checkClosed();
859 if (artifactGeneratorFactories == null) {
860 artifactGeneratorFactories = createArtifactGeneratorFactories();
861 }
862 return artifactGeneratorFactories;
863 }
864
865 protected Map<String, ArtifactGeneratorFactory> createArtifactGeneratorFactories() {
866
867 return new HashMap<>();
868 }
869
870 private Map<String, ArtifactDecoratorFactory> artifactDecoratorFactories;
871
872 public final Map<String, ArtifactDecoratorFactory> getArtifactDecoratorFactories() {
873 checkClosed();
874 if (artifactDecoratorFactories == null) {
875 artifactDecoratorFactories = createArtifactDecoratorFactories();
876 }
877 return artifactDecoratorFactories;
878 }
879
880 protected Map<String, ArtifactDecoratorFactory> createArtifactDecoratorFactories() {
881
882 return new HashMap<>();
883 }
884
885
886
887 private Map<String, MetadataGeneratorFactory> metadataGeneratorFactories;
888
889 public final Map<String, MetadataGeneratorFactory> getMetadataGeneratorFactories() {
890 checkClosed();
891 if (metadataGeneratorFactories == null) {
892 metadataGeneratorFactories = createMetadataGeneratorFactories();
893 }
894 return metadataGeneratorFactories;
895 }
896
897 protected Map<String, MetadataGeneratorFactory> createMetadataGeneratorFactories() {
898
899 HashMap<String, MetadataGeneratorFactory> result = new HashMap<>();
900 result.put(PluginsMetadataGeneratorFactory.NAME, new PluginsMetadataGeneratorFactory());
901 result.put(VersionsMetadataGeneratorFactory.NAME, new VersionsMetadataGeneratorFactory());
902 result.put(SnapshotMetadataGeneratorFactory.NAME, new SnapshotMetadataGeneratorFactory());
903 return result;
904 }
905
906 private ArtifactDescriptorReader artifactDescriptorReader;
907
908 public final ArtifactDescriptorReader getArtifactDescriptorReader() {
909 checkClosed();
910 if (artifactDescriptorReader == null) {
911 artifactDescriptorReader = createArtifactDescriptorReader();
912 }
913 return artifactDescriptorReader;
914 }
915
916 protected ArtifactDescriptorReader createArtifactDescriptorReader() {
917
918 return new DefaultArtifactDescriptorReader(
919 getRemoteRepositoryManager(),
920 getVersionResolver(),
921 getVersionRangeResolver(),
922 getArtifactResolver(),
923 getModelBuilder(),
924 getRepositoryEventDispatcher(),
925 getModelCacheFactory());
926 }
927
928 private VersionResolver versionResolver;
929
930 public final VersionResolver getVersionResolver() {
931 checkClosed();
932 if (versionResolver == null) {
933 versionResolver = createVersionResolver();
934 }
935 return versionResolver;
936 }
937
938 protected VersionResolver createVersionResolver() {
939
940 return new DefaultVersionResolver(
941 getMetadataResolver(), getSyncContextFactory(), getRepositoryEventDispatcher());
942 }
943
944 private VersionRangeResolver versionRangeResolver;
945
946 public final VersionRangeResolver getVersionRangeResolver() {
947 checkClosed();
948 if (versionRangeResolver == null) {
949 versionRangeResolver = createVersionRangeResolver();
950 }
951 return versionRangeResolver;
952 }
953
954 protected VersionRangeResolver createVersionRangeResolver() {
955
956 return new DefaultVersionRangeResolver(
957 getMetadataResolver(), getSyncContextFactory(), getRepositoryEventDispatcher());
958 }
959
960 private ModelBuilder modelBuilder;
961
962 public final ModelBuilder getModelBuilder() {
963 checkClosed();
964 if (modelBuilder == null) {
965 modelBuilder = createModelBuilder();
966 }
967 return modelBuilder;
968 }
969
970 protected ModelBuilder createModelBuilder() {
971
972 return new DefaultModelBuilderFactory().newInstance();
973 }
974
975 private ModelCacheFactory modelCacheFactory;
976
977 public final ModelCacheFactory getModelCacheFactory() {
978 checkClosed();
979 if (modelCacheFactory == null) {
980 modelCacheFactory = createModelCacheFactory();
981 }
982 return modelCacheFactory;
983 }
984
985 protected ModelCacheFactory createModelCacheFactory() {
986
987 return new DefaultModelCacheFactory();
988 }
989
990 private RepositorySystem repositorySystem;
991
992 public final RepositorySystem getRepositorySystem() {
993 checkClosed();
994 if (repositorySystem == null) {
995 repositorySystem = createRepositorySystem();
996 }
997 return repositorySystem;
998 }
999
1000 protected RepositorySystem createRepositorySystem() {
1001 return new DefaultRepositorySystem(
1002 getVersionResolver(),
1003 getVersionRangeResolver(),
1004 getArtifactResolver(),
1005 getMetadataResolver(),
1006 getArtifactDescriptorReader(),
1007 getDependencyCollector(),
1008 getInstaller(),
1009 getDeployer(),
1010 getLocalRepositoryProvider(),
1011 getSyncContextFactory(),
1012 getRemoteRepositoryManager(),
1013 getRepositorySystemLifecycle(),
1014 getArtifactDecoratorFactories());
1015 }
1016
1017 @Override
1018 public RepositorySystem get() {
1019 return getRepositorySystem();
1020 }
1021 }