Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2012-07-31 20:37:30 +0000
committerThomas Watson2012-08-01 20:56:55 +0000
commit86589632ed10c11b9f60986daa52a6db1cc98e02 (patch)
tree2bc1ed708f6a2361317dddb375787a46cc7f8a85 /bundles/org.eclipse.osgi/supplement/src
parentee069e190b7e3ad3eef2dcc1c150aac081c3111c (diff)
downloadrt.equinox.framework-86589632ed10c11b9f60986daa52a6db1cc98e02.tar.gz
rt.equinox.framework-86589632ed10c11b9f60986daa52a6db1cc98e02.tar.xz
rt.equinox.framework-86589632ed10c11b9f60986daa52a6db1cc98e02.zip
update loader and log to use new container
Diffstat (limited to 'bundles/org.eclipse.osgi/supplement/src')
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/BasicLocation.java52
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaNio.java8
2 files changed, 24 insertions, 36 deletions
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/BasicLocation.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/BasicLocation.java
index 9892e470c..f8c2e35e8 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/BasicLocation.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/BasicLocation.java
@@ -13,7 +13,7 @@ package org.eclipse.osgi.internal.location;
import java.io.File;
import java.io.IOException;
import java.net.URL;
-import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
+import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.util.NLS;
@@ -21,6 +21,9 @@ import org.eclipse.osgi.util.NLS;
* Internal class.
*/
public class BasicLocation implements Location {
+ public static final String PROP_OSGI_LOCKING = "osgi.locking"; //$NON-NLS-1$
+ private static String DEFAULT_LOCK_FILENAME = ".metadata/.lock"; //$NON-NLS-1$
+
static class MockLocker implements Locker {
/**
* @throws IOException
@@ -42,32 +45,20 @@ public class BasicLocation implements Location {
}
final private boolean isReadOnly;
- private URL location = null;
- private Location parent;
final private URL defaultValue;
final private String property;
final private String dataAreaPrefix;
+ final private EquinoxConfiguration environmentInfo;
+ final private boolean debug;
+
+ private URL location = null;
+ private Location parent;
// locking related fields
private File lockFile;
private Locker locker;
- public static final String PROP_OSGI_LOCKING = "osgi.locking"; //$NON-NLS-1$
- private static String DEFAULT_LOCK_FILENAME = ".metadata/.lock"; //$NON-NLS-1$
- public static boolean DEBUG;
-
- private static boolean isRunningWithNio() {
- try {
- Class.forName("java.nio.channels.FileLock"); //$NON-NLS-1$
- } catch (ClassNotFoundException e) {
- return false;
- }
- return true;
- }
-
- public static Locker createLocker(File lock, String lockMode) {
- if (lockMode == null)
- lockMode = FrameworkProperties.getProperty(PROP_OSGI_LOCKING);
+ public static Locker createLocker(File lock, String lockMode, boolean debug) {
if ("none".equals(lockMode)) //$NON-NLS-1$
return new MockLocker();
@@ -75,25 +66,20 @@ public class BasicLocation implements Location {
return new Locker_JavaIo(lock);
if ("java.nio".equals(lockMode)) { //$NON-NLS-1$
- if (isRunningWithNio())
- return new Locker_JavaNio(lock);
- // TODO should we return null here. NIO was requested but we could not do it...
- return new Locker_JavaIo(lock);
+ return new Locker_JavaNio(lock, debug);
}
// Backup case if an invalid value has been specified
- if (isRunningWithNio())
- return new Locker_JavaNio(lock);
- return new Locker_JavaIo(lock);
-
+ return new Locker_JavaNio(lock, debug);
}
- public BasicLocation(String property, URL defaultValue, boolean isReadOnly, String dataAreaPrefix) {
- super();
+ public BasicLocation(String property, URL defaultValue, boolean isReadOnly, String dataAreaPrefix, EquinoxConfiguration environmentInfo) {
this.property = property;
this.defaultValue = defaultValue;
this.isReadOnly = isReadOnly;
this.dataAreaPrefix = dataAreaPrefix == null ? "" : dataAreaPrefix; //$NON-NLS-1$
+ this.environmentInfo = environmentInfo;
+ this.debug = environmentInfo.getDebug().DEBUG_LOCATION;
}
public boolean allowsDefault() {
@@ -167,7 +153,7 @@ public class BasicLocation implements Location {
lockFile = file;
location = value;
if (property != null)
- FrameworkProperties.setProperty(property, location.toExternalForm());
+ environmentInfo.setConfiguration(property, location.toExternalForm());
return lock;
}
@@ -236,8 +222,8 @@ public class BasicLocation implements Location {
private void setLocker(File lock) {
if (locker != null)
return;
- String lockMode = FrameworkProperties.getProperty(PROP_OSGI_LOCKING);
- locker = createLocker(lock, lockMode);
+ String lockMode = environmentInfo.getConfiguration(PROP_OSGI_LOCKING);
+ locker = createLocker(lock, lockMode, debug);
}
public synchronized void release() {
@@ -246,7 +232,7 @@ public class BasicLocation implements Location {
}
public Location createLocation(Location parentLocation, URL defaultLocation, boolean readonly) {
- BasicLocation result = new BasicLocation(null, defaultLocation, readonly, dataAreaPrefix);
+ BasicLocation result = new BasicLocation(null, defaultLocation, readonly, dataAreaPrefix, environmentInfo);
result.setParent(parentLocation);
return result;
}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaNio.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaNio.java
index 69657b699..d6319fe5f 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaNio.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaNio.java
@@ -22,11 +22,13 @@ import org.eclipse.osgi.util.NLS;
*/
public class Locker_JavaNio implements Locker {
private final File lockFile;
+ private final boolean debug;
private FileLock fileLock;
private RandomAccessFile raFile;
- public Locker_JavaNio(File lockFile) {
+ public Locker_JavaNio(File lockFile, boolean debug) {
this.lockFile = lockFile;
+ this.debug = debug;
}
public synchronized boolean lock() throws IOException {
@@ -39,7 +41,7 @@ public class Locker_JavaNio implements Locker {
fileLock = raFile.getChannel().tryLock(0, 1, false);
} catch (IOException ioe) {
// print exception if debugging
- if (BasicLocation.DEBUG)
+ if (debug)
System.out.println(NLS.bind(EclipseAdaptorMsg.location_cannotLock, lockFile));
// produce a more specific message for clients
String specificMessage = NLS.bind(EclipseAdaptorMsg.location_cannotLockNIO, new Object[] {lockFile, ioe.getMessage(), "\"-D" + BasicLocation.PROP_OSGI_LOCKING + "=none\""}); //$NON-NLS-1$ //$NON-NLS-2$
@@ -89,7 +91,7 @@ public class Locker_JavaNio implements Locker {
try {
tempLock = temp.getChannel().tryLock(0, 1, false);
} catch (IOException ioe) {
- if (BasicLocation.DEBUG)
+ if (debug)
System.out.println(NLS.bind(EclipseAdaptorMsg.location_cannotLock, lockFile));
// produce a more specific message for clients
String specificMessage = NLS.bind(EclipseAdaptorMsg.location_cannotLockNIO, new Object[] {lockFile, ioe.getMessage(), "\"-D" + BasicLocation.PROP_OSGI_LOCKING + "=none\""}); //$NON-NLS-1$ //$NON-NLS-2$

Back to the top