Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-10-02 03:20:01 -0400
committerUwe Stieber2012-10-02 03:20:01 -0400
commit699f78ea8ed77fd213c36633329a151c148f9b04 (patch)
treec0bde6e766bafb3c3b7df6c86ac65f8f35963ad1 /target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src
parent5ab1fe662867e9a575b604df001149603040d00c (diff)
downloadorg.eclipse.tcf-699f78ea8ed77fd213c36633329a151c148f9b04.tar.gz
org.eclipse.tcf-699f78ea8ed77fd213c36633329a151c148f9b04.tar.xz
org.eclipse.tcf-699f78ea8ed77fd213c36633329a151c148f9b04.zip
Target Explorer: Fix properties container thread access issues
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java153
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertiesContainerPropertyTester.java59
2 files changed, 142 insertions, 70 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java
index 905400350..35fb8adb8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java
@@ -1,70 +1,83 @@
-/*******************************************************************************
- * Copyright (c) 2011, 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.services.interfaces;
-
-import java.util.Map;
-
-/**
- * Properties access service.
- * <p>
- * Allows generic access to properties of a given context without having to know all the details and
- * limitations for accessing the desired properties.
- */
-public interface IPropertiesAccessService extends IService {
-
- /**
- * Returns a unmodifiable map containing the target addresses and ports for the given context,
- * if it can be determined.
- * <p>
- * A context may return multiple target addresses and ports if the context can be reached using
- * different connection methods.
- * <p>
- * <b>Note:</b>
- * <ul>
- * <li>See the constants defined in the properties access constants interface for default
- * address and port types.</li>
- * <li>The target address returned must <b>not</b> necessarily be an IP address.</li>
- * <li>The values of the address or port properties might be <code>null</code>.</li>
- * </ul>
- *
- * @param context The context to get the target addresses and ports from. Must not be <code>null</code>.
- * @return The unmodifiable map containing the target addresses and ports, or <code>null</code>.
- */
- public Map<String, String> getTargetAddress(Object context);
-
- /**
- * Returns the property value stored under the given property key. If the property does not
- * exist, <code>null</code> is returned.
- *
- * @param context The context to get the property from. Must not be <code>null</code>.
- * @param key The property key. Must not be <code>null</code>.
- *
- * @return The stored property value or <code>null</code>.
- */
- public Object getProperty(Object context, String key);
-
- /**
- * Set the property with the key with the given value.
- *
- * @param context The context to set the property to. Must not be <code>null</code>.
- * @param key The property key. Must not be <code>null</code>.
- * @param value The value to set.
- * @return <code>true</code> if the value was set.
- */
- public boolean setProperty(Object context, String key, Object value);
-
- /**
- * Returns the direct parent node of the given context object.
- *
- * @param context The context to get the parent from. Must not be <code>null</code>.
- * @return The direct parent node or <code>null</code>.
- */
- public Object getParent(Object context);
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 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.services.interfaces;
+
+import java.util.Map;
+
+/**
+ * Properties access service.
+ * <p>
+ * Allows generic access to properties of a given context without having to know all the details and
+ * limitations for accessing the desired properties.
+ */
+public interface IPropertiesAccessService extends IService {
+
+ /**
+ * Returns a unmodifiable map containing the target addresses and ports for the given context,
+ * if it can be determined.
+ * <p>
+ * A context may return multiple target addresses and ports if the context can be reached using
+ * different connection methods.
+ * <p>
+ * <b>Note:</b>
+ * <ul>
+ * <li>See the constants defined in the properties access constants interface for default
+ * address and port types.</li>
+ * <li>The target address returned must <b>not</b> necessarily be an IP address.</li>
+ * <li>The values of the address or port properties might be <code>null</code>.</li>
+ * </ul>
+ *
+ * @param context The context to get the target addresses and ports from. Must not be <code>null</code>.
+ * @return The unmodifiable map containing the target addresses and ports, or <code>null</code>.
+ */
+ public Map<String, String> getTargetAddress(Object context);
+
+ /**
+ * Returns the property value stored under the given property key. If the property does not
+ * exist, <code>null</code> is returned.
+ *
+ * @param context The context to get the property from. Must not be <code>null</code>.
+ * @param key The property key. Must not be <code>null</code>.
+ *
+ * @return The stored property value or <code>null</code>.
+ */
+ public Object getProperty(Object context, String key);
+
+ /**
+ * Set the property with the key with the given value.
+ *
+ * @param context The context to set the property to. Must not be <code>null</code>.
+ * @param key The property key. Must not be <code>null</code>.
+ * @param value The value to set.
+ *
+ * @return <code>true</code> if the value was set.
+ */
+ public boolean setProperty(Object context, String key, Object value);
+
+ /**
+ * Test if the property value stored under the given property is equal to the given
+ * expected value.
+ *
+ * @param context The context. Must not be <code>null</code>.
+ * @param key The property key. Must not be <code>null</code>.
+ * @param value The expected property value.
+ *
+ * @return <code>true</code> if the expected value is equal to the stored property value, <code>false</code> otherwise.
+ */
+ public boolean isProperty(Object context, String key, Object value);
+
+ /**
+ * Returns the direct parent node of the given context object.
+ *
+ * @param context The context to get the parent from. Must not be <code>null</code>.
+ * @return The direct parent node or <code>null</code>.
+ */
+ public Object getParent(Object context);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertiesContainerPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertiesContainerPropertyTester.java
new file mode 100644
index 000000000..85194fcba
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertiesContainerPropertyTester.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.services.internal;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService;
+
+/**
+ * Property tester implementation for objects of type {@link IPropertiesContainer}.
+ */
+public class PropertiesContainerPropertyTester extends PropertyTester {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ // The receiver is expected to be a properties container
+ if (receiver instanceof IPropertiesContainer) {
+
+ if ("isProperty".equals(property)) { // //$NON-NLS-1$
+ // Test for an individual property within the property container
+ return testIsProperty((IPropertiesContainer)receiver, args, expectedValue);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Test the specific model node properties.
+ *
+ * @param node The properties container. Must not be <code>null</code>.
+ * @param args The property arguments.
+ * @param expectedValue The expected value.
+ *
+ * @return <code>True</code> if the property to test has the expected value, <code>false</code> otherwise.
+ */
+ protected boolean testIsProperty(IPropertiesContainer node, Object[] args, Object expectedValue) {
+ Assert.isNotNull(node);
+
+ if (args != null && args.length > 0 && args[0] instanceof String) {
+ IPropertiesAccessService service = ServiceManager.getInstance().getService(node, IPropertiesAccessService.class);
+ return service != null ? service.isProperty(node, (String)args[0], expectedValue) : node.isProperty((String)args[0], expectedValue);
+ }
+
+ return false;
+ }
+
+}

Back to the top