blob: 74674fc556116f1efeee3362e9e3f1e7e7e02b83 (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/*******************************************************************************
* Copyright (c) 2008, 2017 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.equinox.internal.p2.extensionlocation;
import java.io.File;
import java.util.*;
import org.eclipse.equinox.internal.provisional.p2.directorywatcher.DirectoryChangeListener;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository;
public class BundlePoolFilteredListener extends DirectoryChangeListener {
private DirectoryChangeListener delegate;
private Set<File> bundlePoolFiles = new HashSet<>();
public BundlePoolFilteredListener(DirectoryChangeListener listener) {
delegate = listener;
IFileArtifactRepository bundlePool = Activator.getBundlePoolRepository();
if (bundlePool != null) {
IQueryResult<IArtifactKey> keys = bundlePool.query(ArtifactKeyQuery.ALL_KEYS, null);
for (Iterator<IArtifactKey> iterator = keys.iterator(); iterator.hasNext();) {
IArtifactKey key = iterator.next();
File artifactFile = bundlePool.getArtifactFile(key);
if (artifactFile != null)
bundlePoolFiles.add(artifactFile);
}
}
}
@Override
public boolean added(File file) {
return delegate.added(file);
}
@Override
public boolean changed(File file) {
return delegate.changed(file);
}
@Override
public Long getSeenFile(File file) {
return delegate.getSeenFile(file);
}
@Override
public boolean isInterested(File file) {
if (bundlePoolFiles.contains(file))
return false;
return delegate.isInterested(file);
}
@Override
public boolean removed(File file) {
return delegate.removed(file);
}
@Override
public void startPoll() {
delegate.startPoll();
}
@Override
public void stopPoll() {
delegate.stopPoll();
}
}
|