Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2010-01-08 22:49:57 +0000
committerThomas Watson2010-01-08 22:49:57 +0000
commitf683b85bb9dfc02038965eeb637c43747fb1ab98 (patch)
tree88dfc4056d8ac178be0ad67fdde2b24b647e6d4c /bundles/org.eclipse.osgi/supplement
parentaceb073cec7aae53502521a6e1b79ab5b6de64d9 (diff)
downloadrt.equinox.framework-f683b85bb9dfc02038965eeb637c43747fb1ab98.tar.gz
rt.equinox.framework-f683b85bb9dfc02038965eeb637c43747fb1ab98.tar.xz
rt.equinox.framework-f683b85bb9dfc02038965eeb637c43747fb1ab98.zip
Bug 177783 - need a way to get state locations for bundlesv20100108
Diffstat (limited to 'bundles/org.eclipse.osgi/supplement')
-rw-r--r--bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java21
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/datalocation/Location.java25
3 files changed, 43 insertions, 5 deletions
diff --git a/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF
index fab062d9e..d8ff0dee5 100644
--- a/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF
@@ -6,7 +6,7 @@ Bundle-Version: 1.3.0.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.osgi.framework.log;version="1.0",
- org.eclipse.osgi.service.datalocation;version="1.2",
+ org.eclipse.osgi.service.datalocation;version="1.3",
org.eclipse.osgi.service.debug;version="1.1",
org.eclipse.osgi.service.environment;version="1.3",
org.eclipse.osgi.service.localization;version="1.1",
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java
index 7dba75f12..d73ef479a 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 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
@@ -43,6 +43,7 @@ public class BasicLocation implements Location {
private Location parent;
final private URL defaultValue;
final private String property;
+ final private String dataAreaPrefix;
// locking related fields
private File lockFile;
@@ -84,11 +85,12 @@ public class BasicLocation implements Location {
}
- public BasicLocation(String property, URL defaultValue, boolean isReadOnly) {
+ public BasicLocation(String property, URL defaultValue, boolean isReadOnly, String dataAreaPrefix) {
super();
this.property = property;
this.defaultValue = defaultValue;
this.isReadOnly = isReadOnly;
+ this.dataAreaPrefix = dataAreaPrefix == null ? "" : dataAreaPrefix; //$NON-NLS-1$
}
public boolean allowsDefault() {
@@ -238,8 +240,21 @@ public class BasicLocation implements Location {
}
public Location createLocation(Location parentLocation, URL defaultLocation, boolean readonly) {
- BasicLocation result = new BasicLocation(null, defaultLocation, readonly);
+ BasicLocation result = new BasicLocation(null, defaultLocation, readonly, dataAreaPrefix);
result.setParent(parentLocation);
return result;
}
+
+ public URL getDataArea(String filename) throws IOException {
+ URL base = getURL();
+ if (base == null)
+ throw new IOException(EclipseAdaptorMsg.location_notSet);
+ String prefix = base.toExternalForm();
+ if (prefix.length() > 0 && prefix.charAt(prefix.length() - 1) != '/')
+ prefix += '/';
+ filename = filename.replace('\\', '/');
+ if (filename.length() > 0 && filename.charAt(0) == '/')
+ filename.substring(1);
+ return new URL(prefix + dataAreaPrefix + filename);
+ }
}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/datalocation/Location.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/datalocation/Location.java
index 29e52360f..8ae36588f 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/datalocation/Location.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/datalocation/Location.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2010 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
@@ -199,4 +199,27 @@ public interface Location {
* @since 3.4
*/
public Location createLocation(Location parent, URL defaultValue, boolean readonly);
+
+ /**
+ * Returns a URL to the specified path within this location. The path
+ * of the returned URL may not exist yet. It is the responsibility of the
+ * client to create the content of the data area returned if it does not exist.
+ * <p>
+ * This method can be used to obtain a private area within the given location.
+ * For example use the symbolic name of a bundle to obtain a data area specific
+ * to that bundle.
+ * </p>
+ * <p>
+ * Clients should check if the location is read only before writing anything
+ * to the returned data area. An <code>IOException</code> will be thrown if
+ * this method is called and the location URL has not been set and there is
+ * no default value for this location.
+ * </p>
+ *
+ * @param path the name of the path to get from this location
+ * @return the URL to the data area with the specified path.
+ * @throws IOException if the location URL is not already set
+ * @since 3.6
+ */
+ public URL getDataArea(String path) throws IOException;
}

Back to the top