connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/AbstractConnectedService2.java
author Ed Swartz <ed.swartz@nokia.com>
Wed, 08 Sep 2010 17:12:10 -0500
changeset 1965 0dd7f79ee65d
parent 1846 02332f802224
permissions -rw-r--r--
Support testing package XML locally
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
894
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
     1
/*
899
b5675f3e69ad update since tags to 2.5
dadubrow
parents: 894
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
894
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
     3
* All rights reserved.
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
     4
* This component and the accompanying materials are made available
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
     6
* which accompanies this distribution, and is available
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
     8
*
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
     9
* Initial Contributors:
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    11
*
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    12
* Contributors:
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    13
*
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    14
* Description: 
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    15
*
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    16
*/
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    17
package com.nokia.carbide.remoteconnections.interfaces;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    18
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    19
import java.lang.reflect.InvocationTargetException;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    20
import java.util.HashMap;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    21
import java.util.Map;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    22
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    23
import org.eclipse.core.runtime.IProgressMonitor;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    24
import org.eclipse.core.runtime.NullProgressMonitor;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    25
import org.eclipse.jface.operation.IRunnableContext;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    26
import org.eclipse.jface.operation.IRunnableWithProgress;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    27
import org.eclipse.jface.wizard.WizardDialog;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    28
import org.eclipse.swt.widgets.Display;
1622
f2409b13f0f8 multiple changes to remote agent installer code:
dadubrow
parents: 1306
diff changeset
    29
import org.osgi.framework.Version;
894
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    30
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    31
import com.nokia.carbide.remoteconnections.Messages;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    32
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    33
import com.nokia.carbide.remoteconnections.internal.ServiceTester;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    34
import com.nokia.carbide.remoteconnections.internal.api.IConnectedService2;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    35
import com.nokia.cpp.internal.api.utils.core.Check;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    36
import com.nokia.cpp.internal.api.utils.core.ListenerList;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    37
import com.nokia.cpp.internal.api.utils.core.ObjectUtils;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    38
899
b5675f3e69ad update since tags to 2.5
dadubrow
parents: 894
diff changeset
    39
/**
b5675f3e69ad update since tags to 2.5
dadubrow
parents: 894
diff changeset
    40
 * @since 2.5
b5675f3e69ad update since tags to 2.5
dadubrow
parents: 894
diff changeset
    41
 */
