Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoribull2010-03-09 15:28:18 -0500
committeribull2010-03-09 15:28:18 -0500
commita10e8c42f42bebe3f87703168219ae4e2026f263 (patch)
treec1be689dba662fec0475e579c53ef3a867d33550 /bundles/org.eclipse.equinox.p2.repository
parent84859d06776f2a1f5aabdc949391e8dadaa3c6ec (diff)
downloadrt.equinox.p2-a10e8c42f42bebe3f87703168219ae4e2026f263.tar.gz
rt.equinox.p2-a10e8c42f42bebe3f87703168219ae4e2026f263.tar.xz
rt.equinox.p2-a10e8c42f42bebe3f87703168219ae4e2026f263.zip
bug 301902: [api] Add an executeBatch to the MetadataRepositoryv20100311-1400
https://bugs.eclipse.org/bugs/show_bug.cgi?id=301902
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/IMetadataRepository.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/spi/AbstractMetadataRepository.java15
2 files changed, 31 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/IMetadataRepository.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/IMetadataRepository.java
index 14ec238b4..af4f5fdd2 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/IMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/IMetadataRepository.java
@@ -11,9 +11,10 @@
package org.eclipse.equinox.p2.repository.metadata;
import java.util.Collection;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.repository.IRepository;
-import org.eclipse.equinox.p2.repository.IRepositoryReference;
+import org.eclipse.equinox.p2.repository.*;
import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
/**
@@ -67,4 +68,17 @@ public interface IMetadataRepository extends IRepository<IInstallableUnit> {
*/
public void removeAll();
+ /**
+ * Executes a runnable against this repository. It is up to the repository
+ * implementor to determine what "batch process" means, for example, it may mean
+ * that the repository index is not stored until after the runnable completes.
+ *
+ * The runnable should not execute anything in a separate thread.
+ *
+ * @param runnable The runnable to execute
+ * @param monitor A progress monitor that will be passed to the runnable
+ * @return The result of running the runnable. Any exceptions thrown during
+ * the execution will be returned in the status.
+ */
+ public IStatus executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor);
}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/spi/AbstractMetadataRepository.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/spi/AbstractMetadataRepository.java
index f86fd03d0..2dfbca51d 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/spi/AbstractMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/metadata/spi/AbstractMetadataRepository.java
@@ -13,10 +13,13 @@ package org.eclipse.equinox.p2.repository.metadata.spi;
import java.net.URI;
import java.util.Collection;
import java.util.Map;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.repository.Activator;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.repository.IRepositoryReference;
+import org.eclipse.equinox.p2.repository.IRunnableWithProgress;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.spi.AbstractRepository;
@@ -134,4 +137,16 @@ public abstract class AbstractMetadataRepository extends AbstractRepository<IIns
return false;
}
+ /**
+ * {@inheritDoc}
+ */
+ public IStatus executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor) {
+ try {
+ runnable.run(monitor);
+ } catch (Exception e) {
+ return new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e);
+ }
+ return Status.OK_STATUS;
+ }
+
}

Back to the top