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