894
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    42
public abstract class AbstractConnectedService2 implements IConnectedService2 {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    43
	
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    44
	public final static int TIMEOUT = 2000;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    45
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    46
	public static class ConnectionFailException extends Exception {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    47
		public ConnectionFailException(String string) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    48
			super(string);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    49
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    50
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    51
		private static final long serialVersionUID = -5438012263174866437L;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    52
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    53
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    54
	public class Status implements IStatus {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    55
		private volatile EStatus estatus;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    56
		private String shortDescription;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    57
		private String longDescription;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    58
		
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    59
		public IConnectedService getConnectedService() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    60
			return AbstractConnectedService2.this;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    61
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    62
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    63
		public EStatus getEStatus() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    64
			return internalGetEStatus();
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    65
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    66
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    67
		protected EStatus internalGetEStatus() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    68
			if (estatus == null)
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    69
				estatus = EStatus.UNKNOWN;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    70
			return estatus;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    71
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    72
		
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    73
		public String getLongDescription() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    74
			return longDescription;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    75
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    76
		
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    77
		public String getShortDescription() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    78
			return shortDescription;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    79
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    80
		
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    81
		public void setEStatus(EStatus estatus, String shortDescription, String longDescription) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    82
			// if everything is the same don't fire status changed
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    83
			if (estatus.equals(this.estatus) &&
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    84
					ObjectUtils.equals(shortDescription, this.shortDescription) &&
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    85
					ObjectUtils.equals(longDescription, this.longDescription))
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    86
				return;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    87
			this.estatus = estatus;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    88
			this.shortDescription = shortDescription;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    89
			this.longDescription = longDescription;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    90
			fireStatusChanged();
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    91
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    92
	}
1089
c18e25401dcf 10843 - set in-use status for non-dynamic connections
dadubrow
parents: 899
diff changeset
    93
894
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    94
	public static class TestResult {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    95
		public TestResult(EStatus estatus, String shortDescription, String longDescription) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    96
			this.estatus = estatus;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    97
			this.shortDescription = shortDescription;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    98
			this.longDescription = longDescription;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
    99
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   100
		private EStatus estatus;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   101
		private String shortDescription;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   102
		private String longDescription;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   103
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   104
	
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   105
	protected abstract TestResult runTestStatus(IProgressMonitor monitor);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   106
	
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   107
	protected IService service;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   108
	protected AbstractSynchronizedConnection connection;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   109
	private ListenerList<IStatusChangedListener> listeners;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   110
	protected IRunnableContext runnableContext;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   111
	protected Status currentStatus;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   112
	protected boolean externalTesting;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   113
	private Map<String, String> properties;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   114
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   115
	public AbstractConnectedService2(IService service, AbstractSynchronizedConnection connection) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   116
		this.service = service;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   117
		this.connection = connection;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   118
		properties = new HashMap<String, String>();
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   119
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   120
	
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   121
	public void setRunnableContext(IRunnableContext runnableContext) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   122
		this.runnableContext = runnableContext;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   123
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   124
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   125
	public void addStatusChangedListener(IStatusChangedListener listener) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   126
		if (listeners == null)
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   127
			listeners = new ListenerList<IStatusChangedListener>();
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   128
		listeners.add(listener);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   129
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   130
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   131
	public void dispose() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   132
		if (listeners != null) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   133
			for (IStatusChangedListener listener : listeners) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   134
				listeners.remove(listener);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   135
			}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   136
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   137
		ServiceTester.getInstance().unregister(this);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   138
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   139
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   140
	public IService getService() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   141
		return service;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   142
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   143
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   144
	protected void fireStatusChanged() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   145
		if (listeners != null) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   146
			for (IStatusChangedListener listener : listeners) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   147
				listener.statusChanged(getStatus());
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   148
			}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   149
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   150
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   151
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   152
	public void removeStatusChangedListener(IStatusChangedListener listener) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   153
		if (listeners != null)
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   154
			listeners.remove(listener);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   155
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   156
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   157
	public IConnection getConnection() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   158
		return connection;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   159
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   160
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   161
	public void testStatus() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   162
		if (!(isEnabled() || externalTesting))
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   163
			return;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   164
			
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   165
		final TestResult result[] = { null };
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   166
		if (runnableContext != null && (!(runnableContext instanceof WizardDialog) || ((WizardDialog) runnableContext).getShell() != null)) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   167
			Display.getDefault().syncExec(new Runnable() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   168
				public void run() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   169
					try {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   170
						runnableContext.run(true, false, new IRunnableWithProgress() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   171
							public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   172
								result[0] = runTestStatus(monitor);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   173
							}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   174
						});
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   175
					} catch (InvocationTargetException e) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   176
					} catch (InterruptedException e) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   177
					}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   178
				}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   179
			});
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   180
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   181
		else {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   182
			result[0] = runTestStatus(new NullProgressMonitor());
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   183
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   184
		
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   185
		if (!(isEnabled() || externalTesting)) // could be waiting for response past when service testing was disabled
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   186
			return;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   187
		if (result[0].shortDescription != null && result[0].longDescription != null) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   188
			currentStatus.setEStatus(result[0].estatus, result[0].shortDescription, result[0].longDescription);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   189
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   190
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   191
	
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   192
	public void setExternalTesting() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   193
		externalTesting = true;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   194
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   195
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   196
	public boolean isEnabled() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   197
		return ServiceTester.getInstance().isRegistered(this);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   198
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   199
1846
02332f802224 Bug 11858 - add toggle action services testing enablement
dadubrow
parents: 1790
diff changeset
   200
	public void setEnabled(boolean enable) {
894
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   201
		if (!service.isTestable())
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   202
			return;
1846
02332f802224 Bug 11858 - add toggle action services testing enablement
dadubrow
parents: 1790
diff changeset
   203
		if (enable && !isEnabled()) {
894
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   204
			Check.checkState(connection.getSettings() != null);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   205
			ServiceTester.getInstance().register(this);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   206
		}
1846
02332f802224 Bug 11858 - add toggle action services testing enablement
dadubrow
parents: 1790
diff changeset
   207
		else if (!enable) {
894
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   208
			ServiceTester.getInstance().unregister(this);
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   209
			currentStatus.setEStatus(EStatus.UNKNOWN, 
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   210
					Messages.getString("AbstractConnectedService.NoTestingLabel"), //$NON-NLS-1$
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   211
					Messages.getString("AbstractConnectedService.UserDisabledMessage")); //$NON-NLS-1$
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   212
		}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   213
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   214
	
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   215
	public Map<String, String> getProperties() {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   216
		return properties;
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   217
	}
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   218
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   219
	public void setStatus(Status status) {
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   220
		if (currentStatus == null)
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   221
			currentStatus = new Status();
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   222
		currentStatus.setEStatus(status.internalGetEStatus(), status.getShortDescription(), status.getLongDescription());
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   223
	}
1622
f2409b13f0f8 multiple changes to remote agent installer code:
dadubrow
parents: 1306
diff changeset
   224
f2409b13f0f8 multiple changes to remote agent installer code:
dadubrow
parents: 1306
diff changeset
   225
	public void setDeviceOS(String familyName, Version version) {
f2409b13f0f8 multiple changes to remote agent installer code:
dadubrow
parents: 1306
diff changeset
   226
		// @deprecated
f2409b13f0f8 multiple changes to remote agent installer code:
dadubrow
parents: 1306
diff changeset
   227
	}
1790
245ab754d54b add empty interface implementation to abstract class to remove burden from subclasses (avoid API break)
dadubrow
parents: 1622
diff changeset
   228
245ab754d54b add empty interface implementation to abstract class to remove burden from subclasses (avoid API break)
dadubrow
parents: 1622
diff changeset
   229
245ab754d54b add empty interface implementation to abstract class to remove burden from subclasses (avoid API break)
dadubrow
parents: 1622
diff changeset
   230
	public void setDeviceOS(String familyName, String version) {
245ab754d54b add empty interface implementation to abstract class to remove burden from subclasses (avoid API break)
dadubrow
parents: 1622
diff changeset
   231
		// empty implementation
245ab754d54b add empty interface implementation to abstract class to remove burden from subclasses (avoid API break)
dadubrow
parents: 1622
diff changeset
   232
	}
894
48b544aebc83 bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff changeset
   233
}