Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5d6b211653fec1949a5d97bedee22c3aefd540a5 (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
/*******************************************************************************
 * 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 v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *      Igor Fedorenko - initial API and implementation
 *******************************************************************************/

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

import java.io.File;

import org.eclipse.osgi.internal.location.LocationHelper;
import org.eclipse.osgi.internal.location.Locker;


/**
 * Adaptor for Equinox internal file Locker implementation
 * 
 * @since 1.5
 */
@SuppressWarnings("restriction")
public class EquinoxLocker implements org.apache.maven.index.fs.Locker {

  private static class EquinoxLock implements org.apache.maven.index.fs.Lock {

    private Locker locker;

    public EquinoxLock(Locker locker) {
      this.locker = locker;
    }

    public void release() {
      locker.release();
    }
  }

  @Override
  public org.apache.maven.index.fs.Lock lock(File directory) {
    File lock = new File(directory, LOCK_FILE);
    return new EquinoxLock(LocationHelper.createLocker(lock, null /*lockMode*/, false /*debug*/));
  }
}

Back to the top