Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/plugin.xml12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/schema/services.exsd13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java62
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertyTester.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.xml4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.xml4
6 files changed, 118 insertions, 15 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/plugin.xml
index 4d69027fc..8521aa65a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/plugin.xml
@@ -5,4 +5,16 @@
<!-- Extension points -->
<extension-point id="services" name="Service Contributions" schema="schema/services.exsd"/>
+<!-- Property tester contributions -->
+ <extension point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.tcf.te.runtime.services.internal.PropertyTester"
+ id="org.eclipse.tcf.te.runtime.services.PropertyTester"
+ namespace="org.eclipse.tcf.te.runtime.services"
+ properties="hasService"
+ type="java.lang.Object">
+ </propertyTester>
+
+ </extension>
+
</plugin>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/schema/services.exsd b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/schema/services.exsd
index f1d14ce06..5247e16bd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/schema/services.exsd
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/schema/services.exsd
@@ -59,7 +59,6 @@ If a enablement expression is specified, the service context is passed in as def
</annotation>
<complexType>
<sequence>
- <element ref="class" minOccurs="0" maxOccurs="1"/>
<element ref="enablement" minOccurs="0" maxOccurs="1"/>
<element ref="serviceType" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
@@ -82,13 +81,6 @@ The service implementation class must be specified either by the class attribute
</documentation>
</annotation>
</attribute>
- <attribute name="plugin" type="string">
- <annotation>
- <documentation>
- The name of the requested contributing bundle if different from the bundle declaring the contribution.
- </documentation>
- </annotation>
- </attribute>
</complexType>
</element>
@@ -161,7 +153,7 @@ The service implementation class must be specified either by the class attribute
<attribute name="bundleId" type="string">
<annotation>
<documentation>
- The unique id of the bundle which contains the class loader required to load the service type class. If not specified, the plugin&apos;s own class loader is used.
+ The unique id of the bundle which contains the class loader required to load the service type class. If not specified, the plug-in&apos;s own class loader is used.
</documentation>
</annotation>
</attribute>
@@ -188,8 +180,7 @@ The service implementation class must be specified either by the class attribute
&lt;extension point=&quot;org.eclipse.tcf.te.runtime.services&quot;&gt;
&lt;service
id=&quot;org.eclipse.tcf.te.runtime.service.myService&quot;
- class=&quot;org.eclipse.tcf.te.runtime.service.MyServiceImpl&quot;
- label=&quot;Service Contribution Example&quot;&gt;
+ class=&quot;org.eclipse.tcf.te.runtime.service.MyServiceImpl&quot;&gt;
&lt;serviceType class=&quot;org.eclipse.tcf.te.runtime.interfaces.services.IMyServiceInterface&quot;/&gt;
&lt;/service&gt;
&lt;/extension&gt;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java
index 334721ea9..6318c37e8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java
@@ -147,10 +147,12 @@ public abstract class AbstractServiceManager {
/**
* Check whether this proxy holds a service that is suitable for the given type.
*
- * @param serviceType The service type
- * @return
+ * @param serviceType The service type. Must not be <code>null</code>.
+ * @return <code>True</code> if the proxy holds a suitable service, <code>false</code> otherwise.
*/
protected boolean isMatching(Class<? extends IService> serviceType) {
+ Assert.isNotNull(serviceType);
+
if (service != null) {
return serviceType.isInstance(service);
}
@@ -168,6 +170,36 @@ public abstract class AbstractServiceManager {
}
/**
+ * Check whether this proxy holds a service that is suitable for the given type.
+ *
+ * @param serviceTypeName The service type name. Must not be <code>null</code>.
+ * @return <code>True</code> if the proxy holds a suitable service, <code>false</code> otherwise.
+ */
+ protected boolean isMatching(String serviceTypeName) {
+ Assert.isNotNull(serviceTypeName);
+
+ if (service != null) {
+ Class<?>[] interfaces = service.getClass().getInterfaces();
+ for (Class<?> interfaze : interfaces) {
+ if (serviceTypeName.equals(interfaze.getName())) {
+ return true;
+ }
+ }
+ }
+ else if (configElement != null) {
+ if (serviceTypeName.equals(clazz)) {
+ return true;
+ }
+ for (Class<? extends IService> type : serviceTypes) {
+ if (serviceTypeName.equals(type.getName())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
* Returns if or if not the service contribution is enabled for the given service context.
* <p>
* If the given service context is <code>null</code>, only globally unbound services are
@@ -362,6 +394,32 @@ public abstract class AbstractServiceManager {
}
/**
+ * Returns if or if not a service contribution for the given service context, implementing the
+ * given service type, exist.
+ *
+ * @param context The service context or <code>null</code>.
+ * @param serviceTypeName The name of a service type the service should at least implement or extend.
+ *
+ * @return <code>True</code> if a matching service contribution exist, <code>false</code> otherwise.
+ */
+ public boolean hasService(Object context, String serviceTypeName) {
+ Assert.isNotNull(serviceTypeName);
+
+ // Get all service contributions
+ Collection<ServiceProxy> proxies = services.values();
+ if (proxies != null && !proxies.isEmpty()) {
+ for (ServiceProxy proxy : proxies) {
+ if (proxy.isMatching(serviceTypeName) && proxy.isEnabled(context)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
* Loads the contributed services into proxies (lazy loading!!) and adds them to this manager;
*/
protected abstract void loadServices();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertyTester.java
new file mode 100644
index 000000000..4343a565f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/PropertyTester.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.tcf.te.runtime.services.ServiceManager;
+
+
+/**
+ * Services plug-in property tester implementation.
+ */
+public class PropertyTester extends org.eclipse.core.expressions.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) {
+
+ // "hasService": Checks if a given service type is available for the given receiver.
+ if ("hasService".equals(property)) { //$NON-NLS-1$
+ // The service type class name is within the expected value
+ String serviceTypeName = expectedValue instanceof String ? (String)expectedValue : null;
+ if (serviceTypeName != null) {
+ return ServiceManager.getInstance().hasService(receiver, serviceTypeName);
+ }
+ }
+
+ return false;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.xml
index 82bd52333..7915221a6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/plugin.xml
@@ -21,7 +21,9 @@
<with variable="selection">
<count value="1"/>
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ <test
+ property="org.eclipse.tcf.te.runtime.services.hasService"
+ value="org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService"/>
</iterate>
</with>
</enablement>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.xml
index 48767c92c..a45d16108 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/plugin.xml
@@ -21,7 +21,9 @@
<with variable="selection">
<count value="1"/>
<iterate operator="and" ifEmpty="false">
- <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ <test
+ property="org.eclipse.tcf.te.runtime.services.hasService"
+ value="org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService"/>
</iterate>
</with>
</enablement>

Back to the top