Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/DirectoryWatcher.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java20
5 files changed, 58 insertions, 50 deletions
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/DirectoryWatcher.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/DirectoryWatcher.java
index c704d2c14..b621c986f 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/DirectoryWatcher.java
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/DirectoryWatcher.java
@@ -140,7 +140,7 @@ public class DirectoryWatcher {
File directory = directories[index];
File list[] = directory.listFiles();
if (list == null)
- return;
+ continue;
for (int i = 0; i < list.length; i++) {
File file = list[i];
// if this is a deletion marker then add to the list of pending deletions.
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
index bf0e5b5cf..a4dcfff7d 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
@@ -167,16 +167,22 @@ public class RepositoryListener extends DirectoryChangeListener {
* @see org.eclipse.equinox.internal.provisional.p2.directorywatcher.IDirectoryChangeListener#added(java.io.File)
*/
public boolean added(File file) {
- currentFiles.put(file, new Long(file.lastModified()));
- return true;
+ if (isFeature(file) || isBundle(file)) {
+ currentFiles.put(file, new Long(file.lastModified()));
+ return true;
+ }
+ return false;
}
/* (non-Javadoc)
* @see org.eclipse.equinox.internal.provisional.p2.directorywatcher.IDirectoryChangeListener#changed(java.io.File)
*/
public boolean changed(File file) {
- currentFiles.put(file, new Long(file.lastModified()));
- return true;
+ if (isFeature(file) || isBundle(file)) {
+ currentFiles.put(file, new Long(file.lastModified()));
+ return true;
+ }
+ return false;
}
/* (non-Javadoc)
@@ -205,7 +211,7 @@ public class RepositoryListener extends DirectoryChangeListener {
* @see org.eclipse.equinox.internal.provisional.p2.directorywatcher.DirectoryChangeListener#isInterested(java.io.File)
*/
public boolean isInterested(File file) {
- return isFeature(file) || isBundle(file);
+ return true;
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
index 9c4ce05a2..c2f9c6e09 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
@@ -16,6 +16,10 @@ import org.osgi.framework.ServiceReference;
public class DropinsRepositoryListener extends RepositoryListener {
+ private static final String JAR = ".jar"; //$NON-NLS-1$
+ private static final String LINK = ".link"; //$NON-NLS-1$
+ private static final String ZIP = ".zip"; //$NON-NLS-1$
+ private static final String LINKS_PATH = "path"; //$NON-NLS-1$
private static final String DROPIN_ARTIFACT_REPOSITORIES = "dropin.artifactRepositories"; //$NON-NLS-1$
private static final String DROPIN_METADATA_REPOSITORIES = "dropin.metadataRepositories"; //$NON-NLS-1$
private static final String PIPE = "|"; //$NON-NLS-1$
@@ -33,12 +37,12 @@ public class DropinsRepositoryListener extends RepositoryListener {
return true;
String name = file.getName();
- return name.endsWith(".jar") || name.endsWith(".zip") || name.endsWith(".link");
+ return name.endsWith(JAR) || name.endsWith(ZIP) || name.endsWith(LINK);
}
public boolean added(File file) {
- if (super.isInterested(file))
- return super.added(file);
+ if (super.added(file))
+ return true;
URL repositoryURL = createRepositoryURL(file);
if (repositoryURL != null) {
@@ -49,8 +53,8 @@ public class DropinsRepositoryListener extends RepositoryListener {
}
public boolean changed(File file) {
- if (super.isInterested(file))
- return super.added(file);
+ if (super.changed(file))
+ return true;
URL repositoryURL = createRepositoryURL(file);
if (repositoryURL != null) {
@@ -72,7 +76,7 @@ public class DropinsRepositoryListener extends RepositoryListener {
} catch (IOException e) {
// ignore
}
- String path = links.getProperty("path");
+ String path = links.getProperty(LINKS_PATH);
if (path == null) {
// log
return null;
@@ -91,19 +95,24 @@ public class DropinsRepositoryListener extends RepositoryListener {
private URL createRepositoryURL(File file) {
try {
- if (file.getName().endsWith(".link")) {
- String path = getLinkPath(file);
+ if (file.getName().endsWith(LINK)) {
+ File linkFile = file;
+ String path = getLinkPath(linkFile);
// todo log
if (path == null)
return null;
file = new File(path);
- if (!file.isAbsolute())
- file = new File(file, path).getCanonicalFile();
+ if (!file.isAbsolute()) {
+ // link support is relative to the install root
+ // For now we will use the parent of dropins folder
+ file = new File(Activator.getDropinsDirectory().getParentFile(), path);
+ }
}
- URL repositoryURL = file.toURL();
- if (file.getName().endsWith(".zip") || file.getName().endsWith(".jar")) {
- repositoryURL = new URL("jar:" + repositoryURL.toString() + "!/");
+ File canonicalFile = file.getCanonicalFile();
+ URL repositoryURL = canonicalFile.toURL();
+ if (canonicalFile.getName().endsWith(ZIP) || canonicalFile.getName().endsWith(JAR)) {
+ repositoryURL = new URL("jar:" + repositoryURL.toString() + "!/"); //$NON-NLS-1$ //$NON-NLS-2$
}
return repositoryURL;
} catch (IOException e) {
diff --git a/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java b/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
index 9c4ce05a2..c2f9c6e09 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler/src/org/eclipse/equinox/internal/p2/reconciler/dropins/DropinsRepositoryListener.java
@@ -16,6 +16,10 @@ import org.osgi.framework.ServiceReference;
public class DropinsRepositoryListener extends RepositoryListener {
+ private static final String JAR = ".jar"; //$NON-NLS-1$
+ private static final String LINK = ".link"; //$NON-NLS-1$
+ private static final String ZIP = ".zip"; //$NON-NLS-1$
+ private static final String LINKS_PATH = "path"; //$NON-NLS-1$
private static final String DROPIN_ARTIFACT_REPOSITORIES = "dropin.artifactRepositories"; //$NON-NLS-1$
private static final String DROPIN_METADATA_REPOSITORIES = "dropin.metadataRepositories"; //$NON-NLS-1$
private static final String PIPE = "|"; //$NON-NLS-1$
@@ -33,12 +37,12 @@ public class DropinsRepositoryListener extends RepositoryListener {
return true;
String name = file.getName();
- return name.endsWith(".jar") || name.endsWith(".zip") || name.endsWith(".link");
+ return name.endsWith(JAR) || name.endsWith(ZIP) || name.endsWith(LINK);
}
public boolean added(File file) {
- if (super.isInterested(file))
- return super.added(file);
+ if (super.added(file))
+ return true;
URL repositoryURL = createRepositoryURL(file);
if (repositoryURL != null) {
@@ -49,8 +53,8 @@ public class DropinsRepositoryListener extends RepositoryListener {
}
public boolean changed(File file) {
- if (super.isInterested(file))
- return super.added(file);
+ if (super.changed(file))
+ return true;
URL repositoryURL = createRepositoryURL(file);
if (repositoryURL != null) {
@@ -72,7 +76,7 @@ public class DropinsRepositoryListener extends RepositoryListener {
} catch (IOException e) {
// ignore
}
- String path = links.getProperty("path");
+ String path = links.getProperty(LINKS_PATH);
if (path == null) {
// log
return null;
@@ -91,19 +95,24 @@ public class DropinsRepositoryListener extends RepositoryListener {
private URL createRepositoryURL(File file) {
try {
- if (file.getName().endsWith(".link")) {
- String path = getLinkPath(file);
+ if (file.getName().endsWith(LINK)) {
+ File linkFile = file;
+ String path = getLinkPath(linkFile);
// todo log
if (path == null)
return null;
file = new File(path);
- if (!file.isAbsolute())
- file = new File(file, path).getCanonicalFile();
+ if (!file.isAbsolute()) {
+ // link support is relative to the install root
+ // For now we will use the parent of dropins folder
+ file = new File(Activator.getDropinsDirectory().getParentFile(), path);
+ }
}
- URL repositoryURL = file.toURL();
- if (file.getName().endsWith(".zip") || file.getName().endsWith(".jar")) {
- repositoryURL = new URL("jar:" + repositoryURL.toString() + "!/");
+ File canonicalFile = file.getCanonicalFile();
+ URL repositoryURL = canonicalFile.toURL();
+ if (canonicalFile.getName().endsWith(ZIP) || canonicalFile.getName().endsWith(JAR)) {
+ repositoryURL = new URL("jar:" + repositoryURL.toString() + "!/"); //$NON-NLS-1$ //$NON-NLS-2$
}
return repositoryURL;
} catch (IOException e) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java
index 710f9c655..1265547e3 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java
@@ -76,7 +76,7 @@ public class RepositoryListenerTest extends AbstractProvisioningTest {
DirectoryWatcher watcher = new DirectoryWatcher(props, TestActivator.getContext());
watcher.addListener(listener);
- watcher.start();
+ // watcher.start();
assertEquals("2.0", 0, getInstallableUnits(listener).length);
assertEquals("2.1", 0, listener.getArtifactRepository().getArtifactKeys().length);
@@ -87,7 +87,6 @@ public class RepositoryListenerTest extends AbstractProvisioningTest {
fail("2.2", e);
}
watcher.poll();
- watcher.stop();
IFileArtifactRepository repo = (IFileArtifactRepository) listener.getArtifactRepository();
IArtifactKey[] keys = repo.getArtifactKeys();
@@ -98,13 +97,6 @@ public class RepositoryListenerTest extends AbstractProvisioningTest {
assertEquals("3.0", 2, getInstallableUnits(listener).length);
assertEquals("3.1", 2, listener.getArtifactRepository().getArtifactKeys().length);
- watcher = new DirectoryWatcher(props, TestActivator.getContext());
- watcher.addListener(listener);
- watcher.start();
-
- assertEquals("4.0", 2, getInstallableUnits(listener).length);
- assertEquals("4.1", 2, listener.getArtifactRepository().getArtifactKeys().length);
-
try {
copy(baseFolder2, folder);
} catch (IOException e) {
@@ -112,15 +104,9 @@ public class RepositoryListenerTest extends AbstractProvisioningTest {
}
watcher.poll();
- assertEquals("5.0", 5, getInstallableUnits(listener).length);
+ assertEquals("5.0", 3, getInstallableUnits(listener).length);
assertEquals("5.1", 3, listener.getArtifactRepository().getArtifactKeys().length);
- watcher.stop();
-
- watcher = new DirectoryWatcher(props, TestActivator.getContext());
- watcher.addListener(listener);
- watcher.start();
-
try {
removeContents(baseFolder, folder);
} catch (Exception e) {
@@ -131,8 +117,6 @@ public class RepositoryListenerTest extends AbstractProvisioningTest {
assertEquals("6.0", 1, getInstallableUnits(listener).length);
assertEquals("6.1", 1, listener.getArtifactRepository().getArtifactKeys().length);
- watcher.stop();
-
delete(folder);
}
}

Back to the top