Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-10-19 04:28:42 +0000
committerTobias Schwarz2012-10-19 04:28:42 +0000
commit7b1c89c7ff1eb8ab019a8d9955b031782dc4ea6b (patch)
treee6446ac5062d467c8986d961a2ad46c172019060 /target_explorer
parent64273084c411ea7b319721f81dc28d108936375e (diff)
downloadorg.eclipse.tcf-7b1c89c7ff1eb8ab019a8d9955b031782dc4ea6b.tar.gz
org.eclipse.tcf-7b1c89c7ff1eb8ab019a8d9955b031782dc4ea6b.tar.xz
org.eclipse.tcf-7b1c89c7ff1eb8ab019a8d9955b031782dc4ea6b.zip
[Target Explorer] introduce IVariableDelegate for persistence delegates
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.properties1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.xml1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/schema/variableDelegates.exsd131
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/GsonMapPersistenceDelegate.java49
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IVariableDelegate.java23
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/VariableDelegateExtensionPointManager.java85
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java90
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelPeerNodeQueryService.java30
9 files changed, 353 insertions, 69 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.properties
index df82e1c61..c3cd6e076 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.properties
@@ -15,6 +15,7 @@ providerName = Eclipse.org - Target Explorer
ExtensionPoint.delegates.name=Persistence Delegates
ExtensionPoint.bindings.name=Persistence Delegate Bindings
+ExtensionPoint.variableDelegates.name=Variable Delegates
# ***** Persistence Delegates *****
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.xml
index 6a6b59149..57db69c0e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/plugin.xml
@@ -5,6 +5,7 @@
<!-- Extension points -->
<extension-point id="delegates" name="%ExtensionPoint.delegates.name" schema="schema/delegates.exsd"/>
<extension-point id="bindings" name="%ExtensionPoint.bindings.name" schema="schema/bindings.exsd"/>
+ <extension-point id="variableDelegates" name="%ExtensionPoint.variableDelegates.name" schema="schema/variableDelegates.exsd"/>
<!-- Service contributions -->
<extension point="org.eclipse.tcf.te.runtime.services.services">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/schema/variableDelegates.exsd b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/schema/variableDelegates.exsd
new file mode 100644
index 000000000..5cac61732
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/schema/variableDelegates.exsd
@@ -0,0 +1,131 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.tcf.te.runtime.persistence" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.tcf.te.runtime.persistence" id="variableDelegates" name="Variable Delegates Extension Point"/>
+ </appinfo>
+ <documentation>
+ This extension point is used to declare the variable delegates.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="delegate" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="delegate">
+ <annotation>
+ <documentation>
+ Declares a variable delegate.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The unique id of the variable delegate contribution.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The variable delegate implementation.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.tcf.te.runtime.persistence.interfaces.IVariableDelegate"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="delegateId" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.tcf.te.runtime.persistence.delegates/delegate/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ Target Explorer 1.0.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ &lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.tcf.te.runtime.persistence.variableDelegatess&quot;&gt;
+ &lt;delegate
+ id=&quot;org.eclipse.tcf.te.runtime.persistence.delegate.VariableDelegate&quot;
+ class=&quot;org.eclipse.tcf.te.runtime.persistence.internal.VariableDelegate&quot;
+ delegateId=&quot;org.eclipse.tcf.te.runtime.persistence.delegate.PersistenceDelegate&quot;/&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+ </documentation>
+ </annotation>
+
+
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ Copyright (c) 2012 Wind River Systems, Inc. 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.
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/GsonMapPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/GsonMapPersistenceDelegate.java
index 854c33209..7772e5f1b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/GsonMapPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/GsonMapPersistenceDelegate.java
@@ -29,6 +29,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IVariableDelegate;
import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
import com.google.gson.Gson;
@@ -41,6 +42,8 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I
private final String defaultFileExtension;
+ protected static final String VARIABLES = "__VariablesMap__"; //$NON-NLS-1$
+
/**
* Constructor.
*/
@@ -76,7 +79,7 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I
* @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#write(java.lang.Object, java.lang.Object, java.lang.String)
*/
@Override
- public Object write(Object context, Object container, String key) throws IOException {
+ public final Object write(Object context, Object container, String key) throws IOException {
Assert.isNotNull(context);
Assert.isNotNull(container);
@@ -106,7 +109,8 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I
try {
writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
Gson gson = new GsonBuilder().setPrettyPrinting().create();
- gson.toJson(toMap(context), Map.class, writer);
+
+ gson.toJson(internalToMap(context), Map.class, writer);
} finally {
if (writer != null) {
writer.close();
@@ -115,17 +119,44 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I
}
else if (container instanceof String || String.class.equals(container)) {
Gson gson = new GsonBuilder().create();
- container = gson.toJson(toMap(context));
+
+ container = gson.toJson(internalToMap(context));
}
return container;
}
+ /*
+ * Convert the context to a Map, extract and use variables and add them to the map as key VARIABLE.
+ */
+ private Map<String,Object> internalToMap(Object context) {
+ try {
+ Map<String,Object> data = toMap(context);
+
+ if (data != null) {
+ Map<String,String> variables = new HashMap<String, String>();
+ IVariableDelegate[] delegates = PersistenceManager.getInstance().getVariableDelegates(this);
+ for (IVariableDelegate delegate : delegates) {
+ delegate.getVariables(data, variables);
+ }
+ if (!variables.isEmpty()) {
+ data.put(VARIABLES, variables);
+ }
+ }
+ return data;
+ }
+ catch (Exception e) {
+
+ }
+
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate#read(java.lang.Object, java.lang.Object, java.lang.String)
*/
@Override
- public Object read(Object context, Object container, String key) throws IOException {
+ public final Object read(Object context, Object container, String key) throws IOException {
Assert.isNotNull(container);
Gson gson = new GsonBuilder().create();
@@ -161,6 +192,14 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I
data = gson.fromJson((String)container, Map.class);
}
+ if (data != null && data.containsKey(VARIABLES)) {
+ Map<String,String> variables = (Map<String,String>)data.remove(VARIABLES);
+ IVariableDelegate[] delegates = PersistenceManager.getInstance().getVariableDelegates(this);
+ for (IVariableDelegate delegate : delegates) {
+ delegate.putVariables(data, variables);
+ }
+ }
+
return data != null ? fromMap(data, context) : context;
}
@@ -241,7 +280,7 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I
* @throws IOException
*/
protected Object fromMap(Map<String,Object> map, Object context) throws IOException {
- if (context == null || (context instanceof Class && ((Class<?>)context).isInstance(map))) {
+ if (context == null || context.equals(map.getClass())) {
return map;
}
else if (context instanceof Map) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java
index c8e03c25f..795c9b564 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/PersistenceManager.java
@@ -21,8 +21,10 @@ import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
import org.eclipse.tcf.te.runtime.persistence.activator.CoreBundleActivator;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IVariableDelegate;
import org.eclipse.tcf.te.runtime.persistence.internal.PersistenceDelegateBinding;
import org.eclipse.tcf.te.runtime.persistence.internal.PersistenceDelegateBindingExtensionPointManager;
+import org.eclipse.tcf.te.runtime.persistence.internal.VariableDelegateExtensionPointManager;
/**
* Persistence delegate manager implementation.
@@ -143,4 +145,14 @@ public class PersistenceManager extends AbstractExtensionPointManager<IPersisten
return delegates.get(0);
}
+
+ /**
+ * Returns the bound variable delegates for the given persistence delegate.
+ *
+ * @param persistenceDelegate The persistence delegate.
+ * @return The list of bound variable delegates or an empty array.
+ */
+ public IVariableDelegate[] getVariableDelegates(IPersistenceDelegate persistenceDelegate) {
+ return VariableDelegateExtensionPointManager.getInstance().getDelegates(persistenceDelegate);
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IVariableDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IVariableDelegate.java
new file mode 100644
index 000000000..5a95009c9
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/interfaces/IVariableDelegate.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tcf.te.runtime.persistence.interfaces;
+
+import java.util.Map;
+
+/**
+ * IVariableDelegate
+ */
+public interface IVariableDelegate {
+
+ public void getVariables(Map<String,Object> map, Map<String,String> variables);
+
+ public void putVariables(Map<String,Object> map, Map<String,String> variables);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/VariableDelegateExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/VariableDelegateExtensionPointManager.java
new file mode 100644
index 000000000..ed00938fd
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/internal/VariableDelegateExtensionPointManager.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.runtime.persistence.internal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IVariableDelegate;
+
+
+/**
+ * VariableDelegateExtensionPointManager
+ */
+public class VariableDelegateExtensionPointManager extends AbstractExtensionPointManager<IVariableDelegate> {
+
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstance {
+ public static VariableDelegateExtensionPointManager instance = new VariableDelegateExtensionPointManager();
+ }
+
+ /**
+ * Constructor.
+ */
+ VariableDelegateExtensionPointManager() {
+ super();
+ }
+
+ /**
+ * Returns the singleton instance of the extension point manager.
+ */
+ public static VariableDelegateExtensionPointManager getInstance() {
+ return LazyInstance.instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
+ */
+ @Override
+ protected String getExtensionPointId() {
+ return "org.eclipse.tcf.te.runtime.persistence.variableDelegates"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
+ */
+ @Override
+ protected String getConfigurationElementName() {
+ return "delegate"; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the bound variable delegates for the given persistence delegate.
+ *
+ * @param persistenceDelegate The persistence delegate.
+ * @return The list of bound variable delegates or an empty array.
+ */
+ public IVariableDelegate[] getDelegates(IPersistenceDelegate persistenceDelegate) {
+ List<IVariableDelegate> contributions = new ArrayList<IVariableDelegate>();
+ Collection<ExecutableExtensionProxy<IVariableDelegate>> delegates = getExtensions().values();
+ for (ExecutableExtensionProxy<IVariableDelegate> delegate : delegates) {
+ String id = delegate.getConfigurationElement().getAttribute("delegateId"); //$NON-NLS-1$
+ if (id == null || id.equals(persistenceDelegate.getId())) {
+ IVariableDelegate instance = delegate.getInstance();
+ if (instance != null && !contributions.contains(instance)) {
+ contributions.add(instance);
+ }
+ }
+ }
+
+ return contributions.toArray(new IVariableDelegate[contributions.size()]);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java
index cdb8cbb90..b700efa2a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java
@@ -15,7 +15,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReference;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
@@ -48,56 +47,6 @@ public class GsonPeerPersistenceDelegate extends GsonMapPersistenceDelegate {
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.persistence.AbstractPropertiesToStringPersistenceDelegate#read(java.lang.Object, java.lang.Object, java.lang.String)
- */
- @Override
- public Object read(final Object context, final Object container, String key) throws IOException {
- Assert.isNotNull(context);
- Assert.isNotNull(container);
-
- final IPeer peer = (IPeer)super.read(context, container, key);
-
- if (peer != null) {
- if (context instanceof IPeer || IPeer.class.equals(context)) {
- return peer;
- }
- else if (context instanceof Class && (((Class<?>)context).isAssignableFrom(IPeerModel.class))) {
- final AtomicReference<IPeerModel> model = new AtomicReference<IPeerModel>();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- // Get the id of the decoded attributes
- String id = peer.getID();
- if (id != null) {
- // Lookup the id within the model
- IPeerModel peerModel = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(id);
- if (peerModel == null) {
- // Not found in the model -> create a ghost object
- peerModel = new PeerModel(Model.getModel(), peer);
- peerModel.setProperty(IModelNode.PROPERTY_IS_GHOST, true);
- }
-
- model.set(peerModel);
- }
- }
- };
-
- if (Protocol.isDispatchThread()) {
- runnable.run();
- }
- else {
- Protocol.invokeAndWait(runnable);
- }
-
- return model.get();
- }
- }
-
- return null;
- }
-
- /* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.persistence.AbstractPropertiesPersistenceDelegate#toMap(java.lang.Object)
*/
@Override
@@ -120,7 +69,44 @@ public class GsonPeerPersistenceDelegate extends GsonMapPersistenceDelegate {
attrs.put(entry.getKey(), entry.getValue().toString());
}
- return new Peer(attrs);
+ final IPeer peer = new Peer(attrs);
+
+ if (context instanceof IPeer || IPeer.class.equals(context)) {
+ return peer;
+ }
+ else if (context instanceof Class && (((Class<?>)context).isAssignableFrom(IPeerModel.class))) {
+ final AtomicReference<IPeerModel> model = new AtomicReference<IPeerModel>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ // Get the id of the decoded attributes
+ String id = peer.getID();
+ if (id != null) {
+ // Lookup the id within the model
+ IPeerModel peerModel = Model.getModel().getService(ILocatorModelLookupService.class).lkupPeerModelById(id);
+ if (peerModel == null) {
+ // Not found in the model -> create a ghost object
+ peerModel = new PeerModel(Model.getModel(), peer);
+ peerModel.setProperty(IModelNode.PROPERTY_IS_GHOST, true);
+ }
+
+ model.set(peerModel);
+ }
+ }
+ };
+
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
+
+ return model.get();
+ }
+
+ return null;
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelPeerNodeQueryService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelPeerNodeQueryService.java
index 0f0e573f2..4b9900d80 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelPeerNodeQueryService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelPeerNodeQueryService.java
@@ -72,18 +72,20 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
@Override
public void run() {
// If the peer is a RemotePeer or has the "remote.transient" property set
- // --> an agent is running and has been associated with the peer model.
+ // --> an agent is running and has been associated with the peer model.
if ("RemotePeer".equals(node.getPeer().getClass().getSimpleName()) || Boolean.valueOf(node.getPeer().getAttributes().get("remote.transient")).booleanValue()) { //$NON-NLS-1$ //$NON-NLS-2$
doQueryServices(node, new DoneQueryServices() {
@Override
public void doneQueryServices(Throwable error) {
- if (error == null) services.set(node.getStringProperty(IPeerModelProperties.PROP_LOCAL_SERVICES));
+ if (error == null) {
+ services.set(node.getStringProperty(IPeerModelProperties.PROP_LOCAL_SERVICES));
+ }
completed.set(true);
}
});
} else {
- completed.set(true);
- }
+ completed.set(true);
+ }
}
});
@@ -136,18 +138,20 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
@Override
public void run() {
// If the peer is a RemotePeer or has the "remote.transient" property set
- // --> an agent is running and has been associated with the peer model.
- if ("RemotePeer".equals(node.getPeer().getClass().getSimpleName()) || Boolean.valueOf(node.getPeer().getAttributes().get("remote.transient")).booleanValue()) { //$NON-NLS-1$ //$NON-NLS-2$
+ // --> an agent is running and has been associated with the peer model.
+ if ("RemotePeer".equals(node.getPeer().getClass().getSimpleName()) || Boolean.valueOf(node.getPeer().getAttributes().get("remote.transient")).booleanValue()) { //$NON-NLS-1$ //$NON-NLS-2$
doQueryServices(node, new DoneQueryServices() {
@Override
public void doneQueryServices(Throwable error) {
- if (error == null) services.set(node.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES));
+ if (error == null) {
+ services.set(node.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES));
+ }
completed.set(true);
}
});
- } else {
- completed.set(true);
- }
+ } else {
+ completed.set(true);
+ }
}
});
@@ -218,8 +222,10 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
public void doneQueryServices(Throwable error) {
// Get the list of the original done callbacks
List<DoneQueryServices> dones = serviceQueriesInProgress.remove(node);
- for (DoneQueryServices done : dones) {
- done.doneQueryServices(error);
+ if (dones != null) {
+ for (DoneQueryServices done : dones) {
+ done.doneQueryServices(error);
+ }
}
}
};

Back to the top