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.resolution;
20  
21  import org.eclipse.aether.RepositorySystemSession;
22  import org.eclipse.aether.artifact.Artifact;
23  import org.eclipse.aether.metadata.Metadata;
24  
25  /**
26   * Controls the caching of resolution errors for artifacts/metadata from remote repositories. If caching is enabled for
27   * a given resource, a marker will be set (usually somewhere in the local repository) to suppress repeated resolution
28   * attempts for the broken resource, thereby avoiding expensive but useless network IO. The error marker is considered
29   * stale once the repository's update policy has expired at which point a future resolution attempt will be allowed.
30   * Error caching considers the current network settings such that fixes to the configuration like authentication or
31   * proxy automatically trigger revalidation with the remote side regardless of the time elapsed since the previous
32   * resolution error.
33   *
34   * @see RepositorySystemSession#getResolutionErrorPolicy()
35   */
36  public interface ResolutionErrorPolicy {
37  
38      /**
39       * Bit mask indicating that resolution errors should not be cached in the local repository. This forces the system
40       * to always query the remote repository for locally missing artifacts/metadata.
41       */
42      int CACHE_DISABLED = 0x00;
43  
44      /**
45       * Bit flag indicating whether missing artifacts/metadata should be cached in the local repository. If caching is
46       * enabled, resolution will not be reattempted until the update policy for the affected resource has expired.
47       */
48      int CACHE_NOT_FOUND = 0x01;
49  
50      /**
51       * Bit flag indicating whether connectivity/transfer errors (e.g. unreachable host, bad authentication) should be
52       * cached in the local repository. If caching is enabled, resolution will not be reattempted until the update policy
53       * for the affected resource has expired.
54       */
55      int CACHE_TRANSFER_ERROR = 0x02;
56  
57      /**
58       * Bit mask indicating that all resolution errors should be cached in the local repository.
59       */
60      int CACHE_ALL = CACHE_NOT_FOUND | CACHE_TRANSFER_ERROR;
61  
62      /**
63       * Gets the error policy for an artifact.
64       *
65       * @param session The repository session during which the policy is determined, must not be {@code null}.
66       * @param request The policy request holding further details, must not be {@code null}.
67       * @return The bit mask describing the desired error policy.
68       */
69      int getArtifactPolicy(RepositorySystemSession session, ResolutionErrorPolicyRequest<Artifact> request);
70  
71      /**
72       * Gets the error policy for some metadata.
73       *
74       * @param session The repository session during which the policy is determined, must not be {@code null}.
75       * @param request The policy request holding further details, must not be {@code null}.
76       * @return The bit mask describing the desired error policy.
77       */
78      int getMetadataPolicy(RepositorySystemSession session, ResolutionErrorPolicyRequest<Metadata> request);
79  }