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