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.util.Map;
22  
23  import org.eclipse.aether.artifact.ArtifactTypeRegistry;
24  import org.eclipse.aether.collection.DependencyGraphTransformer;
25  import org.eclipse.aether.collection.DependencyManager;
26  import org.eclipse.aether.collection.DependencySelector;
27  import org.eclipse.aether.collection.DependencyTraverser;
28  import org.eclipse.aether.collection.VersionFilter;
29  import org.eclipse.aether.repository.AuthenticationSelector;
30  import org.eclipse.aether.repository.LocalRepository;
31  import org.eclipse.aether.repository.LocalRepositoryManager;
32  import org.eclipse.aether.repository.MirrorSelector;
33  import org.eclipse.aether.repository.ProxySelector;
34  import org.eclipse.aether.repository.WorkspaceReader;
35  import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
36  import org.eclipse.aether.resolution.ResolutionErrorPolicy;
37  import org.eclipse.aether.scope.ScopeManager;
38  import org.eclipse.aether.scope.SystemDependencyScope;
39  import org.eclipse.aether.transfer.TransferListener;
40  
41  /**
42   * A special repository system session to enable decorating or proxying another session. To do so, clients have to
43   * create a subclass and implement {@link #getSession()}, and optionally override other methods.
44   */
45  public abstract class AbstractForwardingRepositorySystemSession implements RepositorySystemSession {
46  
47      /**
48       * Creates a new forwarding session.
49       */
50      protected AbstractForwardingRepositorySystemSession() {}
51  
52      /**
53       * Gets the repository system session to which this instance forwards calls. It's worth noting that this class does
54       * not save/cache the returned reference but queries this method before each forwarding. Hence, the session
55       * forwarded to may change over time or depending on the context (e.g. calling thread).
56       *
57       * @return The repository system session to forward calls to, never {@code null}.
58       */
59      protected abstract RepositorySystemSession getSession();
60  
61      @Override
62      public boolean isOffline() {
63          return getSession().isOffline();
64      }
65  
66      @Override
67      public boolean isIgnoreArtifactDescriptorRepositories() {
68          return getSession().isIgnoreArtifactDescriptorRepositories();
69      }
70  
71      @Override
72      public ResolutionErrorPolicy getResolutionErrorPolicy() {
73          return getSession().getResolutionErrorPolicy();
74      }
75  
76      @Override
77      public ArtifactDescriptorPolicy getArtifactDescriptorPolicy() {
78          return getSession().getArtifactDescriptorPolicy();
79      }
80  
81      @Override
82      public String getChecksumPolicy() {
83          return getSession().getChecksumPolicy();
84      }
85  
86      @Override
87      public String getUpdatePolicy() {
88          return getSession().getUpdatePolicy();
89      }
90  
91      @Override
92      public String getArtifactUpdatePolicy() {
93          return getSession().getArtifactUpdatePolicy();
94      }
95  
96      @Override
97      public String getMetadataUpdatePolicy() {
98          return getSession().getMetadataUpdatePolicy();
99      }
100 
101     @Override
102     public LocalRepository getLocalRepository() {
103         return getSession().getLocalRepository();
104     }
105 
106     @Override
107     public LocalRepositoryManager getLocalRepositoryManager() {
108         return getSession().getLocalRepositoryManager();
109     }
110 
111     @Override
112     public WorkspaceReader getWorkspaceReader() {
113         return getSession().getWorkspaceReader();
114     }
115 
116     @Override
117     public RepositoryListener getRepositoryListener() {
118         return getSession().getRepositoryListener();
119     }
120 
121     @Override
122     public TransferListener getTransferListener() {
123         return getSession().getTransferListener();
124     }
125 
126     @Override
127     public Map<String, String> getSystemProperties() {
128         return getSession().getSystemProperties();
129     }
130 
131     @Override
132     public Map<String, String> getUserProperties() {
133         return getSession().getUserProperties();
134     }
135 
136     @Override
137     public Map<String, Object> getConfigProperties() {
138         return getSession().getConfigProperties();
139     }
140 
141     @Override
142     public MirrorSelector getMirrorSelector() {
143         return getSession().getMirrorSelector();
144     }
145 
146     @Override
147     public ProxySelector getProxySelector() {
148         return getSession().getProxySelector();
149     }
150 
151     @Override
152     public AuthenticationSelector getAuthenticationSelector() {
153         return getSession().getAuthenticationSelector();
154     }
155 
156     @Override
157     public ArtifactTypeRegistry getArtifactTypeRegistry() {
158         return getSession().getArtifactTypeRegistry();
159     }
160 
161     @Override
162     public DependencyTraverser getDependencyTraverser() {
163         return getSession().getDependencyTraverser();
164     }
165 
166     @Override
167     public DependencyManager getDependencyManager() {
168         return getSession().getDependencyManager();
169     }
170 
171     @Override
172     public DependencySelector getDependencySelector() {
173         return getSession().getDependencySelector();
174     }
175 
176     @Override
177     public VersionFilter getVersionFilter() {
178         return getSession().getVersionFilter();
179     }
180 
181     @Override
182     public DependencyGraphTransformer getDependencyGraphTransformer() {
183         return getSession().getDependencyGraphTransformer();
184     }
185 
186     @Override
187     public SessionData getData() {
188         return getSession().getData();
189     }
190 
191     @Override
192     public RepositoryCache getCache() {
193         return getSession().getCache();
194     }
195 
196     @Override
197     public ScopeManager getScopeManager() {
198         return getSession().getScopeManager();
199     }
200 
201     @Override
202     public SystemDependencyScope getSystemDependencyScope() {
203         return getSession().getSystemDependencyScope();
204     }
205 
206     @Override
207     public boolean addOnSessionEndedHandler(Runnable handler) {
208         return getSession().addOnSessionEndedHandler(handler);
209     }
210 }