Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2006-12-08 10:06:54 -0500
committerThomas Watson2006-12-08 10:06:54 -0500
commitd8ae8ed3d709e38071c28a799eae0befec1e5168 (patch)
tree00091a3ac4ba0c582729cf9352b8dd4625f28b06
parent666fdebf1b5dee3d2cfbe0abfd4dbd44a9da9172 (diff)
downloadrt.equinox.framework-d8ae8ed3d709e38071c28a799eae0befec1e5168.tar.gz
rt.equinox.framework-d8ae8ed3d709e38071c28a799eae0befec1e5168.tar.xz
rt.equinox.framework-d8ae8ed3d709e38071c28a799eae0befec1e5168.zip
Delete supplement source folder from 3.2 maintenance stream
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java188
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMessages.properties105
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg.java139
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker.java22
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker_JavaIo.java53
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker_JavaNio.java66
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/Debug.java354
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/FrameworkDebugOptions.java172
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties73
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/FrameworkProperties.java74
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java98
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Tokenizer.java152
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java829
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream.java209
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFileOutputStream.java182
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/log/FrameworkLog.java93
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/log/FrameworkLogEntry.java174
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java340
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/datalocation/Location.java142
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/debug/DebugOptions.java79
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/localization/BundleLocalization.java36
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/urlconversion/URLConverter.java62
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/ManagedOutputStream.java102
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java926
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java456
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java183
26 files changed, 0 insertions, 5309 deletions
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
deleted file mode 100644
index 2eb36a2dc..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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.core.runtime.internal.adaptor;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import org.eclipse.core.runtime.adaptor.*;
-import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
-import org.eclipse.osgi.service.datalocation.Location;
-
-/**
- * Internal class.
- */
-public class BasicLocation implements Location {
- private static class MockLocker implements Locker {
- public boolean lock() throws IOException {
- // locking always successful
- return true;
- }
- public void release() {
- // nothing to release
- }
-
- }
- private boolean isReadOnly;
- private URL location = null;
- private Location parent;
- private URL defaultValue;
- private String property;
-
- // locking related fields
- private File lockFile;
- private Locker locker;
- public static final String PROP_OSGI_LOCKING = "osgi.locking"; //$NON-NLS-1$
- private static String 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);
-
- if ("none".equals(lockMode)) //$NON-NLS-1$
- return new MockLocker();
-
- if ("java.io".equals(lockMode)) //$NON-NLS-1$
- return new Locker_JavaIo(lock);
-
- if ("java.nio".equals(lockMode)) { //$NON-NLS-1$
- if (isRunningWithNio()) {
- return new Locker_JavaNio(lock);
- } else {
- // TODO should we return null here. NIO was requested but we could not do it...
- return new Locker_JavaIo(lock);
- }
- }
-
- // Backup case if an invalid value has been specified
- if (isRunningWithNio()) {
- return new Locker_JavaNio(lock);
- } else {
- return new Locker_JavaIo(lock);
- }
- }
-
- public BasicLocation(String property, URL defaultValue, boolean isReadOnly) {
- super();
- this.property = property;
- this.defaultValue = defaultValue;
- this.isReadOnly = isReadOnly;
- }
-
- public boolean allowsDefault() {
- return defaultValue != null;
- }
-
- public URL getDefault() {
- return defaultValue;
- }
-
- public Location getParentLocation() {
- return parent;
- }
-
- public synchronized URL getURL() {
- if (location == null && defaultValue != null)
- setURL(defaultValue, false);
- return location;
- }
-
- public synchronized boolean isSet() {
- return location != null;
- }
-
- public boolean isReadOnly() {
- return isReadOnly;
- }
-
- public synchronized boolean setURL(URL value, boolean lock) throws IllegalStateException {
- if (location != null)
- throw new IllegalStateException(EclipseAdaptorMsg.ECLIPSE_CANNOT_CHANGE_LOCATION);
- File file = null;
- if (value.getProtocol().equalsIgnoreCase("file")) { //$NON-NLS-1$
- try {
- String basePath = new File(value.getFile()).getCanonicalPath();
- value = new URL("file:" + basePath); //$NON-NLS-1$
- } catch (IOException e) {
- // do nothing just use the original value
- }
- file = new File(value.getFile(), LOCK_FILENAME);
- }
- lock = lock && !isReadOnly;
- if (lock) {
- try {
- if (!lock(file))
- return false;
- } catch (IOException e) {
- return false;
- }
- }
- lockFile = file;
- location = LocationManager.buildURL(value.toExternalForm(), true);
- if (property != null)
- FrameworkProperties.setProperty(property, location.toExternalForm());
- return lock;
- }
-
- public synchronized void setParent(Location value) {
- parent = value;
- }
-
- public synchronized boolean lock() throws IOException {
- if (!isSet())
- return false;
- return lock(lockFile);
- }
-
- private boolean lock(File lock) throws IOException {
- if (lock == null || isReadOnly)
- return false;
-
- File parentFile = new File(lock.getParent());
- if (!parentFile.exists())
- if (!parentFile.mkdirs())
- return false;
-
- setLocker(lock);
- if (locker == null)
- return true;
- boolean locked = false;
- try {
- locked = locker.lock();
- return locked;
- } finally {
- if (!locked)
- locker = null;
- }
- }
-
- private void setLocker(File lock) {
- if (locker != null)
- return;
- String lockMode = FrameworkProperties.getProperty(PROP_OSGI_LOCKING);
- locker = createLocker(lock, lockMode);
- }
-
- public synchronized void release() {
- if (locker != null)
- locker.release();
- }
-}
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/core/runtime/internal/adaptor/EclipseAdaptorMessages.properties
deleted file mode 100644
index b49dbf05f..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMessages.properties
+++ /dev/null
@@ -1,105 +0,0 @@
-###############################################################################
-# Copyright (c) 2004, 2006 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
-###############################################################################
-
-#External Messages for EN locale
-
-#EclipseAdaptor messages
-ECLIPSE_ADAPTOR_ERROR_XML_SERVICE=Error registering XML parser services.
-ECLIPSE_ADAPTOR_RUNTIME_ERROR=An unexpected runtime error has occurred.
-ECLIPSE_ADAPTOR_EXITING=The application will terminate.
-
-#EclipseStarter messages
-ECLIPSE_STARTUP_BUNDLE_NOT_FOUND=Bundle {0} not found.
-ECLIPSE_STARTUP_ROOTS_NOT_RESOLVED=One or more bundles are not resolved because the following root constraints are not resolved:
-ECLIPSE_STARTUP_ALL_NOT_RESOLVED=The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
-ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED=Bundle {0} was not resolved.
-ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_ACTIVE=Bundle {0} is not active.
-ECLIPSE_STARTUP_ERROR_NO_APPLICATION=Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
-#Don't use double quotes in the ECLIPSE_STARTUP_ERROR_CHECK_LOG. (See bug 86085)
-ECLIPSE_STARTUP_ERROR_CHECK_LOG=An error has occurred. See the log file\n{0}.
-ECLIPSE_STARTUP_ALREADY_RUNNING=Platform already running
-ECLIPSE_STARTUP_NOT_RUNNING=Platform not running
-ECLIPSE_STARTUP_STARTUP_ERROR=Startup error
-ECLIPSE_STARTUP_APP_ERROR=Application error
-ECLIPSE_STARTUP_SHUTDOWN_ERROR=Shutdown error
-ECLIPSE_STARTUP_INVALID_PORT=Invalid console port: {0}
-ECLIPSE_STARTUP_FAILED_FIND=Failed to find/start: {0}
-ECLIPSE_STARTUP_FAILED_INSTALL=Error installing bundle: {0}
-ECLIPSE_STARTUP_FAILED_UNINSTALL=Error uninstalling bundle: {0}
-ECLIPSE_STARTUP_FAILED_START=Error starting bundle: {0}
-ECLIPSE_STARTUP_FILEMANAGER_OPEN_ERROR=Error reading configuration: {0}
-ECLIPSE_STARTUP_PROPS_NOT_SET=Cannot start without the following system properties set: {0}
-
-#EclipseBundleData messages
-ECLIPSE_DATA_MANIFEST_NOT_FOUND=Manifest not found: {0}
-ECLIPSE_DATA_ERROR_READING_MANIFEST=Error reading manifest for bundle at the location: {0}
-
-#Console extension
-ECLIPSE_CONSOLE_NO_BUNDLE_SPECIFIED_ERROR=No bundle specified!.
-ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR=Cannot find bundle {0}.
-ECLIPSE_CONSOLE_NO_CONSTRAINTS_NO_PLATFORM_ADMIN_MESSAGE=No unresolved constraints [PlatformAdmin service is not registered].
-ECLIPSE_CONSOLE_NO_CONSTRAINTS=No unresolved constraints.
-ECLIPSE_CONSOLE_OTHER_VERSION=Bundle {0} was picked instead.
-ECLIPSE_CONSOLE_COMMANDS_HEADER=Eclipse Runtime commands.
-ECLIPSE_CONSOLE_HELP_DIAG_COMMAND_DESCRIPTION=Displays unsatisfied constraints for the specified bundle(s).
-ECLIPSE_CONSOLE_HELP_ACTIVE_COMMAND_DESCRIPTION=Displays a list of all bundles currently in the ACTIVE state.
-ECLIPSE_CONSOLE_HELP_GETPROP_COMMAND_DESCRIPTION={ name } - Displays the system properties with the given name, or all of them.
-ECLIPSE_CONSOLE_BUNDLES_ACTIVE={0} active bundle(s).
-
-#Bundle resolution messages
-ECLIPSE_MISSING_OPTIONAL_REQUIRED_BUNDLE=Missing optionally required bundle {0}.
-ECLIPSE_MISSING_REQUIRED_BUNDLE=Missing required bundle {0}.
-ECLIPSE_MISSING_IMPORTED_PACKAGE=Missing imported package {0}.
-ECLIPSE_MISSING_HOST=Missing host {0}.
-
-#Conversion messages
-ECLIPSE_CONVERTER_ERROR_CONVERTING=Error converting plugin at {0}.
-ECLIPSE_CONVERTER_ERROR_CREATING_BUNDLE_MANIFEST=Error creating bundle manifest file for {0} at {1}.
-ECLIPSE_CONVERTER_ERROR_PARSING_PLUGIN_MANIFEST=Error parsing plugin manifest file {0} at {1}.
-ECLIPSE_CONVERTER_MISSING_ATTRIBUTE=Error parsing {0} manifest. Missing attribute \"{1}\" in element \"{2}\".
-ECLIPSE_CONVERTER_PLUGIN_LIBRARY_IGNORED=Plugin library {0} ignored when creating manifest for {1}.
-ECLIPSE_CONVERTER_NO_SAX_FACTORY=No SAX factory parser has been found.
-ECLIPSE_CONVERTER_PARSE_UNKNOWNTOP_ELEMENT = Unknown element \"{0}\", found at the top level, ignored.
-ECLIPSE_CONVERTER_FILENOTFOUND = Could not find a META-INF/MANIFEST.MF, plugin.xml or a fragment.xml in {0}.
-parse_error=Error parsing manifest: {0}
-parse_errorNameLineColumn=Error parsing manifest at \"{0}\" line \"{1}\" column \"{2}\": {3}
-
-#Classloader messages
-ECLIPSE_CLASSLOADER_CANNOT_GET_HEADERS=Error loading bundle manifest for {0}. Using default auto-activation settings.
-ECLIPSE_CLASSLOADER_CONCURRENT_STARTUP=While loading class "{1}", thread "{0}" timed out waiting ({4}ms) for thread "{2}" to finish starting bundle "{3}". To avoid deadlock, thread "{0}" is proceeding but "{1}" may not be fully initialized.
-ECLIPSE_CLASSLOADER_ACTIVATION=An error occurred while automatically activating bundle {0} ({1}).
-ECLIPSE_CLASSLOADER_GENERATED_EXCEPTION=Generated exception.
-ECLIPSE_CLASSLOADER_ALREADY_STOPPED= The class \"{0}\" cannot be loaded because the system is shutting down and the plug-in \"{1}\" has already been stopped.
-ECLIPSE_CLASSLOADER_CANNOT_SET_CONTEXTFINDER=The context finder has not been installed.
-
-#CachedManifest messages
-ECLIPSE_CACHEDMANIFEST_UNEXPECTED_EXCEPTION=Unexpected exception occurred loading manifest for bundle at the location: {0}.
-
-#BundleStopper messages
-ECLIPSE_BUNDLESTOPPER_CYCLES_FOUND=Info: cycle(s) found while stopping bundles: {0}.
-ECLIPSE_BUNDLESTOPPER_ERROR_STOPPING_BUNDLE=Error while stopping \"{0}\".
-
-#Location message
-ECLIPSE_CANNOT_CHANGE_LOCATION = Cannot change the location once it is set.
-
-#NL Problem
-error_badNL=Bad value: \"{0}\" for NL. Using system default.
-
-#FileMananger messages
-fileManager_cannotLock = Unable to create lock manager.
-fileManager_couldNotSave = Could not save file table.
-fileManager_updateFailed = File update failed on one or more files.
-fileManager_illegalInReadOnlyMode = Cannot perform operation while in read-only mode.
-fileManager_notOpen = Manager is not opened.
-
-#Location messages
-location_cannotLockNIO = An error occurred while locking file \"{0}\": \"{1}\". A common reason is that the file system or Runtime Environment does not support file locking for that location. Please choose a different location, or disable file locking passing {2} as a VM argument.
-location_cannotLock = An error occurred while locking file \"{0}\".
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/core/runtime/internal/adaptor/EclipseAdaptorMsg.java
deleted file mode 100644
index a39c78513..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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.core.runtime.internal.adaptor;
-
-import java.util.Date;
-import org.eclipse.osgi.service.resolver.*;
-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$
-
- public static String ECLIPSE_MISSING_IMPORTED_PACKAGE;
- public static String ECLIPSE_MISSING_OPTIONAL_REQUIRED_BUNDLE;
- public static String ECLIPSE_MISSING_REQUIRED_BUNDLE;
- public static String ECLIPSE_MISSING_HOST;
- public static String ECLIPSE_CANNOT_CHANGE_LOCATION;
- public static String ECLIPSE_BUNDLESTOPPER_CYCLES_FOUND;
- public static String ECLIPSE_BUNDLESTOPPER_ERROR_STOPPING_BUNDLE;
- public static String ECLIPSE_CACHEDMANIFEST_UNEXPECTED_EXCEPTION;
-
- public static String fileManager_cannotLock;
- public static String fileManager_couldNotSave;
- public static String fileManager_updateFailed;
- public static String fileManager_illegalInReadOnlyMode;
- public static String fileManager_notOpen;
-
- public static String ECLIPSE_ADAPTOR_ERROR_XML_SERVICE;
- public static String ECLIPSE_ADAPTOR_RUNTIME_ERROR;
- public static String ECLIPSE_ADAPTOR_EXITING;
-
- public static String ECLIPSE_DATA_MANIFEST_NOT_FOUND;
- public static String ECLIPSE_CONVERTER_ERROR_CONVERTING;
- public static String ECLIPSE_DATA_ERROR_READING_MANIFEST;
- public static String ECLIPSE_CLASSLOADER_CANNOT_GET_HEADERS;
-
- public static String ECLIPSE_CLASSLOADER_CONCURRENT_STARTUP;
- public static String ECLIPSE_CLASSLOADER_ACTIVATION;
- public static String ECLIPSE_CLASSLOADER_ALREADY_STOPPED;
- public static String ECLIPSE_CLASSLOADER_GENERATED_EXCEPTION;
- public static String ECLIPSE_CLASSLOADER_CANNOT_SET_CONTEXTFINDER;
-
- public static String ECLIPSE_CONSOLE_COMMANDS_HEADER;
- public static String ECLIPSE_CONSOLE_HELP_DIAG_COMMAND_DESCRIPTION;
- public static String ECLIPSE_CONSOLE_HELP_ACTIVE_COMMAND_DESCRIPTION;
- public static String ECLIPSE_CONSOLE_HELP_GETPROP_COMMAND_DESCRIPTION;
- public static String ECLIPSE_CONSOLE_NO_BUNDLE_SPECIFIED_ERROR;
- public static String ECLIPSE_CONSOLE_NO_CONSTRAINTS_NO_PLATFORM_ADMIN_MESSAGE;
- public static String ECLIPSE_CONSOLE_CANNOT_FIND_BUNDLE_ERROR;
- public static String ECLIPSE_CONSOLE_NO_CONSTRAINTS;
- public static String ECLIPSE_CONSOLE_OTHER_VERSION;
- public static String ECLIPSE_CONSOLE_BUNDLES_ACTIVE;
-
- public static String ECLIPSE_STARTUP_ALREADY_RUNNING;
- public static String ECLIPSE_STARTUP_STARTUP_ERROR;
- public static String ECLIPSE_STARTUP_SHUTDOWN_ERROR;
- public static String ECLIPSE_STARTUP_ERROR_CHECK_LOG;
- public static String ECLIPSE_STARTUP_NOT_RUNNING;
- public static String ECLIPSE_STARTUP_ERROR_NO_APPLICATION;
- public static String ECLIPSE_STARTUP_ROOTS_NOT_RESOLVED;
- public static String ECLIPSE_STARTUP_ALL_NOT_RESOLVED;
- public static String ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_ACTIVE;
- public static String ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED;
- public static String ECLIPSE_STARTUP_BUNDLE_NOT_FOUND;
- public static String ECLIPSE_STARTUP_INVALID_PORT;
- public static String ECLIPSE_STARTUP_FAILED_FIND;
- public static String ECLIPSE_STARTUP_FAILED_UNINSTALL;
- public static String ECLIPSE_STARTUP_FAILED_INSTALL;
- public static String ECLIPSE_STARTUP_FAILED_START;
- public static String ECLIPSE_STARTUP_APP_ERROR;
- public static String ECLIPSE_STARTUP_FILEMANAGER_OPEN_ERROR;
- public static String ECLIPSE_STARTUP_PROPS_NOT_SET;
-
- public static String error_badNL;
-
- public static String location_cannotLock;
- public static String location_cannotLockNIO;
-
- public static String ECLIPSE_CONVERTER_FILENOTFOUND;
- public static String ECLIPSE_CONVERTER_ERROR_CREATING_BUNDLE_MANIFEST;
- public static String ECLIPSE_CONVERTER_PLUGIN_LIBRARY_IGNORED;
-
- public static String ECLIPSE_CONVERTER_ERROR_PARSING_PLUGIN_MANIFEST;
- public static String ECLIPSE_CONVERTER_MISSING_ATTRIBUTE;
- public static String parse_error;
- public static String parse_errorNameLineColumn;
-
- public static String ECLIPSE_CONVERTER_NO_SAX_FACTORY;
- public static String ECLIPSE_CONVERTER_PARSE_UNKNOWNTOP_ELEMENT;
-
- public static final String NEW_LINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- static {
- // initialize resource bundles
- NLS.initializeMessages(BUNDLE_NAME, EclipseAdaptorMsg.class);
- }
-
- public static String getResolutionFailureMessage(VersionConstraint unsatisfied) {
- if (unsatisfied.isResolved())
- throw new IllegalArgumentException();
- if (unsatisfied instanceof ImportPackageSpecification)
- return NLS.bind(ECLIPSE_MISSING_IMPORTED_PACKAGE, toString(unsatisfied));
- else if (unsatisfied instanceof BundleSpecification)
- if (((BundleSpecification) unsatisfied).isOptional())
- return NLS.bind(ECLIPSE_MISSING_OPTIONAL_REQUIRED_BUNDLE, toString(unsatisfied));
- else
- return NLS.bind(ECLIPSE_MISSING_REQUIRED_BUNDLE, toString(unsatisfied));
- else
- return NLS.bind(ECLIPSE_MISSING_HOST, toString(unsatisfied));
- }
-
- /**
- * Print a debug message to the console.
- * Pre-pend the message with the current date and the name of the current thread.
- */
- public static void debug(String message) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(new Date(System.currentTimeMillis()));
- buffer.append(" - ["); //$NON-NLS-1$
- buffer.append(Thread.currentThread().getName());
- buffer.append("] "); //$NON-NLS-1$
- buffer.append(message);
- System.out.println(buffer.toString());
- }
-
- private static String toString(VersionConstraint constraint) {
- org.eclipse.osgi.service.resolver.VersionRange versionRange = constraint.getVersionRange();
- if (versionRange == null)
- return constraint.getName();
- return constraint.getName() + '_' + versionRange;
- }
-}
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/core/runtime/internal/adaptor/Locker.java
deleted file mode 100644
index 1d3150fce..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.core.runtime.internal.adaptor;
-
-import java.io.IOException;
-
-/**
- * Internal class.
- */
-public interface Locker {
- public boolean lock() throws IOException;
-
- public void release();
-}
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/core/runtime/internal/adaptor/Locker_JavaIo.java
deleted file mode 100644
index dcc5b59ee..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker_JavaIo.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.core.runtime.internal.adaptor;
-
-import java.io.*;
-
-/**
- * Internal class.
- */
-public class Locker_JavaIo implements Locker {
- private File lockFile;
- private RandomAccessFile lockRAF;
-
- public Locker_JavaIo(File lockFile) {
- this.lockFile = lockFile;
- }
-
- public synchronized boolean lock() throws IOException {
- //if the lock file already exists, try to delete,
- //assume failure means another eclipse has it open
- if (lockFile.exists())
- lockFile.delete();
- if (lockFile.exists())
- return false;
-
- //open the lock file so other instances can't co-exist
- lockRAF = new RandomAccessFile(lockFile, "rw"); //$NON-NLS-1$
- lockRAF.writeByte(0);
-
- return true;
- }
-
- public synchronized void release() {
- try {
- if (lockRAF != null) {
- lockRAF.close();
- lockRAF = null;
- }
- } catch (IOException e) {
- //don't complain, we're making a best effort to clean up
- }
- if (lockFile != null)
- lockFile.delete();
- }
-}
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/core/runtime/internal/adaptor/Locker_JavaNio.java
deleted file mode 100644
index 8cea82caf..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/Locker_JavaNio.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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.core.runtime.internal.adaptor;
-
-import java.io.*;
-import java.nio.channels.FileLock;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Internal class.
- */
-public class Locker_JavaNio implements Locker {
- private File lockFile;
- private FileLock fileLock;
- private RandomAccessFile raFile;
-
- public Locker_JavaNio(File lockFile) {
- this.lockFile = lockFile;
- }
-
- public synchronized boolean lock() throws IOException {
- raFile = new RandomAccessFile(lockFile, "rw"); //$NON-NLS-1$
- try {
- fileLock = raFile.getChannel().tryLock();
- } catch (IOException ioe) {
- // print exception if debugging
- if (BasicLocation.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$
- throw new IOException(specificMessage);
- }
- if (fileLock != null)
- return true;
- raFile.close();
- raFile = null;
- return false;
- }
-
- public synchronized void release() {
- if (fileLock != null) {
- try {
- fileLock.release();
- } catch (IOException e) {
- //don't complain, we're making a best effort to clean up
- }
- fileLock = null;
- }
- if (raFile != null) {
- try {
- raFile.close();
- } catch (IOException e) {
- //don't complain, we're making a best effort to clean up
- }
- raFile = null;
- }
- }
-}
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/framework/debug/Debug.java
deleted file mode 100644
index 87c9486fc..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/Debug.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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.osgi.framework.debug;
-
-import java.io.PrintStream;
-import java.lang.reflect.*;
-
-/**
- * This class has debug constants which can be used by the Framework implementation
- * and Adaptor implementations
- * @since 3.1
- */
-public class Debug {
- /**
- * DEBUG flag. If set to false then the debug statements will be optimized out during compilation.
- */
- public static final boolean DEBUG = true;
-
- /**
- * Indicates if tracing is enabled
- */
- public static boolean DEBUG_ENABLED = false;
-
- /**
- * General debug flag.
- */
- public static boolean DEBUG_GENERAL = false; // "debug"
- /**
- * Bundle time debug flag.
- */
- public static boolean DEBUG_BUNDLE_TIME = false; //"debug.bundleTime"
- /**
- * Loader debug flag.
- */
- public static boolean DEBUG_LOADER = false; // "debug.loader"
- /**
- * Events debug flag.
- */
- public static boolean DEBUG_EVENTS = false; // "debug.events"
- /**
- * Services debug flag.
- */
- public static boolean DEBUG_SERVICES = false; // "debug.services"
- /**
- * Packages debug flag.
- */
- // TODO remove this or use it somewhere
- public static boolean DEBUG_PACKAGES = false; // "debug.packages"
- /**
- * Manifest debug flag.
- */
- public static boolean DEBUG_MANIFEST = false; // "debug.manifest"
- /**
- * Filter debug flag.
- */
- public static boolean DEBUG_FILTER = false; // "debug.filter"
- /**
- * Security debug flag.
- */
- public static boolean DEBUG_SECURITY = false; // "debug.security"
- /**
- * Start level debug flag.
- */
- public static boolean DEBUG_STARTLEVEL = false; // "debug.startlevel"
- /**
- * PackageAdmin debug flag.
- */
- public static boolean DEBUG_PACKAGEADMIN = false; // "debug.packageadmin"
- /**
- * PackageAdmin timing debug flag.
- */
- // TODO remove this or use it somewhere
- public static boolean DEBUG_PACKAGEADMIN_TIMING = false; //"debug.packageadmin/timing"
- /**
- * Message debug flag.
- */
- public static boolean DEBUG_MESSAGE_BUNDLES = false; //"/debug/messageBundles"
- /**
- * Monitor activation debug flag.
- */
- public static boolean MONITOR_ACTIVATION = false; // "monitor/bundles"
-
- /**
- * Base debug option key (org.eclispe.osgi).
- */
- public static final String ECLIPSE_OSGI = "org.eclipse.osgi"; //$NON-NLS-1$
- /**
- * General Debug option key.
- */
- public static final String OPTION_DEBUG_GENERAL = ECLIPSE_OSGI + "/debug"; //$NON-NLS-1$
- /**
- * Bundle time Debug option key.
- */
- // TODO remove this or use it somewhere
- public static final String OPTION_DEBUG_BUNDLE_TIME = ECLIPSE_OSGI + "/debug/bundleTime"; //$NON-NLS-1$
- /**
- * Loader Debug option key.
- */
- public static final String OPTION_DEBUG_LOADER = ECLIPSE_OSGI + "/debug/loader"; //$NON-NLS-1$
- /**
- * Events Debug option key.
- */
- public static final String OPTION_DEBUG_EVENTS = ECLIPSE_OSGI + "/debug/events"; //$NON-NLS-1$
- /**
- * Services Debug option key.
- */
- public static final String OPTION_DEBUG_SERVICES = ECLIPSE_OSGI + "/debug/services"; //$NON-NLS-1$
- /**
- * Packages Debug option key.
- */
- public static final String OPTION_DEBUG_PACKAGES = ECLIPSE_OSGI + "/debug/packages"; //$NON-NLS-1$
- /**
- * Manifest Debug option key.
- */
- public static final String OPTION_DEBUG_MANIFEST = ECLIPSE_OSGI + "/debug/manifest"; //$NON-NLS-1$
- /**
- * Filter Debug option key.
- */
- public static final String OPTION_DEBUG_FILTER = ECLIPSE_OSGI + "/debug/filter"; //$NON-NLS-1$
- /**
- * Security Debug option key.
- */
- public static final String OPTION_DEBUG_SECURITY = ECLIPSE_OSGI + "/debug/security"; //$NON-NLS-1$
- /**
- * Start level Debug option key.
- */
- public static final String OPTION_DEBUG_STARTLEVEL = ECLIPSE_OSGI + "/debug/startlevel"; //$NON-NLS-1$
- /**
- * PackageAdmin Debug option key.
- */
- public static final String OPTION_DEBUG_PACKAGEADMIN = ECLIPSE_OSGI + "/debug/packageadmin"; //$NON-NLS-1$
- /**
- * PackageAdmin timing Debug option key.
- */
- public static final String OPTION_DEBUG_PACKAGEADMIN_TIMING = ECLIPSE_OSGI + "/debug/packageadmin/timing"; //$NON-NLS-1$
- /**
- * Monitor activation Debug option key.
- */
- public static final String OPTION_MONITOR_ACTIVATION = ECLIPSE_OSGI + "/monitor/activation"; //$NON-NLS-1$
- /**
- * Message bundles Debug option key.
- */
- public static final String OPTION_DEBUG_MESSAGE_BUNDLES = ECLIPSE_OSGI + "/debug/messageBundles"; //$NON-NLS-1$
-
- static {
- FrameworkDebugOptions dbgOptions = FrameworkDebugOptions.getDefault();
- if (dbgOptions != null) {
- DEBUG_ENABLED = true;
- 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_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);
- }
- }
-
- /**
- * The PrintStream to print debug messages to.
- */
- public static PrintStream out = System.out;
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void print(boolean x) {
- out.print(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void print(char x) {
- out.print(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void print(int x) {
- out.print(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void print(long x) {
- out.print(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void print(float x) {
- out.print(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void print(double x) {
- out.print(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void print(char x[]) {
- out.print(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void print(String x) {
- out.print(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void print(Object x) {
- out.print(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void println(boolean x) {
- out.println(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void println(char x) {
- out.println(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void println(int x) {
- out.println(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void println(long x) {
- out.println(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void println(float x) {
- out.println(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void println(double x) {
- out.println(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void println(char x[]) {
- out.println(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void println(String x) {
- out.println(x);
- }
-
- /**
- * Prints x to the PrintStream
- * @param x
- */
- public static void println(Object x) {
- out.println(x);
- }
-
- /**
- * Prints t to the PrintStream
- * @param t
- */
- public static void printStackTrace(Throwable t) {
- t.printStackTrace(out);
-
- Method[] methods = t.getClass().getMethods();
-
- int size = methods.length;
- Class throwable = Throwable.class;
-
- for (int i = 0; i < size; i++) {
- Method method = methods[i];
-
- if (Modifier.isPublic(method.getModifiers()) && method.getName().startsWith("get") && throwable.isAssignableFrom(method.getReturnType()) && (method.getParameterTypes().length == 0)) { //$NON-NLS-1$
- try {
- Throwable nested = (Throwable) method.invoke(t, null);
-
- if ((nested != null) && (nested != t)) {
- out.println("Nested Exception:"); //$NON-NLS-1$
- printStackTrace(nested);
- }
- } catch (IllegalAccessException e) {
- } catch (InvocationTargetException e) {
- }
- }
- }
- }
-
-}
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/framework/debug/FrameworkDebugOptions.java
deleted file mode 100644
index 4f186fd37..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/debug/FrameworkDebugOptions.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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.osgi.framework.debug;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.Properties;
-import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
-import org.eclipse.osgi.service.debug.DebugOptions;
-
-/**
- * The DebugOptions class used by the framework to get debug options from.
- * @since 3.1
- */
-public class FrameworkDebugOptions implements DebugOptions {
- private Properties options = null;
- private static FrameworkDebugOptions singleton = null;
- private static boolean debugEnabled = true;
- private static final String OPTIONS = ".options"; //$NON-NLS-1$
-
- /**
- * Returns the singleton instance of <code>FrameworkDebugOptions</code>. If
- * debug is not enabled then <code>null</code> is returned.
- * @return the instance of <code>FrameworkDebugOptions</code>
- */
- public static FrameworkDebugOptions getDefault() {
- if (singleton == null && debugEnabled) {
- FrameworkDebugOptions result = new FrameworkDebugOptions();
- debugEnabled = result.isDebugEnabled();
- if (debugEnabled)
- singleton = result;
- }
- return singleton;
- }
-
- private static URL 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) {
- // 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 null;
- }
- }
- }
-
- private static URL adjustTrailingSlash(URL url, boolean trailingSlash) throws MalformedURLException {
- String file = url.getFile();
- 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);
- }
-
- private FrameworkDebugOptions() {
- super();
- loadOptions();
- }
-
- /**
- * @see DebugOptions#getBooleanOption(String, boolean)
- */
- public boolean getBooleanOption(String option, boolean defaultValue) {
- String optionValue = getOption(option);
- return (optionValue != null && optionValue.equalsIgnoreCase("true")) || defaultValue; //$NON-NLS-1$
- }
-
- /**
- * @see DebugOptions#getOption(String)
- */
- public String getOption(String option) {
- return options != null ? options.getProperty(option) : null;
- }
-
- /**
- * @see DebugOptions#getOption(String, String)
- */
- public String getOption(String option, String defaultValue) {
- return options != null ? options.getProperty(option, defaultValue) : defaultValue;
- }
-
- /**
- * @see DebugOptions#getIntegerOption(String, int)
- */
- public int getIntegerOption(String option, int defaultValue) {
- String value = getOption(option);
- try {
- return value == null ? defaultValue : Integer.parseInt(value);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
-
- /**
- * @see DebugOptions#setOption(String, String)
- */
- public void setOption(String option, String value) {
- if (options != null)
- options.put(option, value.trim());
- }
-
- private boolean isDebugEnabled() {
- return options != null;
- }
-
- private void loadOptions() {
- // 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"); //$NON-NLS-1$
- if (debugOptionsFilename == null)
- return;
- options = new Properties();
- URL optionsFile;
- if (debugOptionsFilename.length() == 0) {
- // 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$
- if (!userDir.endsWith("/")) //$NON-NLS-1$
- userDir += "/"; //$NON-NLS-1$
- debugOptionsFilename = new File(userDir, OPTIONS).toString();
- }
- optionsFile = buildURL(debugOptionsFilename, false);
- if (optionsFile == null) {
- System.out.println("Unable to construct URL for options file: " + debugOptionsFilename); //$NON-NLS-1$
- return;
- }
- System.out.print("Debug options:\n " + optionsFile.toExternalForm()); //$NON-NLS-1$
- try {
- InputStream input = optionsFile.openStream();
- try {
- options.load(input);
- System.out.println(" loaded"); //$NON-NLS-1$
- } finally {
- input.close();
- }
- } catch (FileNotFoundException e) {
- System.out.println(" not found"); //$NON-NLS-1$
- } catch (IOException e) {
- System.out.println(" did not parse"); //$NON-NLS-1$
- e.printStackTrace(System.out);
- }
- // trim off all the blanks since properties files don't do that.
- for (Iterator i = options.keySet().iterator(); i.hasNext();) {
- Object key = i.next();
- options.put(key, ((String) options.get(key)).trim());
- }
- if (options.size() == 0)
- options = null;
- }
-}
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
deleted file mode 100644
index ae0115d28..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties
+++ /dev/null
@@ -1,73 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2005 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
-###############################################################################
-
-#External Messages for EN locale
-ECLIPSE_OSGI_NAME=Eclipse OSGi Framework
-ECLIPSE_OSGI_VERSION=3.6.0
-OSGI_VERSION=OSGi Service Platform Release 3
-ECLIPSE_COPYRIGHT=Copyright (c) 2003, 2004 IBM Corporation and others. \nAll rights reserved. This program and the accompanying materials \nare made available under the terms of the Eclipse Public License v1.0 \nwhich accompanies this distribution, and is available at \nhttp://www.eclipse.org/legal/epl-v10.html \nContributors: \n IBM Corporation - initial API and implementation
-OSGI_SYSTEMBUNDLE_CREATE_EXCEPTION=Exception while creating System Bundle: {0}
-OSGI_SYSTEMBUNDLE_DESCRIPTION_ERROR=Unable to construct System Bundle description.
-OSGI_INTERNAL_ERROR=Internal Error in the OSGi framework. Please report this problem.
-BUNDLE_INSTALL_RECURSION_EXCEPTION=Bundle is already being installed
-BUNDLE_INSTALL_REQUIRED_EE_EXCEPTION=No match is available for the required execution environment: {0}
-BUNDLE_INSTALL_SAME_UNIQUEID=Bundle \"{0}\" version \"{1}\" has already been installed from: {2}
-BUNDLE_UNINSTALLED_EXCEPTION=Bundle \"{0}\" has been uninstalled
-BUNDLE_CONTEXT_INVALID_EXCEPTION=BundleContext is no longer valid
-BUNDLE_NATIVECODE_MATCH_EXCEPTION=No Bundle-NativeCode match
-BUNDLE_NATIVECODE_INVALID_FILTER=Invalid selection filter in Bundle-NativeCode: {0}
-BUNDLE_STATE_CHANGE_EXCEPTION=State change in progress for bundle \"{0}\" by thread \"{1}\".
-BUNDLE_REFRESH_FAILURE=PackageAdmin.refreshPackages failed to complete
-BUNDLE_ACTIVATOR_EXCEPTION=Exception in {0}.{1}() of bundle {2}.
-BUNDLE_INVALID_ACTIVATOR_EXCEPTION=The activator {0} for bundle {1} is invalid
-BUNDLE_UNRESOLVED_EXCEPTION=The bundle could not be resolved
-BUNDLE_UNRESOLVED_STATE_CONFLICT=The state indicates the bundle is resolved
-BUNDLE_UNRESOLVED_UNSATISFIED_CONSTRAINT_EXCEPTION=The bundle could not be resolved. Reason: {0}
-BUNDLE_SYSTEMBUNDLE_UNINSTALL_EXCEPTION=The System Bundle cannot be uninstalled
-BUNDLE_READ_EXCEPTION=An error occurred trying to read the bundle
-BUNDLE_CLASSPATH_ENTRY_NOT_FOUND_EXCEPTION=The Bundle-ClassPath entry \"{0}\" was not found in the bundle: {1}
-BUNDLE_NO_CLASSPATH_MATCH=The Bundle-ClassPath does not have any matching entries
-BUNDLE_NOT_IN_FRAMEWORK=The bundle does not exist in the framework: {0}
-BUNDLE_LOADER_ATTACHMENT_ERROR=Cannot attach fragment bundle \"{0}\" to resolved host \"{1}\". Try refreshing the host bundle.
-BUNDLE_FRAGMENT_CNFE=A fragment bundle cannot load classes: {0}
-BUNDLE_FRAGMENT_START=A fragment bundle cannot be started: {0}
-BUNDLE_FRAGMENT_STOP=A fragment bundle cannot be stopped: {0}
-BUNDLE_FRAGMENT_IMPORT_CONFLICT=Fragment bundle \"{0}\" attempted to import additional package \"{1}\". Try refreshing the host bundle \"{2}\".
-BUNDLE_EXTENSION_PERMISSION=Extension bundles must have AllPermission assigned.
-BUNDLE_CNFE_NOT_RESOLVED=Cannot load \"{0}"\ because the bundle \"{1}\" cannot be resolved.
-MANIFEST_INVALID_SPACE=The manifest line \"{0}\" has an invalid leading space \' \' character.
-MANIFEST_INVALID_LINE_NOCOLON=The manifest line \"{0}\" is invalid; it has no colon \':\' character after the header key.
-MANIFEST_INVALID_HEADER_EXCEPTION=Invalid manifest header {0}: \"{1}\"
-MANIFEST_IOEXCEPTION=An error occurred while reading the manifest file.
-SERVICE_FACTORY_EXCEPTION=Exception in {0}.{1}()
-SERVICE_NOT_INSTANCEOF_CLASS_EXCEPTION={0}.getService() returned a service object that is not an instanceof the service class {1}
-SERVICE_OBJECT_NULL_EXCEPTION={0}.getService() returned a null service object
-SERVICE_ARGUMENT_NULL_EXCEPTION=The service parameter is null
-SERVICE_ALREADY_UNREGISTERED_EXCEPTION=The service has been unregistered
-SERVICE_EMPTY_CLASS_LIST_EXCEPTION=The array of service names is empty
-HEADER_DUPLICATE_KEY_EXCEPTION=The key \"{0}\" already exists in another case variation
-FILTER_INVALID=The filter is invalid.
-FILTER_MISSING_LEFTPAREN=Missing \'(\' at character {0}
-FILTER_MISSING_RIGHTPAREN=Missing \')\' at character {0}
-FILTER_TRAILING_CHARACTERS=Extraneous trailing characters at character {0}
-FILTER_TERMINATED_ABRUBTLY=Filter ended abruptly
-FILTER_INVALID_OPERATOR=Invalid operator at character {0}
-FILTER_MISSING_ATTR=Missing attr at character {0}
-FILTER_MISSING_VALUE=Missing value at character {0}
-FILTER_INVALID_VALUE=Invalid value at character {0}
-PROPERTIES_INVALID_FW_STARTLEVEL=Invalid initial framework start level. Value must be a positive integer. Using Default={0}
-STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL=The requested start level of {0} is invalid. The value must be a positive integer.
-STARTLEVEL_CANT_CHANGE_SYSTEMBUNDLE_STARTLEVEL=The System Bundle's start level can not be modified.
-
-LAUNCHER_ADAPTOR_ERROR=Unable to create FrameworkAdaptor.
-LAUNCHER_INVALID_PORT=Invalid console port: {0}
-LAUNCHER_COMPONENT_MISSING=Warning: The requested component \'{0}\' is not included in this runtime.
-LAUNCHER_COMPONENT_JAR=Add \'{0}\' to the classpath.
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 95aa84c7d..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/FrameworkProperties.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.util.Properties;
-import java.util.PropertyPermission;
-
-/*
- * 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 {
-
- 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$
-
- static {
- Properties systemProperties = System.getProperties();
- String 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
- properties.putAll(systemProperties);
- }
- }
-
- public static Properties getProperties() {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPropertiesAccess();
- return properties;
- }
-
- 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 properties.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) properties.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) properties.remove(key);
- }
-}
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
deleted file mode 100644
index 2b7c3a7ca..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.osgi.framework.internal.core;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Msg extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.osgi.framework.internal.core.ExternalMessages"; //$NON-NLS-1$
-
- public static String BUNDLE_CLASSPATH_ENTRY_NOT_FOUND_EXCEPTION;
- public static String MANIFEST_INVALID_HEADER_EXCEPTION;
- public static String BUNDLE_STATE_CHANGE_EXCEPTION;
- public static String BUNDLE_UNINSTALLED_EXCEPTION;
- public static String BUNDLE_UNRESOLVED_EXCEPTION;
- public static String BUNDLE_UNRESOLVED_STATE_CONFLICT;
- public static String BUNDLE_UNRESOLVED_UNSATISFIED_CONSTRAINT_EXCEPTION;
- public static String BUNDLE_INVALID_ACTIVATOR_EXCEPTION;
- public static String BUNDLE_EXTENSION_PERMISSION;
-
- public static String SERVICE_ARGUMENT_NULL_EXCEPTION;
- public static String SERVICE_EMPTY_CLASS_LIST_EXCEPTION;
- public static String SERVICE_NOT_INSTANCEOF_CLASS_EXCEPTION;
- public static String BUNDLE_ACTIVATOR_EXCEPTION;
- public static String BUNDLE_CONTEXT_INVALID_EXCEPTION;
-
- public static String BUNDLE_READ_EXCEPTION;
- public static String BUNDLE_FRAGMENT_CNFE;
- public static String BUNDLE_FRAGMENT_START;
- public static String BUNDLE_FRAGMENT_STOP;
-
- public static String BUNDLE_CNFE_NOT_RESOLVED;
- public static String BUNDLE_LOADER_ATTACHMENT_ERROR;
-
- public static String BUNDLE_FRAGMENT_IMPORT_CONFLICT;
- public static String BUNDLE_NO_CLASSPATH_MATCH;
- public static String FILTER_INVALID;
-
- public static String BUNDLE_NATIVECODE_INVALID_FILTER;
-
- public static String FILTER_TERMINATED_ABRUBTLY;
- public static String FILTER_TRAILING_CHARACTERS;
- public static String FILTER_MISSING_LEFTPAREN;
- public static String FILTER_MISSING_RIGHTPAREN;
- public static String FILTER_INVALID_OPERATOR;
- public static String FILTER_MISSING_ATTR;
- public static String FILTER_INVALID_VALUE;
- public static String FILTER_MISSING_VALUE;
-
- public static String OSGI_SYSTEMBUNDLE_CREATE_EXCEPTION;
- public static String BUNDLE_INSTALL_RECURSION_EXCEPTION;
- public static String BUNDLE_NATIVECODE_MATCH_EXCEPTION;
- public static String BUNDLE_INSTALL_REQUIRED_EE_EXCEPTION;
- public static String BUNDLE_INSTALL_SAME_UNIQUEID;
-
- public static String ECLIPSE_OSGI_NAME;
- public static String ECLIPSE_OSGI_VERSION;
- public static String OSGI_VERSION;
- public static String ECLIPSE_COPYRIGHT;
-
- public static String OSGI_INTERNAL_ERROR;
- public static String BUNDLE_NOT_IN_FRAMEWORK;
- public static String BUNDLE_REFRESH_FAILURE;
- public static String OSGI_SYSTEMBUNDLE_DESCRIPTION_ERROR;
-
- public static String SERVICE_ALREADY_UNREGISTERED_EXCEPTION;
-
- public static String SERVICE_FACTORY_EXCEPTION;
- public static String SERVICE_OBJECT_NULL_EXCEPTION;
-
- public static String PROPERTIES_INVALID_FW_STARTLEVEL;
- public static String STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL;
- public static String STARTLEVEL_CANT_CHANGE_SYSTEMBUNDLE_STARTLEVEL;
-
- public static String BUNDLE_SYSTEMBUNDLE_UNINSTALL_EXCEPTION;
-
- public static String LAUNCHER_ADAPTOR_ERROR;
- public static String LAUNCHER_COMPONENT_JAR;
- public static String LAUNCHER_COMPONENT_MISSING;
- public static String LAUNCHER_INVALID_PORT;
-
- public static String HEADER_DUPLICATE_KEY_EXCEPTION;
- public static String MANIFEST_INVALID_SPACE;
- public static String MANIFEST_INVALID_LINE_NOCOLON;
- public static String MANIFEST_IOEXCEPTION;
-
- 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
deleted file mode 100644
index 3f6d529ce..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Tokenizer.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.osgi.framework.internal.core;
-
-/**
- * Simple tokenizer class. Used to parse data.
- */
-public class Tokenizer {
- protected char value[];
- protected int max;
- protected int cursor;
-
- public Tokenizer(String value) {
- this.value = value.toCharArray();
- max = this.value.length;
- cursor = 0;
- }
-
- private void skipWhiteSpace() {
- char[] val = value;
- int cur = cursor;
-
- for (; cur < max; cur++) {
- char c = val[cur];
- if ((c == ' ') || (c == '\t') || (c == '\n') || (c == '\r')) {
- continue;
- }
- break;
- }
- cursor = cur;
- }
-
- public String getToken(String terminals) {
- skipWhiteSpace();
- char[] val = value;
- int cur = cursor;
-
- int begin = cur;
- for (; cur < max; cur++) {
- char c = val[cur];
- if ((terminals.indexOf(c) != -1)) {
- break;
- }
- }
- cursor = cur;
- int count = cur - begin;
- if (count > 0) {
- skipWhiteSpace();
- while (count > 0 && (val[begin + count - 1] == ' ' || val[begin + count - 1] == '\t'))
- count--;
- return (new String(val, begin, count));
- }
- return (null);
- }
-
- public String getString(String terminals) {
- skipWhiteSpace();
- char[] val = value;
- int cur = cursor;
-
- if (cur < max) {
- if (val[cur] == '\"') /* if a quoted string */
- {
- cur++; /* skip quote */
- char c = '\0';
- int begin = cur;
- for (; cur < max; cur++) {
- c = val[cur];
- if (c == '\"') {
- break;
- }
- }
- int count = cur - begin;
- if (c == '\"') {
- cur++;
- }
- cursor = cur;
- if (count > 0) {
- skipWhiteSpace();
- return (new String(val, begin, count));
- }
- } else /* not a quoted string; same as token */
- {
- int begin = cur;
- for (; cur < max; cur++) {
- char c = val[cur];
- if (c == '\"') {
- // but there could be a quoted string in the middle of the string
- cur = cur + skipQuotedString(val, cur);
- } else if ((terminals.indexOf(c) != -1)) {
- break;
- }
- }
- cursor = cur;
- int count = cur - begin;
- if (count > 0) {
- skipWhiteSpace();
- while (count > 0 && (val[begin + count - 1] == ' ' || val[begin + count - 1] == '\t'))
- count--;
- return (new String(val, begin, count));
- }
- }
- }
- return (null);
- }
-
- private int skipQuotedString(char[] val, int cur) {
- cur++; /* skip quote */
- char c = '\0';
- int begin = cur;
- for (; cur < max; cur++) {
- c = val[cur];
- if (c == '\"') {
- break;
- }
- }
- int count = cur - begin;
- if (c == '\"') {
- cur++;
- }
- cursor = cur;
- if (count > 0) {
- skipWhiteSpace();
- }
- return count;
- }
-
- public char getChar() {
- int cur = cursor;
- if (cur < max) {
- cursor = cur + 1;
- return (value[cur]);
- }
- return ('\0'); /* end of value */
- }
-
- public boolean hasMoreTokens() {
- if (cursor < max) {
- return true;
- }
- return false;
- }
-}
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
deleted file mode 100644
index 0321479b0..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFile.java
+++ /dev/null
@@ -1,829 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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.osgi.framework.internal.reliablefile;
-
-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.
- * This class encapsulates all the logic for reliable file support.
- *
- */
-public class ReliableFile {
- /**
- * Open mask. Obtain the best data stream available. If the primary data
- * contents are invalid (corrupt, missing, etc.), the data for a prior
- * version may be used.
- * An IOException will be thrown if a valid data content can not be
- * determined.
- * This is mutually exclusive with <code>OPEN_FAIL_ON_PRIMARY</code>.
- */
- public static final int OPEN_BEST_AVAILABLE = 0;
- /**
- * Open mask. Obtain only the data stream for the primary file where any other
- * version will not be valid. This should be used for data streams that are
- * managed as a group as a prior contents may not match the other group data.
- * If the primary data is not invalid, a IOException will be thrown.
- * This is mutually exclusive with <code>OPEN_BEST_AVAILABLE</code>.
- */
- public static final int OPEN_FAIL_ON_PRIMARY = 1;
-
- /**
- * Use the last generation of the file
- */
- public static final int GENERATION_LATEST = 0;
- /**
- * Keep intinite backup files
- */
- public static final int GENERATIONS_INFINITE = 0;
-
- /**
- * Extension of tmp file used during writing.
- * A reliable file with this extension should
- * never be directly used.
- */
- public static final String tmpExt = ".tmp"; //$NON-NLS-1$
-
- /**
- * Property to set the maximum size of a file that will be buffered. When calculating a ReliableFile
- * checksum, if the file is this size or small, ReliableFile will read the file contents into a
- * <code>BufferedInputStream</code> and reset the buffer to avoid having to read the data from the
- * media twice. Since this method require memory for storage, it is limited to this size. The default
- * maximum is 128-KBytes.
- */
- public static final String PROP_MAX_BUFFER = "osgi.reliableFile.maxInputStreamBuffer"; //$NON-NLS-1$
- /**
- * The maximum number of generations to keep as backup files in case last generation
- * file is determined to be invalid.
- */
- public static final String PROP_MAX_GENERATIONS = "osgi.ReliableFile.maxGenerations"; //$NON-NLS-1$
- /**
- * @see org.eclipse.core.runtime.internal.adaptor.BasicLocation#PROP_OSGI_LOCKING
- */
- public static final String PROP_OSGI_LOCKING = "osgi.locking"; //$NON-NLS-1$
-
- protected static final int FILETYPE_UNKNOWN = -1;
- protected static final int FILETYPE_VALID = 0;
- protected static final int FILETYPE_CORRUPT = 1;
- protected static final int FILETYPE_NOSIGNATURE = 2;
-
- protected static final byte identifier1[] = {'.', 'c', 'r', 'c'};
- protected static final byte identifier2[] = {'.', 'v', '1', '\n'};
-
- private static final int BUF_SIZE = 4096;
- private static int maxInputStreamBuffer = 128 * 1024; //128k
- private static int defaultMaxGenerations = 2;
- private static boolean fileSharing = true;
- //our cache of the last lookuped up generations for a file
- private static File lastGenerationFile = null;
- private static int[] lastGenerations = null;
-
- static {
- String prop = FrameworkProperties.getProperty(PROP_MAX_BUFFER);
- if (prop != null) {
- try {
- maxInputStreamBuffer = Integer.parseInt(prop);
- } catch (NumberFormatException e) {/*ignore*/
- }
- }
- prop = FrameworkProperties.getProperty(PROP_MAX_GENERATIONS);
- if (prop != null) {
- try {
- defaultMaxGenerations = Integer.parseInt(prop);
- } catch (NumberFormatException e) {/*ignore*/
- }
- }
- prop = FrameworkProperties.getProperty(PROP_OSGI_LOCKING);
- if (prop != null) {
- if (prop.equals("none")) { //$NON-NLS-1$
- fileSharing = false;
- }
- }
- }
-
- /** File object for original reference file */
- private File referenceFile;
-
- /** List of checksum file objects: File => specific ReliableFile generation */
- private static Hashtable cacheFiles = new Hashtable(20);
-
- private File inputFile = null;
- private File outputFile = null;
- private Checksum appendChecksum = null;
-
- /**
- * ReliableFile object factory. This method is called by ReliableFileInputStream
- * and ReliableFileOutputStream to get a ReliableFile object for a target file.
- * If the object is in the cache, the cached copy is returned.
- * Otherwise a new ReliableFile object is created and returned.
- * The use count of the returned ReliableFile object is incremented.
- *
- * @param name Name of the target file.
- * @return A ReliableFile object for the target file.
- * @throws IOException If the target file is a directory.
- */
- protected static ReliableFile getReliableFile(String name) throws IOException {
- return getReliableFile(new File(name));
- }
-
- /**
- * ReliableFile object factory. This method is called by ReliableFileInputStream
- * and ReliableFileOutputStream to get a ReliableFile object for a target file.
- * If the object is in the cache, the cached copy is returned.
- * Otherwise a new ReliableFile object is created and returned.
- * The use count of the returned ReliableFile object is incremented.
- *
- * @param file File object for the target file.
- * @return A ReliableFile object for the target file.
- * @throws IOException If the target file is a directory.
- */
- protected static ReliableFile getReliableFile(File file) throws IOException {
- if (file.isDirectory()) {
- throw new FileNotFoundException("file is a directory"); //$NON-NLS-1$
- }
- return new ReliableFile(file);
- }
-
- /**
- * Private constructor used by the static getReliableFile factory methods.
- *
- * @param file File object for the target file.
- */
- private ReliableFile(File file) {
- referenceFile = file;
- }
-
- private static int[] getFileGenerations(File file) {
- if (!fileSharing && lastGenerationFile != null) {
- //shortcut maybe, only if filesharing is not supported
- if (file.equals(lastGenerationFile))
- return lastGenerations;
- }
- int[] generations = null;
- try {
- String name = file.getName();
- String prefix = name + '.';
- int prefixLen = prefix.length();
- File parent = new File(file.getParent());
- String[] files = parent.list();
- if (files == null)
- return null;
- ArrayList list = new ArrayList(defaultMaxGenerations);
- if (file.exists())
- list.add(new Integer(0)); //base file exists
- for (int i = 0; i < files.length; i++) {
- if (files[i].startsWith(prefix)) {
- try {
- int id = Integer.parseInt(files[i].substring(prefixLen));
- list.add(new Integer(id));
- } catch (NumberFormatException e) {/*ignore*/
- }
- }
- }
- if (list.size() == 0)
- return null;
- Object[] array = list.toArray();
- Arrays.sort(array);
- generations = new int[array.length];
- for (int i = 0, j = array.length - 1; i < array.length; i++, j--) {
- generations[i] = ((Integer) array[j]).intValue();
- }
- return generations;
- } finally {
- if (!fileSharing) {
- lastGenerationFile = file;
- lastGenerations = generations;
- }
- }
- }
-
- /**
- * Returns an InputStream object for reading the target file.
- *
- * @param generation the maximum generation to evaluate
- * @param openMask mask used to open data.
- * are invalid (corrupt, missing, etc).
- * @return An InputStream object which can be used to read the target file.
- * @throws IOException If an error occurs preparing the file.
- */
- protected InputStream getInputStream(int generation, int openMask) throws IOException {
- if (inputFile != null) {
- throw new IOException("Input stream already open"); //$NON-NLS-1$
- }
- int[] generations = getFileGenerations(referenceFile);
- if (generations == null) {
- throw new FileNotFoundException("File not found"); //$NON-NLS-1$
- }
- String name = referenceFile.getName();
- File parent = new File(referenceFile.getParent());
-
- boolean failOnPrimary = (openMask & OPEN_FAIL_ON_PRIMARY) != 0;
- if (failOnPrimary && generation == GENERATIONS_INFINITE)
- generation = generations[0];
-
- File textFile = null;
- InputStream textIS = null;
- for (int idx = 0; idx < generations.length; idx++) {
- if (generation != 0) {
- if (generations[idx] > generation || (failOnPrimary && generations[idx] != generation))
- continue;
- }
- File file;
- if (generations[idx] != 0)
- file = new File(parent, name + '.' + generations[idx]);
- else
- file = referenceFile;
- InputStream is = null;
- CacheInfo info;
- synchronized (cacheFiles) {
- info = (CacheInfo) cacheFiles.get(file);
- }
- long timeStamp = file.lastModified();
- if (info == null || timeStamp != info.timeStamp) {
- try {
- is = new FileInputStream(file);
- if (is.available() < maxInputStreamBuffer)
- is = new BufferedInputStream(is);
- Checksum cksum = getChecksumCalculator();
- int filetype = getStreamType(is, cksum);
- info = new CacheInfo(filetype, cksum, timeStamp);
- synchronized (cacheFiles) {
- cacheFiles.put(file, info);
- }
- } catch (IOException e) {/*ignore*/
- }
- }
-
- // if looking for a specific generation only, only look at one
- // and return the result.
- if (failOnPrimary) {
- if (info != null && info.filetype == FILETYPE_VALID) {
- inputFile = file;
- if (is != null)
- return is;
- return new FileInputStream(file);
- }
- throw new IOException("ReliableFile is corrupt"); //$NON-NLS-1$
- }
-
- // if error, ignore this file & try next
- if (info == null)
- continue;
-
- // we're not looking for a specific version, so let's pick the best case
- switch (info.filetype) {
- case FILETYPE_VALID :
- inputFile = file;
- if (is != null)
- return is;
- return new FileInputStream(file);
-
- case FILETYPE_NOSIGNATURE :
- if (textFile == null) {
- textFile = file;
- textIS = is;
- }
- break;
- }
- }
-
- // didn't find any valid files, if there are any plain text files
- // use it instead
- if (textFile != null) {
- inputFile = textFile;
- if (textIS != null)
- return textIS;
- return new FileInputStream(textFile);
- }
- throw new IOException("ReliableFile is corrupt"); //$NON-NLS-1$
- }
-
- /**
- * Returns an OutputStream object for writing the target file.
- *
- * @param append append new data to an existing file.
- * @param appendGeneration specific generation of file to append from.
- * @return An OutputStream object which can be used to write the target file.
- * @throws IOException IOException If an error occurs preparing the file.
- */
- protected OutputStream getOutputStream(boolean append, int appendGeneration) throws IOException {
- if (outputFile != null)
- throw new IOException("Output stream is already open"); //$NON_NLS-1$ //$NON-NLS-1$
- String name = referenceFile.getName();
- File parent = new File(referenceFile.getParent());
- File tmpFile = File.createTempFile(name, tmpExt, parent);
-
- if (!append) {
- OutputStream os = new FileOutputStream(tmpFile);
- outputFile = tmpFile;
- return os;
- }
-
- InputStream is;
- try {
- is = getInputStream(appendGeneration, OPEN_BEST_AVAILABLE);
- } catch (FileNotFoundException e) {
- OutputStream os = new FileOutputStream(tmpFile);
- outputFile = tmpFile;
- return os;
- }
-
- try {
- CacheInfo info = (CacheInfo) cacheFiles.get(inputFile);
- appendChecksum = info.checksum;
- OutputStream os = new FileOutputStream(tmpFile);
- if (info.filetype == FILETYPE_NOSIGNATURE) {
- cp(is, os, 0);
- } else {
- cp(is, os, 16); // don't copy checksum signature
- }
- outputFile = tmpFile;
- return os;
- } finally {
- closeInputFile();
- }
- }
-
- /**
- * Close the target file for reading.
- *
- * @param checksum Checksum of the file contenets
- * @throws IOException If an error occurs closing the file.
- */
- protected void closeOutputFile(Checksum checksum) throws IOException {
- if (outputFile == null)
- throw new IOException("Output stream is not open"); //$NON-NLS-1$
- int[] generations = getFileGenerations(referenceFile);
- String name = referenceFile.getName();
- File parent = new File(referenceFile.getParent());
- File newFile;
- if (generations == null)
- newFile = new File(parent, name + ".1"); //$NON-NLS-1$
- else
- newFile = new File(parent, name + '.' + (generations[0] + 1));
-
- mv(outputFile, newFile); // throws IOException if problem
- outputFile = null;
- appendChecksum = null;
- CacheInfo info = new CacheInfo(FILETYPE_VALID, checksum, newFile.lastModified());
- cacheFiles.put(newFile, info);
- cleanup(generations, true);
- lastGenerationFile = null;
- lastGenerations = null;
- }
-
- /**
- * Abort the current output stream and do not update the reliable file table.
- *
- */
- protected void abortOutputFile() {
- if (outputFile == null)
- return;
- outputFile.delete();
- outputFile = null;
- appendChecksum = null;
- }
-
- protected File getOutputFile() {
- return outputFile;
- }
-
- /**
- * Close the target file for reading.
- */
- void closeInputFile() {
- inputFile = null;
- }
-
- private void cleanup(int[] generations, boolean generationAdded) {
- if (generations == null)
- return;
- String name = referenceFile.getName();
- File parent = new File(referenceFile.getParent());
- int generationCount = generations.length;
- // if a base file is in the list (0 in generations[]), we will
- // never delete these files, so don't count them in the old
- // generation count.
- if (generations[generationCount - 1] == 0)
- generationCount--;
- // assume here that the int[] does not include a file just created
- int rmCount = generationCount - defaultMaxGenerations;
- if (generationAdded)
- rmCount++;
- if (rmCount < 1)
- return;
- synchronized (cacheFiles) {
- // first, see if any of the files not deleted are known to
- // be corrupt. If so, be sure to keep not to delete good
- // backup files.
- for (int idx = 0, count = generationCount - rmCount; idx < count; idx++) {
- File file = new File(parent, name + '.' + generations[idx]);
- CacheInfo info = (CacheInfo) cacheFiles.get(file);
- if (info != null) {
- if (info.filetype == FILETYPE_CORRUPT)
- rmCount--;
- }
- }
- for (int idx = generationCount - 1; rmCount > 0; idx--, rmCount--) {
- File rmFile = new File(parent, name + '.' + generations[idx]);
- rmFile.delete();
- cacheFiles.remove(rmFile);
- }
- }
- }
-
- /**
- * Rename a file.
- *
- * @param from The original file.
- * @param to The new file name.
- * @throws IOException If the rename failed.
- */
- private static void mv(File from, File to) throws IOException {
- if (!from.renameTo(to)) {
- throw new IOException("rename failed"); //$NON-NLS-1$
- }
- }
-
- /**
- * Copy a file.
- *
- * @throws IOException If the copy failed.
- */
- private static void cp(InputStream in, OutputStream out, int truncateSize) throws IOException {
- try {
- int length = in.available();
- if (truncateSize > length)
- length = 0;
- else
- length -= truncateSize;
- if (length > 0) {
- int bufferSize;
- if (length > BUF_SIZE) {
- bufferSize = BUF_SIZE;
- } else {
- bufferSize = length;
- }
-
- byte buffer[] = new byte[bufferSize];
- int size = 0;
- int count;
- while ((count = in.read(buffer, 0, length)) > 0) {
- if ((size + count) >= length)
- count = length - size;
- out.write(buffer, 0, count);
- size += count;
- }
- }
- } finally {
- try {
- in.close();
- } catch (IOException e) {/*ignore*/
- }
- out.close();
- }
- }
-
- /**
- * Answers a boolean indicating whether or not the specified reliable file
- * exists on the underlying file system. This call only returns if a file
- * exists and not if the file contents are valid.
- * @param file returns true if the specified reliable file exists; otherwise false is returned
- *
- * @return <code>true</code> if the specified reliable file exists,
- * <code>false</code> otherwise.
- */
- public static boolean exists(File file) {
- String prefix = file.getName() + '.';
- File parent = new File(file.getParent());
- int prefixLen = prefix.length();
- String[] files = parent.list();
- if (files == null)
- return false;
- for (int i = 0; i < files.length; i++) {
- if (files[i].startsWith(prefix)) {
- try {
- Integer.parseInt(files[i].substring(prefixLen));
- return true;
- } catch (NumberFormatException e) {/*ignore*/
- }
- }
- }
- return file.exists();
- }
-
- /**
- * Returns the time that the reliable file was last modified. Only the time
- * of the last file generation is returned.
- * @param file the file to determine the time of.
- * @return time the file was last modified (see java.io.File.lastModified()).
- */
- public static long lastModified(File file) {
- int[] generations = getFileGenerations(file);
- if (generations == null)
- return 0L;
- if (generations[0] == 0)
- return file.lastModified();
- String name = file.getName();
- File parent = new File(file.getParent());
- File newFile = new File(parent, name + '.' + generations[0]);
- return newFile.lastModified();
- }
-
- /**
- * Returns the time that this ReliableFile was last modified. This method is only valid
- * after requesting an input stream and the time of the actual input file is returned.
- *
- * @return time the file was last modified (see java.io.File.lastModified()) or
- * 0L if an input stream is not open.
- */
- public long lastModified() {
- if (inputFile != null) {
- return inputFile.lastModified();
- }
- return 0L;
- }
-
- /**
- * Returns the a version number of a reliable managed file. The version can be expected
- * to be unique for each successfule file update.
- *
- * @param file the file to determine the version of.
- * @return a unique version of this current file. A value of -1 indicates the file does
- * not exist or an error occurred.
- */
- public static int lastModifiedVersion(File file) {
- int[] generations = getFileGenerations(file);
- if (generations == null)
- return -1;
- return generations[0];
- }
-
- /**
- * Delete the specified reliable file on the underlying file system.
- * @param deleteFile the reliable file to delete
- *
- * @return <code>true</code> if the specified reliable file was deleted,
- * <code>false</code> otherwise.
- */
- public static boolean delete(File deleteFile) {
- int[] generations = getFileGenerations(deleteFile);
- if (generations == null)
- return false;
- String name = deleteFile.getName();
- File parent = new File(deleteFile.getParent());
- synchronized (cacheFiles) {
- for (int idx = 0; idx < generations.length; idx++) {
- // base files (.0 in generations[]) will never be deleted
- if (generations[idx] == 0)
- continue;
- File file = new File(parent, name + '.' + generations[idx]);
- if (file.exists()) {
- file.delete();
- }
- cacheFiles.remove(file);
- }
- }
- return true;
- }
-
- /**
- * Get a list of ReliableFile base names in a given directory. Only files with a valid
- * ReliableFile generation are included.
- * @param directory the directory to inquire.
- * @return an array of ReliableFile names in the directory.
- * @throws IOException if an error occurs.
- */
- public static String[] getBaseFiles(File directory) throws IOException {
- if (!directory.isDirectory())
- throw new IOException("Not a valid directory"); //$NON-NLS-1$
- String files[] = directory.list();
- HashSet list = new HashSet(files.length / 2);
- for (int idx = 0; idx < files.length; idx++) {
- String file = files[idx];
- int pos = file.lastIndexOf('.');
- if (pos == -1)
- continue;
- String ext = file.substring(pos + 1);
- int generation = 0;
- try {
- generation = Integer.parseInt(ext);
- } catch (NumberFormatException e) {/*skip*/
- }
- if (generation == 0)
- continue;
- String base = file.substring(0, pos);
- list.add(base);
- }
- files = new String[list.size()];
- int idx = 0;
- for (Iterator iter = list.iterator(); iter.hasNext();) {
- files[idx++] = (String) iter.next();
- }
- return files;
- }
-
- /**
- * Delete any old excess generations of a given reliable file.
- * @param base realible file.
- */
- public static void cleanupGenerations(File base) {
- ReliableFile rf = new ReliableFile(base);
- int[] generations = getFileGenerations(base);
- rf.cleanup(generations, false);
- lastGenerationFile = null;
- lastGenerations = null;
- }
-
- /**
- * Inform ReliableFile that a file has been updated outside of
- * ReliableFile.
- * @param file
- */
- public static void fileUpdated(File file) {
- lastGenerationFile = null;
- lastGenerations = null;
- }
-
- /**
- * Append a checksum value to the end of an output stream.
- * @param out the output stream.
- * @param checksum the checksum value to append to the file.
- * @throws IOException if a write error occurs.
- */
- protected void writeChecksumSignature(OutputStream out, Checksum checksum) throws IOException {
- // tag on our signature and checksum
- out.write(ReliableFile.identifier1);
- out.write(intToHex((int) checksum.getValue()));
- out.write(ReliableFile.identifier2);
- }
-
- /**
- * Returns the size of the ReliableFile signature + CRC at the end of the file.
- * This method should be called only after calling getInputStream() or
- * getOutputStream() methods.
- *
- * @return <code>int</code> size of the ReliableFIle signature + CRC appended
- * to the end of the file.
- * @throws IOException if getInputStream() or getOutputStream has not been
- * called.
- */
- protected int getSignatureSize() throws IOException {
- if (inputFile != null) {
- CacheInfo info;
- synchronized (cacheFiles) {
- info = (CacheInfo) cacheFiles.get(inputFile);
- }
- if (info != null) {
- switch (info.filetype) {
- case FILETYPE_VALID :
- case FILETYPE_CORRUPT :
- return 16;
- case FILETYPE_NOSIGNATURE :
- return 0;
- }
- }
- }
- throw new IOException("ReliableFile signature size is unknown"); //$NON-NLS-1$
- }
-
- /**
- * Returns a Checksum object for the current file contents. This method
- * should be called only after calling getInputStream() or
- * getOutputStream() methods.
- *
- * @return Object implementing Checksum interface initialized to the
- * current file contents.
- * @throws IOException if getOutputStream for append has not been called.
- */
- protected Checksum getFileChecksum() throws IOException {
- if (appendChecksum == null)
- throw new IOException("Checksum is invalid!"); //$NON-NLS-1$
- return appendChecksum;
- }
-
- /**
- * Create a checksum implementation used by ReliableFile.
- *
- * @return Object implementing Checksum interface used to calculate
- * a reliable file checksum
- */
- protected Checksum getChecksumCalculator() {
- // Using CRC32 because Adler32 isn't in the eeMinimum library.
- return new CRC32();
- }
-
- /**
- * Determine if a File is a valid ReliableFile
- *
- * @return <code>true</code> if the file is a valid ReliableFile
- * @throws IOException If an error occurs verifying the file.
- */
- private int getStreamType(InputStream is, Checksum crc) throws IOException {
- boolean markSupported = is.markSupported();
- if (markSupported)
- is.mark(is.available());
- try {
- int len = is.available();
- if (len < 16) {
- if (crc != null) {
- byte data[] = new byte[16];
- int num = is.read(data);
- if (num > 0)
- crc.update(data, 0, num);
- }
- return FILETYPE_NOSIGNATURE;
- }
- len -= 16;
-
- int pos = 0;
- byte data[] = new byte[BUF_SIZE];
-
- while (pos < len) {
- int read = data.length;
- if (pos + read > len)
- read = len - pos;
-
- int num = is.read(data, 0, read);
- if (num == -1) {
- throw new IOException("Unable to read entire file."); //$NON-NLS-1$
- }
-
- crc.update(data, 0, num);
- pos += num;
- }
-
- int num = is.read(data); // read last 16-byte signature
- if (num != 16) {
- throw new IOException("Unable to read entire file."); //$NON-NLS-1$
- }
-
- int i, j;
- for (i = 0; i < 4; i++)
- if (identifier1[i] != data[i]) {
- crc.update(data, 0, 16); // update crc w/ sig bytes
- return FILETYPE_NOSIGNATURE;
- }
- for (i = 0, j = 12; i < 4; i++, j++)
- if (identifier2[i] != data[j]) {
- crc.update(data, 0, 16); // update crc w/ sig bytes
- return FILETYPE_NOSIGNATURE;
- }
- long crccmp;
- try {
- crccmp = Long.valueOf(new String(data, 4, 8, "UTF-8"), 16).longValue(); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- crccmp = Long.valueOf(new String(data, 4, 8), 16).longValue();
- }
- if (crccmp == crc.getValue()) {
- return FILETYPE_VALID;
- }
- // do not update CRC
- return FILETYPE_CORRUPT;
- } finally {
- if (markSupported)
- is.reset();
- }
- }
-
- private static byte[] intToHex(int l) {
- byte[] buffer = new byte[8];
- int count = 8;
-
- do {
- int ch = (l & 0xf);
- if (ch > 9)
- ch = ch - 10 + 'a';
- else
- ch += '0';
- buffer[--count] = (byte) ch;
- l >>= 4;
- } while (count > 0);
- return buffer;
- }
-
- private class CacheInfo {
- int filetype;
- Checksum checksum;
- long timeStamp;
-
- CacheInfo(int filetype, Checksum checksum, long timeStamp) {
- this.filetype = filetype;
- this.checksum = checksum;
- this.timeStamp = timeStamp;
- }
- }
-}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream.java
deleted file mode 100644
index b7d6e1082..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFileInputStream.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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.osgi.framework.internal.reliablefile;
-
-import java.io.*;
-
-/**
- * A ReliableFile FileInputStream replacement class.
- * This class can be used just like FileInputStream. The class
- * is in partnership with ReliableFileOutputStream to avoid losing
- * file data by using multiple files.
- *
- * @see ReliableFileOutputStream
- */
-public class ReliableFileInputStream extends FilterInputStream {
- /**
- * ReliableFile object for this file.
- */
- private ReliableFile reliable;
-
- /**
- * size of crc and signature
- */
- private int sigSize;
-
- /**
- * current position reading from file
- */
- private int readPos;
-
- /**
- * total file length available for reading
- */
- private int length;
-
- /**
- * Constructs a new ReliableFileInputStream on the file named <code>name</code>. If the
- * file does not exist, the <code>FileNotFoundException</code> is thrown.
- * The <code>name</code> may be absolute or relative
- * to the System property <code>"user.dir"</code>.
- *
- * @param name the file on which to stream reads.
- * @exception java.io.IOException If an error occurs opening the file.
- */
- public ReliableFileInputStream(String name) throws IOException {
- this(ReliableFile.getReliableFile(name), ReliableFile.GENERATION_LATEST, ReliableFile.OPEN_BEST_AVAILABLE);
- }
-
- /**
- * Constructs a new ReliableFileInputStream on the File <code>file</code>. If the
- * file does not exist, the <code>FileNotFoundException</code> is thrown.
- *
- * @param file the File on which to stream reads.
- * @exception java.io.IOException If an error occurs opening the file.
- */
- public ReliableFileInputStream(File file) throws IOException {
- this(ReliableFile.getReliableFile(file), ReliableFile.GENERATION_LATEST, ReliableFile.OPEN_BEST_AVAILABLE);
- }
-
- /**
- * Constructs a new ReliableFileInputStream on the File <code>file</code>. If the
- * file does not exist, the <code>FileNotFoundException</code> is thrown.
- *
- * @param file the File on which to stream reads.
- * @param generation a specific generation requested.
- * @param openMask mask used to open data.
- * are invalid (corrupt, missing, etc).
- * @exception java.io.IOException If an error occurs opening the file.
- */
- public ReliableFileInputStream(File file, int generation, int openMask) throws IOException {
- this(ReliableFile.getReliableFile(file), generation, openMask);
- }
-
- /**
- *
- * @param reliable The ReliableFile on which to read.
- * @param generation a specific generation requested.
- * @param openMask mask used to open data.
- * are invalid (corrupt, missing, etc).
- * @throws IOException If an error occurs opening the file.
- */
- private ReliableFileInputStream(ReliableFile reliable, int generation, int openMask) throws IOException {
- super(reliable.getInputStream(generation, openMask));
-
- this.reliable = reliable;
- sigSize = reliable.getSignatureSize();
- readPos = 0;
- length = super.available();
- if (sigSize > length)
- length = 0; // shouldn't ever happen
- else
- length -= sigSize;
- }
-
- /**
- * Closes this input stream and releases any system resources associated
- * with the stream.
- *
- * @exception java.io.IOException If an error occurs closing the file.
- */
- public synchronized void close() throws IOException {
- if (reliable != null) {
- try {
- super.close();
- } finally {
- reliable.closeInputFile();
- reliable = null;
- }
- }
- }
-
- /**
- * Override default FilterInputStream method.
- * @see FilterInputStream#read(byte[], int, int)
- */
- public synchronized int read(byte b[], int off, int len) throws IOException {
- if (readPos >= length) {
- return -1;
- }
- int num = super.read(b, off, len);
-
- if (num != -1) {
- if (num + readPos > length) {
- num = length - readPos;
- }
- readPos += num;
- }
- return num;
- }
-
- /**
- * Override default FilterInputStream method.
- * @see FilterInputStream#read(byte[])
- */
- public synchronized int read(byte b[]) throws IOException {
- return read(b, 0, b.length);
- }
-
- /**
- * Override default FilterInputStream method.
- * @see FilterInputStream#read()
- */
- public synchronized int read() throws IOException {
- if (readPos >= length) {
- return -1;
- }
- int num = super.read();
-
- if (num != -1) {
- readPos++;
- }
- return num;
- }
-
- /**
- * Override default available method.
- * @see FilterInputStream#available()
- */
- public synchronized int available() throws IOException {
- if (readPos < length) // just in case
- return (length - readPos);
- return 0;
- }
-
- /**
- * Override default skip method.
- * @see FilterInputStream#skip(long)
- */
- public synchronized long skip(long n) throws IOException {
- long len = super.skip(n);
- if (readPos + len > length)
- len = length - readPos;
- readPos += len;
- return len;
- }
-
- /**
- * Override default markSupported method.
- * @see FilterInputStream#markSupported()
- */
- public boolean markSupported() {
- return false;
- }
-
- /**
- * Override default mark method.
- * @see FilterInputStream#mark(int)
- */
- public void mark(int readlimit) {
- //ignore
- }
-
- /**
- * Override default reset method.
- * @see FilterInputStream#reset()
- */
- public void reset() throws IOException {
- throw new IOException("reset not supported."); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFileOutputStream.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFileOutputStream.java
deleted file mode 100644
index c14929777..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/reliablefile/ReliableFileOutputStream.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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.osgi.framework.internal.reliablefile;
-
-import java.io.*;
-import java.util.zip.Checksum;
-
-/**
- * A ReliableFile FileOutputStream replacement class.
- * This class can be used just like FileOutputStream. The class
- * is in partnership with ReliableFileInputStream to avoid losing
- * file data by using multiple files.
- *
- * @see ReliableFileInputStream
- */
-public class ReliableFileOutputStream extends FilterOutputStream {
- /**
- * ReliableFile object for the file.
- */
- private ReliableFile reliable;
-
- /**
- * Checksum calculator
- */
- private Checksum crc;
-
- private boolean outputOpen = false;
-
- /**
- * Constructs a new ReliableFileOutputStream on the File <code>file</code>. If the
- * file exists, it is written over. See the constructor which can append to
- * the file if so desired.
- *
- * @param file the File on which to stream reads.
- * @exception java.io.IOException If an error occurs opening the file.
- */
- public ReliableFileOutputStream(File file) throws IOException {
- this(ReliableFile.getReliableFile(file), false);
- }
-
- /**
- * Constructs a new ReliableFileOutputStream on the File <code>file</code>.
- *
- * @param file the File on which to stream reads.
- * @param append a boolean indicating whether or not to append to an existing file.
- * @exception java.io.IOException If an error occurs opening the file.
- */
- public ReliableFileOutputStream(File file, boolean append) throws IOException {
- this(ReliableFile.getReliableFile(file), append);
- }
-
- /**
- * Constructs a new ReliableFileOutputStream on the file named <code>name</code>. If
- * the file exists, it is written over. See the constructor which can append to
- * the file if so desired.
- * The <code>name</code> may be absolute or relative
- * to the System property <code>"user.dir"</code>.
- *
- * @param name the file on which to stream writes.
- * @exception java.io.IOException If an error occurs opening the file.
- */
- public ReliableFileOutputStream(String name) throws IOException {
- this(ReliableFile.getReliableFile(name), false);
- }
-
- /**
- * Constructs a new ReliableFileOutputStream on the file named <code>name</code>.
- * The <code>name</code> may be absolute or relative
- * to the System property <code>"user.dir"</code>.
- *
- * @param name the file on which to stream writes.
- * @param append a boolean indicating whether or not to append to an existing file.
- * @exception java.io.IOException If an error occurs opening the file.
- */
- public ReliableFileOutputStream(String name, boolean append) throws IOException {
- this(ReliableFile.getReliableFile(name), append);
- }
-
- /**
- * Private constructor used by other constructors.
- *
- * @param reliable the ReliableFile on which to read.
- * @param append a boolean indicating whether or not to append to an existing file.
- * @exception java.io.IOException If an error occurs opening the file.
- */
- private ReliableFileOutputStream(ReliableFile reliable, boolean append) throws IOException {
- super(reliable.getOutputStream(append, ReliableFile.GENERATION_LATEST));
-
- this.reliable = reliable;
- outputOpen = true;
- if (append)
- crc = reliable.getFileChecksum();
- else
- crc = reliable.getChecksumCalculator();
- }
-
- /**
- * Closes this output stream and releases any system resources
- * associated with this stream. The general contract of <code>close</code>
- * is that it closes the output stream. A closed stream cannot perform
- * output operations and cannot be reopened.
- *
- * @exception java.io.IOException If an error occurs closing the file.
- */
- public synchronized void close() throws IOException {
- closeIntermediateFile();
- reliable.closeOutputFile(crc);
- // if the previouse closeOutpuFile() throws exception,
- // we don't null out reliable to give another opportunity
- // to rename the file.
- reliable = null;
- }
-
- public File closeIntermediateFile() throws IOException {
- if (reliable == null)
- throw new IOException("ReliableFile stream not open"); //$NON-NLS-1$
- if (outputOpen) {
- // tag on our signature and checksum
- reliable.writeChecksumSignature(out, crc);
- out.flush();
- try {
- ((FileOutputStream) out).getFD().sync();
- } catch (IOException e) {
- // just ignore this Exception
- //Debug
- e.printStackTrace();
- }
- out.close();
- outputOpen = false;
- }
- return reliable.getOutputFile();
- }
-
- /**
- * Override default FilterOutputStream method.
- * @see FilterOutputStream#write(byte[])
- */
- public void write(byte[] b) throws IOException {
- this.write(b, 0, b.length);
- }
-
- /**
- * Override default FilterOutputStream method.
- * @see FilterOutputStream#write(byte[], int, int)
- */
- public void write(byte[] b, int off, int len) throws IOException {
- out.write(b, off, len);
- crc.update(b, off, len);
- }
-
- /**
- * Override default FilterOutputStream method.
- * @see FilterOutputStream#write(int)
- */
- public void write(int b) throws IOException {
- out.write(b);
- crc.update((byte) b);
- }
-
- public void abort() {
- if (reliable == null)
- return;
- if (outputOpen) {
- try {
- out.close();
- } catch (IOException e) {/*ignore*/
- }
- outputOpen = false;
- }
- reliable.abortOutputFile();
- reliable = null;
- }
-}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/log/FrameworkLog.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/log/FrameworkLog.java
deleted file mode 100644
index ca0b7f0b4..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/log/FrameworkLog.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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.osgi.framework.log;
-
-import java.io.*;
-import org.osgi.framework.FrameworkEvent;
-
-/**
- * The FramworkLog interface. A FrameworkLog implementation is provided by the
- * FrameworkAdaptor and used by the Framework to log any error messages and
- * FrameworkEvents of type ERROR. The FrameworkLog may persist the log messages
- * to the filesystem or allow other ways of accessing the log information.
- * @since 3.1
- */
-public interface FrameworkLog {
- /**
- * A service lookup constant (value "performance") indicating an
- * implementation of the logging service that logs performance events.
- * Create a filter with this property set to <code>"true"</code> in order to
- * obtain a performance log.
- *
- * @since 3.1
- */
- public static final String SERVICE_PERFORMANCE = "performance"; //$NON-NLS-1$
-
- /**
- * Logs the information from a FrameworkEvent to the FrameworkLog.
- * @param frameworkEvent The FrameworkEvent to log.
- */
- public void log(FrameworkEvent frameworkEvent);
-
- /**
- * Logs the FrameworkLogEntry to the FrameworkLog
- * @param logEntry The entry to log.
- */
- public void log(FrameworkLogEntry logEntry);
-
- /**
- * Sets the current Writer used to log messages to the specified
- * newWriter. If append is set to true then the content
- * of the current Writer will be appended to the new Writer
- * if possible.
- * @param newWriter The Writer to use for logging messages.
- * @param append Indicates whether the content of the current Writer
- * used for logging messages should be appended to the end of the new
- * Writer.
- */
- public void setWriter(Writer newWriter, boolean append);
-
- /**
- * Sets the current File used to log messages to a FileWriter
- * using the specified File. If append is set to true then the
- * content of the current Writer will be appended to the
- * new File if possible.
- * @param newFile The File to create a new FileWriter which will be
- * used for logging messages.
- * @param append Indicates whether the content of the current Writer
- * used for logging messages should be appended to the end of the new
- * File.
- * @throws IOException if any problem occurs while constructing a
- * FileWriter from the newFile. If this exception is thrown the
- * FrameworkLog will not be effected and will continue to use the
- * current Writer to log messages.
- */
- public void setFile(File newFile, boolean append) throws IOException;
-
- /**
- * Returns the log File if it is set, otherwise null is returned.
- * @return the log File if it is set, otherwise null is returned.
- */
- public File getFile();
-
- /**
- * Sets the console log option. If this is set then all logs will be
- * logged to System.out as well as the current Writer.
- * @param consoleLog indicates whether to log to System.out
- */
- public void setConsoleLog(boolean consoleLog);
-
- /**
- * Closes the FrameworkLog. After the FrameworkLog is closed messages may
- * no longer be logged to it.
- */
- public void close();
-}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/log/FrameworkLogEntry.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/log/FrameworkLogEntry.java
deleted file mode 100644
index d3efbb3e6..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/log/FrameworkLogEntry.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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.osgi.framework.log;
-
-/**
- * A framework log entry used to log information to a FrameworkLog
- * @since 3.1
- */
-public class FrameworkLogEntry {
- /**
- * Severity constant (value 0) indicating this log entry represents the nominal case.
- * @see #getSeverity()
- * @since 3.2
- */
- public static final int OK = 0;
-
- /**
- * Severity constant (bit mask, value 1) indicating this log entry is informational only.
- * @see #getSeverity()
- * @since 3.2
- */
- public static final int INFO = 0x01;
-
- /**
- * Severity constant (bit mask, value 2) indicating this log entry represents a warning.
- * @see #getSeverity()
- * @since 3.2
- */
- public static final int WARNING = 0x02;
-
- /**
- * Severity constant (bit mask, value 4) indicating this log entry represents an error.
- * @see #getSeverity()
- * @since 3.2
- */
- public static final int ERROR = 0x04;
-
- /**
- * Status type severity (bit mask, value 8) indicating this log entry represents a cancelation.
- * @see #getSeverity()
- * @since 3.2
- */
- public static final int CANCEL = 0x08;
-
-
- // It would be nice to rename some of these fields but we cannot change the getter method
- // names without breaking clients. Changing only the field names would be confusing.
- //TODO "entry" has another meaning here - title, summary, tag are better names
- private String entry;
- private String message;
- //TODO get rid of this
- private int stackCode;
- //TODO: use "reason" or "cause" instead
- private Throwable throwable;
- private FrameworkLogEntry[] children;
- private int severity = 0;
- private int bundleCode = 0;
-
- /**
- * Constructs a new FrameworkLogEntry
- * @param entry the entry
- * @param message the message
- * @param stackCode the stack code
- * @param throwable the throwable
- * @param children the children
- */
- public FrameworkLogEntry(String entry, String message, int stackCode, Throwable throwable, FrameworkLogEntry[] children) {
- this.entry = entry;
- this.message = message;
- this.stackCode = stackCode;
- this.throwable = throwable;
- this.children = children;
- }
-
- /**
- * Constructs a new FrameworkLogEntry
- * @param entry the entry
- * @param severity the severity
- * @param bundleCode the bundle code
- * @param message the message
- * @param stackCode the stack code
- * @param throwable the throwable
- * @param children the children
- * @since 3.2
- */
- public FrameworkLogEntry(String entry, int severity, int bundleCode, String message, int stackCode, Throwable throwable, FrameworkLogEntry[] children) {
- this.entry = entry;
- this.message = message;
- this.stackCode = stackCode;
- this.throwable = throwable;
- this.children = children;
- this.severity = severity;
- this.bundleCode = bundleCode;
- }
-
- /**
- *
- * @return Returns the children.
- */
- public FrameworkLogEntry[] getChildren() {
- return children;
- }
-
- /**
- * @return Returns the entry.
- */
- public String getEntry() {
- return entry;
- }
-
- /**
- * @return Returns the message.
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * @return Returns the stackCode.
- */
- public int getStackCode() {
- return stackCode;
- }
-
- /**
- * @return Returns the throwable.
- */
- public Throwable getThrowable() {
- return throwable;
- }
-
- /**
- * Returns the severity. The severities are as follows (in descending order):
- * <ul>
- * <li><code>CANCEL</code> - cancelation occurred</li>
- * <li><code>ERROR</code> - a serious error (most severe)</li>
- * <li><code>WARNING</code> - a warning (less severe)</li>
- * <li><code>INFO</code> - an informational ("fyi") message (least severe)</li>
- * <li><code>OK</code> - everything is just fine</li>
- * </ul>
- * <p>
- * The severity of a multi-entry log is defined to be the maximum
- * severity of any of its children, or <code>OK</code> if it has
- * no children.
- * </p>
- *
- * @return the severity: one of <code>OK</code>, <code>ERROR</code>,
- * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
- * @since 3.2
- */
- public int getSeverity() {
- return severity;
- }
-
- /**
- * Returns the bundle-specific code describing the outcome.
- *
- * @return bundle-specific code
- * @since 3.2
- */
- public int getBundleCode() {
- return bundleCode;
- }
-
-}
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
deleted file mode 100644
index f934157b9..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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.osgi.framework.util;
-
-import java.io.*;
-import java.net.*;
-import java.security.*;
-import java.util.Properties;
-import java.util.zip.ZipFile;
-import org.eclipse.osgi.framework.internal.core.FrameworkProperties;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Utility class to execute common privileged code.
- * @since 3.1
- */
-public class SecureAction {
- // make sure we use the correct controlContext;
- private AccessControlContext controlContext;
-
- /**
- * Constructs a new SecureAction object. The constructed SecureAction object
- * uses the caller's AccessControlContext to perform security checks
- */
- public SecureAction() {
- // save the control context to be used.
- this.controlContext = AccessController.getContext();
- }
-
- /**
- * Returns a system property. Same as calling
- * System.getProperty(String).
- * @param property the property key.
- * @return the value of the property or null if it does not exist.
- */
- public String getProperty(final String property) {
- if (System.getSecurityManager() == null)
- return FrameworkProperties.getProperty(property);
- return (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object 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 (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object 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 (Properties) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return FrameworkProperties.getProperties();
- }
- }, controlContext);
- }
-
- /**
- * Creates a FileInputStream from a File. Same as calling
- * new FileInputStream(File).
- * @param file the File to craete a FileInputStream from.
- * @return The FileInputStream.
- * @throws FileNotFoundException if the File does not exist.
- */
- public FileInputStream getFileInputStream(final File file) throws FileNotFoundException {
- if (System.getSecurityManager() == null)
- return new FileInputStream(file);
- try {
- return (FileInputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws FileNotFoundException {
- return new FileInputStream(file);
- }
- }, controlContext);
- } catch (PrivilegedActionException e) {
- if (e.getException() instanceof FileNotFoundException)
- throw (FileNotFoundException) e.getException();
- throw (RuntimeException) e.getException();
- }
- }
-
- /**
- * Creates a FileInputStream from a File. Same as calling
- * new FileOutputStream(File,boolean).
- * @param file the File to create a FileOutputStream from.
- * @param append indicates if the OutputStream should append content.
- * @return The FileOutputStream.
- * @throws FileNotFoundException if the File does not exist.
- */
- public FileOutputStream getFileOutputStream(final File file, final boolean append) throws FileNotFoundException {
- if (System.getSecurityManager() == null)
- return new FileOutputStream(file.getAbsolutePath(), append);
- try {
- return (FileOutputStream) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws FileNotFoundException {
- return new FileOutputStream(file.getAbsolutePath(), append);
- }
- }, controlContext);
- } catch (PrivilegedActionException e) {
- if (e.getException() instanceof FileNotFoundException)
- throw (FileNotFoundException) e.getException();
- throw (RuntimeException) e.getException();
- }
- }
-
- /**
- * Returns the length of a file. Same as calling
- * file.length().
- * @param file a file object
- * @return the length of a file.
- */
- public long length(final File file) {
- if (System.getSecurityManager() == null)
- return file.length();
- return ((Long) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new Long(file.length());
- }
- }, controlContext)).longValue();
- }
-
- /**
- * Returns true if a file exists, otherwise false is returned. Same as calling
- * file.exists().
- * @param file a file object
- * @return true if a file exists, otherwise false
- */
- public boolean exists(final File file) {
- if (System.getSecurityManager() == null)
- return file.exists();
- return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return file.exists() ? Boolean.TRUE : Boolean.FALSE;
- }
- }, controlContext)).booleanValue();
- }
-
- /**
- * Returns true if a file is a directory, otherwise false is returned. Same as calling
- * file.isDirectory().
- * @param file a file object
- * @return true if a file is a directory, otherwise false
- */
- public boolean isDirectory(final File file) {
- if (System.getSecurityManager() == null)
- return file.isDirectory();
- return ((Boolean) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return file.isDirectory() ? Boolean.TRUE : Boolean.FALSE;
- }
- }, controlContext)).booleanValue();
- }
-
- /**
- * Returns a file's last modified stamp. Same as calling
- * file.lastModified().
- * @param file a file object
- * @return a file's last modified stamp.
- */
- public long lastModified(final File file) {
- if (System.getSecurityManager() == null)
- return file.lastModified();
- return ((Long) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new Long(file.lastModified());
- }
- }, controlContext)).longValue();
- }
-
- /**
- * Returns a file's list. Same as calling
- * file.list().
- * @param file a file object
- * @return a file's list.
- */
- public String[] list(final File file) {
- if (System.getSecurityManager() == null)
- return file.list();
- return (String[]) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return file.list();
- }
- }, controlContext);
- }
-
- /**
- * Returns a ZipFile. Same as calling
- * new ZipFile(file)
- * @param file the file to get a ZipFile for
- * @return a ZipFile
- * @throws IOException if an error occured
- */
- public ZipFile getZipFile(final File file) throws IOException {
- if (System.getSecurityManager() == null)
- return new ZipFile(file);
- try {
- return (ZipFile) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws IOException {
- return new ZipFile(file);
- }
- }, controlContext);
- } catch (PrivilegedActionException e) {
- if (e.getException() instanceof IOException)
- throw (IOException) e.getException();
- throw (RuntimeException) e.getException();
- }
- }
-
- /**
- * Gets a URL. Same a calling
- * {@link URL#URL(java.lang.String, java.lang.String, int, java.lang.String, java.net.URLStreamHandler)}
- * @param protocol the protocol
- * @param host the host
- * @param port the port
- * @param file the file
- * @param handler the URLStreamHandler
- * @return a URL
- * @throws MalformedURLException
- */
- public URL getURL(final String protocol, final String host, final int port, final String file, final URLStreamHandler handler) throws MalformedURLException {
- if (System.getSecurityManager() == null)
- return new URL(protocol, host, port, file, handler);
- try {
- return (URL) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws MalformedURLException {
- return new URL(protocol, host, port, file, handler);
- }
- }, controlContext);
- } catch (PrivilegedActionException e) {
- if (e.getException() instanceof MalformedURLException)
- throw (MalformedURLException) e.getException();
- throw (RuntimeException) e.getException();
- }
- }
-
- /**
- * Creates a new Thread from a Runnable. Same as calling
- * new Thread(target,name).
- * @param target the Runnable to create the Thread from.
- * @param name The name of the Thread.
- * @return The new Thread
- */
- public Thread createThread(final Runnable target, final String name) {
- if (System.getSecurityManager() == null)
- return new Thread(target, name);
- return (Thread) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new Thread(target, name);
- }
- }, controlContext);
- }
-
- /**
- * Gets a service object. Same as calling
- * context.getService(reference)
- * @param reference the ServiceReference
- * @param context the BundleContext
- * @return a service object
- */
- public Object getService(final ServiceReference reference, final BundleContext context) {
- if (System.getSecurityManager() == null)
- return context.getService(reference);
- return AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return context.getService(reference);
- }
- }, controlContext);
- }
-
- /**
- * Returns a Class. Same as calling
- * Class.forName(name)
- * @param name the name of the class.
- * @return a Class
- * @throws ClassNotFoundException
- */
- public Class forName(final String name) throws ClassNotFoundException {
- if (System.getSecurityManager() == null)
- return Class.forName(name);
- try {
- return (Class) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception {
- return Class.forName(name);
- }
- }, controlContext);
- } catch (PrivilegedActionException e) {
- if (e.getException() instanceof ClassNotFoundException)
- throw (ClassNotFoundException) e.getException();
- throw (RuntimeException) e.getException();
- }
- }
-
- /**
- * Opens a ServiceTracker. Same as calling tracker.open()
- * @param tracker the ServiceTracker to open.
- */
- public void open(final ServiceTracker tracker) {
- if (System.getSecurityManager() == null) {
- tracker.open();
- return;
- }
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- tracker.open();
- return null;
- }
- }, controlContext);
- }
-}
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
deleted file mode 100644
index 31264e819..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/datalocation/Location.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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.osgi.service.datalocation;
-
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * A Location represents a URL which may have a default value, may be read only, may
- * or may not have a current value and may be cascaded on to a parent location.
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- * @since 3.0
- */
-public interface Location {
-
- /**
- * Constant which defines the filter string for acquiring the service which
- * specifies the instance location.
- *
- * @since 3.2
- */
- public static final String INSTANCE_FILTER = "(&(objectClass=" + Location.class.getName() + ")(type=osgi.instance.area))"; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Constant which defines the filter string for acquiring the service which
- * specifies the install location.
- *
- * @since 3.2
- */
- public static final String INSTALL_FILTER = "(&(objectClass=" + Location.class.getName() + ")(type=osgi.install.area))"; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Constant which defines the filter string for acquiring the service which
- * specifies the configuration location.
- *
- * @since 3.2
- */
- public static final String CONFIGURATION_FILTER = "(&(objectClass=" + Location.class.getName() + ")(type=osgi.configuration.area))"; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Constant which defines the filter string for acquiring the service which
- * specifies the user location.
- *
- * @since 3.2
- */
- public static final String USER_FILTER = "(&(objectClass=" + Location.class.getName() + ")(type=osgi.user.area))"; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Returns <code>true</code> if this location allows a default value to be assigned
- * and <code>false</code> otherwise.
- *
- * @return whether or not this location can have a default value assigned
- */
- public boolean allowsDefault();
-
- /**
- * Returns the default value of this location if any. If no default is available then
- * <code>null</code> is returned. Note that even locations which allow defaults may still
- * return <code>null</code>.
- *
- * @return the default value for this location or <code>null</code>
- */
- public URL getDefault();
-
- /**
- * Returns the parent of this location or <code>null</code> if none is available.
- *
- * @return the parent of this location or <code>null</code>
- */
- public Location getParentLocation();
-
- /**
- * 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();
-
- /**
- * Returns <code>true</code> if this location has a value and <code>false</code>
- * otherwise.
- *
- * @return boolean value indicating whether or not the value is set
- */
- public boolean isSet();
-
- /**
- * Returns <code>true</code> if this location represents a read only location and
- * <code>false</code> otherwise. The read only character
- * of a location is not in enforced in any way but rather expresses the intention of the
- * location's creator.
- *
- * @return boolean value indicating whether the location is read only
- */
- public boolean isReadOnly();
-
- /**
- * Sets and optionally locks the location's value to the given {@link URL}. If the location
- * already has a value an exception is thrown. If locking is requested and fails, <code>false</code>
- * is returned and the {@link URL} of this location is not set.
- *
- * @param value the value of this location
- * @param lock whether or not to lock this location
- * @return whether or not the location was successfully set and, if requested, locked.
- * @throws IllegalStateException if the location's value is already set
- */
- public boolean setURL(URL value, boolean lock) throws IllegalStateException;
-
- /**
- * Attempts to lock this location with a canonical locking mechanism and return
- * <code>true</code> if the lock could be acquired. Not all locations can be
- * locked.
- * <p>
- * Locking a location is advisory only. That is, it does not prevent other applications from
- * modifying the same location
- * </p>
- * @return true if the lock could be acquired; otherwise false is returned
- *
- * @exception IOException if there was an unexpected problem while acquiring the lock
- */
- public boolean lock() throws IOException;
-
- /**
- * Releases the lock on this location. If the location is not already locked, no action
- * is taken.
- */
- public void release();
-}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/debug/DebugOptions.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/debug/DebugOptions.java
deleted file mode 100644
index cf88ce494..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/debug/DebugOptions.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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.osgi.service.debug;
-
-/**
- * Used to get debug options settings.
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- * @since 3.1
- */
-public interface DebugOptions {
-
- /**
- * Returns the identified option as a boolean value. The specified
- * defaultValue is returned if no such option is found. Options are specified
- * in the general form <i>&lt;Bundle-SymbolicName&gt;/&lt;option-path&gt;</i>.
- * For example, <code>org.eclipse.core.runtime/debug</code>
- *
- * @param option the name of the option to lookup
- * @param defaultValue the value to return if no such option is found
- * @return the value of the requested debug option or the
- * defaultValue if no such option is found.
- */
- public boolean getBooleanOption(String option, boolean defaultValue);
-
- /**
- * Returns the identified option. <code>null</code>
- * is returned if no such option is found. Options are specified
- * in the general form <i>&lt;Bundle-SymbolicName&gt;/&lt;option-path&gt;</i>.
- * For example, <code>org.eclipse.core.runtime/debug</code>
- *
- * @param option the name of the option to lookup
- * @return the value of the requested debug option or <code>null</code>
- */
- public abstract String getOption(String option);
-
- /**
- * Returns the identified option. The specified defaultValue is
- * returned if no such option is found or if a NumberFormatException is thrown
- * while converting the option value to an integer. Options are specified
- * in the general form <i>&lt;Bundle-SymbolicName&gt;/&lt;option-path&gt;</i>.
- * For example, <code>org.eclipse.core.runtime/debug</code>
- *
- * @param option the name of the option to lookup
- * @param defaultValue the value to return if no such option is found
- * @return the value of the requested debug option or the
- * defaultValue if no such option is found.
- */
- public abstract String getOption(String option, String defaultValue);
-
- /**
- * Returns the identified option as an int value. The specified
- * defaultValue is returned if no such option is found. Options are specified
- * in the general form <i>&lt;Bundle-SymbolicName&gt;/&lt;option-path&gt;</i>.
- * For example, <code>org.eclipse.core.runtime/debug</code>
- *
- * @param option the name of the option to lookup
- * @param defaultValue the value to return if no such option is found
- * @return the value of the requested debug option or the
- * defaultValue if no such option is found.
- */
- public abstract int getIntegerOption(String option, int defaultValue);
-
- /**
- * Sets the identified option to the identified value.
- * @param option the name of the option to set
- * @param value the value of the option to set
- */
- public abstract void setOption(String option, String value);
-}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/localization/BundleLocalization.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/localization/BundleLocalization.java
deleted file mode 100644
index 31b4ff3d9..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/localization/BundleLocalization.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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.osgi.service.localization;
-
-import java.util.ResourceBundle;
-import org.osgi.framework.Bundle;
-
-/**
- * The interface of the service that gets {@link ResourceBundle} objects from a given
- * bundle with a given locale.
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- * @since 3.1
- */
-public interface BundleLocalization {
-
- /**
- * The getLocalization method gets a ResourceBundle object for the given
- * locale and bundle.
- * @param bundle the bundle to get localization for
- * @param locale the name of the locale to get
- *
- * @return A <code>ResourceBundle</code> object for the given bundle and locale.
- * If <code>null</code> is passed for the locale parameter, the default locale is used.
- */
- public ResourceBundle getLocalization(Bundle bundle, String locale);
-}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/urlconversion/URLConverter.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/urlconversion/URLConverter.java
deleted file mode 100644
index f16054436..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/service/urlconversion/URLConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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.osgi.service.urlconversion;
-
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * The interface of the service that allows client-defined protocol
- * URLs to be converted to native file URLs on the local file system.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @since 3.1
- */
-public interface URLConverter {
-
- /**
- * Converts a URL that uses a user-defined protocol into a URL that uses the file
- * protocol. The contents of the URL may be extracted into a cache on the file-system
- * in order to get a file URL.
- * <p>
- * If the protocol for the given URL is not recognized by this converter, the original
- * URL is returned as-is.
- * </p>
- * @param url the original URL
- * @return the converted file URL or the original URL passed in if it is
- * not recognized by this converter
- * @throws IOException if an error occurs during the conversion
- * @since 3.2
- */
- public URL toFileURL(URL url) throws IOException;
-
- /**
- * Converts a URL that uses a client-defined protocol into a URL that uses a
- * protocol which is native to the Java class library (file, jar, http, etc).
- * <p>
- * Note however that users of this API should not assume too much about the
- * results of this method. While it may consistently return a file: URL in certain
- * installation configurations, others may result in jar: or http: URLs.
- * </p>
- * <p>
- * If the protocol is not reconized by this converter, then the original URL is
- * returned as-is.
- * </p>
- * @param url the original URL
- * @return the resolved URL or the original if the protocol is unknown to this converter
- * @exception IOException if unable to resolve URL
- * @throws IOException if an error occurs during the resolution
- * @since 3.2
- */
- public URL resolve(URL url) throws IOException;
-}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/ManagedOutputStream.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/ManagedOutputStream.java
deleted file mode 100644
index 4c4cf045d..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/ManagedOutputStream.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 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.osgi.storagemanager;
-
-import java.io.*;
-
-/**
- * Represents a managed output stream for target managed by a storage manager.
- * @see StorageManager#getOutputStream(String)
- * @see StorageManager#getOutputStreamSet(String[])
- * <p>
- * Clients may not extend this class.
- * </p>
- * @since 3.2
- */
-// Note the implementation of this class originated from the following deprecated classes:
-// /org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/StreamManagerOutputStream.java
-public final class ManagedOutputStream extends FilterOutputStream {
- static final int ST_OPEN = 0;
- static final int ST_CLOSED = 1;
- private String target;
- private StorageManager manager;
- private File outputFile;
- private int state;
- private ManagedOutputStream[] streamSet = null;
-
- ManagedOutputStream(OutputStream out, StorageManager manager, String target, File outputFile) {
- super(out);
- this.manager = manager;
- this.target = target;
- this.outputFile = outputFile;
- this.state = ST_OPEN;
- }
-
- /**
- * Instructs this output stream to be closed and storage manager to
- * be updated as appropriate. If this managed output stream is part of
- * a set returned by {@link StorageManager#getOutputStreamSet(String[])} then
- * the storage manager will only be updated with the new content after all
- * of the managed output streams in the set are closed successfully.
- * @see FilterOutputStream#close()
- */
- public void close() throws IOException {
- manager.closeOutputStream(this);
- }
-
- /**
- * Instructs this output stream to be closed and the contents discarded.
- * If this managed output stream is part of a set returned by
- * {@link StorageManager#getOutputStreamSet(String[])} then the new
- * content of all managed output streams in the set will be discarded.
- */
- public void abort() {
- manager.abortOutputStream(this);
- }
-
- OutputStream getOutputStream() {
- return out;
- }
-
- String getTarget() {
- return target;
- }
-
- File getOutputFile() {
- return outputFile;
- }
-
- int getState() {
- return state;
- }
-
- void setState(int state) {
- this.state = state;
- }
-
- void setStreamSet(ManagedOutputStream[] set) {
- streamSet = set;
- }
-
- ManagedOutputStream[] getStreamSet() {
- return streamSet;
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.FilterOutputStream#write(byte[], int, int)
- * Override this method to prevent single byte writes to the output stream
- * which is done by the default implementation of FilteredOutputStream
- */
- public void write(byte[] bytes, int off, int len) throws IOException {
- out.write(bytes, off, len);
- }
-}
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
deleted file mode 100644
index 09f973563..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/storagemanager/StorageManager.java
+++ /dev/null
@@ -1,926 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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.osgi.storagemanager;
-
-import java.io.*;
-import java.util.*;
-import org.eclipse.core.runtime.internal.adaptor.*;
-import org.eclipse.osgi.framework.internal.reliablefile.*;
-import org.eclipse.osgi.framework.util.SecureAction;
-
-/**
- * Storage managers provide a facility for tracking the state of a group of files having
- * relationship with each others and being updated by several entities at the same time.
- * The typical usecase is in shared configuration data areas.
- * <p>
- * The facilities provided here are cooperative. That is, all participants must
- * agree to the conventions and to calling the given API. There is no capacity
- * to enforce these conventions or prohibit corruption.
- * </p>
- * <p>
- * Clients can not extend this class
- * </p>
- * <p>
- * Example
- * <pre>
- * //Open the storage manager
- * org.eclipse.osgi.storagemanager.StorageManager cacheStorageManager = new StorageManager("d:/sharedFolder/bar/", false); //$NON-NLS-1$
- * try {
- * cacheStorageManager.open(true);
- * } catch (IOException e) {
- * // Ignore the exception. The registry will be rebuilt from source.
- * }
- *
- * //To read from a file
- * java.io.File fileA = cacheStorageManager.lookup("fileA", false));
- * java.io.File fileB = cacheStorageManager.lookup("fileB", false));
- * //Do the reading code
- * new java.io.FileOutputStream(fileA);
- *
- * //To write in files
- * cacheStorageManager.add("fileC"); //add the file to the filemanager (in this case we assume it is not already here)
- * cacheStorageManager.add("fileD");
- *
- * // The file is never written directly into the file name, so we create some temporary file
- * java.io.File fileC = cacheStorageManager.createTempFile("fileC");
- * java.io.File fileD = cacheStorageManager.createTempFile("fileD");
- *
- * //Do the actual writing here...
- *
- * //Finally update the storagemanager with the actual file to manage.
- * cacheStorageManager.update(new String[] {"fileC", "fileD"}, new String[] {fileC.getName(), fileD.getName()};
- *
- * //Close the file manager at the end
- * cacheStorageManager.close();
- * </pre>
- * </p>
- * <p>
- * Implementation details <br>
- * The following implementation details are provided to help with understanding the
- * behavior of this class.
- * The general principle is to maintain a table which maps user-level file names
- * onto an actual disk files. If a file needs to be modified,
- * it is stored into a new file. The old content is not removed from disk until all entities
- * have closed there instance of the storage manager.
- * Once the instance has been created, open() must be called before performing any other operation.
- * On open the storage manager obtains a snapshot of the current managed files contents. If an
- * entity updates a managed file, the storage manager will save the content for that instance of the
- * storage manager, all other storage manager instances will still have access to that managed file's
- * content as it was when the instance was first opened.
- * </p>
- * @since 3.2
- */
-
-// Note the implementation of this class originated from the following deprecated classes:
-// /org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/FileManager.java
-// /org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/StreamManager.java
-public final class StorageManager {
- private static final int FILETYPE_STANDARD = 0;
- private static final int FILETYPE_RELIABLEFILE = 1;
- private static final SecureAction secure = new SecureAction();
- private static boolean tempCleanup = Boolean.valueOf(secure.getProperty("osgi.embedded.cleanTempFiles")).booleanValue(); //$NON-NLS-1$
- private static boolean openCleanup = Boolean.valueOf(secure.getProperty("osgi.embedded.cleanupOnOpen")).booleanValue(); //$NON-NLS-1$
- private static final String MANAGER_FOLDER = ".manager"; //$NON-NLS-1$
- private static final String TABLE_FILE = ".fileTable"; //$NON-NLS-1$
- private static final String LOCK_FILE = ".fileTableLock"; //$NON-NLS-1$
- private static final int MAX_LOCK_WAIT = 5000; // 5 seconds
-
- private class Entry {
- int readId;
- int writeId;
- int fileType;
-
- Entry(int readId, int writeId, int type) {
- this.readId = readId;
- this.writeId = writeId;
- this.fileType = type;
- }
-
- int getReadId() {
- return readId;
- }
-
- int getWriteId() {
- return writeId;
- }
-
- int getFileType() {
- return fileType;
- }
-
- void setReadId(int value) {
- readId = value;
- }
-
- void setWriteId(int value) {
- writeId = value;
- }
-
- void setFileType(int type) {
- fileType = type;
- }
- }
-
- private File base; //The folder managed
- private File managerRoot; //The folder that will contain all the file related to the functionning of the manager (typically a subdir of base)
-
- private String lockMode = null;
- private File tableFile = null;
- private File lockFile; // The lock file for the table (this file is the same for all the instances)
- private Locker locker; // The locker for the lock
-
- private File instanceFile = null; //The file reprensenting the running instance. It is created when the table file is read.
- private Locker instanceLocker = null; //The locker for the instance file.
- private boolean readOnly; // Whether this storage manager is in read-only mode
- private boolean open; // Whether this storage manager is open for use
-
- // locking related fields
- private int tableStamp = -1;
-
- private Properties table = new Properties();
- private boolean useReliableFiles = Boolean.valueOf(secure.getProperty("osgi.useReliableFiles")).booleanValue(); //$NON-NLS-1$
-
- /**
- * Returns a new storage manager for the area identified by the given base
- * directory.
- *
- * @param base the directory holding the files to be managed
- * @param lockMode the lockMode to use for the storage manager. It can have one the 3 values: none, java.io, java.nio
- * and also supports null in which case the lock strategy will be the global one.
- */
- public StorageManager(File base, String lockMode) {
- this(base, lockMode, false);
- }
-
- /**
- * Returns a new storage manager for the area identified by the given base
- * directory.
- *
- * @param base the directory holding the files to be managed
- * @param lockMode the lockMode to use for the storage manager. It can have one the 3 values: none, java.io, java.nio
- * and also supports null in which case the lock strategy will be the global one.
- * @param readOnly true if the managed files are read-only
- */
- public StorageManager(File base, String lockMode, boolean readOnly) {
- this.base = base;
- this.lockMode = lockMode;
- this.managerRoot = new File(base, MANAGER_FOLDER);
- if (!readOnly)
- this.managerRoot.mkdirs();
- this.tableFile = new File(managerRoot, TABLE_FILE);
- this.lockFile = new File(managerRoot, LOCK_FILE);
- this.readOnly = readOnly;
- open = false;
- }
-
- private void initializeInstanceFile() throws IOException {
- if (instanceFile != null || readOnly)
- return;
- this.instanceFile = File.createTempFile(".tmp", ".instance", managerRoot); //$NON-NLS-1$//$NON-NLS-2$
- this.instanceFile.deleteOnExit();
- instanceLocker = BasicLocation.createLocker(instanceFile, lockMode);
- instanceLocker.lock();
- }
-
- private String getAbsolutePath(String file) {
- return new File(base, file).getAbsolutePath();
- }
-
- /**
- * Add the given managed file name to the list of files managed by this manager.
- *
- * @param managedFile name of the file to manage
- * @throws IOException if there are any problems adding the given file name to the manager
- */
- public void add(String managedFile) throws IOException {
- add(managedFile, FILETYPE_STANDARD);
- }
-
- /* (non-Javadoc
- * Add the given file name to the list of files managed by this manager.
- *
- * @param managedFile name of the file to manage.
- * @param fileType the file type.
- * @throws IOException if there are any problems adding the given file to the manager
- */
- private void add(String managedFile, int fileType) throws IOException {
- if (!open)
- throw new IOException(EclipseAdaptorMsg.fileManager_notOpen);
- if (readOnly)
- throw new IOException(EclipseAdaptorMsg.fileManager_illegalInReadOnlyMode);
- if (!lock(true))
- throw new IOException(EclipseAdaptorMsg.fileManager_cannotLock);
- try {
- updateTable();
- Entry entry = (Entry) table.get(managedFile);
- if (entry == null) {
- entry = new Entry(0, 1, fileType);
- table.put(managedFile, entry);
- // if this managed file existed before, ensure there is not an old
- // version on the disk to avoid name collisions. If version found,
- // us the oldest generation+1 for the write ID.
- int oldestGeneration = findOldestGeneration(managedFile);
- if (oldestGeneration != 0)
- entry.setWriteId(oldestGeneration + 1);
- save();
- } else {
- if (entry.getFileType() != fileType) {
- entry.setFileType(fileType);
- updateTable();
- save();
- }
- }
- } finally {
- release();
- }
- }
-
- /* (non-Javadoc)
- * Find the oldest generation of a file still available on disk
- * @param file the file from which to obtain the oldest generation.
- * @return the oldest generation of the file or 0 if the file does
- * not exist.
- */
- private int findOldestGeneration(String managedFile) {
- String[] files = base.list();
- int oldestGeneration = 0;
- if (files != null) {
- String name = managedFile + '.';
- int len = name.length();
- for (int i = 0; i < files.length; i++) {
- if (!files[i].startsWith(name))
- continue;
- try {
- int generation = Integer.parseInt(files[i].substring(len));
- if (generation > oldestGeneration)
- oldestGeneration = generation;
- } catch (NumberFormatException e) {
- continue;
- }
- }
- }
- return oldestGeneration;
- }
-
- /**
- * Update the given managed files with the content in the given source files.
- * The managedFiles is a list of managed file names which are currently managed.
- * If a managed file name is not currently managed it will be added as a
- * managed file for this storage manager.
- * The sources are absolute (or relative to the current working directory)
- * file paths containing the new content for the corresponding managed files.
- *
- * @param managedFiles the managed files to update
- * @param sources the new content for the managed files
- * @throws IOException if there are any problems updating the given managed files
- */
- public void update(String[] managedFiles, String[] sources) throws IOException {
- if (!open)
- throw new IOException(EclipseAdaptorMsg.fileManager_notOpen);
- if (readOnly)
- throw new IOException(EclipseAdaptorMsg.fileManager_illegalInReadOnlyMode);
- if (!lock(true))
- throw new IOException(EclipseAdaptorMsg.fileManager_cannotLock);
- try {
- updateTable();
- int[] originalReadIDs = new int[managedFiles.length];
- boolean error = false;
- for (int i = 0; i < managedFiles.length; i++) {
- originalReadIDs[i] = getId(managedFiles[i]);
- if (!update(managedFiles[i], sources[i]))
- error = true;
- }
- if (error) {
- // restore the original readIDs to avoid inconsistency for this group
- for (int i = 0; i < managedFiles.length; i++) {
- Entry entry = (Entry) table.get(managedFiles[i]);
- entry.setReadId(originalReadIDs[i]);
- }
- throw new IOException(EclipseAdaptorMsg.fileManager_updateFailed);
- }
- save(); //save only if no errors
- } finally {
- release();
- }
- }
-
- /**
- * Returns a list of all the managed files currently being managed.
- *
- * @return the names of the managed files
- */
- public String[] getManagedFiles() {
- if (!open)
- return null;
- Set set = table.keySet();
- String[] keys = (String[]) set.toArray(new String[set.size()]);
- String[] result = new String[keys.length];
- for (int i = 0; i < keys.length; i++)
- result[i] = new String(keys[i]);
- return result;
- }
-
- /**
- * Returns the directory containing the files being managed by this storage
- * manager.
- *
- * @return the directory containing the managed files
- */
- public File getBase() {
- return base;
- }
-
- /**
- * Returns the current numeric id (appendage) of the given managed file.
- * <code>managedFile + "." + getId(target)</code>. A value of -1 is returned
- * if the given name is not managed.
- *
- * @param managedFile the name of the managed file
- * @return the id of the managed file
- */
- public int getId(String managedFile) {
- if (!open)
- return -1;
- Entry entry = (Entry) table.get(managedFile);
- if (entry == null)
- return -1;
- return entry.getReadId();
- }
-
- /**
- * Returns if readOnly state this storage manager is using.
- *
- * @return if this storage manager update state is read-only.
- */
- public boolean isReadOnly() {
- return readOnly;
- }
-
- /* (non-Javadoc)
- * Attempts to lock the state of this manager and returns <code>true</code>
- * if the lock could be acquired.
- * <p>
- * Locking a manager is advisory only. That is, it does not prevent other
- * applications from modifying the files managed by this manager.
- * </p>
- *
- * @exception IOException
- * if there was an unexpected problem while acquiring the
- * lock.
- */
- private boolean lock(boolean wait) throws IOException {
- if (readOnly)
- return false;
- if (locker == null) {
- locker = BasicLocation.createLocker(lockFile, lockMode);
- if (locker == null)
- throw new IOException(EclipseAdaptorMsg.fileManager_cannotLock);
- }
- boolean locked = locker.lock();
- if (locked || !wait)
- return locked;
- //Someone else must have the directory locked, but they should release it quickly
- long start = System.currentTimeMillis();
- while (true) {
- try {
- Thread.sleep(200); // 5x per second
- } catch (InterruptedException e) {/*ignore*/
- }
- locked = locker.lock();
- if (locked)
- return true;
- // never wait longer than 5 seconds
- long time = System.currentTimeMillis() - start;
- if (time > MAX_LOCK_WAIT)
- return false;
- }
- }
-
- /**
- * Returns the actual file location to use when reading the given managed file.
- * A value of <code>null</code> can be returned if the given managed file name is not
- * managed and add is set to false.
- * <p>
- * The returned file should be considered read-only. Any updates to the content of this
- * file should be done using {@link #update(String[], String[])}.
- *
- * @param managedFile the managed file to lookup
- * @param add indicate whether the managed file name should be added to the manager if
- * it is not already managed.
- * @throws IOException if the add flag is set to true and the addition of the managed file failed
- * @return the absolute file location to use for the given managed file or
- * <code>null</code> if the given managed file is not managed
- */
- public File lookup(String managedFile, boolean add) throws IOException {
- if (!open)
- throw new IOException(EclipseAdaptorMsg.fileManager_notOpen);
- Entry entry = (Entry) table.get(managedFile);
- if (entry == null) {
- if (add) {
- add(managedFile);
- entry = (Entry) table.get(managedFile);
- } else {
- return null;
- }
- }
- return new File(getAbsolutePath(managedFile + '.' + entry.getReadId()));
- }
-
- private boolean move(String source, String managedFile) {
- File original = new File(source);
- File targetFile = new File(managedFile);
- // its ok if the original does not exist. The table entry will capture
- // that fact. There is no need to put something in the filesystem.
- if (!original.exists() || targetFile.exists())
- return false;
- return original.renameTo(targetFile);
- }
-
- /**
- * Saves the state of the storage manager and releases any locks held.
- */
- private void release() {
- if (locker == null)
- return;
- locker.release();
- }
-
- /**
- * Removes the given managed file from management by this storage manager.
- *
- * @param managedFile the managed file to remove
- * @throws IOException if an error occured removing the managed file
- */
- public void remove(String managedFile) throws IOException {
- if (!open)
- throw new IOException(EclipseAdaptorMsg.fileManager_notOpen);
- if (readOnly)
- throw new IOException(EclipseAdaptorMsg.fileManager_illegalInReadOnlyMode);
- // The removal needs to be done eagerly, so the value is effectively removed from the disktable.
- // Otherwise, an updateTable() caused by an update(,) could cause the file to readded to the local table.
- if (!lock(true))
- throw new IOException(EclipseAdaptorMsg.fileManager_cannotLock);
- try {
- updateTable();
- table.remove(managedFile);
- save();
- } finally {
- release();
- }
- }
-
- private void updateTable() throws IOException {
- int stamp;
- stamp = ReliableFile.lastModifiedVersion(tableFile);
- if (stamp == tableStamp || stamp == -1)
- return;
- Properties diskTable = new Properties();
- try {
- InputStream input;
- input = new ReliableFileInputStream(tableFile);
- try {
- diskTable.load(input);
- } finally {
- input.close();
- }
- } catch (IOException e) {
- throw e; // rethrow the exception, we have nothing to add here
- }
- tableStamp = stamp;
- for (Enumeration e = diskTable.keys(); e.hasMoreElements();) {
- String file = (String) e.nextElement();
- String value = diskTable.getProperty(file);
- if (value != null) {
- Entry entry = (Entry) table.get(file);
- // check front of value for ReliableFile
- int id;
- int fileType;
- int idx = value.indexOf(',');
- if (idx != -1) {
- id = Integer.parseInt(value.substring(0, idx));
- fileType = Integer.parseInt(value.substring(idx + 1));
- } else {
- id = Integer.parseInt(value);
- fileType = FILETYPE_STANDARD;
- }
- if (entry == null) {
- table.put(file, new Entry(id, id + 1, fileType));
- } else {
- entry.setWriteId(id + 1);
- //don't change type
- }
- }
- }
- }
-
- /*
- * This method should be called while the manager is locked.
- */
- private void save() throws IOException {
- if (readOnly)
- return;
- // if the table file has change on disk, update our data structures then
- // rewrite the file.
- updateTable();
-
- Properties props = new Properties();
- for (Enumeration e = table.keys(); e.hasMoreElements();) {
- String file = (String) e.nextElement();
- Entry entry = (Entry) table.get(file);
- String value;
- if (entry.getFileType() != FILETYPE_STANDARD) {
- value = Integer.toString(entry.getWriteId() - 1) + ',' + //In the table we save the write number - 1, because the read number can be totally different.
- Integer.toString(entry.getFileType());
- } else {
- value = Integer.toString(entry.getWriteId() - 1); //In the table we save the write number - 1, because the read number can be totally different.
- }
- props.put(file, value);
- }
- ReliableFileOutputStream fileStream = new ReliableFileOutputStream(tableFile);
- try {
- boolean error = true;
- try {
- props.store(fileStream, "safe table"); //$NON-NLS-1$
- fileStream.close();
- error = false;
- } finally {
- if (error)
- fileStream.abort();
- }
- } catch (IOException e) {
- throw new IOException(EclipseAdaptorMsg.fileManager_couldNotSave);
- }
- tableStamp = ReliableFile.lastModifiedVersion(tableFile);
- }
-
- private boolean update(String managedFile, String source) throws IOException {
- Entry entry = (Entry) table.get(managedFile);
- if (entry == null)
- add(managedFile);
- int newId = entry.getWriteId();
- // attempt to rename the file to the next generation
- boolean success = move(getAbsolutePath(source), getAbsolutePath(managedFile) + '.' + newId);
- if (!success) {
- //possible the next write generation file exists? Lets determine the largest
- //generation number, then use that + 1.
- newId = findOldestGeneration(managedFile) + 1;
- success = move(getAbsolutePath(source), getAbsolutePath(managedFile) + '.' + newId);
- }
- if (!success)
- return false;
- // update the entry. read and write ids should be the same since
- // everything is in sync
- entry.setReadId(newId);
- entry.setWriteId(newId + 1);
- return true;
- }
-
- /**
- * This methods remove all the temporary files that have been created by the storage manager.
- * This removal is only done if the instance of eclipse calling this method is the last instance using this storage manager.
- * @throws IOException
- */
- private void cleanup() throws IOException {
- if (readOnly)
- return;
- //Lock first, so someone else can not start while we're in the middle of cleanup
- if (!lock(true))
- throw new IOException(EclipseAdaptorMsg.fileManager_cannotLock);
- try {
- //Iterate through the temp files and delete them all, except the one representing this storage manager.
- String[] files = managerRoot.list();
- 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);
- if (tmpLocker.lock()) {
- //If I can lock it is a file that has been left behind by a crash
- tmpLocker.release();
- new File(managerRoot, files[i]).delete();
- } else {
- tmpLocker.release();
- return; //The file is still being locked by somebody else
- }
- }
- }
- }
-
- //If we are here it is because we are the last instance running. After locking the table and getting its latest content, remove all the backup files and change the table
- updateTable();
- Collection managedFiles = table.entrySet();
- for (Iterator iter = managedFiles.iterator(); iter.hasNext();) {
- Map.Entry fileEntry = (Map.Entry) iter.next();
- String fileName = (String) fileEntry.getKey();
- Entry info = (Entry) fileEntry.getValue();
- if (info.getFileType() == FILETYPE_RELIABLEFILE) {
- ReliableFile.cleanupGenerations(new File(base, fileName));
- } else {
- //Because we are cleaning up, we are giving up the values from our table, and we must delete all the files that are not referenced by the table
- String readId = Integer.toString(info.getWriteId() - 1);
- deleteCopies(fileName, readId);
- }
- }
-
- if (tempCleanup) {
- files = base.list();
- if (files != null) {
- for (int i = 0; i < files.length; i++) {
- if (files[i].endsWith(ReliableFile.tmpExt)) {
- new File(base, files[i]).delete();
- }
- }
- }
- }
- } catch (IOException e) {
- //If the exception comes from the updateTable(), there has been a problem in reading the file.
- //If an exception occured in the save, then the table won't be up to date!
- throw e;
- } finally {
- release();
- }
- }
-
- private void deleteCopies(String fileName, String exceptionNumber) {
- String notToDelete = fileName + '.' + exceptionNumber;
- String[] files = base.list();
- if (files == null)
- return;
- for (int i = 0; i < files.length; i++) {
- if (files[i].startsWith(fileName + '.') && !files[i].equals(notToDelete))
- new File(base, files[i]).delete();
- }
- }
-
- /**
- * This method declares the storage manager as closed. From thereon, the instance can no longer be used.
- * It is important to close the manager as it also cleans up old copies of the managed files.
- */
- public void close() {
- if (!open)
- return;
- open = false;
- if (readOnly)
- return;
- try {
- cleanup();
- } catch (IOException e) {
- //Ignore and close.
- }
- if (instanceLocker != null)
- instanceLocker.release();
-
- if (instanceFile != null)
- instanceFile.delete();
- }
-
- /**
- * This methods opens the storage manager.
- * This method must be called before any operation on the storage manager.
- * @param wait indicates if the open operation must wait in case of contention on the lock file.
- * @throws IOException if an error occured opening the storage manager
- */
- public void open(boolean wait) throws IOException {
- if (openCleanup)
- cleanup();
- if (!readOnly) {
- boolean locked = lock(wait);
- if (!locked && wait)
- throw new IOException(EclipseAdaptorMsg.fileManager_cannotLock);
- }
-
- try {
- initializeInstanceFile();
- updateTable();
- open = true;
- } finally {
- release();
- }
- }
-
- /**
- * Creates a new unique empty temporary-file in the storage manager base directory. The file name
- * must be at least 3 characters. This file can later be used to update a managed file.
- *
- * @param file the file name to create temporary file from.
- * @return the newly-created empty file.
- * @throws IOException if the file can not be created.
- * @see #update(String[], String[])
- */
- public File createTempFile(String file) throws IOException {
- if (readOnly)
- throw new IOException(EclipseAdaptorMsg.fileManager_illegalInReadOnlyMode);
- File tmpFile = File.createTempFile(file, ReliableFile.tmpExt, base);
- tmpFile.deleteOnExit();
- return tmpFile;
- }
-
- /**
- * Returns a managed <code>InputStream</code> for a managed file.
- * <code>null</code> can be returned if the given name is not managed.
- *
- * @param managedFile the name of the managed file to open.
- * @return an input stream to the managed file or
- * <code>null</code> if the given name is not managed.
- * @throws IOException if the content is missing, corrupt or an error occurs.
- */
- public InputStream getInputStream(String managedFile) throws IOException {
- return getInputStream(managedFile, ReliableFile.OPEN_BEST_AVAILABLE);
- }
-
- /**
- * Returns a managed input stream set for the managed file names.
- * Elements of the returned set may be <code>null</code> if a given name is not managed.
- * This method should be used for managed file sets which use the output streams returned
- * by the {@link #getOutputStreamSet(String[])} to save data.
- *
- * @param managedFiles the names of the managed files to open.
- * @return a set input streams to the given managed files.
- * @throws IOException if the content of one of the managed files is missing, corrupt or an error occurs.
- */
- public InputStream[] getInputStreamSet(String[] managedFiles) throws IOException {
- InputStream[] streams = new InputStream[managedFiles.length];
- for (int i = 0; i < streams.length; i++)
- streams[i] = getInputStream(managedFiles[i], ReliableFile.OPEN_FAIL_ON_PRIMARY);
- return streams;
- }
-
- private InputStream getInputStream(String managedFiles, int openMask) throws IOException {
- if (useReliableFiles) {
- int id = getId(managedFiles);
- if (id == -1)
- return null;
- return new ReliableFileInputStream(new File(getBase(), managedFiles), id, openMask);
- }
- File lookup = lookup(managedFiles, false);
- if (lookup == null)
- return null;
- return new FileInputStream(lookup);
- }
-
- /**
- * Returns a <code>ManagedOutputStream</code> for a managed file.
- * Closing the ouput stream will update the storage manager with the
- * new content of the managed file.
- *
- * @param managedFile the name of the managed file to write.
- * @return a managed output stream for the managed file.
- * @throws IOException if an error occurs opening the managed file.
- */
- public ManagedOutputStream getOutputStream(String managedFile) throws IOException {
- if (useReliableFiles) {
- ReliableFileOutputStream out = new ReliableFileOutputStream(new File(getBase(), managedFile));
- return new ManagedOutputStream(out, this, managedFile, null);
- }
- File tmpFile = createTempFile(managedFile);
- return new ManagedOutputStream(new FileOutputStream(tmpFile), this, managedFile, tmpFile);
- }
-
- /**
- * Returns an array of <code>ManagedOutputStream</code> for a set of managed files.
- * When all managed output streams in the set have been closed, the storage manager
- * will be updated with the new content of the managed files.
- * Aborting any one of the streams will cause the entire content of the set to abort
- * and be discarded.
- *
- * @param managedFiles list of names of the managed file to write.
- * @return an array of managed output streams respectively of managed files.
- * @throws IOException if an error occurs opening the managed files.
- */
- public ManagedOutputStream[] getOutputStreamSet(String[] managedFiles) throws IOException {
- int count = managedFiles.length;
- ManagedOutputStream[] streams = new ManagedOutputStream[count];
- int idx = 0;
- try {
- for (; idx < count; idx++) {
- ManagedOutputStream newStream = getOutputStream(managedFiles[idx]);
- newStream.setStreamSet(streams);
- streams[idx] = newStream;
- }
- } catch (IOException e) {
- // cleanup
- for (int jdx = 0; jdx < idx; jdx++)
- streams[jdx].abort();
- throw e;
- }
- return streams;
- }
-
- /* (non-Javadoc)
- * Instructs this manager to abort and discard a managed output stream.
- * This method should be used if any errors occur after opening a managed
- * output stream where the contents should not be saved.
- * If this output stream is part of a set, all other managed output streams in this set
- * will also be closed and aborted.
- * @param out the managed output stream
- * @see #getOutputStream(String)
- * @see #getOutputStreamSet(String[])
- */
- void abortOutputStream(ManagedOutputStream out) {
- ManagedOutputStream[] set = out.getStreamSet();
- if (set == null) {
- set = new ManagedOutputStream[] {out};
- }
- synchronized (set) {
- for (int idx = 0; idx < set.length; idx++) {
- out = set[idx];
- if (out.getOutputFile() == null) {
- // this is a ReliableFileOutpuStream
- ReliableFileOutputStream rfos = (ReliableFileOutputStream) out.getOutputStream();
- rfos.abort();
- } else {
- // plain FileOutputStream();
- if (out.getState() == ManagedOutputStream.ST_OPEN) {
- try {
- out.getOutputStream().close();
- } catch (IOException e) {/*do nothing*/
- }
- }
- out.getOutputFile().delete();
- }
- out.setState(ManagedOutputStream.ST_CLOSED);
- }
- }
- }
-
- /* (non-Javadoc)
- * Close the managed output stream and update the new content to
- * this manager. If this managed output stream is part of a set, only after closing
- * all managed output streams in the set will storage manager be updated.
- *
- * @param smos the output stream.
- * @throws IOException if an errors occur.
- * @see #getOutputStream(String)
- * @see #getOutputStreamSet(String[])
- */
- void closeOutputStream(ManagedOutputStream smos) throws IOException {
- if (smos.getState() != ManagedOutputStream.ST_OPEN)
- return;
- ManagedOutputStream[] streamSet = smos.getStreamSet();
- if (smos.getOutputFile() == null) {
- // this is a ReliableFileOutputStream
- ReliableFileOutputStream rfos = (ReliableFileOutputStream) smos.getOutputStream();
- // manage file deletes
- File file = rfos.closeIntermediateFile();
- smos.setState(ManagedOutputStream.ST_CLOSED);
- String target = smos.getTarget();
- if (streamSet == null) {
- add(target, StorageManager.FILETYPE_RELIABLEFILE);
- update(new String[] {smos.getTarget()}, new String[] {file.getName()});
- ReliableFile.fileUpdated(new File(getBase(), smos.getTarget()));
- }
- } else {
- // this is a plain old file output steam
- OutputStream out = smos.getOutputStream();
- out.flush();
- try {
- ((FileOutputStream) out).getFD().sync();
- } catch (SyncFailedException e) {/*ignore*/
- }
- out.close();
- smos.setState(ManagedOutputStream.ST_CLOSED);
- String target = smos.getTarget();
- if (streamSet == null) {
- add(target, StorageManager.FILETYPE_STANDARD);
- update(new String[] {target}, new String[] {smos.getOutputFile().getName()});
- }
- }
-
- if (streamSet != null) {
- synchronized (streamSet) {
- //check all the streams to see if there are any left open....
- for (int idx = 0; idx < streamSet.length; idx++) {
- if (streamSet[idx].getState() == ManagedOutputStream.ST_OPEN)
- return; //done
- }
- //all streams are closed, we need to update storage manager
- String[] targets = new String[streamSet.length];
- String[] sources = new String[streamSet.length];
- for (int idx = 0; idx < streamSet.length; idx++) {
- smos = streamSet[idx];
- targets[idx] = smos.getTarget();
- File outputFile = smos.getOutputFile();
- if (outputFile == null) {
- // this is a ReliableFile
- add(smos.getTarget(), StorageManager.FILETYPE_RELIABLEFILE);
- ReliableFileOutputStream rfos = (ReliableFileOutputStream) smos.getOutputStream();
- File file = rfos.closeIntermediateFile(); //multiple calls to close() ok
- sources[idx] = file.getName();
- ReliableFile.fileUpdated(new File(getBase(), smos.getTarget()));
- } else {
- add(smos.getTarget(), StorageManager.FILETYPE_STANDARD);
- sources[idx] = outputFile.getName();
- }
- }
- update(targets, sources);
- }
- }
- }
-} \ No newline at end of file
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
deleted file mode 100644
index 48bd05567..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/ManifestElement.java
+++ /dev/null
@@ -1,456 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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.osgi.util;
-
-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.osgi.framework.BundleException;
-
-/**
- * This class represents a single manifest element. A manifest element must consist of a single
- * {@link String} value. The {@link String} value may be split up into component values each
- * separated by a semi-colon (';'). A manifest element may optionally have a set of
- * attribute values associated with it. The general syntax of a manifest element is as follows:
- * <p>
- * <pre>
- * ManifestElement ::= headervalues (';' attribute)*
- * headervalues ::= headervalue (';' headervalue)*
- * headervalue ::= <any string value that does not have ';'>
- * attribute ::= key '=' value
- * key ::= token
- * value ::= token | quoted-string
- * </pre>
- * </p>
- * <p>
- * For example, The following is an example of a manifest element to the <tt>Export-Package</tt> header:
- * </p>
- * <p>
- * <pre>
- * org.osgi.framework; specification-version="1.2"; another-attr="examplevalue"
- * </pre>
- * </p>
- * <p>
- * This manifest element has a value of <tt>org.osgi.framework</tt> and it has two attributes,
- * <tt>specification-version</tt> and <tt>another-attr</tt>.
- * </p>
- * <p>
- * The following manifest element is an example of a manifest element that has multiple
- * components to its value:
- * </p>
- * <p>
- * <pre>
- * code1.jar;code2.jar;code3.jar;attr1=value1;attr2=value2;attr3=value3
- * </pre>
- * </p>
- * <p>
- * This manifest element has a value of <tt>code1.jar;code2.jar;code3.jar</tt>.
- * This is an example of a multiple component value. This value has three
- * components: <tt>code1.jar</tt>, <tt>code2.jar</tt>, and <tt>code3.jar</tt>.
- * </p>
- * <p>
- * This class is not intended to be subclassed by clients.
- * </p>
- *
- * @since 3.0
- */
-public class ManifestElement {
-
- /**
- * The value of the manifest element.
- */
- protected String value;
-
- /**
- * The value components of the manifest element.
- */
- protected String[] valueComponents;
-
- /**
- * The table of attributes for the manifest element.
- */
- protected Hashtable attributes;
-
- /**
- * The table of directives for the manifest element.
- */
- protected Hashtable directives;
-
- /**
- * Constructs an empty manifest element with no value or attributes.
- */
- protected ManifestElement() {
- super();
- }
-
- /**
- * Returns the value of the manifest element. The value returned is the
- * complete value up to the first attribute. For example, the
- * following manifest element:
- * <p>
- * <pre>
- * test1.jar;test2.jar;test3.jar;selection-filter="(os.name=Windows XP)"
- * </pre>
- * </p>
- * <p>
- * This manifest element has a value of <tt>test1.jar;test2.jar;test3.jar</tt>
- * </p>
- *
- * @return the value of the manifest element.
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Returns the value components of the manifest element. The value
- * components returned are the complete list of value components up to
- * the first attribute.
- * For example, the folowing manifest element:
- * <p>
- * <pre>
- * test1.jar;test2.jar;test3.jar;selection-filter="(os.name=Windows XP)"
- * </pre>
- * </p>
- * <p>
- * This manifest element has the value components array
- * <tt>{ "test1.jar", "test2.jar", "test3.jar" }</tt>
- * Each value component is delemited by a semi-colon (<tt>';'</tt>).
- * </p>
- *
- * @return the String[] of value components
- */
- public String[] getValueComponents() {
- return valueComponents;
- }
-
- /**
- * Returns the value for the specified attribute or <code>null</code> if it does
- * not exist. If the attribute has multiple values specified then the last value
- * specified is returned. For example the following manifest element:
- * <p>
- * <pre>
- * elementvalue; myattr="value1"; myattr="value2"
- * </pre>
- * </p>
- * <p>
- * specifies two values for the attribute key <tt>myattr</tt>. In this case <tt>value2</tt>
- * will be returned because it is the last value specified for the attribute
- * <tt>myattr</tt>.
- * </p>
- *
- * @param key the attribute key to return the value for
- * @return the attribute value or <code>null</code>
- */
- public String getAttribute(String key) {
- return getTableValue(attributes, key);
- }
-
- /**
- * Returns an array of values for the specified attribute or
- * <code>null</code> if the attribute does not exist.
- *
- * @param key the attribute key to return the values for
- * @return the array of attribute values or <code>null</code>
- * @see #getAttribute(String)
- */
- public String[] getAttributes(String key) {
- return getTableValues(attributes, key);
- }
-
- /**
- * Returns an enumeration of attribute keys for this manifest element or
- * <code>null</code> if none exist.
- *
- * @return the enumeration of attribute keys or null if none exist.
- */
- public Enumeration getKeys() {
- return getTableKeys(attributes);
- }
-
- /**
- * Add an attribute to this manifest element.
- *
- * @param key the key of the attribute
- * @param value the value of the attribute
- */
- protected void addAttribute(String key, String value) {
- attributes = addTableValue(attributes, key, value);
- }
-
- /**
- * Returns the value for the specified directive or <code>null</code> if it
- * does not exist. If the directive has multiple values specified then the
- * last value specified is returned. For example the following manifest element:
- * <p>
- * <pre>
- * elementvalue; mydir:="value1"; mydir:="value2"
- * </pre>
- * </p>
- * <p>
- * specifies two values for the directive key <tt>mydir</tt>. In this case <tt>value2</tt>
- * will be returned because it is the last value specified for the directive <tt>mydir</tt>.
- * </p>
- *
- * @param key the directive key to return the value for
- * @return the directive value or <code>null</code>
- */
- public String getDirective(String key) {
- return getTableValue(directives, key);
- }
-
- /**
- * Returns an array of string values for the specified directives or
- * <code>null</code> if it does not exist.
- *
- * @param key the directive key to return the values for
- * @return the array of directive values or <code>null</code>
- * @see #getDirective(String)
- */
- public String[] getDirectives(String key) {
- return getTableValues(directives, key);
- }
-
- /**
- * Return an enumeration of directive keys for this manifest element or
- * <code>null</code> if there are none.
- *
- * @return the enumeration of directive keys or <code>null</code>
- */
- public Enumeration getDirectiveKeys() {
- return getTableKeys(directives);
- }
-
- /**
- * Add a directive to this manifest element.
- *
- * @param key the key of the attribute
- * @param value the value of the attribute
- */
- protected void addDirective(String key, String value) {
- directives = addTableValue(directives, key, value);
- }
-
- /*
- * Return the last value associated with the given key in the specified table.
- */
- private String getTableValue(Hashtable table, String key) {
- if (table == null)
- return null;
- Object result = table.get(key);
- if (result == null)
- return null;
- if (result instanceof String)
- return (String) result;
-
- ArrayList valueList = (ArrayList) result;
- //return the last value
- return (String) valueList.get(valueList.size() - 1);
- }
-
- /*
- * Return the values associated with the given key in the specified table.
- */
- private String[] getTableValues(Hashtable table, String key) {
- if (table == null)
- return null;
- Object result = table.get(key);
- if (result == null)
- return null;
- if (result instanceof String)
- return new String[] {(String) result};
- ArrayList valueList = (ArrayList) result;
- return (String[]) valueList.toArray(new String[valueList.size()]);
- }
-
- /*
- * Return an enumeration of table keys for the specified table.
- */
- private Enumeration getTableKeys(Hashtable table) {
- if (table == null)
- return null;
- return table.keys();
- }
-
- /*
- * Add the given key/value association to the specified table. If an entry already exists
- * for this key, then create an array list from the current value (if necessary) and
- * append the new value to the end of the list.
- */
- private Hashtable addTableValue(Hashtable table, String key, String value) {
- if (table == null) {
- table = new Hashtable(7);
- }
- Object curValue = table.get(key);
- if (curValue != null) {
- ArrayList newList;
- // create a list to contain multiple values
- if (curValue instanceof ArrayList) {
- newList = (ArrayList) curValue;
- } else {
- newList = new ArrayList(5);
- newList.add(curValue);
- }
- newList.add(value);
- table.put(key, newList);
- } else {
- table.put(key, value);
- }
- return table;
- }
-
- /**
- * Parses a manifest header value into an array of ManifestElements. Each
- * ManifestElement returned will have a non-null value returned by getValue().
- *
- * @param header the header name to parse. This is only specified to provide error messages
- * when the header value is invalid.
- * @param value the header value to parse.
- * @return the array of ManifestElements that are represented by the header value; null will be
- * returned if the value specified is null or if the value does not parse into
- * one or more ManifestElements.
- * @throws BundleException if the header value is invalid
- */
- public static ManifestElement[] parseHeader(String header, String value) throws BundleException {
- if (value == null)
- return (null);
- ArrayList headerElements = new ArrayList(10);
- Tokenizer tokenizer = new Tokenizer(value);
- parseloop: while (true) {
- String next = tokenizer.getToken(";,"); //$NON-NLS-1$
- if (next == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
- ArrayList headerValues = new ArrayList();
- StringBuffer headerValue = new StringBuffer(next);
- headerValues.add(next);
-
- if (Debug.DEBUG && Debug.DEBUG_MANIFEST)
- Debug.print("paserHeader: " + next); //$NON-NLS-1$
- boolean directive = false;
- char c = tokenizer.getChar();
- // Header values may be a list of ';' separated values. Just append them all into one value until the first '=' or ','
- while (c == ';') {
- next = tokenizer.getToken(";,=:"); //$NON-NLS-1$
- if (next == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
- c = tokenizer.getChar();
- while (c == ':') { // may not really be a :=
- c = tokenizer.getChar();
- if (c != '=') {
- String restOfNext = tokenizer.getToken(";,=:"); //$NON-NLS-1$
- if (restOfNext == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
- next += ":" + c + restOfNext; //$NON-NLS-1$
- c = tokenizer.getChar();
- } else
- directive = true;
- }
- if (c == ';' || c == '\0') /* more */{
- headerValues.add(next);
- headerValue.append(";").append(next); //$NON-NLS-1$
- if (Debug.DEBUG && Debug.DEBUG_MANIFEST)
- Debug.print(";" + next); //$NON-NLS-1$
- }
- }
- // found the header value create a manifestElement for it.
- ManifestElement manifestElement = new ManifestElement();
- manifestElement.value = headerValue.toString();
- manifestElement.valueComponents = (String[]) headerValues.toArray(new String[headerValues.size()]);
-
- // now add any attributes/directives for the manifestElement.
- while (c == '=' || c == ':') {
- while (c == ':') { // may not really be a :=
- c = tokenizer.getChar();
- if (c != '=') {
- String restOfNext = tokenizer.getToken("=:"); //$NON-NLS-1$
- if (restOfNext == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
- next += ":" + c + restOfNext; //$NON-NLS-1$
- c = tokenizer.getChar();
- } else
- directive = true;
- }
- String val = tokenizer.getString(";,"); //$NON-NLS-1$
- if (val == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
-
- if (Debug.DEBUG && Debug.DEBUG_MANIFEST)
- Debug.print(";" + next + "=" + val); //$NON-NLS-1$ //$NON-NLS-2$
- try {
- if (directive)
- manifestElement.addDirective(next, val);
- else
- manifestElement.addAttribute(next, val);
- directive = false;
- } catch (Exception e) {
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
- }
- c = tokenizer.getChar();
- if (c == ';') /* more */{
- next = tokenizer.getToken("=:"); //$NON-NLS-1$
- if (next == null)
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
- c = tokenizer.getChar();
- }
- }
- headerElements.add(manifestElement);
- if (Debug.DEBUG && Debug.DEBUG_MANIFEST)
- Debug.println(""); //$NON-NLS-1$
- if (c == ',') /* another manifest element */
- continue parseloop;
- if (c == '\0') /* end of value */
- break parseloop;
- throw new BundleException(NLS.bind(Msg.MANIFEST_INVALID_HEADER_EXCEPTION, header, value));
- }
- int size = headerElements.size();
- if (size == 0)
- return (null);
-
- ManifestElement[] result = (ManifestElement[]) headerElements.toArray(new ManifestElement[size]);
- return (result);
- }
-
- /**
- * Returns the result of converting a list of comma-separated tokens into an array.
- *
- * @return the array of string tokens or <code>null</code> if there are none
- * @param stringList the initial comma-separated string
- */
- public static String[] getArrayFromList(String stringList) {
- String[] result = getArrayFromList(stringList, ","); //$NON-NLS-1$
- return result.length == 0 ? null : result;
- }
-
- /**
- * Returns the result of converting a list of tokens into an array. The tokens
- * are split using the specified separator.
- *
- * @return the array of string tokens. If there are none then an empty array
- * is returned.
- * @param stringList the initial string list
- * @param separator the separator to use to split the list into tokens.
- * @since 3.2
- */
- public static String[] getArrayFromList(String stringList, String separator) {
- if (stringList == null || stringList.trim().length() == 0)
- return new String[0];
- ArrayList list = new ArrayList();
- StringTokenizer tokens = new StringTokenizer(stringList, separator);
- while (tokens.hasMoreTokens()) {
- String token = tokens.nextToken().trim();
- if (token.length() != 0)
- list.add(token);
- }
- return (String[]) list.toArray(new String[list.size()]);
- }
-}
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
deleted file mode 100644
index 24ef05e6e..000000000
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/util/NLS.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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 - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.util;
-
-import org.eclipse.osgi.framework.internal.core.MessageResourceBundle;
-
-/**
- * Common superclass for all message bundle classes. Provides convenience
- * methods for manipulating messages.
- * <p>
- * The <code>#bind</code> methods perform string substitution and should be considered a
- * convenience and <em>not</em> a full substitute replacement for <code>MessageFormat#format</code>
- * method calls.
- * </p>
- * <p>
- * Text appearing within curly braces in the given message, will be interpreted
- * as a numeric index to the corresponding substitution object in the given array. Calling
- * the <code>#bind</code> methods with text that does not map to an integer will result in an
- * {@link IllegalArgumentException}.
- * </p>
- * <p>
- * Text appearing within single quotes is treated as a literal. A single quote is escaped by
- * a preceeding single quote.
- * </p>
- * <p>
- * Clients who wish to use the full substitution power of the <code>MessageFormat</code> class should
- * call that class directly and not use these <code>#bind</code> methods.
- * </p>
- * <p>
- * Clients may subclass this type.
- * </p>
- *
- * @since 3.1
- */
-public abstract class NLS {
-
- private static final Object[] EMPTY_ARGS = new Object[0];
-
- /**
- * Bind the given message's substitution locations with the given string value.
- *
- * @param message the message to be manipulated
- * @param binding the object to be inserted into the message
- * @return the manipulated String
- */
- public static String bind(String message, Object binding) {
- return internalBind(message, null, String.valueOf(binding), null);
- }
-
- /**
- * Bind the given message's substitution locations with the given string values.
- *
- * @param message the message to be manipulated
- * @param binding1 An object to be inserted into the message
- * @param binding2 A second object to be inserted into the message
- * @return the manipulated String
- */
- public static String bind(String message, Object binding1, Object binding2) {
- return internalBind(message, null, String.valueOf(binding1), String.valueOf(binding2));
- }
-
- /**
- * Bind the given message's substitution locations with the given string values.
- *
- * @param message the message to be manipulated
- * @param bindings An array of objects to be inserted into the message
- * @return the manipulated String
- */
- public static String bind(String message, Object[] bindings) {
- return internalBind(message, bindings, null, null);
- }
-
- /**
- * Initialize the given class with the values from the specified message bundle.
- *
- * @param bundleName fully qualified path of the class name
- * @param clazz the class where the constants will exist
- */
- public static void initializeMessages(String bundleName, Class clazz) {
- MessageResourceBundle.load(bundleName, clazz);
- }
-
- /*
- * Perform the string substitution on the given message with the specified args.
- * See the class comment for exact details.
- */
- private static String internalBind(String message, Object[] args, String argZero, String argOne) {
- if (message == null)
- return "No message available."; //$NON-NLS-1$
- if (args == null || args.length == 0)
- args = EMPTY_ARGS;
-
- int length = message.length();
- //estimate correct size of string buffer to avoid growth
- int bufLen = length + (args.length * 5);
- if (argZero != null)
- bufLen += argZero.length() - 3;
- if (argOne != null)
- bufLen += argOne.length() - 3;
- StringBuffer buffer = new StringBuffer(bufLen);
- for (int i = 0; i < length; i++) {
- char c = message.charAt(i);
- switch (c) {
- case '{' :
- int index = message.indexOf('}', i);
- // if we don't have a matching closing brace then...
- if (index == -1) {
- buffer.append(c);
- break;
- }
- i++;
- if (i >= length) {
- buffer.append(c);
- break;
- }
- // look for a substitution
- int number = -1;
- try {
- number = Integer.parseInt(message.substring(i, index));
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException();
- }
- if (number == 0 && argZero != null)
- buffer.append(argZero);
- else if (number == 1 && argOne != null)
- buffer.append(argOne);
- else {
- if (number >= args.length || number < 0) {
- buffer.append("<missing argument>"); //$NON-NLS-1$
- i = index;
- break;
- }
- buffer.append(args[number]);
- }
- i = index;
- break;
- case '\'' :
- // if a single quote is the last char on the line then skip it
- int nextIndex = i + 1;
- if (nextIndex >= length) {
- buffer.append(c);
- break;
- }
- char next = message.charAt(nextIndex);
- // if the next char is another single quote then write out one
- if (next == '\'') {
- i++;
- buffer.append(c);
- break;
- }
- // otherwise we want to read until we get to the next single quote
- index = message.indexOf('\'', nextIndex);
- // if there are no more in the string, then skip it
- if (index == -1) {
- buffer.append(c);
- break;
- }
- // otherwise write out the chars inside the quotes
- buffer.append(message.substring(nextIndex, index));
- i = index;
- break;
- default :
- buffer.append(c);
- }
- }
- return buffer.toString();
- }
-
- /**
- * Creates a new NLS instance.
- */
- protected NLS() {
- super();
- }
-} \ No newline at end of file

Back to the top