diff options
author | John Arthorne | 2009-11-09 18:33:34 +0000 |
---|---|---|
committer | John Arthorne | 2009-11-09 18:33:34 +0000 |
commit | 0ad28f0b3d269564b7ca614516e78dacdf08f2fc (patch) | |
tree | 677dec8dde7432a7fd6ad5e5c0b2a07de3f5e452 | |
parent | 25ff775d2021da0bbdf2df7f3996181859e9ea99 (diff) | |
download | rt.equinox.p2-0ad28f0b3d269564b7ca614516e78dacdf08f2fc.tar.gz rt.equinox.p2-0ad28f0b3d269564b7ca614516e78dacdf08f2fc.tar.xz rt.equinox.p2-0ad28f0b3d269564b7ca614516e78dacdf08f2fc.zip |
Bug 290317 - AgentLocation API cleanup
32 files changed, 201 insertions, 273 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF index cdcd5f47b..59da8b26e 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF @@ -63,7 +63,6 @@ Import-Package: javax.xml.parsers, org.eclipse.equinox.internal.p2.repository.helpers, org.eclipse.equinox.internal.provisional.p2.core, org.eclipse.equinox.internal.provisional.p2.core.eventbus, - org.eclipse.equinox.internal.provisional.p2.core.location, org.eclipse.equinox.internal.provisional.p2.metadata, org.eclipse.equinox.internal.provisional.p2.metadata.query, org.eclipse.equinox.internal.provisional.p2.repository, diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java index 46811e78f..0d79e93a3 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/ArtifactRepositoryManager.java @@ -11,6 +11,8 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.artifact.repository; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.net.URI; import java.util.*; import org.eclipse.core.runtime.*; @@ -19,7 +21,6 @@ import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager; import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.ArtifactRepositoryFactory; @@ -102,12 +103,14 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager impleme */ protected void restoreSpecialRepositories() { // TODO while recreating, we may want to have proxies on repo instead of the real repo object to limit what is activated. - AgentLocation location = (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName()); + IAgentLocation location = (IAgentLocation) ServiceHelper.getService(Activator.getContext(), IAgentLocation.class.getName()); if (location == null) // TODO should do something here since we are failing to restore. return; + URI cacheLocation = URIUtil.append(location.getDataArea("org.eclipse.equinox.p2.core"), "cache/"); //$NON-NLS-1$ //$NON-NLS-2$ + try { - loadRepository(location.getArtifactRepositoryURI(), null); + loadRepository(cacheLocation, null); return; } catch (ProvisionException e) { // log but still continue and try to create a new one @@ -117,7 +120,7 @@ public class ArtifactRepositoryManager extends AbstractRepositoryManager impleme try { Map properties = new HashMap(1); properties.put(IRepository.PROP_SYSTEM, Boolean.TRUE.toString()); - createRepository(location.getArtifactRepositoryURI(), "download cache", TYPE_SIMPLE_REPOSITORY, properties); //$NON-NLS-1$ + createRepository(cacheLocation, "download cache", TYPE_SIMPLE_REPOSITORY, properties); //$NON-NLS-1$ } catch (ProvisionException e) { LogHelper.log(e); } diff --git a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF index de1a72cde..d1e149b8c 100644 --- a/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF @@ -88,13 +88,6 @@ Export-Package: org.eclipse.equinox.internal.p2.core;x-friends:="org.eclipse.equ org.eclipse.equinox.p2.touchpoint.natives, org.eclipse.equinox.p2.publisher, org.eclipse.equinox.p2.repository", - org.eclipse.equinox.internal.provisional.p2.core.location; - x-friends:="org.eclipse.equinox.p2.artifact.repository, - org.eclipse.equinox.p2.touchpoint.natives, - org.eclipse.equinox.p2.metadata.repository, - org.eclipse.equinox.p2.director, - org.eclipse.equinox.p2.engine, - org.eclipse.equinox.p2.touchpoint.eclipse", org.eclipse.equinox.p2.core, org.eclipse.equinox.p2.core.spi Bundle-ActivationPolicy: lazy diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java index 8b67449da..de5a479d5 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/Activator.java @@ -10,19 +10,20 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.core; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; import java.util.Dictionary; import java.util.Hashtable; import org.eclipse.core.runtime.Path; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.osgi.framework.log.FrameworkLog; import org.osgi.framework.*; import org.osgi.util.tracker.ServiceTracker; public class Activator implements BundleActivator { - public static AgentLocation agentDataLocation = null; + public static IAgentLocation agentDataLocation = null; public static BundleContext context; private static final String DEFAULT_AGENT_LOCATION = "../p2"; //$NON-NLS-1$ @@ -51,12 +52,12 @@ public class Activator implements BundleActivator { * NOTE: This method is copied from LocationHelper in org.eclipse.osgi * due to access restrictions. */ - private static URL adjustTrailingSlash(URL url, boolean trailingSlash) throws MalformedURLException { - String file = url.getFile(); + private static URI adjustTrailingSlash(URI url, boolean trailingSlash) throws URISyntaxException { + String file = url.toString(); if (trailingSlash == (file.endsWith("/"))) //$NON-NLS-1$ return url; file = trailingSlash ? file + "/" : file.substring(0, file.length() - 1); //$NON-NLS-1$ - return new URL(url.getProtocol(), url.getHost(), file); + return new URI(file); } /** @@ -68,22 +69,22 @@ public class Activator implements BundleActivator { * @param trailingSlash flag to indicate a trailing slash on the spec * @return a URL */ - private static URL buildURL(String spec, boolean trailingSlash) { + private static URI buildURL(String spec, boolean trailingSlash) { if (spec == null) return null; boolean isFile = spec.startsWith("file:"); //$NON-NLS-1$ try { if (isFile) - return adjustTrailingSlash(new File(spec.substring(5)).toURL(), trailingSlash); - return new URL(spec); - } catch (MalformedURLException e) { + return adjustTrailingSlash(new File(spec.substring(5)).toURI(), trailingSlash); + return new URI(spec); + } catch (URISyntaxException e) { // if we failed and it is a file spec, there is nothing more we can do // otherwise, try to make the spec into a file URL. if (isFile) return null; try { - return adjustTrailingSlash(new File(spec).toURL(), trailingSlash); - } catch (MalformedURLException e1) { + return adjustTrailingSlash(new File(spec).toURI(), trailingSlash); + } catch (URISyntaxException e1) { return null; } } @@ -114,16 +115,16 @@ public class Activator implements BundleActivator { return value + source.substring(var.length()); } - private AgentLocation buildLocation(String property, URL defaultLocation, boolean readOnlyDefault, boolean addTrailingSlash) { + private IAgentLocation buildLocation(String property, URI defaultLocation, boolean readOnlyDefault, boolean addTrailingSlash) { String location = Activator.context.getProperty(property); // if the instance location is not set, predict where the workspace will be and // put the instance area inside the workspace meta area. if (location == null) - return new BasicLocation(defaultLocation); + return new AgentLocation(defaultLocation); if (location.equalsIgnoreCase(NONE)) return null; if (location.equalsIgnoreCase(NO_DEFAULT)) - return new BasicLocation(null); + return new AgentLocation(null); if (location.startsWith(VAR_USER_HOME)) { String base = substituteVar(location, VAR_USER_HOME, PROP_USER_HOME); location = new Path(base).toFile().getAbsolutePath(); @@ -134,10 +135,10 @@ public class Activator implements BundleActivator { //note the config dir system property is already a URL location = substituteVar(location, VAR_CONFIG_DIR, PROP_CONFIG_DIR); } - URL url = buildURL(location, addTrailingSlash); - BasicLocation result = null; + URI url = buildURL(location, addTrailingSlash); + AgentLocation result = null; if (url != null) { - result = new BasicLocation(url); + result = new AgentLocation(url); } return result; } @@ -156,12 +157,12 @@ public class Activator implements BundleActivator { public void start(BundleContext aContext) throws Exception { instance = this; Activator.context = aContext; - URL defaultLocation = new URL(aContext.getProperty(PROP_CONFIG_DIR) + DEFAULT_AGENT_LOCATION + '/'); + URI defaultLocation = new URI(aContext.getProperty(PROP_CONFIG_DIR) + DEFAULT_AGENT_LOCATION + '/'); agentDataLocation = buildLocation(PROP_AGENT_DATA_AREA, defaultLocation, false, true); Dictionary locationProperties = new Hashtable(); if (agentDataLocation != null) { locationProperties.put("type", PROP_AGENT_DATA_AREA); //$NON-NLS-1$ - agentLocationRegistration = aContext.registerService(AgentLocation.SERVICE_NAME, agentDataLocation, locationProperties); + agentLocationRegistration = aContext.registerService(IAgentLocation.SERVICE_NAME, agentDataLocation, locationProperties); } } diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/AgentLocation.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/AgentLocation.java new file mode 100644 index 000000000..57320bf31 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/AgentLocation.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2004, 2009 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.core; + +import org.eclipse.equinox.p2.core.IAgentLocation; + +import java.net.URI; +import org.eclipse.core.runtime.URIUtil; + +/** + * Internal class. + */ +public class AgentLocation implements IAgentLocation { + + private URI location = null; + + public AgentLocation(URI location) { + this.location = location; + } + + public synchronized URI getRootLocation() { + return location; + } + + public URI getDataArea(String touchpointId) { + return URIUtil.append(getRootLocation(), touchpointId + '/'); + } +} diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/BasicLocation.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/BasicLocation.java deleted file mode 100644 index 327d6a0a1..000000000 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/BasicLocation.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2009 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.core; - -import java.net.*; -import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; - -/** - * Internal class. - */ -public class BasicLocation implements AgentLocation { - - private URL location = null; - - public BasicLocation(URL location) { - this.location = location; - } - - public synchronized URL getURL() { - return location; - } - - public URI getArtifactRepositoryURI() { - //the cache is a co-located repository - return getMetadataRepositoryURI(); - } - - public URI getMetadataRepositoryURI() { - try { - return URIUtil.toURI(new URL(getDataArea(Activator.ID), "cache/")); //$NON-NLS-1$ - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - } - return null; - } - - public URL getDataArea(String touchpointId) { - try { - return new URL(getURL(), touchpointId + '/'); - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - return null; - } - } -} diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java index 09679ffdf..99446da99 100644 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningAgent.java @@ -10,12 +10,10 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.core; -import java.net.MalformedURLException; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.net.URI; import java.util.*; -import org.eclipse.core.runtime.*; -import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; import org.osgi.framework.*; @@ -68,22 +66,18 @@ public class ProvisioningAgent implements IProvisioningAgent { } public void setLocation(URI location) { - try { - //treat a null location as using the currently running platform - AgentLocation agentLocation = null; - if (location == null) { - ServiceReference ref = context.getServiceReference(AgentLocation.SERVICE_NAME); - if (ref != null) { - agentLocation = (AgentLocation) context.getService(ref); - context.ungetService(ref); - } - } else { - agentLocation = new BasicLocation(URIUtil.toURL(location)); + //treat a null location as using the currently running platform + IAgentLocation agentLocation = null; + if (location == null) { + ServiceReference ref = context.getServiceReference(IAgentLocation.SERVICE_NAME); + if (ref != null) { + agentLocation = (IAgentLocation) context.getService(ref); + context.ungetService(ref); } - agentServices.put(AgentLocation.SERVICE_NAME, agentLocation); - } catch (MalformedURLException e) { - LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Invalid agent location", e)); //$NON-NLS-1$ + } else { + agentLocation = new AgentLocation(location); } + agentServices.put(IAgentLocation.SERVICE_NAME, agentLocation); } public void unregisterService(String serviceName, Object service) { diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/provisional/p2/core/location/AgentLocation.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/provisional/p2/core/location/AgentLocation.java deleted file mode 100644 index aacd84ac4..000000000 --- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/provisional/p2/core/location/AgentLocation.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.provisional.p2.core.location; - -import java.net.URI; -import java.net.URL; - -public interface AgentLocation { - public static final String SERVICE_NAME = AgentLocation.class.getName(); - - public URI getArtifactRepositoryURI(); - - public URI getMetadataRepositoryURI(); - - /** - * Returns the location where the bundle with the given namespace - * may write its agent-related data. - * @param namespace The namespace of the bundle storing the data - * @return The data location - */ - public URL getDataArea(String namespace); - - /** - * Returns the actual {@link URL} of this location. If the location's value has been set, - * that value is returned. If the value is not set and the location allows defaults, - * the value is set to the default and returned. In all other cases <code>null</code> - * is returned. - * - * @return the URL for this location or <code>null</code> if none - */ - public URL getURL(); - -} diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/IAgentLocation.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/IAgentLocation.java new file mode 100644 index 000000000..8ee422f98 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/p2/core/IAgentLocation.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2007, 2009 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.p2.core; + +import java.net.URI; + +/** + * An instance of this service represents the location of a provisioning agent's + * metadata. + * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + * @since 1.1 + */ +public interface IAgentLocation { + /** + * Service name constant for the agent location service. + */ + public static final String SERVICE_NAME = IAgentLocation.class.getName(); + + /** + * Returns the location where the bundle with the given namespace + * may write its agent-related data. + * @param namespace The namespace of the bundle storing the data + * @return The data location + */ + public URI getDataArea(String namespace); + + /** + * Returns the root {@link URI} of the agent metadata. + * + * @return the location of the agent metadata + */ + public URI getRootLocation(); + +} diff --git a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF index 0227cf441..8d8196071 100644 --- a/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.engine/META-INF/MANIFEST.MF @@ -35,7 +35,6 @@ Import-Package: javax.xml.parsers, org.eclipse.equinox.internal.provisional.p2.artifact.repository, org.eclipse.equinox.internal.provisional.p2.core, org.eclipse.equinox.internal.provisional.p2.core.eventbus, - org.eclipse.equinox.internal.provisional.p2.core.location, org.eclipse.equinox.internal.provisional.p2.metadata, org.eclipse.equinox.internal.provisional.p2.metadata.query, org.eclipse.equinox.internal.provisional.p2.metadata.repository, diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfilePreferences.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfilePreferences.java index 8c84e4031..6b2fd5574 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfilePreferences.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfilePreferences.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.engine; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.io.File; import java.util.*; import org.eclipse.core.internal.preferences.EclipsePreferences; @@ -17,7 +19,6 @@ import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.equinox.internal.p2.core.helpers.*; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -122,12 +123,12 @@ public class ProfilePreferences extends EclipsePreferences { */ private IPath getDefaultLocation() { //use engine agent location for preferences if there is no self profile - AgentLocation location = (AgentLocation) ServiceHelper.getService(EngineActivator.getContext(), AgentLocation.SERVICE_NAME); + IAgentLocation location = (IAgentLocation) ServiceHelper.getService(EngineActivator.getContext(), IAgentLocation.SERVICE_NAME); if (location == null) { LogHelper.log(new Status(IStatus.WARNING, EngineActivator.ID, "Agent location service not available", new RuntimeException())); //$NON-NLS-1$ return null; } - IPath dataArea = new Path(URLUtil.toFile(location.getDataArea(EngineActivator.ID)).getAbsolutePath()); + IPath dataArea = new Path(URIUtil.toFile(location.getDataArea(EngineActivator.ID)).getAbsolutePath()); return computeLocation(dataArea, qualifier); } diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java index 1e05b8a91..15a62ab1f 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileRegistryComponent.java @@ -10,8 +10,9 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.engine; +import org.eclipse.equinox.p2.core.IAgentLocation; + import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; @@ -22,7 +23,7 @@ import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; public class ProfileRegistryComponent implements IAgentServiceFactory { public Object createService(IProvisioningAgent agent) { - AgentLocation location = (AgentLocation) agent.getService(AgentLocation.SERVICE_NAME); + IAgentLocation location = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME); SimpleProfileRegistry registry = new SimpleProfileRegistry(SimpleProfileRegistry.getDefaultRegistryDirectory(location)); registry.setEventBus((IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME)); return registry; diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java index 271f66675..4a919f1b1 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java @@ -8,10 +8,11 @@ ******************************************************************************/ package org.eclipse.equinox.internal.p2.engine; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.io.*; import java.lang.ref.SoftReference; -import java.net.MalformedURLException; -import java.net.URL; +import java.net.URI; import java.util.*; import java.util.Map.Entry; import java.util.zip.GZIPInputStream; @@ -21,7 +22,6 @@ import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.*; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; @@ -70,19 +70,14 @@ public class SimpleProfileRegistry implements IProfileRegistry { this.updateSelfProfile = updateSelfProfile; } - public static File getDefaultRegistryDirectory(AgentLocation agent) { + public static File getDefaultRegistryDirectory(IAgentLocation agent) { File registryDirectory = null; if (agent == null) throw new IllegalStateException("Profile Registry inialization failed: Agent Location is not available"); //$NON-NLS-1$ - final URL engineDataArea = agent.getDataArea(EngineActivator.ID); - try { - URL registryURL = new URL(engineDataArea, DEFAULT_STORAGE_DIR); - registryDirectory = new File(registryURL.getPath()); - registryDirectory.mkdirs(); - } catch (MalformedURLException e) { - //this is not possible because we know the above URL is valid - throw new IllegalStateException("Profile Registry inialization failed. Agent Location is invalid:" + engineDataArea); //$NON-NLS-1$ - } + final URI engineDataArea = agent.getDataArea(EngineActivator.ID); + URI registryURL = URIUtil.append(engineDataArea, DEFAULT_STORAGE_DIR); + registryDirectory = new File(registryURL); + registryDirectory.mkdirs(); return registryDirectory; } diff --git a/bundles/org.eclipse.equinox.p2.exemplarysetup/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.exemplarysetup/META-INF/MANIFEST.MF index 4ecf7c3d5..0c2bed786 100644 --- a/bundles/org.eclipse.equinox.p2.exemplarysetup/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.exemplarysetup/META-INF/MANIFEST.MF @@ -8,7 +8,6 @@ Bundle-Version: 1.0.100.qualifier Import-Package: org.eclipse.equinox.internal.p2.core.helpers, org.eclipse.equinox.internal.p2.garbagecollector, org.eclipse.equinox.internal.provisional.p2.core.eventbus, - org.eclipse.equinox.internal.provisional.p2.core.location, org.eclipse.equinox.internal.provisional.p2.director, org.eclipse.equinox.internal.provisional.p2.engine, org.eclipse.equinox.internal.provisional.p2.metadata.repository, diff --git a/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java b/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java index 589f7abd5..24f54bde9 100644 --- a/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java +++ b/bundles/org.eclipse.equinox.p2.exemplarysetup/src/org/eclipse/equinox/internal/p2/exemplarysetup/Activator.java @@ -10,11 +10,13 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.exemplarysetup; -import org.eclipse.core.runtime.*; +import org.eclipse.equinox.p2.core.IAgentLocation; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.garbagecollector.GarbageCollector; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; @@ -45,21 +47,21 @@ public class Activator implements BundleActivator { private void registerAgent() { //currently location is defined by p2.core but will be defined by the agent in the future //for now continue to treat it as a singleton - ServiceReference locationRef = context.getServiceReference(AgentLocation.SERVICE_NAME); + ServiceReference locationRef = context.getServiceReference(IAgentLocation.SERVICE_NAME); if (locationRef == null) throw new RuntimeException("Unable to instantiate p2 agent because agent location is not available"); //$NON-NLS-1$ - AgentLocation location = (AgentLocation) context.getService(locationRef); + IAgentLocation location = (IAgentLocation) context.getService(locationRef); if (location == null) throw new RuntimeException("Unable to instantiate p2 agent because agent location is not available"); //$NON-NLS-1$ ServiceReference agentProviderRef = context.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME); IProvisioningAgentProvider provider = (IProvisioningAgentProvider) context.getService(agentProviderRef); try { - agent = provider.createAgent(URIUtil.toURI(location.getURL())); + agent = provider.createAgent(location.getRootLocation()); agentRegistration = context.registerService(IProvisioningAgent.class.getName(), agent, null); } catch (Exception e) { //we can't proceed without an agent, so fail early - final String msg = "Unable to instantiate p2 agent at location " + location.getURL(); //$NON-NLS-1$ + final String msg = "Unable to instantiate p2 agent at location " + location.getRootLocation(); //$NON-NLS-1$ LogHelper.log(new Status(IStatus.ERROR, ID, msg, e)); throw new RuntimeException(msg); } diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF index 7c35657dc..66e0e7647 100644 --- a/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.metadata.repository/META-INF/MANIFEST.MF @@ -45,7 +45,6 @@ Import-Package: javax.xml.parsers, org.eclipse.equinox.internal.p2.repository.helpers, org.eclipse.equinox.internal.provisional.p2.core, org.eclipse.equinox.internal.provisional.p2.core.eventbus, - org.eclipse.equinox.internal.provisional.p2.core.location, org.eclipse.equinox.internal.provisional.p2.metadata, org.eclipse.equinox.internal.provisional.p2.metadata.query, org.eclipse.equinox.internal.provisional.p2.repository, diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java index e589b0bf4..eee6622e4 100644 --- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java +++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CacheManager.java @@ -11,20 +11,19 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.metadata.repository; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.io.*; import java.net.URI; -import java.net.URL; import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.ecf.filetransfer.UserCancelledException; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; -import org.eclipse.equinox.internal.p2.core.helpers.URLUtil; import org.eclipse.equinox.internal.p2.repository.*; import org.eclipse.equinox.internal.p2.repository.Activator; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.SynchronousProvisioningListener; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.repository.*; import org.eclipse.osgi.util.NLS; @@ -37,7 +36,7 @@ import org.eclipse.osgi.util.NLS; * was created for the repository. */ public class CacheManager { - private final AgentLocation agentLocation; + private final IAgentLocation agentLocation; /** * IStateful implementation of BufferedOutputStream. Class is used to get the status from @@ -61,7 +60,7 @@ public class CacheManager { } - public CacheManager(AgentLocation agentLocation) { + public CacheManager(IAgentLocation agentLocation) { this.agentLocation = agentLocation; } @@ -241,8 +240,7 @@ public class CacheManager { * Returns the file corresponding to the data area to be used by the cache manager. */ private File getCacheDirectory() { - URL dataArea = agentLocation.getDataArea(Activator.ID + "/cache/"); //$NON-NLS-1$ - return URLUtil.toFile(dataArea); + return URIUtil.toFile(agentLocation.getDataArea(Activator.ID + "/cache/")); //$NON-NLS-1$ } /** diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java index 22b792f7e..0c8d522dd 100644 --- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java +++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryComponent.java @@ -11,8 +11,8 @@ package org.eclipse.equinox.internal.p2.metadata.repository; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.core.IAgentLocation; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; @@ -25,7 +25,7 @@ public class MetadataRepositoryComponent implements IAgentServiceFactory { MetadataRepositoryManager manager = new MetadataRepositoryManager(); final IProvisioningEventBus eventBus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME); manager.setEventBus(eventBus); - CacheManager cache = new CacheManager((AgentLocation) agent.getService(AgentLocation.SERVICE_NAME)); + CacheManager cache = new CacheManager((IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME)); cache.setEventBus(eventBus); Activator.cacheManager = cache;//todo avoid global cache return manager; diff --git a/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF index ab4ec69b4..4ceb61a64 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.metadata/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-SymbolicName: org.eclipse.equinox.p2.metadata;singleton:=true Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin -Bundle-Version: 1.0.100.qualifier +Bundle-Version: 2.0.0.qualifier Export-Package: org.eclipse.equinox.internal.p2.metadata; x-friends:="org.eclipse.equinox.p2.metadata.generator, org.eclipse.equinox.p2.metadata.repository, diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQuery.java index d7f938403..41de77a7c 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQuery.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQuery.java @@ -21,7 +21,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable; * * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. - * + * @since 2.0 */ public interface IQuery { diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java index e589b0bf4..eee6622e4 100644 --- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/CacheManager.java @@ -11,20 +11,19 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.metadata.repository; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.io.*; import java.net.URI; -import java.net.URL; import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.ecf.filetransfer.UserCancelledException; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; -import org.eclipse.equinox.internal.p2.core.helpers.URLUtil; import org.eclipse.equinox.internal.p2.repository.*; import org.eclipse.equinox.internal.p2.repository.Activator; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.SynchronousProvisioningListener; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.repository.*; import org.eclipse.osgi.util.NLS; @@ -37,7 +36,7 @@ import org.eclipse.osgi.util.NLS; * was created for the repository. */ public class CacheManager { - private final AgentLocation agentLocation; + private final IAgentLocation agentLocation; /** * IStateful implementation of BufferedOutputStream. Class is used to get the status from @@ -61,7 +60,7 @@ public class CacheManager { } - public CacheManager(AgentLocation agentLocation) { + public CacheManager(IAgentLocation agentLocation) { this.agentLocation = agentLocation; } @@ -241,8 +240,7 @@ public class CacheManager { * Returns the file corresponding to the data area to be used by the cache manager. */ private File getCacheDirectory() { - URL dataArea = agentLocation.getDataArea(Activator.ID + "/cache/"); //$NON-NLS-1$ - return URLUtil.toFile(dataArea); + return URIUtil.toFile(agentLocation.getDataArea(Activator.ID + "/cache/")); //$NON-NLS-1$ } /** diff --git a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF index b98e671d4..f75b757a4 100644 --- a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF @@ -39,14 +39,12 @@ Import-Package: javax.xml.parsers, org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing, org.eclipse.equinox.internal.provisional.p2.core, org.eclipse.equinox.internal.provisional.p2.core.eventbus, - org.eclipse.equinox.internal.provisional.p2.core.location, org.eclipse.equinox.internal.provisional.p2.director, org.eclipse.equinox.internal.provisional.p2.directorywatcher, org.eclipse.equinox.internal.provisional.p2.engine, org.eclipse.equinox.internal.provisional.p2.engine.phases, org.eclipse.equinox.internal.provisional.p2.metadata, org.eclipse.equinox.internal.provisional.p2.metadata.query, - org.eclipse.equinox.p2.metadata.query, org.eclipse.equinox.internal.provisional.p2.metadata.repository, org.eclipse.equinox.internal.provisional.p2.repository, org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository, @@ -54,6 +52,7 @@ Import-Package: javax.xml.parsers, org.eclipse.equinox.internal.provisional.spi.p2.repository, org.eclipse.equinox.p2.core, org.eclipse.equinox.p2.internal.repository.tools, + org.eclipse.equinox.p2.metadata.query, org.eclipse.equinox.spi.p2.publisher, org.eclipse.internal.provisional.equinox.p2.jarprocessor, org.eclipse.osgi.service.datalocation, diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java index ae123c9c0..4428ed2cd 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java @@ -10,14 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.director; -import java.net.*; +import org.eclipse.equinox.p2.core.IAgentLocation; + +import java.net.URI; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.director.DirectorActivator; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.engine.*; @@ -64,17 +65,9 @@ public class RollbackTest extends AbstractProvisioningTest { } private IMetadataRepository getRollbackRepository() throws ProvisionException { - try { - IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); - URL location = ((AgentLocation) ServiceHelper.getService(DirectorActivator.context, AgentLocation.class.getName())).getDataArea(DirectorActivator.PI_DIRECTOR); - return repoMan.loadRepository(URIUtil.toURI(new URL(location, "rollback")), null); - } catch (MalformedURLException e) { - fail("0.02", e); - return null; - } catch (URISyntaxException e) { - fail("0.03", e); - return null; - } + IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + URI location = ((IAgentLocation) ServiceHelper.getService(DirectorActivator.context, IAgentLocation.class.getName())).getDataArea(DirectorActivator.PI_DIRECTOR); + return repoMan.loadRepository(URIUtil.append(location, "rollback"), null); } public void testRollbackProfileProperties() { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java index 15d011f39..754ab6b1d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.io.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -18,7 +20,6 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; @@ -246,7 +247,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { profile = (Profile) registry.getProfile(PROFILE_NAME); assertTrue(registry.isCurrent(profile)); - AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(TestActivator.getContext(), AgentLocation.SERVICE_NAME); + IAgentLocation agentLocation = (IAgentLocation) ServiceHelper.getService(TestActivator.getContext(), IAgentLocation.SERVICE_NAME); SimpleProfileRegistry simpleRegistry2 = new SimpleProfileRegistry(SimpleProfileRegistry.getDefaultRegistryDirectory(agentLocation)); profile2 = (Profile) simpleRegistry2.getProfile(PROFILE_NAME); simpleRegistry2.lockProfile(profile2); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java index 14764bbcc..68bedc1df 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java @@ -10,12 +10,12 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.full; -import java.util.*; +import java.util.HashMap; +import java.util.Map; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; @@ -24,7 +24,6 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; @@ -99,21 +98,5 @@ public class DirectorTest extends AbstractProvisioningTest { IInstallableUnit[] result = (IInstallableUnit[]) p.query(new InstallableUnitQuery(allRoots[0].getId(), VersionRange.emptyRange), new Collector(), null).toArray(IInstallableUnit.class); assertEquals(result.length, (!doUninstall ? 1 : 0)); result = (IInstallableUnit[]) p.query(new InstallableUnitQuery("toolingdefault", VersionRange.emptyRange), new Collector(), null).toArray(IInstallableUnit.class); - - ensureFragmentAssociationIsNotPersisted(mgr); - } - - private void ensureFragmentAssociationIsNotPersisted(IMetadataRepositoryManager mgr) throws ProvisionException { - //Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=177661 - AgentLocation location = (AgentLocation) ServiceHelper.getService(TestActivator.getContext(), AgentLocation.class.getName()); - mgr.removeRepository(location.getMetadataRepositoryURI()); - IMetadataRepository repo = null; - repo = mgr.loadRepository(location.getMetadataRepositoryURI(), null); - Iterator it = repo.query(new InstallableUnitQuery("org.eclipse.equinox.simpleconfigurator", VersionRange.emptyRange), new Collector(), null).iterator(); - if (!it.hasNext()) - return; - IInstallableUnit sc = (IInstallableUnit) it.next(); - if (sc.isResolved()) - fail("The repository should not store resolved installable units"); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java index 004752c03..7846afc94 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java @@ -10,23 +10,24 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata.repository; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.io.File; import java.io.IOException; import java.lang.reflect.Field; -import java.net.*; +import java.net.URI; +import java.net.URISyntaxException; import java.util.*; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.internal.p2.core.helpers.URLUtil; import org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager; import org.eclipse.equinox.internal.p2.updatesite.metadata.UpdateSiteMetadataRepositoryFactory; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.SynchronousProvisioningListener; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; @@ -327,9 +328,9 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest { */ public void testMetadataCachingLocalRepo() throws ProvisionException { File repoLocation = getTempLocation(); - AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(TestActivator.getContext(), AgentLocation.class.getName()); - URL dataArea = agentLocation.getDataArea("org.eclipse.equinox.p2.metadata.repository/cache/"); - File dataAreaFile = URLUtil.toFile(dataArea); + IAgentLocation agentLocation = (IAgentLocation) ServiceHelper.getService(TestActivator.getContext(), IAgentLocation.class.getName()); + URI dataArea = agentLocation.getDataArea("org.eclipse.equinox.p2.metadata.repository/cache/"); + File dataAreaFile = URIUtil.toFile(dataArea); File cacheFileXML = new File(dataAreaFile, "content" + repoLocation.hashCode() + ".xml"); File cacheFileJAR = new File(dataAreaFile, "content" + repoLocation.hashCode() + ".jar"); @@ -349,9 +350,9 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest { URI repoLocation = new URI("http://download.eclipse.org/eclipse/updates/3.4milestones/"); if (!repoAvailable(repoLocation)) return; - AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(TestActivator.getContext(), AgentLocation.class.getName()); - URL dataArea = agentLocation.getDataArea("org.eclipse.equinox.p2.metadata.repository/cache/"); - File dataAreaFile = URLUtil.toFile(dataArea); + IAgentLocation agentLocation = (IAgentLocation) ServiceHelper.getService(TestActivator.getContext(), IAgentLocation.class.getName()); + URI dataArea = agentLocation.getDataArea("org.eclipse.equinox.p2.metadata.repository/cache/"); + File dataAreaFile = URIUtil.toFile(dataArea); File cacheFileXML = new File(dataAreaFile, "content" + repoLocation.hashCode() + ".xml"); File cacheFileJAR = new File(dataAreaFile, "content" + repoLocation.hashCode() + ".jar"); File cacheFile; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UtilTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UtilTest.java index e1b3bfe17..4e9f35eb8 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UtilTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UtilTest.java @@ -10,18 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.touchpoint.eclipse; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.io.File; import java.net.MalformedURLException; -import java.net.URISyntaxException; import java.util.Collections; import java.util.Properties; import junit.framework.Test; import junit.framework.TestSuite; -import org.eclipse.core.runtime.URIUtil; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Activator; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.ITouchpointData; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; @@ -47,12 +46,8 @@ public class UtilTest extends AbstractProvisioningTest { public void testDefaultBundlePool() { IProfile profile = createProfile("test"); - AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName()); - try { - assertEquals(URIUtil.toURI(agentLocation.getDataArea("org.eclipse.equinox.p2.touchpoint.eclipse")), Util.getBundlePoolLocation(profile)); - } catch (URISyntaxException e) { - fail("0.99", e); - } + IAgentLocation agentLocation = (IAgentLocation) ServiceHelper.getService(Activator.getContext(), IAgentLocation.class.getName()); + assertEquals(agentLocation.getDataArea("org.eclipse.equinox.p2.touchpoint.eclipse"), Util.getBundlePoolLocation(profile)); } public void testExplicitBundlePool() throws MalformedURLException { diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF index 2ff17fed1..ba0d91a26 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/META-INF/MANIFEST.MF @@ -13,7 +13,6 @@ Import-Package: javax.xml.parsers, org.eclipse.equinox.internal.provisional.frameworkadmin, org.eclipse.equinox.internal.provisional.p2.artifact.repository, org.eclipse.equinox.internal.provisional.p2.core, - org.eclipse.equinox.internal.provisional.p2.core.location, org.eclipse.equinox.internal.provisional.p2.director;resolution:=optional, org.eclipse.equinox.internal.provisional.p2.engine, org.eclipse.equinox.internal.provisional.p2.metadata, @@ -22,6 +21,7 @@ Import-Package: javax.xml.parsers, org.eclipse.equinox.internal.provisional.p2.repository, org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository, org.eclipse.equinox.internal.simpleconfigurator.manipulator, + org.eclipse.equinox.p2.core, org.eclipse.equinox.p2.metadata.query, org.eclipse.equinox.p2.publisher;resolution:=optional, org.eclipse.equinox.p2.publisher.eclipse;resolution:=optional, diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java index d432a4e6d..04da6ccfd 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java @@ -11,8 +11,6 @@ package org.eclipse.equinox.internal.p2.touchpoint.eclipse; import java.io.IOException; -import java.net.URISyntaxException; -import org.eclipse.core.runtime.URIUtil; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; @@ -61,12 +59,7 @@ public class LazyManipulator implements Manipulator { } //TODO These values should be inserted by a configuration unit (bug 204124) manipulator.getConfigData().setProperty("eclipse.p2.profile", profile.getProfileId()); //$NON-NLS-1$ - try { - manipulator.getConfigData().setProperty("eclipse.p2.data.area", URIUtil.toURI(Util.getAgentLocation().getURL()).toString()); //$NON-NLS-1$ - } catch (URISyntaxException e) { - LogHelper.log(Util.createError(Messages.error_loading_manipulator, e)); - throw new IllegalStateException(Messages.error_loading_manipulator); - } + manipulator.getConfigData().setProperty("eclipse.p2.data.area", Util.getAgentLocation().getRootLocation().toString()); //$NON-NLS-1$ } public static FrameworkAdmin getFrameworkAdmin() { diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java index 68784218c..789ab8f7f 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.touchpoint.eclipse; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.io.*; import java.net.*; import java.util.*; @@ -20,7 +22,6 @@ import org.eclipse.equinox.internal.p2.core.helpers.*; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; @@ -53,8 +54,8 @@ public class Util { */ public static final int AGGREGATE_CACHE_EXTENSIONS = 0x04; - public static AgentLocation getAgentLocation() { - return (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName()); + public static IAgentLocation getAgentLocation() { + return (IAgentLocation) ServiceHelper.getService(Activator.getContext(), IAgentLocation.class.getName()); } public static IArtifactRepositoryManager getArtifactRepositoryManager() { @@ -65,16 +66,10 @@ public class Util { String path = profile.getProperty(IProfile.PROP_CACHE); if (path != null) return new File(path).toURI(); - AgentLocation location = getAgentLocation(); + IAgentLocation location = getAgentLocation(); if (location == null) return null; - try { - return URIUtil.toURI(location.getDataArea(Activator.ID)); - } catch (URISyntaxException e) { - // unexpected, URLs should be pre-checked - LogHelper.log(new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e)); - throw new RuntimeException(e); - } + return location.getDataArea(Activator.ID); } public static synchronized IFileArtifactRepository getBundlePoolRepository(IProfile profile) { diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF index edb4e9e6d..a875461fb 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF @@ -10,10 +10,10 @@ Import-Package: org.eclipse.equinox.internal.p2.core.helpers, org.eclipse.equinox.internal.p2.engine, org.eclipse.equinox.internal.provisional.p2.artifact.repository, org.eclipse.equinox.internal.provisional.p2.core, - org.eclipse.equinox.internal.provisional.p2.core.location, org.eclipse.equinox.internal.provisional.p2.engine, org.eclipse.equinox.internal.provisional.p2.metadata, org.eclipse.equinox.internal.provisional.p2.repository, + org.eclipse.equinox.p2.core, org.eclipse.osgi.util;version="1.0.0", org.osgi.framework;version="1.3.0" Bundle-ActivationPolicy: lazy diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Util.java index b9f79725f..8f256590a 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Util.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Util.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.touchpoint.natives; +import org.eclipse.equinox.p2.core.IAgentLocation; + import java.io.*; import java.net.URI; import java.util.*; @@ -20,7 +22,6 @@ import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; import org.eclipse.osgi.util.NLS; @@ -39,8 +40,8 @@ public class Util { return profile.getProperty(IProfile.PROP_INSTALL_FOLDER); } - private static AgentLocation getAgentLocation() { - return (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName()); + private static IAgentLocation getAgentLocation() { + return (IAgentLocation) ServiceHelper.getService(Activator.getContext(), IAgentLocation.class.getName()); } public static IArtifactRepositoryManager getArtifactRepositoryManager() { @@ -72,8 +73,10 @@ public class Util { } static private URI getDownloadCacheLocation() { - AgentLocation location = getAgentLocation(); - return (location != null ? location.getArtifactRepositoryURI() : null); + IAgentLocation location = getAgentLocation(); + if (location == null) + return null; + return URIUtil.append(location.getDataArea("org.eclipse.equinox.p2.core"), "cache/"); //$NON-NLS-1$ //$NON-NLS-2$ } /** |