View Javadoc
1   /*******************************************************************************
2    * Copyright (c) 2012, 2013 Sonatype, Inc.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *    Sonatype, Inc. - initial API and implementation
10   *******************************************************************************/
11  package org.eclipse.aether.resolution;
12  
13  import org.eclipse.aether.RepositorySystemSession;
14  import org.eclipse.aether.artifact.Artifact;
15  import org.eclipse.aether.metadata.Metadata;
16  
17  /**
18   * Controls the caching of resolution errors for artifacts/metadata from remote repositories. If caching is enabled for
19   * a given resource, a marker will be set (usually somewhere in the local repository) to suppress repeated resolution
20   * attempts for the broken resource, thereby avoiding expensive but useless network IO. The error marker is considered
21   * stale once the repository's update policy has expired at which point a future resolution attempt will be allowed.
22   * Error caching considers the current network settings such that fixes to the configuration like authentication or
23   * proxy automatically trigger revalidation with the remote side regardless of the time elapsed since the previous
24   * resolution error.
25   * 
26   * @see RepositorySystemSession#getResolutionErrorPolicy()
27   */
28  public interface ResolutionErrorPolicy
29  {
30  
31      /**
32       * Bit mask indicating that resolution errors should not be cached in the local repository. This forces the system
33       * to always query the remote repository for locally missing artifacts/metadata.
34       */
35      int CACHE_DISABLED = 0x00;
36  
37      /**
38       * Bit flag indicating whether missing artifacts/metadata should be cached in the local repository. If caching is
39       * enabled, resolution will not be reattempted until the update policy for the affected resource has expired.
40       */
41      int CACHE_NOT_FOUND = 0x01;
42  
43      /**
44       * Bit flag indicating whether connectivity/transfer errors (e.g. unreachable host, bad authentication) 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      int CACHE_TRANSFER_ERROR = 0x02;
49  
50      /**
51       * Bit mask indicating that all resolution errors should be cached in the local repository.
52       */
53      int CACHE_ALL = CACHE_NOT_FOUND | CACHE_TRANSFER_ERROR;
54  
55      /**
56       * Gets the error policy for an artifact.
57       * 
58       * @param session The repository session during which the policy is determined, must not be {@code null}.
59       * @param request The policy request holding further details, must not be {@code null}.
60       * @return The bit mask describing the desired error policy.
61       */
62      int getArtifactPolicy( RepositorySystemSession session, ResolutionErrorPolicyRequest<Artifact> request );
63  
64      /**
65       * Gets the error policy for some metadata.
66       * 
67       * @param session The repository session during which the policy is determined, must not be {@code null}.
68       * @param request The policy request holding further details, must not be {@code null}.
69       * @return The bit mask describing the desired error policy.
70       */
71      int getMetadataPolicy( RepositorySystemSession session, ResolutionErrorPolicyRequest<Metadata> request );
72  
73  }