Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 41be0a777019e3de7c9ddc3bd86c1ea00eb4bd55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*******************************************************************************
 * Copyright (c) 2013 Igor Fedorenko
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *      Igor Fedorenko - initial API and implementation
 *******************************************************************************/

package org.eclipse.m2e.core.internal.embedder;

import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.SessionData;
import org.eclipse.aether.transfer.TransferListener;


/**
 * FilterRepositorySystemSession implementation that allows setting of some/relevant session attributes.
 * 
 * @since 1.4
 */
class FilterRepositorySystemSession extends org.eclipse.aether.AbstractForwardingRepositorySystemSession {

  private final String updatePolicy;

  private final DefaultRepositorySystemSession session;

  public FilterRepositorySystemSession(DefaultRepositorySystemSession session, String updatePolicy) {
    this.session = session;
    this.updatePolicy = updatePolicy;
  }

  public String getUpdatePolicy() {
    return updatePolicy != null ? updatePolicy : super.getUpdatePolicy();
  }

  public TransferListener setTransferListener(TransferListener transferListener) {
    DefaultRepositorySystemSession session = getSession();
    TransferListener origTransferListener = session.getTransferListener();
    session.setTransferListener(transferListener);
    return origTransferListener;
  }

  public SessionData setData(SessionData data) {
    DefaultRepositorySystemSession session = getSession();
    SessionData origSessionData = session.getData();
    session.setData(data);
    return origSessionData;
  }

  protected DefaultRepositorySystemSession getSession() {
    return this.session;
  }
}

Back to the top