Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.osgi/supplement')
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties10
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/FrameworkProperties.java233
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java11
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Tokenizer.java18
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java9
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java76
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/Debug.java (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/Debug.java)194
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/EclipseDebugTrace.java)8
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/FrameworkDebugOptions.java)56
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/FrameworkDebugTraceEntry.java (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/FrameworkDebugTraceEntry.java)2
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/BasicLocation.java (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java)54
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/EclipseAdaptorMessages.properties (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMessages.properties)0
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/EclipseAdaptorMsg.java (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg.java)4
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/LocationHelper.java (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/LocationHelper.java)2
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker.java (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker.java)2
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaIo.java (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker_JavaIo.java)2
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaNio.java (renamed from bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker_JavaNio.java)10
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java8
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java10
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java13
20 files changed, 238 insertions, 484 deletions
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties
index e0e3f9d60..7174046a1 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties
@@ -63,3 +63,13 @@ STARTLEVEL_CANT_CHANGE_SYSTEMBUNDLE_STARTLEVEL=The System Bundle's start level c
CANNOT_SET_CONTEXTFINDER=The context finder has not been installed.
URL_HANDLER_INCORRECT_TYPE=The service property "{0}" is not the correct type for the service "{1}" registered by the bundle "{2}"
+
+HEADER_REQUIRED=The \"{0}\" header must be specified
+HEADER_PACKAGE_DUPLICATES=Cannot import a package more than once \"{0}\"
+HEADER_PACKAGE_JAVA=Cannot specify java.* packages in Import/Export headers \"{0}\"
+HEADER_VERSION_ERROR=The attributes \"{0}\" and \"{1}\" must match
+HEADER_EXPORT_ATTR_ERROR=Specifying \"{0}\" in the \"{1}\" header is not permitted
+HEADER_DIRECTIVE_DUPLICATES=Duplicate directives are not permitted \"{0}\"
+HEADER_ATTRIBUTE_DUPLICATES=Duplicate attributes are not permitted \"{0}\"
+HEADER_EXTENSION_ERROR=Extension bundle is not a fragment to the system bundle \"{0}\"
+
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/FrameworkProperties.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/FrameworkProperties.java
deleted file mode 100644
index 7767c0512..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/FrameworkProperties.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Cognos Incorporated, 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
- *
- *******************************************************************************/
-package org.eclipse.osgi.framework.internal.core;
-
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.security.CodeSource;
-import java.util.*;
-import org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorMsg;
-import org.eclipse.osgi.util.NLS;
-
-/*
- * This class should be used in ALL places in the framework implementation to get "system" properties.
- * The static methods on this class should be used instead of the System#getProperty, System#setProperty etc methods.
- */
-public class FrameworkProperties {
-
- /**@GuardedBy FrameworkProperties.class*/
- private static Properties properties;
-
- // A flag of some sort will have to be supported.
- // Many existing plugins get framework propeties directly from System instead of BundleContext.
- // Note that the OSGi TCK is one example where this property MUST be set to false because many TCK bundles set and read system properties.
- private static final String USING_SYSTEM_PROPERTIES_KEY = "osgi.framework.useSystemProperties"; //$NON-NLS-1$
- private static final String PROP_FRAMEWORK = "osgi.framework"; //$NON-NLS-1$
- private static final String PROP_INSTALL_AREA = "osgi.install.area"; //$NON-NLS-1$
-
- public static Properties getProperties() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPropertiesAccess();
- return internalGetProperties(null);
- }
-
- public static String getProperty(String key) {
- return getProperty(key, null);
- }
-
- public static String getProperty(String key, String defaultValue) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPropertyAccess(key);
- return internalGetProperties(null).getProperty(key, defaultValue);
- }
-
- public static String setProperty(String key, String value) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new PropertyPermission(key, "write")); //$NON-NLS-1$
- return (String) internalGetProperties(null).put(key, value);
- }
-
- public static String clearProperty(String key) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new PropertyPermission(key, "write")); //$NON-NLS-1$
- return (String) internalGetProperties(null).remove(key);
- }
-
- private static synchronized Properties internalGetProperties(String usingSystemProperties) {
- if (properties == null) {
- Properties systemProperties = System.getProperties();
- if (usingSystemProperties == null)
- usingSystemProperties = systemProperties.getProperty(USING_SYSTEM_PROPERTIES_KEY);
- if (usingSystemProperties == null || usingSystemProperties.equalsIgnoreCase(Boolean.TRUE.toString())) {
- properties = systemProperties;
- } else {
- // use systemProperties for a snapshot
- // also see requirements in Bundlecontext.getProperty(...))
- properties = new Properties();
- // snapshot of System properties for uses of getProperties who expect to see framework properties set as System properties
- // we need to do this for all system properties because the properties object is used to back
- // BundleContext#getProperty method which expects all system properties to be available
- synchronized (systemProperties) {
- // bug 360198 - must synchronize on systemProperties to avoid concurrent modification exception
- properties.putAll(systemProperties);
- }
- }
- }
- return properties;
- }
-
- public static synchronized void setProperties(Map<String, String> input) {
- if (input == null) {
- // just use internal props; note that this will reuse a previous set of properties if they were set
- internalGetProperties("false"); //$NON-NLS-1$
- return;
- }
- properties = null;
- Properties toSet = internalGetProperties("false"); //$NON-NLS-1$
- for (Iterator<String> keys = input.keySet().iterator(); keys.hasNext();) {
- String key = keys.next();
- Object value = input.get(key);
- if (value instanceof String) {
- toSet.setProperty(key, (String) value);
- continue;
- }
- value = input.get(key);
- if (value != null)
- toSet.put(key, value);
- else
- toSet.remove(key);
- }
- }
-
- public static synchronized boolean inUse() {
- return properties != null;
- }
-
- public static void initializeProperties() {
- // initialize some framework properties that must always be set
- if (getProperty(PROP_FRAMEWORK) == null || getProperty(PROP_INSTALL_AREA) == null) {
- CodeSource cs = FrameworkProperties.class.getProtectionDomain().getCodeSource();
- if (cs == null)
- throw new IllegalArgumentException(NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_PROPS_NOT_SET, PROP_FRAMEWORK + ", " + PROP_INSTALL_AREA)); //$NON-NLS-1$
- URL url = cs.getLocation();
- // allow props to be preset
- if (getProperty(PROP_FRAMEWORK) == null)
- setProperty(PROP_FRAMEWORK, url.toExternalForm());
- if (getProperty(PROP_INSTALL_AREA) == null) {
- String filePart = url.getFile();
- setProperty(PROP_INSTALL_AREA, filePart.substring(0, filePart.lastIndexOf('/')));
- }
- }
- // always decode these properties
- setProperty(PROP_FRAMEWORK, decode(getProperty(PROP_FRAMEWORK)));
- setProperty(PROP_INSTALL_AREA, decode(getProperty(PROP_INSTALL_AREA)));
- }
-
- public static String decode(String urlString) {
- //try to use Java 1.4 method if available
- try {
- Class<? extends URLDecoder> clazz = URLDecoder.class;
- Method method = clazz.getDeclaredMethod("decode", new Class[] {String.class, String.class}); //$NON-NLS-1$
- //first encode '+' characters, because URLDecoder incorrectly converts
- //them to spaces on certain class library implementations.
- if (urlString.indexOf('+') >= 0) {
- int len = urlString.length();
- StringBuffer buf = new StringBuffer(len);
- for (int i = 0; i < len; i++) {
- char c = urlString.charAt(i);
- if (c == '+')
- buf.append("%2B"); //$NON-NLS-1$
- else
- buf.append(c);
- }
- urlString = buf.toString();
- }
- Object result = method.invoke(null, new Object[] {urlString, "UTF-8"}); //$NON-NLS-1$
- if (result != null)
- return (String) result;
- } catch (Exception e) {
- //JDK 1.4 method not found -- fall through and decode by hand
- }
- //decode URL by hand
- boolean replaced = false;
- byte[] encodedBytes = urlString.getBytes();
- int encodedLength = encodedBytes.length;
- byte[] decodedBytes = new byte[encodedLength];
- int decodedLength = 0;
- for (int i = 0; i < encodedLength; i++) {
- byte b = encodedBytes[i];
- if (b == '%') {
- byte enc1 = encodedBytes[++i];
- byte enc2 = encodedBytes[++i];
- b = (byte) ((hexToByte(enc1) << 4) + hexToByte(enc2));
- replaced = true;
- }
- decodedBytes[decodedLength++] = b;
- }
- if (!replaced)
- return urlString;
- try {
- return new String(decodedBytes, 0, decodedLength, "UTF-8"); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- //use default encoding
- return new String(decodedBytes, 0, decodedLength);
- }
- }
-
- private static int hexToByte(byte b) {
- switch (b) {
- case '0' :
- return 0;
- case '1' :
- return 1;
- case '2' :
- return 2;
- case '3' :
- return 3;
- case '4' :
- return 4;
- case '5' :
- return 5;
- case '6' :
- return 6;
- case '7' :
- return 7;
- case '8' :
- return 8;
- case '9' :
- return 9;
- case 'A' :
- case 'a' :
- return 10;
- case 'B' :
- case 'b' :
- return 11;
- case 'C' :
- case 'c' :
- return 12;
- case 'D' :
- case 'd' :
- return 13;
- case 'E' :
- case 'e' :
- return 14;
- case 'F' :
- case 'f' :
- return 15;
- default :
- throw new IllegalArgumentException("Switch error decoding URL"); //$NON-NLS-1$
- }
- }
-}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java
index fd32c8c28..a09bc6ee7 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java
@@ -81,8 +81,17 @@ public class Msg extends NLS {
public static String URL_HANDLER_INCORRECT_TYPE;
+ public static String HEADER_REQUIRED;
+ public static String HEADER_PACKAGE_DUPLICATES;
+ public static String HEADER_PACKAGE_JAVA;
+ public static String HEADER_VERSION_ERROR;
+ public static String HEADER_EXPORT_ATTR_ERROR;
+ public static String HEADER_DIRECTIVE_DUPLICATES;
+ public static String HEADER_ATTRIBUTE_DUPLICATES;
+ public static String HEADER_EXTENSION_ERROR;
+
static {
// initialize resource bundles
NLS.initializeMessages(BUNDLE_NAME, Msg.class);
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Tokenizer.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Tokenizer.java
index 2cbf602d9..33310209a 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Tokenizer.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Tokenizer.java
@@ -110,7 +110,6 @@ public class Tokenizer {
StringBuffer sb = new StringBuffer();
cur++; /* skip quote */
char c = '\0';
- int begin = cur;
for (; cur < max; cur++) {
c = val[cur];
// this is an escaped char
@@ -126,19 +125,18 @@ public class Tokenizer {
}
sb.append(c);
}
- int count = cur - begin;
+
if (c == '\"') {
cur++;
- }
+ } // TODO else error; no closing quote?
+
cursor = cur;
- if (count > 0) {
- skipWhiteSpace();
- return sb.toString();
- }
- } else /* not a quoted string; same as token */
- {
- return getToken(terminals);
+ skipWhiteSpace();
+ return sb.toString();
+
}
+ /* not a quoted string; same as token */
+ return getToken(terminals);
}
return (null);
}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java
index 9582ee5f5..6db71a435 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java
@@ -15,7 +15,6 @@ import java.io.*;
import java.util.*;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
-import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
/**
* ReliableFile class used by ReliableFileInputStream and ReliableOutputStream.
@@ -71,7 +70,7 @@ public class ReliableFile {
*/
public static final String PROP_MAX_GENERATIONS = "osgi.ReliableFile.maxGenerations"; //$NON-NLS-1$
/**
- * @see org.eclipse.core.runtime.internal.adaptor.BasicLocation#PROP_OSGI_LOCKING
+ * @see org.eclipse.osgi.internal.location.BasicLocation#PROP_OSGI_LOCKING
*/
public static final String PROP_OSGI_LOCKING = "osgi.locking"; //$NON-NLS-1$
@@ -92,7 +91,7 @@ public class ReliableFile {
private static final Object lastGenerationLock = new Object();
static {
- String prop = FrameworkProperties.getProperty(PROP_MAX_BUFFER);
+ String prop = System.getProperty(PROP_MAX_BUFFER);
int tmpMaxInput = 128 * 1024; //128k
if (prop != null) {
try {
@@ -103,7 +102,7 @@ public class ReliableFile {
maxInputStreamBuffer = tmpMaxInput;
int tmpDefaultMax = 2;
- prop = FrameworkProperties.getProperty(PROP_MAX_GENERATIONS);
+ prop = System.getProperty(PROP_MAX_GENERATIONS);
if (prop != null) {
try {
tmpDefaultMax = Integer.parseInt(prop);
@@ -112,7 +111,7 @@ public class ReliableFile {
}
defaultMaxGenerations = tmpDefaultMax;
- prop = FrameworkProperties.getProperty(PROP_OSGI_LOCKING);
+ prop = System.getProperty(PROP_OSGI_LOCKING);
boolean tmpFileSharing = true;
if (prop != null) {
if (prop.equals("none")) { //$NON-NLS-1$
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java
index 2e654b16c..562738f73 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java
@@ -14,10 +14,9 @@ package org.eclipse.osgi.framework.util;
import java.io.*;
import java.net.*;
import java.security.*;
-import java.util.Properties;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
-import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
+import org.eclipse.osgi.container.Module;
import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
@@ -70,43 +69,10 @@ public class SecureAction {
*/
public String getProperty(final String property) {
if (System.getSecurityManager() == null)
- return FrameworkProperties.getProperty(property);
+ return System.getProperty(property);
return AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
- return FrameworkProperties.getProperty(property);
- }
- }, controlContext);
- }
-
- /**
- * Returns a system property. Same as calling
- * System.getProperty(String,String).
- * @param property the property key.
- * @param def the default value if the property key does not exist.
- * @return the value of the property or the def value if the property
- * does not exist.
- */
- public String getProperty(final String property, final String def) {
- if (System.getSecurityManager() == null)
- return FrameworkProperties.getProperty(property, def);
- return AccessController.doPrivileged(new PrivilegedAction<String>() {
- public String run() {
- return FrameworkProperties.getProperty(property, def);
- }
- }, controlContext);
- }
-
- /**
- * Returns the system properties. Same as calling
- * System.getProperties().
- * @return the system properties.
- */
- public Properties getProperties() {
- if (System.getSecurityManager() == null)
- return FrameworkProperties.getProperties();
- return AccessController.doPrivileged(new PrivilegedAction<Properties>() {
- public Properties run() {
- return FrameworkProperties.getProperties();
+ return System.getProperty(property);
}
}, controlContext);
}
@@ -213,6 +179,16 @@ public class SecureAction {
}, controlContext).booleanValue();
}
+ public boolean mkdirs(final File file) {
+ if (System.getSecurityManager() == null)
+ return file.mkdirs();
+ return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ public Boolean run() {
+ return file.mkdirs() ? Boolean.TRUE : Boolean.FALSE;
+ }
+ }, controlContext).booleanValue();
+ }
+
/**
* Returns true if a file is a directory, otherwise false is returned. Same as calling
* file.isDirectory().
@@ -430,20 +406,20 @@ public class SecureAction {
}
/**
- * Starts a bundle.
- * @param bundle the bundle to start
+ * Starts a module.
+ * @param module the module to start
* @param options the start options
* @throws BundleException
*/
- public void start(final Bundle bundle, final int options) throws BundleException {
+ public void start(final Module module, final Module.StartOptions... options) throws BundleException {
if (System.getSecurityManager() == null) {
- bundle.start(options);
+ module.start(options);
return;
}
try {
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() throws BundleException {
- bundle.start(options);
+ module.start(options);
return null;
}
}, controlContext);
@@ -455,12 +431,14 @@ public class SecureAction {
}
}
- /**
- * Starts a bundle
- * @param bundle
- * @throws BundleException
- */
- public void start(final Bundle bundle) throws BundleException {
- start(bundle, 0);
+ public BundleContext getContext(final Bundle bundle) {
+ if (System.getSecurityManager() == null) {
+ return bundle.getBundleContext();
+ }
+ return AccessController.doPrivileged(new PrivilegedAction<BundleContext>() {
+ public BundleContext run() {
+ return bundle.getBundleContext();
+ }
+ }, controlContext);
}
}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/Debug.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/Debug.java
index b9443df43..ced7f37cc 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/Debug.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/Debug.java
@@ -9,10 +9,12 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.osgi.framework.debug;
+package org.eclipse.osgi.internal.debug;
import java.io.PrintStream;
import java.lang.reflect.*;
+import org.eclipse.osgi.internal.framework.EquinoxContainer;
+import org.eclipse.osgi.service.debug.DebugOptions;
/**
* This class has debug constants which can be used by the Framework implementation
@@ -21,160 +23,174 @@ import java.lang.reflect.*;
*/
public class Debug {
/**
- * Indicates if tracing is enabled
+ * Base debug option key (org.eclispe.osgi).
*/
- public static boolean DEBUG_ENABLED = false;
-
+ public static final String ECLIPSE_OSGI = EquinoxContainer.NAME;
/**
- * General debug flag.
+ * General Debug option key.
*/
- public static boolean DEBUG_GENERAL = false; // "debug"
+ public static final String OPTION_DEBUG_GENERAL = ECLIPSE_OSGI + "/debug"; //$NON-NLS-1$
/**
- * Bundle time debug flag.
+ * Bundle time Debug option key.
*/
- public static boolean DEBUG_BUNDLE_TIME = false; //"debug.bundleTime"
+ // TODO remove this or use it somewhere
+ public static final String OPTION_DEBUG_BUNDLE_TIME = ECLIPSE_OSGI + "/debug/bundleTime"; //$NON-NLS-1$
/**
- * Loader debug flag.
+ * Loader Debug option key.
*/
- public static boolean DEBUG_LOADER = false; // "debug.loader"
+ public static final String OPTION_DEBUG_LOADER = ECLIPSE_OSGI + "/debug/loader"; //$NON-NLS-1$
/**
- * Events debug flag.
+ * Events Debug option key.
*/
- public static boolean DEBUG_EVENTS = false; // "debug.events"
+ public static final String OPTION_DEBUG_EVENTS = ECLIPSE_OSGI + "/debug/events"; //$NON-NLS-1$
/**
- * Services debug flag.
+ * Services Debug option key.
*/
- public static boolean DEBUG_SERVICES = false; // "debug.services"
-
+ public static final String OPTION_DEBUG_SERVICES = ECLIPSE_OSGI + "/debug/services"; //$NON-NLS-1$
/**
- * Hooks debug flag.
+ * Services Debug option key.
*/
- public static boolean DEBUG_HOOKS = false; // "debug.hooks"
+ public static final String OPTION_DEBUG_HOOKS = ECLIPSE_OSGI + "/debug/hooks"; //$NON-NLS-1$
/**
- * Packages debug flag.
+ * Packages Debug option key.
*/
- // TODO remove this or use it somewhere
- public static boolean DEBUG_PACKAGES = false; // "debug.packages"
+ public static final String OPTION_DEBUG_PACKAGES = ECLIPSE_OSGI + "/debug/packages"; //$NON-NLS-1$
/**
- * Manifest debug flag.
+ * Manifest Debug option key.
*/
- public static boolean DEBUG_MANIFEST = false; // "debug.manifest"
+ public static final String OPTION_DEBUG_MANIFEST = ECLIPSE_OSGI + "/debug/manifest"; //$NON-NLS-1$
/**
- * Filter debug flag.
+ * Filter Debug option key.
*/
- public static boolean DEBUG_FILTER = false; // "debug.filter"
+ public static final String OPTION_DEBUG_FILTER = ECLIPSE_OSGI + "/debug/filter"; //$NON-NLS-1$
/**
- * Security debug flag.
+ * Security Debug option key.
*/
- public static boolean DEBUG_SECURITY = false; // "debug.security"
+ public static final String OPTION_DEBUG_SECURITY = ECLIPSE_OSGI + "/debug/security"; //$NON-NLS-1$
/**
- * Start level debug flag.
+ * Start level Debug option key.
*/
- public static boolean DEBUG_STARTLEVEL = false; // "debug.startlevel"
+ public static final String OPTION_DEBUG_STARTLEVEL = ECLIPSE_OSGI + "/debug/startlevel"; //$NON-NLS-1$
/**
- * PackageAdmin debug flag.
+ * PackageAdmin Debug option key.
*/
- public static boolean DEBUG_PACKAGEADMIN = false; // "debug.packageadmin"
+ public static final String OPTION_DEBUG_PACKAGEADMIN = ECLIPSE_OSGI + "/debug/packageadmin"; //$NON-NLS-1$
/**
- * PackageAdmin timing debug flag.
+ * PackageAdmin timing Debug option key.
*/
- // TODO remove this or use it somewhere
- public static boolean DEBUG_PACKAGEADMIN_TIMING = false; //"debug.packageadmin/timing"
+ public static final String OPTION_DEBUG_PACKAGEADMIN_TIMING = ECLIPSE_OSGI + "/debug/packageadmin/timing"; //$NON-NLS-1$
/**
- * Message debug flag.
+ * Monitor activation Debug option key.
*/
- public static boolean DEBUG_MESSAGE_BUNDLES = false; //"/debug/messageBundles"
+ public static final String OPTION_MONITOR_ACTIVATION = ECLIPSE_OSGI + "/monitor/activation"; //$NON-NLS-1$
/**
- * Monitor activation debug flag.
+ * Message bundles Debug option key.
*/
- public static boolean MONITOR_ACTIVATION = false; // "monitor/bundles"
+ public static final String OPTION_DEBUG_MESSAGE_BUNDLES = ECLIPSE_OSGI + "/debug/messageBundles"; //$NON-NLS-1$
+
+ public static final String OPTION_DEBUG_LOCATION = ECLIPSE_OSGI + "/debug/location"; //$NON-NLS-1$
/**
- * Base debug option key (org.eclispe.osgi).
+ * Indicates if tracing is enabled
*/
- public static final String ECLIPSE_OSGI = "org.eclipse.osgi"; //$NON-NLS-1$
+ public boolean DEBUG_ENABLED = false;
+
+ // these static debug options are left overs because it would be messy to fix references to them
+ // this means that if multiple frameworks are using this class these debug options may get overwritten
+ public static boolean STATIC_DEBUG_GENERAL = false; // "debug"
+ public static boolean STATIC_DEBUG_MANIFEST = false; // "debug.manifest"
+ public static boolean STATIC_DEBUG_MESSAGE_BUNDLES = false; //"/debug/messageBundles"
+
/**
- * General Debug option key.
+ * General debug flag.
*/
- public static final String OPTION_DEBUG_GENERAL = ECLIPSE_OSGI + "/debug"; //$NON-NLS-1$
+ public boolean DEBUG_GENERAL = false; // "debug"
/**
- * Bundle time Debug option key.
+ * Bundle time debug flag.
*/
- // TODO remove this or use it somewhere
- public static final String OPTION_DEBUG_BUNDLE_TIME = ECLIPSE_OSGI + "/debug/bundleTime"; //$NON-NLS-1$
+ public boolean DEBUG_BUNDLE_TIME = false; //"debug.bundleTime"
/**
- * Loader Debug option key.
+ * Loader debug flag.
*/
- public static final String OPTION_DEBUG_LOADER = ECLIPSE_OSGI + "/debug/loader"; //$NON-NLS-1$
+ public boolean DEBUG_LOADER = false; // "debug.loader"
/**
- * Events Debug option key.
+ * Events debug flag.
*/
- public static final String OPTION_DEBUG_EVENTS = ECLIPSE_OSGI + "/debug/events"; //$NON-NLS-1$
+ public boolean DEBUG_EVENTS = false; // "debug.events"
/**
- * Services Debug option key.
+ * Services debug flag.
*/
- public static final String OPTION_DEBUG_SERVICES = ECLIPSE_OSGI + "/debug/services"; //$NON-NLS-1$
+ public boolean DEBUG_SERVICES = false; // "debug.services"
+
/**
- * Services Debug option key.
+ * Hooks debug flag.
*/
- public static final String OPTION_DEBUG_HOOKS = ECLIPSE_OSGI + "/debug/hooks"; //$NON-NLS-1$
+ public boolean DEBUG_HOOKS = false; // "debug.hooks"
/**
- * Packages Debug option key.
+ * Packages debug flag.
*/
- public static final String OPTION_DEBUG_PACKAGES = ECLIPSE_OSGI + "/debug/packages"; //$NON-NLS-1$
+ // TODO remove this or use it somewhere
+ public boolean DEBUG_PACKAGES = false; // "debug.packages"
/**
- * Manifest Debug option key.
+ * Manifest debug flag.
*/
- public static final String OPTION_DEBUG_MANIFEST = ECLIPSE_OSGI + "/debug/manifest"; //$NON-NLS-1$
+ public boolean DEBUG_MANIFEST = false; // "debug.manifest"
/**
- * Filter Debug option key.
+ * Filter debug flag.
*/
- public static final String OPTION_DEBUG_FILTER = ECLIPSE_OSGI + "/debug/filter"; //$NON-NLS-1$
+ public boolean DEBUG_FILTER = false; // "debug.filter"
/**
- * Security Debug option key.
+ * Security debug flag.
*/
- public static final String OPTION_DEBUG_SECURITY = ECLIPSE_OSGI + "/debug/security"; //$NON-NLS-1$
+ public boolean DEBUG_SECURITY = false; // "debug.security"
/**
- * Start level Debug option key.
+ * Start level debug flag.
*/
- public static final String OPTION_DEBUG_STARTLEVEL = ECLIPSE_OSGI + "/debug/startlevel"; //$NON-NLS-1$
+ public boolean DEBUG_STARTLEVEL = false; // "debug.startlevel"
/**
- * PackageAdmin Debug option key.
+ * PackageAdmin debug flag.
*/
- public static final String OPTION_DEBUG_PACKAGEADMIN = ECLIPSE_OSGI + "/debug/packageadmin"; //$NON-NLS-1$
+ public boolean DEBUG_PACKAGEADMIN = false; // "debug.packageadmin"
/**
- * PackageAdmin timing Debug option key.
+ * PackageAdmin timing debug flag.
*/
- public static final String OPTION_DEBUG_PACKAGEADMIN_TIMING = ECLIPSE_OSGI + "/debug/packageadmin/timing"; //$NON-NLS-1$
+ // TODO remove this or use it somewhere
+ public boolean DEBUG_PACKAGEADMIN_TIMING = false; //"debug.packageadmin/timing"
/**
- * Monitor activation Debug option key.
+ * Message debug flag.
*/
- public static final String OPTION_MONITOR_ACTIVATION = ECLIPSE_OSGI + "/monitor/activation"; //$NON-NLS-1$
+ public boolean DEBUG_MESSAGE_BUNDLES = false; //"/debug/messageBundles"
/**
- * Message bundles Debug option key.
+ * Monitor activation debug flag.
*/
- public static final String OPTION_DEBUG_MESSAGE_BUNDLES = ECLIPSE_OSGI + "/debug/messageBundles"; //$NON-NLS-1$
+ public boolean MONITOR_ACTIVATION = false; // "monitor/bundles"
+
+ public boolean DEBUG_LOCATION = false; // debug/location
- static {
- FrameworkDebugOptions dbgOptions = FrameworkDebugOptions.getDefault();
- if (dbgOptions != null) {
- DEBUG_ENABLED = dbgOptions.isDebugEnabled();
- DEBUG_GENERAL = dbgOptions.getBooleanOption(OPTION_DEBUG_GENERAL, false);
- DEBUG_BUNDLE_TIME = dbgOptions.getBooleanOption(OPTION_DEBUG_BUNDLE_TIME, false) || dbgOptions.getBooleanOption("org.eclipse.core.runtime/timing/startup", false); //$NON-NLS-1$
- DEBUG_LOADER = dbgOptions.getBooleanOption(OPTION_DEBUG_LOADER, false);
- DEBUG_EVENTS = dbgOptions.getBooleanOption(OPTION_DEBUG_EVENTS, false);
- DEBUG_SERVICES = dbgOptions.getBooleanOption(OPTION_DEBUG_SERVICES, false);
- DEBUG_HOOKS = dbgOptions.getBooleanOption(OPTION_DEBUG_HOOKS, false);
- DEBUG_PACKAGES = dbgOptions.getBooleanOption(OPTION_DEBUG_PACKAGES, false);
- DEBUG_MANIFEST = dbgOptions.getBooleanOption(OPTION_DEBUG_MANIFEST, false);
- DEBUG_FILTER = dbgOptions.getBooleanOption(OPTION_DEBUG_FILTER, false);
- DEBUG_SECURITY = dbgOptions.getBooleanOption(OPTION_DEBUG_SECURITY, false);
- DEBUG_STARTLEVEL = dbgOptions.getBooleanOption(OPTION_DEBUG_STARTLEVEL, false);
- DEBUG_PACKAGEADMIN = dbgOptions.getBooleanOption(OPTION_DEBUG_PACKAGEADMIN, false);
- DEBUG_PACKAGEADMIN_TIMING = dbgOptions.getBooleanOption(OPTION_DEBUG_PACKAGEADMIN_TIMING, false) || dbgOptions.getBooleanOption("org.eclipse.core.runtime/debug", false); //$NON-NLS-1$
- DEBUG_MESSAGE_BUNDLES = dbgOptions.getBooleanOption(OPTION_DEBUG_MESSAGE_BUNDLES, false);
- MONITOR_ACTIVATION = dbgOptions.getBooleanOption(OPTION_MONITOR_ACTIVATION, false);
+ public Debug(DebugOptions dbgOptions) {
+ if (dbgOptions == null) {
+ return;
}
+ DEBUG_ENABLED = dbgOptions.isDebugEnabled();
+ DEBUG_GENERAL = dbgOptions.getBooleanOption(OPTION_DEBUG_GENERAL, false);
+ STATIC_DEBUG_GENERAL = DEBUG_GENERAL;
+ DEBUG_BUNDLE_TIME = dbgOptions.getBooleanOption(OPTION_DEBUG_BUNDLE_TIME, false) || dbgOptions.getBooleanOption("org.eclipse.core.runtime/timing/startup", false); //$NON-NLS-1$
+ DEBUG_LOADER = dbgOptions.getBooleanOption(OPTION_DEBUG_LOADER, false);
+ DEBUG_EVENTS = dbgOptions.getBooleanOption(OPTION_DEBUG_EVENTS, false);
+ DEBUG_SERVICES = dbgOptions.getBooleanOption(OPTION_DEBUG_SERVICES, false);
+ DEBUG_HOOKS = dbgOptions.getBooleanOption(OPTION_DEBUG_HOOKS, false);
+ DEBUG_PACKAGES = dbgOptions.getBooleanOption(OPTION_DEBUG_PACKAGES, false);
+ DEBUG_MANIFEST = dbgOptions.getBooleanOption(OPTION_DEBUG_MANIFEST, false);
+ STATIC_DEBUG_MANIFEST = DEBUG_MANIFEST;
+ DEBUG_FILTER = dbgOptions.getBooleanOption(OPTION_DEBUG_FILTER, false);
+ DEBUG_SECURITY = dbgOptions.getBooleanOption(OPTION_DEBUG_SECURITY, false);
+ DEBUG_STARTLEVEL = dbgOptions.getBooleanOption(OPTION_DEBUG_STARTLEVEL, false);
+ DEBUG_PACKAGEADMIN = dbgOptions.getBooleanOption(OPTION_DEBUG_PACKAGEADMIN, false);
+ DEBUG_PACKAGEADMIN_TIMING = dbgOptions.getBooleanOption(OPTION_DEBUG_PACKAGEADMIN_TIMING, false) || dbgOptions.getBooleanOption("org.eclipse.core.runtime/debug", false); //$NON-NLS-1$
+ DEBUG_MESSAGE_BUNDLES = dbgOptions.getBooleanOption(OPTION_DEBUG_MESSAGE_BUNDLES, false);
+ STATIC_DEBUG_MESSAGE_BUNDLES = DEBUG_MESSAGE_BUNDLES;
+ MONITOR_ACTIVATION = dbgOptions.getBooleanOption(OPTION_MONITOR_ACTIVATION, false);
+ DEBUG_LOCATION = dbgOptions.getBooleanOption(OPTION_DEBUG_LOCATION, false);
}
/**
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/EclipseDebugTrace.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java
index de13dcd70..09cc632d4 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/EclipseDebugTrace.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/EclipseDebugTrace.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.osgi.framework.debug;
+package org.eclipse.osgi.internal.debug;
import java.io.*;
import java.security.AccessController;
@@ -369,7 +369,7 @@ class EclipseDebugTrace implements DebugTrace {
*/
private void readLogProperties() {
- String newMaxTraceFileSize = secureAction.getProperty(PROP_TRACE_SIZE_MAX);
+ String newMaxTraceFileSize = debugOptions.getConfiguration().getConfiguration(PROP_TRACE_SIZE_MAX);
if (newMaxTraceFileSize != null) {
maxTraceFileSize = Integer.parseInt(newMaxTraceFileSize);
if (maxTraceFileSize != 0 && maxTraceFileSize < DEFAULT_TRACE_FILE_MIN_SIZE) {
@@ -379,7 +379,7 @@ class EclipseDebugTrace implements DebugTrace {
}
}
- String newMaxLogFiles = secureAction.getProperty(PROP_TRACE_FILE_MAX);
+ String newMaxLogFiles = debugOptions.getConfiguration().getConfiguration(PROP_TRACE_FILE_MAX);
if (newMaxLogFiles != null) {
maxTraceFiles = Integer.parseInt(newMaxLogFiles);
if (maxTraceFiles < 1) {
@@ -523,7 +523,7 @@ class EclipseDebugTrace implements DebugTrace {
writeComment(traceWriter, EclipseDebugTrace.TRACE_FILE_VERSION_COMMENT + EclipseDebugTrace.TRACE_FILE_VERSION);
writeComment(traceWriter, EclipseDebugTrace.TRACE_FILE_VERBOSE_COMMENT + debugOptions.isVerbose());
writeComment(traceWriter, "The following option strings are specified for this debug session:"); //$NON-NLS-1$
- final String[] allOptions = FrameworkDebugOptions.getDefault().getAllOptions();
+ final String[] allOptions = debugOptions.getAllOptions();
for (int i = 0; i < allOptions.length; i++) {
writeComment(traceWriter, "\t" + allOptions[i]); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/FrameworkDebugOptions.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java
index 7c245f649..71fe5a28a 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/FrameworkDebugOptions.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/FrameworkDebugOptions.java
@@ -8,13 +8,13 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.osgi.framework.debug;
+package org.eclipse.osgi.internal.debug;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
-import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
+import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
import org.eclipse.osgi.service.debug.*;
import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
@@ -32,35 +32,33 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
private static final String OSGI_DEBUG = "osgi.debug"; //$NON-NLS-1$
private static final String OSGI_DEBUG_VERBOSE = "osgi.debug.verbose"; //$NON-NLS-1$
public static final String PROP_TRACEFILE = "osgi.tracefile"; //$NON-NLS-1$
+ /** The default name of the .options file if loading when the -debug command-line argument is used */
+ private static final String OPTIONS = ".options"; //$NON-NLS-1$
+
/** monitor used to lock the options maps */
private final Object lock = new Object();
/** A current map of all the options with values set */
private Properties options = null;
/** A map of all the disabled options with values set at the time debug was disabled */
private Properties disabledOptions = null;
- /** The singleton object of this class */
- private static FrameworkDebugOptions singleton = null;
- /** The default name of the .options file if loading when the -debug command-line argument is used */
- private static final String OPTIONS = ".options"; //$NON-NLS-1$
/** A cache of all of the bundles <code>DebugTrace</code> in the format <key,value> --> <bundle name, DebugTrace> */
- protected final static Map<String, DebugTrace> debugTraceCache = new HashMap<String, DebugTrace>();
+ protected final Map<String, DebugTrace> debugTraceCache = new HashMap<String, DebugTrace>();
/** The File object to store messages. This value may be null. */
protected File outFile = null;
/** Is verbose debugging enabled? Changing this value causes a new tracing session to start. */
protected boolean verboseDebug = true;
+ private final EquinoxConfiguration environmentInfo;
private volatile BundleContext context;
private volatile ServiceTracker<DebugOptionsListener, DebugOptionsListener> listenerTracker;
- /**
- * Internal constructor to create a <code>FrameworkDebugOptions</code> singleton object.
- */
- private FrameworkDebugOptions() {
+ public FrameworkDebugOptions(EquinoxConfiguration environmentInfo) {
+ this.environmentInfo = environmentInfo;
// check if verbose debugging was set during initialization. This needs to be set even if debugging is disabled
- this.verboseDebug = Boolean.valueOf(FrameworkProperties.getProperty(OSGI_DEBUG_VERBOSE, Boolean.TRUE.toString())).booleanValue();
+ this.verboseDebug = Boolean.valueOf(environmentInfo.getConfiguration(OSGI_DEBUG_VERBOSE, Boolean.TRUE.toString())).booleanValue();
// if no debug option was specified, don't even bother to try.
// Must ensure that the options slot is null as this is the signal to the
// platform that debugging is not enabled.
- String debugOptionsFilename = FrameworkProperties.getProperty(OSGI_DEBUG);
+ String debugOptionsFilename = environmentInfo.getConfiguration(OSGI_DEBUG);
if (debugOptionsFilename == null)
return;
options = new Properties();
@@ -69,7 +67,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
// default options location is user.dir (install location may be r/o so
// is not a good candidate for a trace options that need to be updatable by
// by the user)
- String userDir = FrameworkProperties.getProperty("user.dir").replace(File.separatorChar, '/'); //$NON-NLS-1$
+ String userDir = System.getProperty("user.dir").replace(File.separatorChar, '/'); //$NON-NLS-1$
if (!userDir.endsWith("/")) //$NON-NLS-1$
userDir += "/"; //$NON-NLS-1$
debugOptionsFilename = new File(userDir, OPTIONS).toString();
@@ -112,18 +110,6 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
this.context = null;
}
- /**
- * Returns the singleton instance of <code>FrameworkDebugOptions</code>.
- * @return the instance of <code>FrameworkDebugOptions</code>
- */
- public static FrameworkDebugOptions getDefault() {
-
- if (FrameworkDebugOptions.singleton == null) {
- FrameworkDebugOptions.singleton = new FrameworkDebugOptions();
- }
- return FrameworkDebugOptions.singleton;
- }
-
@SuppressWarnings("deprecation")
private static URL buildURL(String spec, boolean trailingSlash) {
if (spec == null)
@@ -363,7 +349,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
EclipseDebugTrace.newSession = true;
// enable platform debugging - there is no .options file
- FrameworkProperties.setProperty(OSGI_DEBUG, ""); //$NON-NLS-1$
+ environmentInfo.setConfiguration(OSGI_DEBUG, ""); //$NON-NLS-1$
if (disabledOptions != null) {
options = disabledOptions;
disabledOptions = null;
@@ -376,7 +362,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
if (options == null)
return;
// disable platform debugging.
- FrameworkProperties.clearProperty(OSGI_DEBUG);
+ environmentInfo.clearConfiguration(OSGI_DEBUG);
if (options.size() > 0) {
// Save the current options off in case debug is re-enabled
disabledOptions = options;
@@ -408,11 +394,11 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
public final DebugTrace newDebugTrace(String bundleSymbolicName, Class<?> traceEntryClass) {
DebugTrace debugTrace = null;
- synchronized (FrameworkDebugOptions.debugTraceCache) {
- debugTrace = FrameworkDebugOptions.debugTraceCache.get(bundleSymbolicName);
+ synchronized (debugTraceCache) {
+ debugTrace = debugTraceCache.get(bundleSymbolicName);
if (debugTrace == null) {
- debugTrace = new EclipseDebugTrace(bundleSymbolicName, FrameworkDebugOptions.singleton, traceEntryClass);
- FrameworkDebugOptions.debugTraceCache.put(bundleSymbolicName, debugTrace);
+ debugTrace = new EclipseDebugTrace(bundleSymbolicName, this, traceEntryClass);
+ debugTraceCache.put(bundleSymbolicName, debugTrace);
}
}
return debugTrace;
@@ -434,7 +420,7 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
public synchronized void setFile(final File traceFile) {
this.outFile = traceFile;
- FrameworkProperties.setProperty(PROP_TRACEFILE, this.outFile.getAbsolutePath());
+ environmentInfo.setConfiguration(PROP_TRACEFILE, this.outFile.getAbsolutePath());
// the file changed so start a new session
EclipseDebugTrace.newSession = true;
}
@@ -448,6 +434,10 @@ public class FrameworkDebugOptions implements DebugOptions, ServiceTrackerCustom
return this.verboseDebug;
}
+ EquinoxConfiguration getConfiguration() {
+ return this.environmentInfo;
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.osgi.service.debug.DebugOptions#setVerbose(boolean)
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/FrameworkDebugTraceEntry.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/FrameworkDebugTraceEntry.java
index 0fca678b9..98678539c 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/FrameworkDebugTraceEntry.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/debug/FrameworkDebugTraceEntry.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.osgi.framework.debug;
+package org.eclipse.osgi.internal.debug;
/**
* A framework trace entry is a bean containing all of the attributes for a single trace message.
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/osgi/internal/location/BasicLocation.java
index aa5d1f44b..f8c2e35e8 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/osgi/internal/location/BasicLocation.java
@@ -8,12 +8,12 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.core.runtime.internal.adaptor;
+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/core/runtime/internal/adaptor/EclipseAdaptorMessages.properties b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/EclipseAdaptorMessages.properties
index 4e67bcb00..4e67bcb00 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMessages.properties
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/EclipseAdaptorMessages.properties
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/EclipseAdaptorMsg.java
index 4b965a35a..4d84d8cbd 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/EclipseAdaptorMsg.java
@@ -8,12 +8,12 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.core.runtime.internal.adaptor;
+package org.eclipse.osgi.internal.location;
import org.eclipse.osgi.util.NLS;
public class EclipseAdaptorMsg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorMessages"; //$NON-NLS-1$
+ private static final String BUNDLE_NAME = "org.eclipse.osgi.internal.location.EclipseAdaptorMessages"; //$NON-NLS-1$
public static String ECLIPSE_MISSING_IMPORTED_PACKAGE;
public static String ECLIPSE_MISSING_OPTIONAL_IMPORTED_PACKAGE;
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/LocationHelper.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/LocationHelper.java
index 0180bf04c..a8ee6af5c 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/LocationHelper.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/LocationHelper.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.core.runtime.internal.adaptor;
+package org.eclipse.osgi.internal.location;
import java.io.File;
import java.net.MalformedURLException;
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker.java
index 0031f5ed6..91c224e7d 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.core.runtime.internal.adaptor;
+package org.eclipse.osgi.internal.location;
import java.io.IOException;
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker_JavaIo.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaIo.java
index a0e16699c..ebd96c94f 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker_JavaIo.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaIo.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.core.runtime.internal.adaptor;
+package org.eclipse.osgi.internal.location;
import java.io.*;
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker_JavaNio.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaNio.java
index 3009b12a9..d6319fe5f 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker_JavaNio.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/internal/location/Locker_JavaNio.java
@@ -10,7 +10,7 @@
* Danail Nachev (Prosyst) - bug 185654
* Andrei Loskutov - bug 44735
*******************************************************************************/
-package org.eclipse.core.runtime.internal.adaptor;
+package org.eclipse.osgi.internal.location;
import java.io.*;
import java.nio.channels.FileLock;
@@ -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$
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java
index 396e0e8fc..f975dfe95 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java
@@ -13,9 +13,9 @@ package org.eclipse.osgi.storagemanager;
import java.io.*;
import java.security.AccessController;
import java.util.*;
-import org.eclipse.core.runtime.internal.adaptor.*;
import org.eclipse.osgi.framework.internal.reliablefile.*;
import org.eclipse.osgi.framework.util.SecureAction;
+import org.eclipse.osgi.internal.location.*;
/**
* Storage managers provide a facility for tracking the state of a group of files having
@@ -187,7 +187,7 @@ public final class StorageManager {
return;
this.instanceFile = File.createTempFile(".tmp", ".instance", managerRoot); //$NON-NLS-1$//$NON-NLS-2$
this.instanceFile.deleteOnExit();
- instanceLocker = BasicLocation.createLocker(instanceFile, lockMode);
+ instanceLocker = BasicLocation.createLocker(instanceFile, lockMode, false);
instanceLocker.lock();
}
@@ -382,7 +382,7 @@ public final class StorageManager {
if (readOnly)
return false;
if (locker == null) {
- locker = BasicLocation.createLocker(lockFile, lockMode);
+ locker = BasicLocation.createLocker(lockFile, lockMode, false);
if (locker == null)
throw new IOException(EclipseAdaptorMsg.fileManager_cannotLock);
}
@@ -608,7 +608,7 @@ public final class StorageManager {
if (files != null) {
for (int i = 0; i < files.length; i++) {
if (files[i].endsWith(".instance") && (instanceFile == null || !files[i].equalsIgnoreCase(instanceFile.getName()))) { //$NON-NLS-1$
- Locker tmpLocker = BasicLocation.createLocker(new File(managerRoot, files[i]), lockMode);
+ Locker tmpLocker = BasicLocation.createLocker(new File(managerRoot, files[i]), lockMode, false);
if (tmpLocker.lock()) {
//If I can lock it is a file that has been left behind by a crash
tmpLocker.release();
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java
index f19cbd909..f8d3ab3e5 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java
@@ -13,9 +13,9 @@ package org.eclipse.osgi.util;
import java.io.*;
import java.util.*;
-import org.eclipse.osgi.framework.debug.Debug;
import org.eclipse.osgi.framework.internal.core.Msg;
import org.eclipse.osgi.framework.internal.core.Tokenizer;
+import org.eclipse.osgi.internal.debug.Debug;
import org.osgi.framework.BundleException;
/**
@@ -355,7 +355,7 @@ public class ManifestElement {
StringBuffer headerValue = new StringBuffer(next);
headerValues.add(next);
- if (Debug.DEBUG_MANIFEST)
+ if (Debug.STATIC_DEBUG_MANIFEST)
Debug.print("parseHeader: " + next); //$NON-NLS-1$
boolean directive = false;
char c = tokenizer.getChar();
@@ -379,7 +379,7 @@ public class ManifestElement {
if (c == ';' || c == ',' || c == '\0') /* more */{
headerValues.add(next);
headerValue.append(";").append(next); //$NON-NLS-1$
- if (Debug.DEBUG_MANIFEST)
+ if (Debug.STATIC_DEBUG_MANIFEST)
Debug.print(";" + next); //$NON-NLS-1$
}
}
@@ -413,7 +413,7 @@ public class ManifestElement {
if (val == null)
throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value), BundleException.MANIFEST_ERROR);
- if (Debug.DEBUG_MANIFEST)
+ if (Debug.STATIC_DEBUG_MANIFEST)
Debug.print(";" + next + "=" + val); //$NON-NLS-1$ //$NON-NLS-2$
try {
if (directive)
@@ -433,7 +433,7 @@ public class ManifestElement {
}
}
headerElements.add(manifestElement);
- if (Debug.DEBUG_MANIFEST)
+ if (Debug.STATIC_DEBUG_MANIFEST)
Debug.println(""); //$NON-NLS-1$
if (c == ',') /* another manifest element */
continue parseloop;
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java
index dbe8f0e66..d69e96403 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java
@@ -17,10 +17,9 @@ import java.lang.reflect.Modifier;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
-import org.eclipse.osgi.framework.debug.Debug;
-import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
+import org.eclipse.osgi.internal.debug.Debug;
/**
* Common superclass for all message bundle classes. Provides convenience
@@ -59,7 +58,7 @@ public abstract class NLS {
private static final String IGNORE = "ignore"; //$NON-NLS-1$
private static final boolean ignoreWarnings = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() {
- return IGNORE.equals(FrameworkProperties.getProperty(PROP_WARNINGS));
+ return IGNORE.equals(System.getProperty(PROP_WARNINGS));
}
});
@@ -286,7 +285,7 @@ public abstract class NLS {
// log it and continue. This means that the field will (most likely) be un-initialized and
// will fail later in the code and if so then we will see both the NPE and this error.
String value = "NLS missing message: " + field.getName() + " in: " + bundleName; //$NON-NLS-1$ //$NON-NLS-2$
- if (Debug.DEBUG_MESSAGE_BUNDLES)
+ if (Debug.STATIC_DEBUG_MESSAGE_BUNDLES)
System.out.println(value);
log(SEVERITY_WARNING, value, null);
if (!isAccessible)
@@ -338,7 +337,7 @@ public abstract class NLS {
}
}
computeMissingMessages(bundleName, clazz, fields, fieldArray, isAccessible);
- if (Debug.DEBUG_MESSAGE_BUNDLES)
+ if (Debug.STATIC_DEBUG_MESSAGE_BUNDLES)
System.out.println("Time to load message bundle: " + bundleName + " was " + (System.currentTimeMillis() - start) + "ms."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@@ -411,7 +410,7 @@ public abstract class NLS {
return null;
if (fieldObject == null) {
final String msg = "NLS unused message: " + key + " in: " + bundleName;//$NON-NLS-1$ //$NON-NLS-2$
- if (Debug.DEBUG_MESSAGE_BUNDLES)
+ if (Debug.STATIC_DEBUG_MESSAGE_BUNDLES)
System.out.println(msg);
log(SEVERITY_WARNING, msg, null);
return null;
@@ -440,4 +439,4 @@ public abstract class NLS {
return null;
}
}
-} \ No newline at end of file
+}

Back to the top