diff options
author | DJ Houghton | 2006-11-24 01:02:23 +0000 |
---|---|---|
committer | DJ Houghton | 2006-11-24 01:02:23 +0000 |
commit | 9e8cff5b77d3b4e8a78af8ea46e30db85572ac14 (patch) | |
tree | 19b6b5da8bf7748a49f5d1398ff413ee0048d9ff /bundles | |
parent | bd62752dbe77c7045007f092ed58d195f6720741 (diff) | |
download | rt.equinox.framework-9e8cff5b77d3b4e8a78af8ea46e30db85572ac14.tar.gz rt.equinox.framework-9e8cff5b77d3b4e8a78af8ea46e30db85572ac14.tar.xz rt.equinox.framework-9e8cff5b77d3b4e8a78af8ea46e30db85572ac14.zip |
Refactor supplement bundle to be nested within OSGI.zz20061127v20061127
Diffstat (limited to 'bundles')
13 files changed, 127 insertions, 491 deletions
diff --git a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/SecureAction.java b/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/SecureAction.java deleted file mode 100644 index ad9ed1c6d..000000000 --- a/bundles/org.eclipse.osgi/core/adaptor/org/eclipse/osgi/framework/util/SecureAction.java +++ /dev/null @@ -1,418 +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.AbstractBundle; -import org.eclipse.osgi.framework.internal.core.FrameworkProperties; -import org.osgi.framework.*; -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; - - // This ClassLoader is used in loadSystemClass if System.getClassLoader() returns null - static final ClassLoader bootClassLoader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return new ClassLoader(null) { - // parentless ClassLoader - }; - } - }); - - /* - * Package privaet constructor a new SecureAction object. - * The constructed SecureAction object uses the caller's AccessControlContext - * to perform security checks - */ - SecureAction() { - // save the control context to be used. - this.controlContext = AccessController.getContext(); - } - - /** - * Creates a privileged action that can be used to construct a SecureAction object. - * The recommended way to construct a SecureAction object is the following: <p> - * <pre> - * SecureAction secureAction = (SecureAction) AccessController.doPrivileged(SecureAction.createSecureAction()); - * </pre> - * @return a privileged action object that can be used to construct a SecureAction object. - */ - public static PrivilegedAction createSecureAction() { - return new PrivilegedAction() { - public Object run() { - return new SecureAction(); - } - }; - } - - /** - * 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(); - } - } - - /** - * Returns a Class. - * Tries to load a class from the System ClassLoader or if that doesn't exist tries the boot ClassLoader - * @param name the name of the class. - * @return a Class - * @throws ClassNotFoundException - */ - public Class loadSystemClass(final String name) throws ClassNotFoundException { - if (System.getSecurityManager() == null) { - ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); - return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : bootClassLoader.loadClass(name); - } - try { - return (Class) AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); - return (systemClassLoader != null) ? systemClassLoader.loadClass(name) : bootClassLoader.loadClass(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); - } - - /** - * Starts a bundle. - * @param bundle the bundle to start - * @param options the start options - * @throws BundleException - */ - public void start(final AbstractBundle bundle, final int options) throws BundleException { - if (System.getSecurityManager() == null) { - bundle.start(options); - return; - } - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws BundleException { - bundle.start(options); - return null; - } - }, controlContext); - return; - } catch (PrivilegedActionException e) { - if (e.getException() instanceof BundleException) - throw (BundleException) e.getException(); - throw (RuntimeException) e.getException(); - } - } -} diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java index 94850b0e2..3c4abd342 100644 --- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java +++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/EclipseStarter.java @@ -440,7 +440,7 @@ public class EclipseStarter { ArrayList constraints = (ArrayList) missing.get(description); FrameworkLogEntry[] logChildren = new FrameworkLogEntry[constraints.size()]; for (int i = 0; i < logChildren.length; i++) - logChildren[i] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.getResolutionFailureMessage((VersionConstraint) constraints.get(i)), 0, null, null); + logChildren[i] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, MessageHelper.getResolutionFailureMessage((VersionConstraint) constraints.get(i)), 0, null, null); rootChildren[rootIndex] = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, generalMessage, 0, null, logChildren); } logService.log(new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.ECLIPSE_STARTUP_ROOTS_NOT_RESOLVED, 0, null, rootChildren)); @@ -463,7 +463,7 @@ public class EclipseStarter { // the bundle wasn't resolved due to some of its constraints were unsatisfiable logChildren = new FrameworkLogEntry[unsatisfied.length]; for (int j = 0; j < unsatisfied.length; j++) - logChildren[j] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, EclipseAdaptorMsg.getResolutionFailureMessage(unsatisfied[j]), 0, null, null); + logChildren[j] = new FrameworkLogEntry(symbolicName, FrameworkLogEntry.WARNING, 0, MessageHelper.getResolutionFailureMessage(unsatisfied[j]), 0, null, null); } else { ResolverError[] resolverErrors = state.getResolverErrors(description); if (resolverErrors.length > 0) { diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/LocationManager.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/LocationManager.java index 86fbf6462..cd0675c85 100644 --- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/LocationManager.java +++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/adaptor/LocationManager.java @@ -15,6 +15,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.Properties; import org.eclipse.core.runtime.internal.adaptor.BasicLocation; +import org.eclipse.core.runtime.internal.adaptor.LocationHelper; import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor; import org.eclipse.osgi.framework.internal.core.FrameworkProperties; import org.eclipse.osgi.service.datalocation.Location; @@ -75,33 +76,7 @@ public class LocationManager { * @return a URL */ public 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); - else - 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); + return LocationHelper.buildURL(spec, trailingSlash); } private static void mungeConfigurationLocation() { diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java index 01feaed4e..6dce830d3 100644 --- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java +++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorHook.java @@ -132,7 +132,7 @@ public class EclipseAdaptorHook implements AdaptorHook, HookConfigurator { return; String registryParsing = debugOptions.getOption("org.eclipse.core.runtime/registry/parsing/timing/value"); //$NON-NLS-1$ if (registryParsing != null) - EclipseAdaptorMsg.debug("Time spent in registry parsing: " + registryParsing); //$NON-NLS-1$ + MessageHelper.debug("Time spent in registry parsing: " + registryParsing); //$NON-NLS-1$ String packageAdminResolution = debugOptions.getOption("debug.packageadmin/timing/value"); //$NON-NLS-1$ if (packageAdminResolution != null) System.out.println("Time spent in package admin resolve: " + packageAdminResolution); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider.java index c9bbacc73..193d44556 100644 --- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider.java +++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseCommandProvider.java @@ -96,7 +96,7 @@ public class EclipseCommandProvider implements CommandProvider { } for (int i = 0; i < unsatisfied.length; i++) { ci.print(" "); //$NON-NLS-1$ - ci.println(EclipseAdaptorMsg.getResolutionFailureMessage(unsatisfied[i])); + ci.println(MessageHelper.getResolutionFailureMessage(unsatisfied[i])); } nextArg = ci.nextArgument(); } diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/MessageHelper.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/MessageHelper.java new file mode 100644 index 000000000..ef4bb4bfb --- /dev/null +++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/MessageHelper.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 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; + +/** + * @since 3.3 + */ +public class MessageHelper { + public static String getResolutionFailureMessage(VersionConstraint unsatisfied) { + if (unsatisfied.isResolved()) + throw new IllegalArgumentException(); + if (unsatisfied instanceof ImportPackageSpecification) + return NLS.bind(EclipseAdaptorMsg.ECLIPSE_MISSING_IMPORTED_PACKAGE, toString(unsatisfied)); + else if (unsatisfied instanceof BundleSpecification) + if (((BundleSpecification) unsatisfied).isOptional()) + return NLS.bind(EclipseAdaptorMsg.ECLIPSE_MISSING_OPTIONAL_REQUIRED_BUNDLE, toString(unsatisfied)); + else + return NLS.bind(EclipseAdaptorMsg.ECLIPSE_MISSING_REQUIRED_BUNDLE, toString(unsatisfied)); + else + return NLS.bind(EclipseAdaptorMsg.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/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF index feb15801c..bf6f0563f 100644 --- a/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.osgi/supplement/META-INF/MANIFEST.MF @@ -10,13 +10,17 @@ Export-Package: org.eclipse.core.runtime.internal.adaptor;x-internal:=true, org.eclipse.osgi.framework.internal.core;x-internal:=true, org.eclipse.osgi.framework.internal.reliablefile;x-internal:=true, org.eclipse.osgi.framework.log, + org.eclipse.osgi.framework.util, org.eclipse.osgi.service.datalocation, org.eclipse.osgi.service.debug, org.eclipse.osgi.service.localization, org.eclipse.osgi.service.urlconversion, org.eclipse.osgi.storagemanager, - org.eclipse.osgi.util + org.eclipse.osgi.util, + org.osgi.framework, + org.osgi.util.tracker Bundle-RequiredExecutionEnvironment: J2SE-1.4, CDC-1.0/Foundation-1.0, J2SE-1.3 -Import-Package: org.osgi.framework +Import-Package: org.osgi.framework, + org.osgi.util.tracker diff --git a/bundles/org.eclipse.osgi/supplement/build.properties b/bundles/org.eclipse.osgi/supplement/build.properties index fd3fff9c2..d1f3b19ac 100644 --- a/bundles/org.eclipse.osgi/supplement/build.properties +++ b/bundles/org.eclipse.osgi/supplement/build.properties @@ -17,3 +17,4 @@ bin.includes = META-INF/,\ about.html src.includes = about.html jre.compilation.profile = J2SE-1.4 +jars.extra.classpath = osgi/osgi.jar diff --git a/bundles/org.eclipse.osgi/supplement/osgi/osgi.jar b/bundles/org.eclipse.osgi/supplement/osgi/osgi.jar Binary files differnew file mode 100644 index 000000000..f25df407c --- /dev/null +++ b/bundles/org.eclipse.osgi/supplement/osgi/osgi.jar diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java index 2eb36a2dc..7fc18ccc7 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/BasicLocation.java @@ -13,7 +13,6 @@ 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; @@ -136,7 +135,7 @@ public class BasicLocation implements Location { } } lockFile = file; - location = LocationManager.buildURL(value.toExternalForm(), true); + location = LocationHelper.buildURL(value.toExternalForm(), true); if (property != null) FrameworkProperties.setProperty(property, location.toExternalForm()); return lock; 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 index e65c871c4..077b3aaf8 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/EclipseAdaptorMsg.java @@ -10,8 +10,6 @@ *******************************************************************************/ 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 { @@ -101,38 +99,4 @@ public class EclipseAdaptorMsg extends NLS { 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/LocationHelper.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/LocationHelper.java new file mode 100644 index 000000000..3018e6039 --- /dev/null +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/core/runtime/internal/adaptor/LocationHelper.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 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.net.MalformedURLException; +import java.net.URL; + +/** + * @since 3.3 + */ +public class LocationHelper { + /** + * Builds a URL with the given specification + * @param spec the URL specification + * @param trailingSlash flag to indicate a trailing slash on the spec + * @return a URL + */ + public 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); + } + +} diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java index ad9ed1c6d..106d783d1 100644 --- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java +++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/util/SecureAction.java @@ -16,7 +16,6 @@ import java.net.*; import java.security.*; import java.util.Properties; import java.util.zip.ZipFile; -import org.eclipse.osgi.framework.internal.core.AbstractBundle; import org.eclipse.osgi.framework.internal.core.FrameworkProperties; import org.osgi.framework.*; import org.osgi.util.tracker.ServiceTracker; @@ -396,7 +395,7 @@ public class SecureAction { * @param options the start options * @throws BundleException */ - public void start(final AbstractBundle bundle, final int options) throws BundleException { + public void start(final Bundle bundle, final int options) throws BundleException { if (System.getSecurityManager() == null) { bundle.start(options); return; |