001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.eclipse.aether;
020
021import java.util.Map;
022
023import org.eclipse.aether.artifact.ArtifactTypeRegistry;
024import org.eclipse.aether.collection.DependencyCollectionChecker;
025import org.eclipse.aether.collection.DependencyGraphTransformer;
026import org.eclipse.aether.collection.DependencyManager;
027import org.eclipse.aether.collection.DependencySelector;
028import org.eclipse.aether.collection.DependencyTraverser;
029import org.eclipse.aether.collection.VersionFilter;
030import org.eclipse.aether.repository.AuthenticationSelector;
031import org.eclipse.aether.repository.LocalRepository;
032import org.eclipse.aether.repository.LocalRepositoryManager;
033import org.eclipse.aether.repository.MirrorSelector;
034import org.eclipse.aether.repository.ProxySelector;
035import org.eclipse.aether.repository.WorkspaceReader;
036import org.eclipse.aether.resolution.ArtifactDescriptorPolicy;
037import org.eclipse.aether.resolution.ResolutionErrorPolicy;
038import org.eclipse.aether.scope.ScopeManager;
039import org.eclipse.aether.scope.SystemDependencyScope;
040import org.eclipse.aether.transfer.TransferListener;
041
042/**
043 * A special repository system session to enable decorating or proxying another session. To do so, clients have to
044 * create a subclass and implement {@link #getSession()}, and optionally override other methods.
045 */
046public abstract class AbstractForwardingRepositorySystemSession implements RepositorySystemSession {
047
048    /**
049     * Creates a new forwarding session.
050     */
051    protected AbstractForwardingRepositorySystemSession() {}
052
053    /**
054     * Gets the repository system session to which this instance forwards calls. It's worth noting that this class does
055     * not save/cache the returned reference but queries this method before each forwarding. Hence, the session
056     * forwarded to may change over time or depending on the context (e.g. calling thread).
057     *
058     * @return The repository system session to forward calls to, never {@code null}.
059     */
060    protected abstract RepositorySystemSession getSession();
061
062    @Override
063    public boolean isOffline() {
064        return getSession().isOffline();
065    }
066
067    @Override
068    public boolean isIgnoreArtifactDescriptorRepositories() {
069        return getSession().isIgnoreArtifactDescriptorRepositories();
070    }
071
072    @Override
073    public ResolutionErrorPolicy getResolutionErrorPolicy() {
074        return getSession().getResolutionErrorPolicy();
075    }
076
077    @Override
078    public ArtifactDescriptorPolicy getArtifactDescriptorPolicy() {
079        return getSession().getArtifactDescriptorPolicy();
080    }
081
082    @Override
083    public String getChecksumPolicy() {
084        return getSession().getChecksumPolicy();
085    }
086
087    @Override
088    public String getUpdatePolicy() {
089        return getSession().getUpdatePolicy();
090    }
091
092    @Override
093    public String getArtifactUpdatePolicy() {
094        return getSession().getArtifactUpdatePolicy();
095    }
096
097    @Override
098    public String getMetadataUpdatePolicy() {
099        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}