View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.eclipse.aether;
20  
21  import java.io.Closeable;
22  import java.nio.file.Path;
23  import java.util.Collection;
24  import java.util.Map;
25  import java.util.function.Supplier;
26  
27  import org.eclipse.aether.artifact.ArtifactTypeRegistry;
28  import org.eclipse.aether.collection.DependencyGraphTransformer;
29  import org.eclipse.aether.collection.DependencyManager;
30  import org.eclipse.aether.collection.DependencySelector;
31  import org.eclipse.aether.collection.DependencyTraverser;
32  import org.eclipse.aether.collection.VersionFilter;
33  import org.eclipse.aether.repository.AuthenticationSelector;
34  import org.eclipse.aether.repository.LocalRepository;
35  import org.eclipse.aether.repository.LocalRepositoryManager;
36  import org.eclipse.aether.repository.MirrorSelector;
37  import org.eclipse.aether.repository.ProxySelector;
38  import org.eclipse.aether.repository.RemoteRepository;
39  import org.eclipse.aether.repository.RepositoryPolicy;
40  import org.eclipse.aether.repository.WorkspaceReader;
41  import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
42  import org.eclipse.aether.resolution.ResolutionErrorPolicy;
43  import org.eclipse.aether.transfer.TransferListener;
44  
45  /**
46   * Defines settings and components that control the repository system. Once initialized, the session object itself is
47   * supposed to be immutable and hence can safely be shared across an entire application and any concurrent threads
48   * reading it. Components that wish to tweak some aspects of an existing session should use the copy constructor of
49   * {@link DefaultRepositorySystemSession} and its mutators to derive a custom session.
50   *
51   * @noimplement This interface is not intended to be implemented by clients.
52   * @noextend This interface is not intended to be extended by clients.
53   */
54  public interface RepositorySystemSession {
55  
56      /**
57       * Immutable session that is closeable, should be handled as a resource. These session instances can be
58       * created with {@link SessionBuilder}.
59       *
60       * @noimplement This interface is not intended to be implemented by clients.
61       * @noextend This interface is not intended to be extended by clients.
62       *
63       * @since 2.0.0
64       */
65      interface CloseableSession extends RepositorySystemSession, Closeable {
66          /**
67           * Returns the ID of this closeable session instance. Each closeable session has different ID, unique within
68           * repository system they were created with.
69           *
70           * @return The session ID that is never {@code null}.
71           */
72          String sessionId();
73  
74          /**
75           * Closes the session. The session should be closed by its creator. A closed session should not be used anymore.
76           * This method may be invoked multiple times, but close will act only once (first time).
77           */
78          @Override
79          void close();
80      }
81  
82      /**
83       * Builder for building {@link CloseableSession} instances. Builder instances can be created with
84       * {@link RepositorySystem#createSessionBuilder()} method. Instances are not thread-safe nor immutable.
85       * <p>
86       * Important: if you set a stateful member on builder (for example {@link SessionData} or {@link RepositoryCache}),
87       * the builder will create session instances using same provided stateful members, that may lead to unexpected side
88       * effects. Solution for these cases is to not reuse builder instances, or, keep reconfiguring it, or ultimately
89       * provide suppliers that create new instance per each call.
90       *
91       * @noimplement This interface is not intended to be implemented by clients.
92       * @noextend This interface is not intended to be extended by clients.
93       *
94       * @since 2.0.0
95       */
96      interface SessionBuilder {
97          /**
98           * Controls whether the repository system operates in offline mode and avoids/refuses any access to remote
99           * repositories.
100          *
101          * @param offline {@code true} if the repository system is in offline mode, {@code false} otherwise.
102          * @return This session for chaining, never {@code null}.
103          */
104         SessionBuilder setOffline(boolean offline);
105 
106         /**
107          * Controls whether repositories declared in artifact descriptors should be ignored during transitive dependency
108          * collection. If enabled, only the repositories originally provided with the collect request will be considered.
109          *
110          * @param ignoreArtifactDescriptorRepositories {@code true} to ignore additional repositories from artifact
111          *                                             descriptors, {@code false} to merge those with the originally
112          *                                             specified repositories.
113          * @return This session for chaining, never {@code null}.
114          */
115         SessionBuilder setIgnoreArtifactDescriptorRepositories(boolean ignoreArtifactDescriptorRepositories);
116 
117         /**
118          * Sets the policy which controls whether resolutions errors from remote repositories should be cached.
119          *
120          * @param resolutionErrorPolicy The resolution error policy for this session, may be {@code null} if resolution
121          *                              errors should generally not be cached.
122          * @return This session for chaining, never {@code null}.
123          */
124         SessionBuilder setResolutionErrorPolicy(ResolutionErrorPolicy resolutionErrorPolicy);
125 
126         /**
127          * Sets the policy which controls how errors related to reading artifact descriptors should be handled.
128          *
129          * @param artifactDescriptorPolicy The descriptor error policy for this session, may be {@code null} if descriptor
130          *                                 errors should generally not be tolerated.
131          * @return This session for chaining, never {@code null}.
132          */
133         SessionBuilder setArtifactDescriptorPolicy(ArtifactDescriptorPolicy artifactDescriptorPolicy);
134 
135         /**
136          * Sets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
137          * repositories being used for resolution.
138          *
139          * @param checksumPolicy The global checksum policy, may be {@code null}/empty to apply the per-repository policies.
140          * @return This session for chaining, never {@code null}.
141          * @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
142          * @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
143          * @see RepositoryPolicy#CHECKSUM_POLICY_WARN
144          */
145         SessionBuilder setChecksumPolicy(String checksumPolicy);
146 
147         /**
148          * Sets the global update policy. If set, the global update policy overrides the update policies of the remote
149          * repositories being used for resolution.
150          * <p>
151          * This method is meant for code that does not want to distinguish between artifact and metadata policies.
152          * Note: applications should either use get/set updatePolicy (this method and
153          * {@link RepositorySystemSession#getUpdatePolicy()}) or also distinguish between artifact and
154          * metadata update policies (and use other methods), but <em>should not mix the two!</em>
155          *
156          * @param updatePolicy The global update policy, may be {@code null}/empty to apply the per-repository policies.
157          * @return This session for chaining, never {@code null}.
158          * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
159          * @see RepositoryPolicy#UPDATE_POLICY_DAILY
160          * @see RepositoryPolicy#UPDATE_POLICY_NEVER
161          * @see #setArtifactUpdatePolicy(String)
162          * @see #setMetadataUpdatePolicy(String)
163          */
164         SessionBuilder setUpdatePolicy(String updatePolicy);
165 
166         /**
167          * Sets the global artifact update policy. If set, the global update policy overrides the artifact update policies
168          * of the remote repositories being used for resolution.
169          *
170          * @param artifactUpdatePolicy The global update policy, may be {@code null}/empty to apply the per-repository policies.
171          * @return This session for chaining, never {@code null}.
172          * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
173          * @see RepositoryPolicy#UPDATE_POLICY_DAILY
174          * @see RepositoryPolicy#UPDATE_POLICY_NEVER
175          * @since 2.0.0
176          */
177         SessionBuilder setArtifactUpdatePolicy(String artifactUpdatePolicy);
178 
179         /**
180          * Sets the global metadata update policy. If set, the global update policy overrides the metadata update policies
181          * of the remote repositories being used for resolution.
182          *
183          * @param metadataUpdatePolicy The global update policy, may be {@code null}/empty to apply the per-repository policies.
184          * @return This session for chaining, never {@code null}.
185          * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
186          * @see RepositoryPolicy#UPDATE_POLICY_DAILY
187          * @see RepositoryPolicy#UPDATE_POLICY_NEVER
188          * @since 2.0.0
189          */
190         SessionBuilder setMetadataUpdatePolicy(String metadataUpdatePolicy);
191 
192         /**
193          * Sets the local repository manager used during this session. <em>Note:</em> Eventually, a valid session must have
194          * a local repository manager set.
195          *
196          * @param localRepositoryManager The local repository manager used during this session, may be {@code null}.
197          * @return This session for chaining, never {@code null}.
198          */
199         SessionBuilder setLocalRepositoryManager(LocalRepositoryManager localRepositoryManager);
200 
201         /**
202          * Sets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
203          * to resolve artifacts.
204          *
205          * @param workspaceReader The workspace reader for this session, may be {@code null} if none.
206          * @return This session for chaining, never {@code null}.
207          */
208         SessionBuilder setWorkspaceReader(WorkspaceReader workspaceReader);
209 
210         /**
211          * Sets the listener being notified of actions in the repository system.
212          *
213          * @param repositoryListener The repository listener, may be {@code null} if none.
214          * @return This session for chaining, never {@code null}.
215          */
216         SessionBuilder setRepositoryListener(RepositoryListener repositoryListener);
217 
218         /**
219          * Sets the listener being notified of uploads/downloads by the repository system.
220          *
221          * @param transferListener The transfer listener, may be {@code null} if none.
222          * @return This session for chaining, never {@code null}.
223          */
224         SessionBuilder setTransferListener(TransferListener transferListener);
225 
226         /**
227          * Sets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
228          * collected from the runtime environment like {@link System#getProperties()} and environment variables.
229          * <p>
230          * <em>Note:</em> System properties are of type {@code Map<String, String>} and any key-value pair in the input map
231          * that doesn't match this type will be silently ignored.
232          *
233          * @param systemProperties The system properties, may be {@code null} or empty if none.
234          * @return This session for chaining, never {@code null}.
235          */
236         SessionBuilder setSystemProperties(Map<?, ?> systemProperties);
237 
238         /**
239          * Sets the specified system property.
240          *
241          * @param key   The property key, must not be {@code null}.
242          * @param value The property value, may be {@code null} to remove/unset the property.
243          * @return This session for chaining, never {@code null}.
244          */
245         SessionBuilder setSystemProperty(String key, String value);
246 
247         /**
248          * Sets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
249          * system properties but are set on the discretion of the user and hence are considered of higher priority than
250          * system properties in case of conflicts.
251          * <p>
252          * <em>Note:</em> User properties are of type {@code Map<String, String>} and any key-value pair in the input map
253          * that doesn't match this type will be silently ignored.
254          *
255          * @param userProperties The user properties, may be {@code null} or empty if none.
256          * @return This session for chaining, never {@code null}.
257          */
258         SessionBuilder setUserProperties(Map<?, ?> userProperties);
259 
260         /**
261          * Sets the specified user property.
262          *
263          * @param key   The property key, must not be {@code null}.
264          * @param value The property value, may be {@code null} to remove/unset the property.
265          * @return This session for chaining, never {@code null}.
266          */
267         SessionBuilder setUserProperty(String key, String value);
268 
269         /**
270          * Sets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
271          * connector-specific behavior, etc.).
272          * <p>
273          * <em>Note:</em> Configuration properties are of type {@code Map<String, Object>} and any key-value pair in the
274          * input map that doesn't match this type will be silently ignored.
275          *
276          * @param configProperties The configuration properties, may be {@code null} or empty if none.
277          * @return This session for chaining, never {@code null}.
278          */
279         SessionBuilder setConfigProperties(Map<?, ?> configProperties);
280 
281         /**
282          * Sets the specified configuration property.
283          *
284          * @param key   The property key, must not be {@code null}.
285          * @param value The property value, may be {@code null} to remove/unset the property.
286          * @return This session for chaining, never {@code null}.
287          */
288         SessionBuilder setConfigProperty(String key, Object value);
289 
290         /**
291          * Sets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
292          * not used for remote repositories which are passed as request parameters to the repository system, those
293          * repositories are supposed to denote the effective repositories.
294          *
295          * @param mirrorSelector The mirror selector to use, may be {@code null}.
296          * @return This session for chaining, never {@code null}.
297          */
298         SessionBuilder setMirrorSelector(MirrorSelector mirrorSelector);
299 
300         /**
301          * Sets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
302          * not used for remote repositories which are passed as request parameters to the repository system, those
303          * repositories are supposed to have their proxy (if any) already set.
304          *
305          * @param proxySelector The proxy selector to use, may be {@code null}.
306          * @return This session for chaining, never {@code null}.
307          * @see RemoteRepository#getProxy()
308          */
309         SessionBuilder setProxySelector(ProxySelector proxySelector);
310 
311         /**
312          * Sets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
313          * selector is not used for remote repositories which are passed as request parameters to the repository system,
314          * those repositories are supposed to have their authentication (if any) already set.
315          *
316          * @param authenticationSelector The authentication selector to use, may be {@code null}.
317          * @return This session for chaining, never {@code null}.
318          * @see RemoteRepository#getAuthentication()
319          */
320         SessionBuilder setAuthenticationSelector(AuthenticationSelector authenticationSelector);
321 
322         /**
323          * Sets the registry of artifact types recognized by this session.
324          *
325          * @param artifactTypeRegistry The artifact type registry, may be {@code null}.
326          * @return This session for chaining, never {@code null}.
327          */
328         SessionBuilder setArtifactTypeRegistry(ArtifactTypeRegistry artifactTypeRegistry);
329 
330         /**
331          * Sets the dependency traverser to use for building dependency graphs.
332          *
333          * @param dependencyTraverser The dependency traverser to use for building dependency graphs, may be {@code null}.
334          * @return This session for chaining, never {@code null}.
335          */
336         SessionBuilder setDependencyTraverser(DependencyTraverser dependencyTraverser);
337 
338         /**
339          * Sets the dependency manager to use for building dependency graphs.
340          *
341          * @param dependencyManager The dependency manager to use for building dependency graphs, may be {@code null}.
342          * @return This session for chaining, never {@code null}.
343          */
344         SessionBuilder setDependencyManager(DependencyManager dependencyManager);
345 
346         /**
347          * Sets the dependency selector to use for building dependency graphs.
348          *
349          * @param dependencySelector The dependency selector to use for building dependency graphs, may be {@code null}.
350          * @return This session for chaining, never {@code null}.
351          */
352         SessionBuilder setDependencySelector(DependencySelector dependencySelector);
353 
354         /**
355          * Sets the version filter to use for building dependency graphs.
356          *
357          * @param versionFilter The version filter to use for building dependency graphs, may be {@code null} to not filter
358          *                      versions.
359          * @return This session for chaining, never {@code null}.
360          */
361         SessionBuilder setVersionFilter(VersionFilter versionFilter);
362 
363         /**
364          * Sets the dependency graph transformer to use for building dependency graphs.
365          *
366          * @param dependencyGraphTransformer The dependency graph transformer to use for building dependency graphs, may be
367          *                                   {@code null}.
368          * @return This session for chaining, never {@code null}.
369          */
370         SessionBuilder setDependencyGraphTransformer(DependencyGraphTransformer dependencyGraphTransformer);
371 
372         /**
373          * Sets the custom data associated with this session.
374          * Note: When this method used to set instance, same passed instance will be used for every built session out
375          * of this builder instance, hence the built sessions will share these instances as well!
376          *
377          * @param data The session data, may be {@code null}.
378          * @return This session for chaining, never {@code null}.
379          */
380         SessionBuilder setData(SessionData data);
381 
382         /**
383          * Sets the cache the repository system may use to save data for future reuse during the session.
384          * Note: When this method used to set instance, same passed instance will be used for every built session out
385          * of this builder instance, hence the built sessions will share these instances as well!
386          *
387          * @param cache The repository cache, may be {@code null} if none.
388          * @return This session for chaining, never {@code null}.
389          */
390         SessionBuilder setCache(RepositoryCache cache);
391 
392         /**
393          * Sets the system scope handler for session, may not be {@code null}.
394          *
395          * @param systemScopeHandler The system scope handler, may not be {@code null}.
396          * @return The session for chaining, never {@code null}.
397          */
398         SessionBuilder setSystemScopeHandler(SystemScopeHandler systemScopeHandler);
399 
400         /**
401          * Adds on session ended handler to be immediately registered when this builder creates session.
402          *
403          * @param handler The on session ended handler, may not be {@code null}.
404          * @return The session for chaining, never {@code null}.
405          */
406         SessionBuilder addOnSessionEndedHandler(Runnable handler);
407 
408         /**
409          * Sets the custom session data supplier associated with this session.
410          * Note: The supplier will be used for every built session out of this builder instance, so if supplier supplies
411          * <em>same instance</em> the built sessions will share these instances as well!
412          *
413          * @param dataSupplier The session data supplier, may not be {@code null}.
414          * @return This session for chaining, never {@code null}.
415          */
416         SessionBuilder setSessionDataSupplier(Supplier<SessionData> dataSupplier);
417 
418         /**
419          * Sets the cache supplier for the repository system may use to save data for future reuse during the session.
420          * Note: The supplier will be used for every built session out of this builder instance, so if supplier supplies
421          * <em>same instance</em> the built sessions will share these instances as well!
422          *
423          * @param cacheSupplier The repository cache supplier, may not be {@code null}.
424          * @return This session for chaining, never {@code null}.
425          */
426         SessionBuilder setRepositoryCacheSupplier(Supplier<RepositoryCache> cacheSupplier);
427 
428         /**
429          * Shortcut method to set up local repository manager directly onto builder. There must be at least one non-null
430          * {@link Path} passed in this method. In case multiple files, session builder will use chained local repository
431          * manager.
432          *
433          * @param baseDirectories The local repository base directories.
434          * @return This session for chaining, never {@code null}.
435          * @see #withLocalRepositories(LocalRepository...)
436          */
437         SessionBuilder withLocalRepositoryBaseDirectories(Path... baseDirectories);
438 
439         /**
440          * Shortcut method to set up local repository manager directly onto builder. There must be at least one non-null
441          * {@link Path} present in passed in list. In case multiple files, session builder will use chained local
442          * repository manager.
443          *
444          * @param baseDirectories The local repository base directories.
445          * @return This session for chaining, never {@code null}.
446          * @see #withLocalRepositories(Collection)
447          */
448         SessionBuilder withLocalRepositoryBaseDirectories(Collection<Path> baseDirectories);
449 
450         /**
451          * Shortcut method to set up local repository manager directly onto builder. There must be at least one non-null
452          * {@link LocalRepository} passed in this method. In case multiple local repositories, session builder will
453          * use chained local repository manager.
454          *
455          * @param localRepositories The local repositories.
456          * @return This session for chaining, never {@code null}.
457          */
458         SessionBuilder withLocalRepositories(LocalRepository... localRepositories);
459 
460         /**
461          * Shortcut method to set up local repository manager directly onto builder. There must be at least one non-null
462          * {@link LocalRepository} present in passed in list. In case multiple local repositories, session builder will
463          * use chained local repository manager.
464          *
465          * @param localRepositories The local repositories.
466          * @return This session for chaining, never {@code null}.
467          */
468         SessionBuilder withLocalRepositories(Collection<LocalRepository> localRepositories);
469 
470         /**
471          * Adds the listeners to be notified of actions in the repository system.
472          *
473          * @param repositoryListeners The repository listeners, never {@code null}.
474          * @return This session for chaining, never {@code null}.
475          */
476         SessionBuilder withRepositoryListener(RepositoryListener... repositoryListeners);
477 
478         /**
479          * Adds the listeners to be notified of actions in the repository system.
480          *
481          * @param repositoryListeners The repository listeners, never {@code null}.
482          * @return This session for chaining, never {@code null}.
483          */
484         SessionBuilder withRepositoryListener(Collection<RepositoryListener> repositoryListeners);
485 
486         /**
487          * Adds the listener to be notified of uploads/downloads by the repository system.
488          *
489          * @param transferListeners The transfer listeners, never {@code null}.
490          * @return This session for chaining, never {@code null}.
491          */
492         SessionBuilder withTransferListener(TransferListener... transferListeners);
493 
494         /**
495          * Adds the listener to be notified of uploads/downloads by the repository system.
496          *
497          * @param transferListeners The transfer listeners, never {@code null}.
498          * @return This session for chaining, never {@code null}.
499          */
500         SessionBuilder withTransferListener(Collection<TransferListener> transferListeners);
501 
502         /**
503          * Shortcut method to shallow-copy passed in session into current builder.
504          *
505          * @param session The session to shallow-copy from.
506          * @return This session for chaining, never {@code null}.
507          */
508         SessionBuilder withRepositorySystemSession(RepositorySystemSession session);
509 
510         /**
511          * Creates immutable closeable session out this builder instance.
512          *
513          * @return Immutable closeable session, never {@code null}.
514          */
515         CloseableSession build();
516     }
517 
518     /**
519      * Indicates whether the repository system operates in offline mode and avoids/refuses any access to remote
520      * repositories.
521      *
522      * @return {@code true} if the repository system is in offline mode, {@code false} otherwise.
523      */
524     boolean isOffline();
525 
526     /**
527      * Indicates whether repositories declared in artifact descriptors should be ignored during transitive dependency
528      * collection. If enabled, only the repositories originally provided with the collect request will be considered.
529      *
530      * @return {@code true} if additional repositories from artifact descriptors are ignored, {@code false} to merge
531      *         those with the originally specified repositories.
532      */
533     boolean isIgnoreArtifactDescriptorRepositories();
534 
535     /**
536      * Gets the policy which controls whether resolutions errors from remote repositories should be cached.
537      *
538      * @return The resolution error policy for this session or {@code null} if resolution errors should generally not be
539      *         cached.
540      */
541     ResolutionErrorPolicy getResolutionErrorPolicy();
542 
543     /**
544      * Gets the policy which controls how errors related to reading artifact descriptors should be handled.
545      *
546      * @return The descriptor error policy for this session or {@code null} if descriptor errors should generally not be
547      *         tolerated.
548      */
549     ArtifactDescriptorPolicy getArtifactDescriptorPolicy();
550 
551     /**
552      * Gets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
553      * repositories being used for resolution.
554      *
555      * @return The global checksum policy or {@code null}/empty if not set and the per-repository policies apply.
556      * @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
557      * @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
558      * @see RepositoryPolicy#CHECKSUM_POLICY_WARN
559      */
560     String getChecksumPolicy();
561 
562     /**
563      * Gets the global update policy, or {@code null} if not set.
564      * <p>
565      * This method is meant for code that does not want to distinguish between artifact and metadata policies.
566      * Note: applications should either use get/set updatePolicy (this method and
567      * {@link DefaultRepositorySystemSession#setUpdatePolicy(String)}) or also distinguish between artifact and
568      * metadata update policies (and use other methods), but <em>should not mix the two!</em>
569      *
570      * @see #getArtifactUpdatePolicy()
571      * @see #getMetadataUpdatePolicy()
572      */
573     String getUpdatePolicy();
574 
575     /**
576      * Gets the global artifact update policy. If set, the global update policy overrides the update policies of the
577      * remote repositories being used for resolution.
578      *
579      * @return The global update policy or {@code null}/empty if not set and the per-repository policies apply.
580      * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
581      * @see RepositoryPolicy#UPDATE_POLICY_DAILY
582      * @see RepositoryPolicy#UPDATE_POLICY_NEVER
583      * @since 2.0.0
584      */
585     String getArtifactUpdatePolicy();
586 
587     /**
588      * Gets the global metadata update policy. If set, the global update policy overrides the update policies of the remote
589      * repositories being used for resolution.
590      *
591      * @return The global update policy or {@code null}/empty if not set and the per-repository policies apply.
592      * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
593      * @see RepositoryPolicy#UPDATE_POLICY_DAILY
594      * @see RepositoryPolicy#UPDATE_POLICY_NEVER
595      * @since 2.0.0
596      */
597     String getMetadataUpdatePolicy();
598 
599     /**
600      * Gets the local repository used during this session. This is a convenience method for
601      * {@link LocalRepositoryManager#getRepository()}.
602      *
603      * @return The local repository being during this session, never {@code null}.
604      */
605     LocalRepository getLocalRepository();
606 
607     /**
608      * Gets the local repository manager used during this session.
609      *
610      * @return The local repository manager used during this session, never {@code null}.
611      */
612     LocalRepositoryManager getLocalRepositoryManager();
613 
614     /**
615      * Gets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
616      * to resolve artifacts.
617      *
618      * @return The workspace reader for this session or {@code null} if none.
619      */
620     WorkspaceReader getWorkspaceReader();
621 
622     /**
623      * Gets the listener being notified of actions in the repository system.
624      *
625      * @return The repository listener or {@code null} if none.
626      */
627     RepositoryListener getRepositoryListener();
628 
629     /**
630      * Gets the listener being notified of uploads/downloads by the repository system.
631      *
632      * @return The transfer listener or {@code null} if none.
633      */
634     TransferListener getTransferListener();
635 
636     /**
637      * Gets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
638      * collected from the runtime environment like {@link System#getProperties()} and environment variables.
639      *
640      * @return The (read-only) system properties, never {@code null}.
641      */
642     Map<String, String> getSystemProperties();
643 
644     /**
645      * Gets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
646      * system properties but are set on the discretion of the user and hence are considered of higher priority than
647      * system properties.
648      *
649      * @return The (read-only) user properties, never {@code null}.
650      */
651     Map<String, String> getUserProperties();
652 
653     /**
654      * Gets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
655      * connector-specific behavior, etc.)
656      *
657      * @return The (read-only) configuration properties, never {@code null}.
658      * @see ConfigurationProperties
659      */
660     Map<String, Object> getConfigProperties();
661 
662     /**
663      * Gets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
664      * not used for remote repositories which are passed as request parameters to the repository system, those
665      * repositories are supposed to denote the effective repositories.
666      *
667      * @return The mirror selector to use, never {@code null}.
668      * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
669      */
670     MirrorSelector getMirrorSelector();
671 
672     /**
673      * Gets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
674      * not used for remote repositories which are passed as request parameters to the repository system, those
675      * repositories are supposed to have their proxy (if any) already set.
676      *
677      * @return The proxy selector to use, never {@code null}.
678      * @see org.eclipse.aether.repository.RemoteRepository#getProxy()
679      * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
680      */
681     ProxySelector getProxySelector();
682 
683     /**
684      * Gets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
685      * selector is not used for remote repositories which are passed as request parameters to the repository system,
686      * those repositories are supposed to have their authentication (if any) already set.
687      *
688      * @return The authentication selector to use, never {@code null}.
689      * @see org.eclipse.aether.repository.RemoteRepository#getAuthentication()
690      * @see RepositorySystem#newResolutionRepositories(RepositorySystemSession, java.util.List)
691      */
692     AuthenticationSelector getAuthenticationSelector();
693 
694     /**
695      * Gets the registry of artifact types recognized by this session, for instance when processing artifact
696      * descriptors.
697      *
698      * @return The artifact type registry, never {@code null}.
699      */
700     ArtifactTypeRegistry getArtifactTypeRegistry();
701 
702     /**
703      * Gets the dependency traverser to use for building dependency graphs.
704      *
705      * @return The dependency traverser to use for building dependency graphs or {@code null} if dependencies are
706      *         unconditionally traversed.
707      */
708     DependencyTraverser getDependencyTraverser();
709 
710     /**
711      * Gets the dependency manager to use for building dependency graphs.
712      *
713      * @return The dependency manager to use for building dependency graphs or {@code null} if dependency management is
714      *         not performed.
715      */
716     DependencyManager getDependencyManager();
717 
718     /**
719      * Gets the dependency selector to use for building dependency graphs.
720      *
721      * @return The dependency selector to use for building dependency graphs or {@code null} if dependencies are
722      *         unconditionally included.
723      */
724     DependencySelector getDependencySelector();
725 
726     /**
727      * Gets the version filter to use for building dependency graphs.
728      *
729      * @return The version filter to use for building dependency graphs or {@code null} if versions aren't filtered.
730      */
731     VersionFilter getVersionFilter();
732 
733     /**
734      * Gets the dependency graph transformer to use for building dependency graphs.
735      *
736      * @return The dependency graph transformer to use for building dependency graphs or {@code null} if none.
737      */
738     DependencyGraphTransformer getDependencyGraphTransformer();
739 
740     /**
741      * Gets the custom data associated with this session.
742      *
743      * @return The session data, never {@code null}.
744      */
745     SessionData getData();
746 
747     /**
748      * Gets the cache the repository system may use to save data for future reuse during the session.
749      *
750      * @return The repository cache or {@code null} if none.
751      */
752     RepositoryCache getCache();
753 
754     /**
755      * Returns the system scope handler, never {@code null}.
756      *
757      * @return The system scope handler, never {@code null}.
758      * @since 2.0.0
759      */
760     SystemScopeHandler getSystemScopeHandler();
761 
762     /**
763      * Registers a handler to execute when this session closed.
764      * <p>
765      * Note: Resolver 1.x sessions will not be able to register handlers. Migrate to Resolver 2.x way of handling
766      * sessions to make full use of new features. New features (like HTTP/2 transport) depend on this functionality.
767      * While they will function with Resolver 1.x sessions, they may produce resource leaks.
768      *
769      * @param handler the handler, never {@code null}.
770      * @return {@code true} if handler successfully registered, {@code false} otherwise.
771      * @since 2.0.0
772      */
773     boolean addOnSessionEndedHandler(Runnable handler);
774 }