Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-12-19 11:21:46 +0000
committerUwe Stieber2011-12-19 11:23:21 +0000
commit78351b74cfadfd9ae337d7fa182bece8df18deee (patch)
tree0a8e7b0254fc5ec3e26d54c49ec61d3d8ec6f3d5 /target_explorer/plugins/org.eclipse.tcf.te.runtime.services
parentd54c609bb0a1a4a47473394ccf8d9a90e45f02be (diff)
downloadorg.eclipse.tcf-78351b74cfadfd9ae337d7fa182bece8df18deee.tar.gz
org.eclipse.tcf-78351b74cfadfd9ae337d7fa182bece8df18deee.tar.xz
org.eclipse.tcf-78351b74cfadfd9ae337d7fa182bece8df18deee.zip
Target Explorer: Implement peer model properties access service and remove TCF dependencies from terminals.ui
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime.services')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/AbstractServiceManager.java32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/ServiceManager.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java41
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/IPropertiesAccessServiceConstants.java68
4 files changed, 130 insertions, 21 deletions
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 03b0dd5ae..334721ea9 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
@@ -34,7 +34,7 @@ import org.eclipse.tcf.te.runtime.services.interfaces.IService;
/**
* Abstract service manager implementation.
*/
-public abstract class AbstractServiceManager<V extends IService> {
+public abstract class AbstractServiceManager {
// Map for all contributed services stored by their respective unique id
private Map<String, ServiceProxy> services = new HashMap<String, ServiceProxy>();
@@ -50,9 +50,9 @@ public abstract class AbstractServiceManager<V extends IService> {
// The class implementing the service
public String clazz;
// The service instance
- private V service = null;
+ private IService service = null;
// The list of service types the service is implementing
- private List<Class<? extends V>> serviceTypes = new ArrayList<Class<? extends V>>();
+ private List<Class<? extends IService>> serviceTypes = new ArrayList<Class<? extends IService>>();
// The converted expression
private Expression expression;
@@ -104,7 +104,7 @@ public abstract class AbstractServiceManager<V extends IService> {
*
* @param serviceType The type to add.
*/
- public void addType(Class<? extends V> serviceType) {
+ public void addType(Class<? extends IService> serviceType) {
Assert.isNotNull(serviceType);
if (service == null && serviceTypes != null && !serviceTypes.contains(serviceType)) {
serviceTypes.add(serviceType);
@@ -114,18 +114,17 @@ public abstract class AbstractServiceManager<V extends IService> {
/**
* Return the real service instance for this proxy.
*/
- @SuppressWarnings("unchecked")
- protected V getService(boolean unique) {
+ protected IService getService(boolean unique) {
if ((service == null || unique) && configElement != null) {
try {
// Create the service class instance via the configuration element
Object service = configElement.createExecutableExtension("class"); //$NON-NLS-1$
if (service instanceof IService) {
if (unique) {
- return (V) service;
+ return (IService)service;
}
else if (service instanceof IService) {
- this.service = (V)service;
+ this.service = (IService)service;
}
else {
IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Service '" + service.getClass().getName() + "' not of type IService."); //$NON-NLS-1$ //$NON-NLS-2$
@@ -151,7 +150,7 @@ public abstract class AbstractServiceManager<V extends IService> {
* @param serviceType The service type
* @return
*/
- protected boolean isMatching(Class<? extends V> serviceType) {
+ protected boolean isMatching(Class<? extends IService> serviceType) {
if (service != null) {
return serviceType.isInstance(service);
}
@@ -159,7 +158,7 @@ public abstract class AbstractServiceManager<V extends IService> {
if (serviceType.getClass().getName().equals(clazz)) {
return true;
}
- for (Class<? extends V> type : serviceTypes) {
+ for (Class<? extends IService> type : serviceTypes) {
if (type.equals(serviceType)) {
return true;
}
@@ -221,7 +220,7 @@ public abstract class AbstractServiceManager<V extends IService> {
return expression;
}
- public boolean equals(V service) {
+ public boolean equals(IService service) {
return clazz.equals(service.getClass());
}
@@ -270,7 +269,7 @@ public abstract class AbstractServiceManager<V extends IService> {
*
* @return The service or <code>null</code>.
*/
- public V getService(Object context, Class<? extends V> serviceType) {
+ public <V extends IService> V getService(Object context, Class<? extends V> serviceType) {
return getService(context, serviceType, false);
}
@@ -289,7 +288,8 @@ public abstract class AbstractServiceManager<V extends IService> {
*
* @return The service or <code>null</code>.
*/
- public V getService(Object context, Class<? extends V> serviceType, boolean unique) {
+ @SuppressWarnings("unchecked")
+ public <V extends IService> V getService(Object context, Class<? extends V> serviceType, boolean unique) {
Assert.isNotNull(serviceType);
Collection<ServiceProxy> proxies = services.values();
@@ -299,7 +299,7 @@ public abstract class AbstractServiceManager<V extends IService> {
for (ServiceProxy proxy : proxies) {
if (proxy.isMatching(serviceType) && proxy.isEnabled(context)) {
if (!isInterface && proxy.equals(serviceType)) {
- V service = proxy.getService(unique);
+ V service = (V)proxy.getService(unique);
service.setId(proxy.getId());
return service;
}
@@ -309,7 +309,7 @@ public abstract class AbstractServiceManager<V extends IService> {
V service = null;
if (!candidates.isEmpty()) {
- service = candidates.get(0).getService(unique);
+ service = (V)candidates.get(0).getService(unique);
service.setId(candidates.get(0).getId());
}
@@ -328,7 +328,7 @@ public abstract class AbstractServiceManager<V extends IService> {
*
* @return The service list or empty list.
*/
- public IService[] getServices(Object context, Class<? extends V> serviceType, boolean unique) {
+ public IService[] getServices(Object context, Class<? extends IService> serviceType, boolean unique) {
Assert.isNotNull(serviceType);
Collection<ServiceProxy> proxies = services.values();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/ServiceManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/ServiceManager.java
index d0210c0c4..eda0acb4e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/ServiceManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/ServiceManager.java
@@ -25,7 +25,7 @@ import org.osgi.framework.Bundle;
* Common service manager implementation, handling the extension point
* <code>org.eclipse.tcf.te.runtime.services</code>.
*/
-public class ServiceManager extends AbstractServiceManager<IService> {
+public class ServiceManager extends AbstractServiceManager {
/*
* Thread save singleton instance creation.
*/
@@ -60,8 +60,8 @@ public class ServiceManager extends AbstractServiceManager<IService> {
* @param serviceType The service type the service should at least implement or extend.
* @return The service or <code>null</code>.
*/
- public <V extends IService> V getService(Class<V> serviceType, boolean unique) {
- return (V)super.getService(null, serviceType, unique);
+ public <V extends IService> V getService(Class<? extends V> serviceType, boolean unique) {
+ return super.getService(null, serviceType, unique);
}
/**
@@ -77,8 +77,8 @@ public class ServiceManager extends AbstractServiceManager<IService> {
* @param serviceType The service type the service should at least implement or extend.
* @return The service or <code>null</code>.
*/
- public <V extends IService> V getService(Class<V> serviceType) {
- return (V)super.getService(null, serviceType);
+ public <V extends IService> V getService(Class<? extends V> serviceType) {
+ return super.getService(null, serviceType);
}
/* (non-Javadoc)
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
new file mode 100644
index 000000000..4b2eba006
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IPropertiesAccessService.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.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);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/IPropertiesAccessServiceConstants.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/IPropertiesAccessServiceConstants.java
new file mode 100644
index 000000000..31c35a4a2
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/constants/IPropertiesAccessServiceConstants.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.interfaces.constants;
+
+/**
+ * Defines the properties access service constants.
+ */
+public interface IPropertiesAccessServiceConstants {
+
+ /**
+ * Target name.
+ * <p>
+ * The target name is not meant to be identical with the targets network name. It can
+ * be the targets network name, but it can be any other string identifying the target
+ * to the user as well. The name is for display only, it is not meant to be used for
+ * communicating with the target.
+ */
+ public static String PROP_NAME = "name"; //$NON-NLS-1$
+
+ /**
+ * Target agent address.
+ * <p>
+ * <i>The value is typically the address an agent running at the target.</i>
+ */
+ public static String PROP_ADDRESS = "address"; //$NON-NLS-1$
+
+ /**
+ * Target agent port.
+ * <p>
+ * <i>The value is typically the port an agent running at the target.</i>
+ */
+ public static String PROP_PORT = "port"; //$NON-NLS-1$
+
+ /**
+ * Target address to be used to construct a SSH connection.
+ * <p>
+ * If not specified, clients should fall back to {@link PROP_ADDRESS}.
+ */
+ public static String PROP_SSH_ADDRESS = "ssh.address"; //$NON-NLS-1$
+
+ /**
+ * Target port to be used to construct a SSH connection.
+ * <p>
+ * If not specified, clients should assume the default "22".
+ */
+ public static String PROP_SSH_PORT = "ssh.port"; //$NON-NLS-1$
+
+ /**
+ * Target address to be used to construct a telnet connection.
+ * <p>
+ * If not specified, clients should fall back to {@link PROP_ADDRESS}.
+ */
+ public static String PROP_TELNET_ADDRESS = "telnet.address"; //$NON-NLS-1$
+
+ /**
+ * Target port to be used to construct a telnet connection.
+ * <p>
+ * If not specified, clients should assume the default "23".
+ */
+ public static String PROP_TELNET_PORT = "telnet.port"; //$NON-NLS-1$
+}

Back to the top