Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2008-09-30 22:02:21 +0000
committerDJ Houghton2008-09-30 22:02:21 +0000
commit707ce07abd8561c78d8264a0f7d35db6b8c68181 (patch)
tree59f842cccc566321392bb7308386b38c0f18a138 /bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror
parent7bd29d591afc64af6e95d90465463529a71a62bd (diff)
downloadrt.equinox.p2-707ce07abd8561c78d8264a0f7d35db6b8c68181.tar.gz
rt.equinox.p2-707ce07abd8561c78d8264a0f7d35db6b8c68181.tar.xz
rt.equinox.p2-707ce07abd8561c78d8264a0f7d35db6b8c68181.zip
Bug 249215 - Metadata Mirror Application shouldn't cache repository manager
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror')
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java
index 9f286660c..5c2a68479 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/mirror/MirrorApplication.java
@@ -12,11 +12,10 @@ package org.eclipse.equinox.internal.p2.artifact.mirror;
import java.net.URL;
import java.util.Map;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
+import org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRepositoryManager;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
@@ -33,6 +32,7 @@ public class MirrorApplication implements IApplication {
private IArtifactRepository destination;
private boolean append = false;
private boolean raw = false;
+ private IArtifactRepositoryManager cachedManager;
/* (non-Javadoc)
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
@@ -45,11 +45,21 @@ public class MirrorApplication implements IApplication {
return IApplication.EXIT_OK;
}
- private IArtifactRepositoryManager getManager() throws ProvisionException {
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
- if (manager == null)
- throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID, "Unable to acquire artifact repository manager service."));
- return manager;
+ /*
+ * Return the artifact repository manager. We need to check the service here
+ * as well as creating one manually in case we are running a stand-alone application
+ * in which no one has registered a manager yet.
+ */
+ private IArtifactRepositoryManager getManager() {
+ if (cachedManager != null)
+ return cachedManager;
+ IArtifactRepositoryManager result = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
+ // service not available... create one and hang onto it
+ if (result == null) {
+ cachedManager = new ArtifactRepositoryManager();
+ result = cachedManager;
+ }
+ return result;
}
private void setupRepositories() throws ProvisionException {

Back to the top