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