View Javadoc

1   package org.sonatype.aether;
2   
3   /*******************************************************************************
4    * Copyright (c) 2010-2011 Sonatype, Inc.
5    * All rights reserved. This program and the accompanying materials
6    * are made available under the terms of the Eclipse Public License v1.0
7    * which accompanies this distribution, and is available at
8    *   http://www.eclipse.org/legal/epl-v10.html
9    *******************************************************************************/
10  
11  import java.util.Map;
12  
13  import org.sonatype.aether.artifact.ArtifactTypeRegistry;
14  import org.sonatype.aether.collection.DependencyGraphTransformer;
15  import org.sonatype.aether.collection.DependencyManager;
16  import org.sonatype.aether.collection.DependencySelector;
17  import org.sonatype.aether.collection.DependencyTraverser;
18  import org.sonatype.aether.repository.AuthenticationSelector;
19  import org.sonatype.aether.repository.LocalRepository;
20  import org.sonatype.aether.repository.LocalRepositoryManager;
21  import org.sonatype.aether.repository.MirrorSelector;
22  import org.sonatype.aether.repository.ProxySelector;
23  import org.sonatype.aether.repository.RepositoryPolicy;
24  import org.sonatype.aether.repository.WorkspaceReader;
25  import org.sonatype.aether.transfer.TransferListener;
26  
27  /**
28   * Defines settings and components that control the repository system.
29   * 
30   * @author Benjamin Bentmann
31   */
32  public interface RepositorySystemSession
33  {
34  
35      /**
36       * Indicates whether the repository system operates in offline mode and avoids/refuses any access to remote
37       * repositories.
38       * 
39       * @return {@code true} if the repository system is in offline mode, {@code false} otherwise.
40       */
41      boolean isOffline();
42  
43      /**
44       * Indicates whether transfer errors (e.g. unreachable host, bad authentication) from resolution attempts should be
45       * cached in the local repository. If caching is enabled, resolution will not be reattempted until the update policy
46       * for the affected resource has expired.
47       * 
48       * @return {@code true} if transfer errors are cached, {@code false} to always reattempt downloading.
49       */
50      boolean isTransferErrorCachingEnabled();
51  
52      /**
53       * Indicates whether missing artifacts/metadata from resolution attempts should be cached in the local repository.
54       * If caching is enabled, resolution will not be reattempted until the update policy for the affected resource has
55       * expired.
56       * 
57       * @return {@code true} if missing resources are cached, {@code false} to always reattempt downloading.
58       */
59      boolean isNotFoundCachingEnabled();
60  
61      /**
62       * Indicates whether missing artifact descriptors are silently ignored. If enabled and no artifact descriptor is
63       * available, an empty stub descriptor is used instead.
64       * 
65       * @return {@code true} if missing artifact descriptors are ignored, {@code false} to fail the operation with an
66       *         exception.
67       */
68      boolean isIgnoreMissingArtifactDescriptor();
69  
70      /**
71       * Indicates whether invalid artifact descriptors are silently ignored. If enabled and an artifact descriptor is
72       * invalid, an empty stub descriptor is used instead.
73       * 
74       * @return {@code true} if invalid artifact descriptors are ignored, {@code false} to fail the operation with an
75       *         exception.
76       */
77      boolean isIgnoreInvalidArtifactDescriptor();
78  
79      /**
80       * Gets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote
81       * repositories being used for resolution.
82       * 
83       * @return The global checksum policy or {@code null}/empty if not set and the per-repository policies apply.
84       * @see RepositoryPolicy#CHECKSUM_POLICY_FAIL
85       * @see RepositoryPolicy#CHECKSUM_POLICY_IGNORE
86       * @see RepositoryPolicy#CHECKSUM_POLICY_WARN
87       */
88      String getChecksumPolicy();
89  
90      /**
91       * Gets the global update policy. If set, the global update policy overrides the update policies of the remote
92       * repositories being used for resolution.
93       * 
94       * @return The global update policy or {@code null}/empty if not set and the per-repository policies apply.
95       * @see RepositoryPolicy#UPDATE_POLICY_ALWAYS
96       * @see RepositoryPolicy#UPDATE_POLICY_DAILY
97       * @see RepositoryPolicy#UPDATE_POLICY_NEVER
98       */
99      String getUpdatePolicy();
100 
101     /**
102      * Gets the local repository used during this session. This is a convenience method for
103      * {@link LocalRepositoryManager#getRepository()}.
104      * 
105      * @return The local repository being during this session, never {@code null}.
106      */
107     LocalRepository getLocalRepository();
108 
109     /**
110      * Gets the local repository manager used during this session.
111      * 
112      * @return The local repository manager used during this session, never {@code null}.
113      */
114     LocalRepositoryManager getLocalRepositoryManager();
115 
116     /**
117      * Gets the workspace reader used during this session. If set, the workspace reader will usually be consulted first
118      * to resolve artifacts.
119      * 
120      * @return The workspace reader for this session or {@code null} if none.
121      */
122     WorkspaceReader getWorkspaceReader();
123 
124     /**
125      * Gets the listener being notified of actions in the repository system.
126      * 
127      * @return The repository listener or {@code null} if none.
128      */
129     RepositoryListener getRepositoryListener();
130 
131     /**
132      * Gets the listener being notified of uploads/downloads by the repository system.
133      * 
134      * @return The transfer listener or {@code null} if none.
135      */
136     TransferListener getTransferListener();
137 
138     /**
139      * Gets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually
140      * collected from the runtime environment like {@link System#getProperties()} and environment variables.
141      * 
142      * @return The (read-only) system properties, never {@code null}.
143      */
144     Map<String, String> getSystemProperties();
145 
146     /**
147      * Gets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to
148      * system properties but are set on the discretion of the user and hence are considered of higher priority than
149      * system properties.
150      * 
151      * @return The (read-only) user properties, never {@code null}.
152      */
153     Map<String, String> getUserProperties();
154 
155     /**
156      * Gets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling,
157      * connector-specific behavior, etc.)
158      * 
159      * @return The (read-only) configuration properties, never {@code null}.
160      * @see ConfigurationProperties
161      */
162     Map<String, Object> getConfigProperties();
163 
164     /**
165      * Gets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is
166      * not used for remote repositories which are passed as request parameters to the repository system, those
167      * repositories are supposed to denote the effective repositories.
168      * 
169      * @return The mirror selector to use, never {@code null}.
170      */
171     MirrorSelector getMirrorSelector();
172 
173     /**
174      * Gets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is
175      * not used for remote repositories which are passed as request parameters to the repository system, those
176      * repositories are supposed to have their proxy (if any) already set.
177      * 
178      * @return The proxy selector to use, never {@code null}.
179      * @see org.sonatype.aether.repository.RemoteRepository#getProxy()
180      */
181     ProxySelector getProxySelector();
182 
183     /**
184      * Gets the authentication selector to use for repositories discovered in artifact descriptors. Note that this
185      * selector is not used for remote repositories which are passed as request parameters to the repository system,
186      * those repositories are supposed to have their authentication (if any) already set.
187      * 
188      * @return The authentication selector to use, never {@code null}.
189      * @see org.sonatype.aether.repository.RemoteRepository#getAuthentication()
190      */
191     AuthenticationSelector getAuthenticationSelector();
192 
193     /**
194      * Gets the registry of artifact types recognized by this session.
195      * 
196      * @return The artifact type registry, never {@code null}.
197      */
198     ArtifactTypeRegistry getArtifactTypeRegistry();
199 
200     /**
201      * Gets the dependency traverser to use for building dependency graphs.
202      * 
203      * @return The dependency traverser to use for building dependency graphs, never {@code null}.
204      */
205     DependencyTraverser getDependencyTraverser();
206 
207     /**
208      * Gets the dependency manager to use for building dependency graphs.
209      * 
210      * @return The dependency manager to use for building dependency graphs, never {@code null}.
211      */
212     DependencyManager getDependencyManager();
213 
214     /**
215      * Gets the dependency selector to use for building dependency graphs.
216      * 
217      * @return The dependency selector to use for building dependency graphs, never {@code null}.
218      */
219     DependencySelector getDependencySelector();
220 
221     /**
222      * Gets the dependency graph transformer to use for building dependency graphs.
223      * 
224      * @return The dependency graph transformer to use for building dependency graphs, never {@code null}.
225      */
226     DependencyGraphTransformer getDependencyGraphTransformer();
227 
228     /**
229      * Gets the custom data associated with this session.
230      * 
231      * @return The session data, never {@code null}.
232      */
233     SessionData getData();
234 
235     /**
236      * Gets the cache the repository system may use to save data for future reuse during the session.
237      * 
238      * @return The repository cache or {@code null} if none.
239      */
240     RepositoryCache getCache();
241 
242 }