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