[158825] Checking for environment
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java
index 70780c1..7b5a265 100644
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java
+++ b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java
@@ -8,6 +8,8 @@
**************************************************************************************************/
package org.eclipse.wst.common.internal.emf.resource;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@@ -15,7 +17,6 @@
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
@@ -61,6 +62,9 @@
protected Translator[] childTranslators;
protected boolean isRoot = false;
+
+ private static final String PLATFORM = "org.eclipse.core.runtime.Platform"; //$NON-NLS-1$
+ private static final String ISRUNNING = "isRunning"; //$NON-NLS-1$
private class DependencyAdapter extends org.eclipse.emf.common.notify.impl.AdapterImpl {
@@ -126,9 +130,27 @@
protected void initChildTranslators() {
List children = new ArrayList();
-
- // Get extended child translators if in OSGI mode
- if (Platform.isRunning()) {
+ boolean isRunning = false; //is the OSGI platform running ?
+ try {
+ // If the Platform class can be found, then continue to check if the OSGI platform is running
+ Class clazz = Class.forName(PLATFORM);
+ Method m = clazz.getMethod(ISRUNNING, null);
+ isRunning = ((Boolean)m.invoke(clazz, null)).booleanValue();
+ } catch (ClassNotFoundException e) {
+ // Ignore because this must be in a non_OSGI environment
+ } catch (SecurityException e) {
+ // Ignore because this must be in a non_OSGI environment
+ } catch (NoSuchMethodException e) {
+ // Ignore because this must be in a non_OSGI environment
+ } catch (IllegalArgumentException e) {
+ // Ignore because this must be in a non_OSGI environment
+ } catch (IllegalAccessException e) {
+ // Ignore because this must be in a non_OSGI environment
+ } catch (InvocationTargetException e) {
+ // Ignore because this must be in a non_OSGI environment
+ }
+ //Check for extended child translators because we are in OSGI mode
+ if (isRunning) {
Translator[] extendedChildren = TranslatorService.getInstance().getTranslators();
for (int i = 0; i < extendedChildren.length; i++) {
if (extendedChildren[i] != null)
@@ -136,6 +158,7 @@
}
}
+
children.addAll(Arrays.asList(fTranslator.getChildren(getTarget(), fRenderer.getVersionID())));
VariableTranslatorFactory factory = fTranslator.getVariableTranslatorFactory();