View Javadoc
1   package org.eclipse.aether.resolution;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.eclipse.aether.RepositorySystemSession;
23  import org.eclipse.aether.artifact.Artifact;
24  import org.eclipse.aether.metadata.Metadata;
25  
26  /**
27   * Controls the caching of resolution errors for artifacts/metadata from remote repositories. If caching is enabled for
28   * a given resource, a marker will be set (usually somewhere in the local repository) to suppress repeated resolution
29   * attempts for the broken resource, thereby avoiding expensive but useless network IO. The error marker is considered
30   * stale once the repository's update policy has expired at which point a future resolution attempt will be allowed.
31   * Error caching considers the current network settings such that fixes to the configuration like authentication or
32   * proxy automatically trigger revalidation with the remote side regardless of the time elapsed since the previous
33   * resolution error.
34   * 
35   * @see RepositorySystemSession#getResolutionErrorPolicy()
36   */
37  public interface ResolutionErrorPolicy
38  {
39  
40      /**
41       * Bit mask indicating that resolution errors should not be cached in the local repository. This forces the system
42       * to always query the remote repository for locally missing artifacts/metadata.
43       */
44      int CACHE_DISABLED = 0x00;
45  
46      /**
47       * Bit flag indicating whether missing artifacts/metadata should be cached in the local repository. If caching is
48       * enabled, resolution will not be reattempted until the update policy for the affected resource has expired.
49       */
50      int CACHE_NOT_FOUND = 0x01;
51  
52      /**
53       * Bit flag indicating whether connectivity/transfer errors (e.g. unreachable host, bad authentication) should be
54       * cached in the local repository. If caching is enabled, resolution will not be reattempted until the update policy
55       * for the affected resource has expired.
56       */
57      int CACHE_TRANSFER_ERROR = 0x02;
58  
59      /**
60       * Bit mask indicating that all resolution errors should be cached in the local repository.
61       */
62      int CACHE_ALL = CACHE_NOT_FOUND | CACHE_TRANSFER_ERROR;
63  
64      /**
65       * Gets the error policy for an artifact.
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 getArtifactPolicy( RepositorySystemSession session, ResolutionErrorPolicyRequest<Artifact> request );
72  
73      /**
74       * Gets the error policy for some metadata.
75       * 
76       * @param session The repository session during which the policy is determined, must not be {@code null}.
77       * @param request The policy request holding further details, must not be {@code null}.
78       * @return The bit mask describing the desired error policy.
79       */
80      int getMetadataPolicy( RepositorySystemSession session, ResolutionErrorPolicyRequest<Metadata> request );
81  
82  }