Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/META-INF/MANIFEST.MF3
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/core/util/PlatformHelper.java61
-rw-r--r--framework/bundles/org.eclipse.ecf.identity/src/org/eclipse/ecf/internal/core/identity/Activator.java5
3 files changed, 36 insertions, 33 deletions
diff --git a/framework/bundles/org.eclipse.ecf.identity/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.identity/META-INF/MANIFEST.MF
index 5d5593285..abb18091f 100644
--- a/framework/bundles/org.eclipse.ecf.identity/META-INF/MANIFEST.MF
+++ b/framework/bundles/org.eclipse.ecf.identity/META-INF/MANIFEST.MF
@@ -12,8 +12,7 @@ Export-Package: org.eclipse.ecf.core.identity,
org.eclipse.ecf.internal.core.identity;x-internal:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.3,
CDC-1.0/Foundation-1.0
-Import-Package: org.eclipse.core.runtime,
- org.eclipse.osgi.service.debug;version="1.0.0",
+Import-Package: org.eclipse.osgi.service.debug;version="1.0.0",
org.eclipse.osgi.util;version="1.0.0",
org.osgi.framework;version="1.3.0",
org.osgi.service.log;version="1.3.0",
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,

Back to the top