diff options
author | slewis | 2007-03-20 16:55:28 +0000 |
---|---|---|
committer | slewis | 2007-03-20 16:55:28 +0000 |
commit | 6fdecff5270f7001497a457667e1dd4127906e01 (patch) | |
tree | f59fce4ec49aae849b2c1de054081094dfba5262 /framework/bundles/org.eclipse.ecf.identity/src | |
parent | 61ceaa19ae504a655eed092459a9572ad07069b8 (diff) | |
download | org.eclipse.ecf-6fdecff5270f7001497a457667e1dd4127906e01.tar.gz org.eclipse.ecf-6fdecff5270f7001497a457667e1dd4127906e01.tar.xz org.eclipse.ecf-6fdecff5270f7001497a457667e1dd4127906e01.zip |
Modified PlatformHelper to look for Bundle then Platform class rather than expect classloader to find
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.identity/src')
2 files changed, 35 insertions, 31 deletions
diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/PlatformHelper.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/PlatformHelper.java index 69d854a59..1c4f347c0 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/PlatformHelper.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/PlatformHelper.java @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.ecf.internal.core.identity.Activator; +import org.osgi.framework.Bundle; /** * Helper class for eliminating direct references to Platform static methods @@ -36,9 +37,29 @@ public class PlatformHelper { static { try { - platformClass = Class.forName("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$ + Bundle[] bundles = Activator.getDefault().getBundleContext().getBundles(); + Bundle coreRuntime = null; + for (int i = 0; i < bundles.length; i++) + if (bundles[i].getSymbolicName().equals( + "org.eclipse.core.runtime")) //$NON-NLS-1$ + coreRuntime = bundles[i]; + platformClass = coreRuntime + .loadClass("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$ } catch (Exception e) { - // Platform not available...just leave platformClass == null + // Platform not available...just leave platformClass == null and log + // as error + try { + Activator + .getDefault() + .log( + new Status( + IStatus.ERROR, + Activator.PLUGIN_ID, + IStatus.ERROR, + "Cannot load Platform class. No adapter manager available", //$NON-NLS-1$ + e)); + } catch (Throwable t) { + } } } @@ -49,18 +70,7 @@ public class PlatformHelper { public synchronized static IAdapterManager getPlatformAdapterManager() { if (adapterManagerCache != null) return adapterManagerCache; - if (!isPlatformAvailable()) { - Activator - .getDefault() - .log( - new Status( - IStatus.ERROR, - Activator.PLUGIN_ID, - IStatus.ERROR, - "org.eclipse.core.runtime.Platform class not available", //$NON-NLS-1$ - null)); - return null; - } else { + if (isPlatformAvailable()) { try { Method m = platformClass.getMethod("getAdapterManager", null); //$NON-NLS-1$ adapterManagerCache = (IAdapterManager) m.invoke(null, null); @@ -69,27 +79,16 @@ public class PlatformHelper { Activator.getDefault().log( new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, - "exception in getPlatformAdapterManager", e)); //$NON-NLS-1$ + "Exception in PlatformHelper.getPlatformAdapterManager()", e)); //$NON-NLS-1$ return null; } - } + } else return null; } public synchronized static IExtensionRegistry getExtensionRegistry() { if (extensionRegistryCache != null) return extensionRegistryCache; - if (!isPlatformAvailable()) { - Activator - .getDefault() - .log( - new Status( - IStatus.ERROR, - Activator.PLUGIN_ID, - IStatus.ERROR, - "org.eclipse.core.runtime.Platform class not available", //$NON-NLS-1$ - null)); - return null; - } else { + if (isPlatformAvailable()) { try { Method m = platformClass .getMethod("getExtensionRegistry", null); //$NON-NLS-1$ @@ -100,10 +99,10 @@ public class PlatformHelper { Activator.getDefault().log( new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, - "exception in getExtensionRegistry", e)); //$NON-NLS-1$ + "Exception in PlatformHelper.getExtensionRegistry()", e)); //$NON-NLS-1$ return null; } - } + + } else return null; } - } diff --git a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java index 9c9031ead..511e6d925 100644 --- a/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java +++ b/framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java @@ -138,8 +138,13 @@ public class Activator implements BundleActivator { // Register IIDFactory service idFactoryServiceRegistration = context.registerService(IIDFactory.class .getName(), IDFactory.getDefault(), null); + } + public BundleContext getBundleContext() { + return context; + } + protected class IdentityRegistryManager implements IRegistryChangeListener { public void registryChanged(IRegistryChangeEvent event) { IExtensionDelta delta[] = event.getExtensionDeltas(PLUGIN_ID, |