Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.locator')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml35
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java70
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/activator/CoreBundleActivator.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/IModelListener.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/ITracing.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/ILocatorModel.java158
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModel.java152
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java59
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java)60
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProvider.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProvider.java)52
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IDefaultContextService.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelLookupService.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelLookupService.java)20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelQueryService.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelPeerNodeQueryService.java)10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelRefreshService.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelRefreshService.java)6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelService.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelService.java)15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelUpdateService.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelUpdateService.java)24
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/ModelNodeFactoryDelegate.java129
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/LocatorModelPropertyTester.java)38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/SimulatorPropertyTester.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerNodeStepContext.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelStepContext.java)14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerPersistableURIProvider.java218
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java538
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java24
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerNodeStepGroupIterator.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerModelStepGroupIterator.java)92
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartDebuggerIterator.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartSimulatorIterator.java100
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java28
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java87
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ModelAdapter.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/Model.java32
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java179
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java785
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java839
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java405
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java30
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractPeerModelService.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractLocatorModelService.java)22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelLookupService.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java)85
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelQueryService.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelPeerNodeQueryService.java)40
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelRefreshService.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java)165
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelUpdateService.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelUpdateService.java)58
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/selection/RuntimeServiceContextFilter.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerNodeStep.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerModelStep.java)90
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/CheckServiceStep.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetWaitForReadyStep.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SignalPeerDisconnectedStep.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopDebuggerStep.java110
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopSimulatorStep.java90
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java50
57 files changed, 2193 insertions, 2931 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/META-INF/MANIFEST.MF
index 837d3df41..deffea96f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/META-INF/MANIFEST.MF
@@ -29,7 +29,6 @@ Export-Package: org.eclipse.tcf.te.tcf.locator,
org.eclipse.tcf.te.tcf.locator.interfaces.services,
org.eclipse.tcf.te.tcf.locator.internal;x-internal:=true,
org.eclipse.tcf.te.tcf.locator.internal.adapters;x-internal:=true,
- org.eclipse.tcf.te.tcf.locator.internal.nodes;x-internal:=true,
org.eclipse.tcf.te.tcf.locator.internal.preferences,
org.eclipse.tcf.te.tcf.locator.internal.services;x-internal:=true,
org.eclipse.tcf.te.tcf.locator.iterators,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
index c4582a6d0..71ce90d21 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
@@ -13,23 +13,23 @@
<!-- Adapter factory contributions -->
<extension point="org.eclipse.core.runtime.adapters">
<factory
- adaptableType="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"
+ adaptableType="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"
class="org.eclipse.tcf.te.tcf.locator.internal.adapters.AdapterFactory">
<adapter type="org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider"/>
<adapter type="org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext"/>
- <adapter type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel"/>
+ <adapter type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
</factory>
<factory
adaptableType="org.eclipse.tcf.protocol.IPeer"
class="org.eclipse.tcf.te.tcf.locator.internal.adapters.AdapterFactory">
<adapter type="org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider"/>
- <adapter type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ <adapter type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
</factory>
<factory
- adaptableType="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider"
+ adaptableType="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider"
class="org.eclipse.tcf.te.tcf.locator.internal.adapters.AdapterFactory">
<adapter type="org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider"/>
- <adapter type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ <adapter type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
</factory>
</extension>
@@ -43,22 +43,22 @@
<delegate
class="org.eclipse.tcf.te.tcf.locator.internal.ModelNodeFactoryDelegate"
id="org.eclipse.tcf.te.tcf.locator.model.factory.delegate">
- <nodeType class="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ <nodeType class="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
</delegate>
</extension>
<!-- Eclipse core expressions property tester -->
<extension point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
- class="org.eclipse.tcf.te.tcf.locator.internal.LocatorModelPropertyTester"
+ class="org.eclipse.tcf.te.tcf.locator.internal.PeerModelPropertyTester"
id="org.eclipse.tcf.te.tcf.locator.LocatorModelPropertyTester"
namespace="org.eclipse.tcf.te.tcf.locator"
properties="name,nameRegex,osName,osNameRegex,hasLocalService,hasRemoteService,hasOfflineService,hasAttribute,isAttribute,isStaticPeer,isRedirected,isProxy,isValueAdd,isOfType"
- type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel">
+ type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode">
</propertyTester>
<propertyTester
- class="org.eclipse.tcf.te.tcf.locator.internal.LocatorModelPropertyTester"
+ class="org.eclipse.tcf.te.tcf.locator.internal.PeerModelPropertyTester"
id="org.eclipse.tcf.te.tcf.locator.LocatorModelPropertyTester2"
namespace="org.eclipse.tcf.te.tcf.locator"
properties="name,nameRegex,osName,osNameRegex,hasLocalService,hasRemoteService,hasOfflineService,hasAttribute,isAttribute,isStaticPeer,isRedirected,isProxy,isValueAdd,isOfType"
@@ -70,7 +70,7 @@
id="org.eclipse.tcf.te.tcf.locator.SimulatorPropertyTester"
namespace="org.eclipse.tcf.te.tcf.locator"
properties="isSimulatorState,canStartSimulator"
- type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel">
+ type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode">
</propertyTester>
</extension>
@@ -104,8 +104,8 @@
<with variable="context">
<or>
<instanceof value="org.eclipse.tcf.protocol.IPeer"/>
- <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
- <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider"/>
<and>
<instanceof value="java.lang.Class"/>
<with variable="contextClass">
@@ -127,7 +127,10 @@
bundleId="org.eclipse.tcf.te.runtime.services"
class="org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService"/>
<enablement>
- <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ <or>
+ <instanceof value="org.eclipse.tcf.protocol.IPeer"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
+ </or>
</enablement>
</service>
<service
@@ -138,7 +141,7 @@
class="org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService">
</serviceType>
<enablement>
- <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode"/>
<test forcePluginActivation="true" property="org.eclipse.tcf.te.tcf.locator.isStaticPeer" value="true"/>
<test forcePluginActivation="true" property="org.eclipse.tcf.te.tcf.locator.isOfType" value="null"/>
</enablement>
@@ -267,7 +270,7 @@
is adaptable to IPeerModel and has a simulator service
-->
<definition id="te.expressions.peerModel.hasSimulatorService">
- <adapt type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel">
+ <adapt type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode">
<test property="org.eclipse.tcf.te.runtime.services.hasService"
value="org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService"/>
<test property="org.eclipse.tcf.te.tcf.locator.isAttribute"
@@ -300,7 +303,7 @@
is adaptable to IPeerModel and has remote or offline run control
-->
<definition id="te.expressions.peerModel.hasRunControl">
- <adapt type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel">
+ <adapt type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode">
<or>
<test property="org.eclipse.tcf.te.tcf.locator.hasRemoteService" value="RunControl"/>
<test property="org.eclipse.tcf.te.tcf.locator.hasOfflineService" value="RunControl"/>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java
index 24f488c10..a0adeaa52 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/Scanner.java
@@ -29,9 +29,9 @@ import org.eclipse.tcf.te.tcf.core.async.CallbackInvocationDelegate;
import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner;
import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
import org.eclipse.tcf.te.tcf.locator.model.Model;
@@ -40,7 +40,7 @@ import org.eclipse.tcf.te.tcf.locator.model.Model;
*/
public class Scanner extends Job implements IScanner {
// Reference to the parent model instance.
- private final ILocatorModel parentModel;
+ private final IPeerModel parentModel;
// Reference to the scanner configuration
private final Map<String, Object> configuration = new HashMap<String, Object>();
@@ -53,7 +53,7 @@ public class Scanner extends Job implements IScanner {
*
* @param parentModel The parent model instance. Must not be <code>null</code>.
*/
- public Scanner(ILocatorModel parentModel) {
+ public Scanner(IPeerModel parentModel) {
super(Scanner.class.getName());
Assert.isNotNull(parentModel);
this.parentModel = parentModel;
@@ -68,7 +68,7 @@ public class Scanner extends Job implements IScanner {
*
* @return The parent model instance.
*/
- protected ILocatorModel getParentModel() {
+ protected IPeerModel getParentModel() {
return parentModel;
}
@@ -98,7 +98,7 @@ public class Scanner extends Job implements IScanner {
if (monitor == null) monitor = new NullProgressMonitor();
// Get the current list of peers known to the parent model
- IPeerModel[] peers = getParentModel().getPeers();
+ IPeerNode[] peers = getParentModel().getPeers();
// Do we have something to scan at all
if (peers.length > 0) {
try {
@@ -131,7 +131,7 @@ public class Scanner extends Job implements IScanner {
}, new CallbackInvocationDelegate());
// Loop the nodes and try to get an channel
- for (IPeerModel peer : peers) {
+ for (IPeerNode peer : peers) {
// Check for the progress monitor getting canceled
if (monitor.isCanceled() || isTerminated()) break;
// Scan the peer
@@ -155,7 +155,7 @@ public class Scanner extends Job implements IScanner {
* @param collector The callback collector. Must not be <code>null</code>.
* @param monitor The progress monitor. Must not be <code>null</code>.
*/
- /* default */ void doScan(final IPeerModel peer, final AsyncCallbackCollector collector, final IProgressMonitor monitor) {
+ /* default */ void doScan(final IPeerNode peer, final AsyncCallbackCollector collector, final IProgressMonitor monitor) {
Assert.isNotNull(peer);
Assert.isNotNull(collector);
Assert.isNotNull(monitor);
@@ -174,7 +174,7 @@ public class Scanner extends Job implements IScanner {
@Override
public void run() {
- isExcluded.set(peer.getBooleanProperty(IPeerModelProperties.PROP_SCANNER_EXCLUDE));
+ isExcluded.set(peer.getBooleanProperty(IPeerNodeProperties.PROP_SCANNER_EXCLUDE));
}
};
@@ -191,9 +191,9 @@ public class Scanner extends Job implements IScanner {
if (!monitor.isCanceled() && !isTerminated()) {
// Get the children of the scanned peer model and make sure
// they are scanned too if not excluded
- List<IPeerModel> candidates = Model.getModel().getChildren(peer.getPeerId());
+ List<IPeerNode> candidates = Model.getModel().getChildren(peer.getPeerId());
if (candidates != null && candidates.size() > 0) {
- for (IPeerModel candidate : candidates) {
+ for (IPeerNode candidate : candidates) {
doScan(candidate, collector, monitor);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java
index 51fd51b7c..926d67494 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java
@@ -37,12 +37,12 @@ import org.eclipse.tcf.te.tcf.core.peers.Peer;
import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner;
import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService;
-import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService;
+import org.eclipse.tcf.te.tcf.locator.nodes.PeerNode;
import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector;
@@ -55,7 +55,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
// Reference to the parent model scanner
private final IScanner parentScanner;
// Reference to the peer model node to update
- /* default */ final IPeerModel peerNode;
+ /* default */ final IPeerNode peerNode;
// Reference to the channel
/* default */ IChannel channel = null;
// Mark if the used channel is a shared channel instance
@@ -70,7 +70,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
* @param scanner The parent model scanner or <code>null</code> if the runnable is constructed from outside a scanner.
* @param peerNode The peer model instance. Must not be <code>null</code>.
*/
- public ScannerRunnable(IScanner scanner, IPeerModel peerNode) {
+ public ScannerRunnable(IScanner scanner, IPeerNode peerNode) {
this(scanner, peerNode, null);
}
@@ -81,7 +81,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
* @param peerNode The peer model instance. Must not be <code>null</code>.
* @param callback The callback to invoke once the scan has been completed or <code>null</code>.
*/
- public ScannerRunnable(IScanner scanner, IPeerModel peerNode, ICallback callback) {
+ public ScannerRunnable(IScanner scanner, IPeerNode peerNode, ICallback callback) {
super();
parentScanner = scanner;
@@ -193,19 +193,19 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
final boolean changed = peerNode.setChangeEventsEnabled(false);
// Set the peer state property
- int counter = peerNode.getIntProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER);
- if (!peerNode.isProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_WAITING_FOR_READY)) {
- peerNode.setProperty(IPeerModelProperties.PROP_STATE, counter > 0 ? IPeerModelProperties.STATE_CONNECTED : IPeerModelProperties.STATE_REACHABLE);
- peerNode.setProperty(IPeerModelProperties.PROP_LAST_SCANNER_ERROR, null);
+ int counter = peerNode.getIntProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER);
+ if (!peerNode.isProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_WAITING_FOR_READY)) {
+ peerNode.setProperty(IPeerNodeProperties.PROP_STATE, counter > 0 ? IPeerNodeProperties.STATE_CONNECTED : IPeerNodeProperties.STATE_REACHABLE);
+ peerNode.setProperty(IPeerNodeProperties.PROP_LAST_SCANNER_ERROR, null);
}
// Get the parent model from the model mode
- final ILocatorModel model = (ILocatorModel)peerNode.getAdapter(ILocatorModel.class);
+ final IPeerModel model = (IPeerModel)peerNode.getAdapter(IPeerModel.class);
if (channel != null && channel.getState() == IChannel.STATE_OPEN) {
// Update the services lists
- ILocatorModelUpdateService updateService = model != null ? model.getService(ILocatorModelUpdateService.class) : null;
+ IPeerModelUpdateService updateService = model != null ? model.getService(IPeerModelUpdateService.class) : null;
if (updateService != null) {
Collection<String> localServices = channel.getLocalServices();
Collection<String> remoteServices = channel.getRemoteServices();
@@ -294,7 +294,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
// Update the peer attributes
Map<String, String> attrs = new HashMap<String, String>(channel.getRemotePeer().getAttributes());
attrs.put(IPeer.ATTR_AGENT_ID, agentID);
- peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, new Peer(attrs));
+ peerNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, new Peer(attrs));
}
if (isGetPeersAllowed(channel)) {
@@ -367,7 +367,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
* @param callback The callback. Must not be <code>null</code>.
*/
@SuppressWarnings("unused")
- protected void getPeers(final IChannel channel, final ILocatorModel model, final String ip, final ICallback callback) {
+ protected void getPeers(final IChannel channel, final IPeerModel model, final String ip, final ICallback callback) {
Assert.isNotNull(channel);
Assert.isNotNull(model);
Assert.isNotNull(callback);
@@ -404,7 +404,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
// Get the parent peer
IPeer parentPeer = channel.getRemotePeer();
// Get the old child list
- List<IPeerModel> oldChildren = new ArrayList<IPeerModel>(model.getChildren(parentPeer.getID()));
+ List<IPeerNode> oldChildren = new ArrayList<IPeerNode>(model.getChildren(parentPeer.getID()));
// "getPeers" returns a collection of peer attribute maps
@SuppressWarnings("unchecked")
@@ -428,37 +428,27 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
// Create a peer instance
IPeer peer = new PeerRedirector(parentPeer, attributes);
// Try to find an existing peer node first
- IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(parentPeer.getID(), peerId);
+ IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(parentPeer.getID(), peerId);
if (peerNode == null) {
// Not yet known -> add it
- peerNode = new PeerModel(model, peer);
+ peerNode = new PeerNode(model, peer);
peerNode.setParent(ScannerRunnable.this.peerNode);
- peerNode.setProperty(IPeerModelProperties.PROP_SCANNER_EXCLUDE, true);
+ peerNode.setProperty(IPeerNodeProperties.PROP_SCANNER_EXCLUDE, true);
// Validate the peer node before adding
peerNode = model.validateChildPeerNodeForAdd(peerNode);
if (peerNode != null) {
// Add the child peer node to model
- model.getService(ILocatorModelUpdateService.class).addChild(peerNode);
+ model.getService(IPeerModelUpdateService.class).addChild(peerNode);
}
} else {
// The parent node should be set and match
- Assert.isTrue(peerNode.getParent(IPeerModel.class) != null && peerNode.getParent(IPeerModel.class).equals(ScannerRunnable.this.peerNode));
+ Assert.isTrue(peerNode.getParent(IPeerNode.class) != null && peerNode.getParent(IPeerNode.class).equals(ScannerRunnable.this.peerNode));
// Peer node found, update the peer instance
- peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer);
+ peerNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer);
// And remove it from the old child list
oldChildren.remove(peerNode);
}
}
-
- // Everything left in the old child list is not longer known to the remote peer
- // However, the child list may include manual redirected static peers. Do not
- // remove them here.
- for (IPeerModel child : oldChildren) {
- if (!child.isStatic()) {
- // Remove the child peer node from the model
- model.getService(ILocatorModelUpdateService.class).removeChild(child);
- }
- }
}
// Once everything is processed, close the channel
@@ -500,17 +490,17 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
// Turn off change notifications temporarily
boolean changed = peerNode.setChangeEventsEnabled(false);
- peerNode.setProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER, null);
- if (!peerNode.isProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_WAITING_FOR_READY)) {
+ peerNode.setProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER, null);
+ if (!peerNode.isProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_WAITING_FOR_READY)) {
boolean timeout = error instanceof SocketTimeoutException || (error instanceof ConnectException && error.getMessage() != null && error.getMessage().startsWith("Connection timed out:")); //$NON-NLS-1$
- peerNode.setProperty(IPeerModelProperties.PROP_STATE, timeout ? IPeerModelProperties.STATE_NOT_REACHABLE : IPeerModelProperties.STATE_ERROR);
- peerNode.setProperty(IPeerModelProperties.PROP_LAST_SCANNER_ERROR, error instanceof SocketTimeoutException ? null : error);
+ peerNode.setProperty(IPeerNodeProperties.PROP_STATE, timeout ? IPeerNodeProperties.STATE_NOT_REACHABLE : IPeerNodeProperties.STATE_ERROR);
+ peerNode.setProperty(IPeerNodeProperties.PROP_LAST_SCANNER_ERROR, error instanceof SocketTimeoutException ? null : error);
}
// Clear out previously determined services
- ILocatorModel model = (ILocatorModel)peerNode.getAdapter(ILocatorModel.class);
+ IPeerModel model = (IPeerModel)peerNode.getAdapter(IPeerModel.class);
if (model != null) {
- ILocatorModelUpdateService updateService = model.getService(ILocatorModelUpdateService.class);
+ IPeerModelUpdateService updateService = model.getService(IPeerModelUpdateService.class);
updateService.updatePeerServices(peerNode, null, null);
// Clean out possible child nodes
@@ -534,7 +524,7 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener {
* @param node The peer model node. Must not be <code>null</code>.
* @param changed <code>True</code> if the change events shall be enabled, <code>false</code> otherwise.
*/
- protected void onDone(IPeerModel node, boolean changed) {
+ protected void onDone(IPeerNode node, boolean changed) {
Assert.isNotNull(node);
// Reset the scanner runnable marker
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/activator/CoreBundleActivator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/activator/CoreBundleActivator.java
index 9b25bd98b..5584d8615 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/activator/CoreBundleActivator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/activator/CoreBundleActivator.java
@@ -13,7 +13,7 @@ import org.eclipse.core.runtime.Plugin;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.locator.model.Model;
import org.osgi.framework.BundleContext;
@@ -87,7 +87,7 @@ public class CoreBundleActivator extends Plugin {
plugin = null;
// Dispose the locator model
- final ILocatorModel model = Model.getModel(true);
+ final IPeerModel model = Model.getModel(true);
if (model != null) {
Runnable runnable = new Runnable() {
@Override
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/IModelListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/IModelListener.java
index c592f5362..18fea6a2d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/IModelListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/IModelListener.java
@@ -9,8 +9,8 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.locator.interfaces;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* Interface for clients to implement that wishes to listen to changes to the locator model.
@@ -21,15 +21,15 @@ public interface IModelListener {
* Invoked if a peer is added or removed to/from the locator model.
*
* @param model The changed locator model.
- * @param peerModel The added/removed peer model node.
+ * @param peerNode The added/removed peer model node.
* @param added <code>True</code> if the peer model node got added, <code>false</code> if it got removed.
*/
- public void locatorModelChanged(ILocatorModel model, IPeerModel peerModel, boolean added);
+ public void locatorModelChanged(IPeerModel model, IPeerNode peerNode, boolean added);
/**
* Invoked if the locator model is disposed.
*
* @param model The disposed locator model.
*/
- public void locatorModelDisposed(ILocatorModel model);
+ public void locatorModelDisposed(IPeerModel model);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/ITracing.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/ITracing.java
index b131fbb3b..b8475fb93 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/ITracing.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/ITracing.java
@@ -18,7 +18,7 @@ public interface ITracing {
/**
* If enabled, prints information about locator model method invocations.
*/
- public static String ID_TRACE_LOCATOR_MODEL = "trace/locatorModel"; //$NON-NLS-1$
+ public static String ID_TRACE_LOCATOR_MODEL = "trace/peerModel"; //$NON-NLS-1$
/**
* If enabled, prints information about locator listener method invocations.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/ILocatorModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/ILocatorModel.java
deleted file mode 100644
index 7c89b9d54..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/ILocatorModel.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * 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.tcf.locator.interfaces.nodes;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.services.ILocator;
-import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener;
-import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelService;
-
-
-/**
- * The locator model is an extension to the TCF locator service. The
- * model allows to store additional properties for each peer, keep
- * track of peers from different origins.
- * <p>
- * <b>Note:</b> Updates to the locator model, and the locator model
- * children needs to be performed in the TCF dispatch thread. The
- * locator model and all child model nodes do assert this core
- * assumption. To maintain consistency, and to avoid any performance
- * overhead for thread synchronization, the model read access must
- * happen in the TCF dispatch thread as well.
- *
- * @see ILocator
- */
-public interface ILocatorModel extends IAdaptable {
-
- /**
- * Adds the specified listener to the list of model listener.
- * If the same listener has been added before, the listener will
- * not be added again.
- *
- * @param listener The listener. Must not be <code>null</code>.
- */
- public void addListener(IModelListener listener);
-
- /**
- * Removes the specified listener from the list of model listener.
- *
- * @param listener The listener. Must not be <code>null</code>.
- */
- public void removeListener(IModelListener listener);
-
- /**
- * Returns the list of registered model listeners.
- *
- * @return The list of registered model listeners or an empty list.
- */
- public IModelListener[] getListener();
-
- /**
- * Dispose the locator model instance.
- */
- public void dispose();
-
- /**
- * Returns if or if not the locator model instance is disposed.
- *
- * @return <code>True</code> if the locator model instance is disposed, <code>false/code> otherwise.
- */
- public boolean isDisposed();
-
- /**
- * Returns the list of known peers.
- *
- * @return The list of known peers or an empty list.
- */
- public IPeerModel[] getPeers();
-
- /**
- * Returns an unmodifiable list of known children for the given parent peer.
- *
- * @param parentPeerID The parent peer id. Must not be <code>null</code>.
- * @return The child list.
- */
- public List<IPeerModel> getChildren(String parentPeerID);
-
- /**
- * Sets the list of known children for the given parent peer.
- *
- * @param parentPeerID The parent peer id. Must not be <code>null</code>.
- * @param children The list of children or <code>null</code> to remove the parent peer.
- */
- public void setChildren(String parentPeerID, List<IPeerModel> children);
-
- /**
- * Returns the scanner instance being associated with the
- * locator model.
- *
- * @return The scanner instance.
- */
- public IScanner getScanner();
-
- /**
- * Starts the scanner.
- *
- * @param delay The delay in millisecond before the scanning starts.
- * @param schedule The time in millisecond between the scanner runs.
- */
- public void startScanner(long delay, long schedule);
-
- /**
- * Stops the scanner.
- */
- public void stopScanner();
-
- /**
- * Returns the locator model service, implementing at least the specified
- * service interface.
- *
- * @param serviceInterface The service interface class. Must not be <code>null</code>.
- * @return The service instance implementing the specified service interface, or <code>null</code>.
- */
- public <V extends ILocatorModelService> V getService(Class<V> serviceInterface);
-
- /**
- * Validate the given peer.
- * <p>
- * If the peer is for local host, than only the peer using the loopback address is valid.
- *
- * @param peer The peer. Must not be <code>null</code>.
- * @return The peer if the peer is valid, or <code>null</code> if not.
- */
- public IPeer validatePeer(IPeer peer);
-
- /**
- * Validate the given peer model if or if not it can be added to the locator model as new peer
- * node.
- *
- * @param node The peer model. Must not be <code>null</code>.
- * @return The peer node if it allowed add it to the model, or <code>null</code> if not.
- */
- public IPeerModel validatePeerNodeForAdd(IPeerModel node);
-
- /**
- * Validate the given child peer model node if or if not it can be added to the locator model
- * as new child peer node for the associated parent peer model node.
- * <p>
- * <b>Note:</b> The parent peer node is determined by calling {@link IPeerModel#getParentNode()}.
- * The call has to return a non-null value, otherwise {@link #validateChildPeerNodeForAdd(IPeerModel)}
- * will do nothing.
- *
- * @param node The peer model. Must not be <code>null</code>.
- * @return The peer node if it allowed add it to the model, or <code>null</code> if not.
- */
- public IPeerModel validateChildPeerNodeForAdd(IPeerModel node);
-
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModel.java
index 310dd1b5d..832f225e7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModel.java
@@ -9,80 +9,150 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.locator.interfaces.nodes;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.te.core.interfaces.IDecoratable;
-import org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode;
+import org.eclipse.tcf.services.ILocator;
+import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener;
+import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelService;
+
/**
- * The peer model is an extension to the TCF peer representation, implementing the {@link IPeer}
- * interface. The peer model provides an offline cache for a peers known list of local and remote
- * services and is the merge point of peer attributes from custom data storages.
+ * The locator model is an extension to the TCF locator service. The
+ * model allows to store additional properties for each peer, keep
+ * track of peers from different origins.
* <p>
- * <b>Note:</b> Read and write access to the peer model must happen within the TCF dispatch thread.
+ * <b>Note:</b> Updates to the locator model, and the locator model
+ * children needs to be performed in the TCF dispatch thread. The
+ * locator model and all child model nodes do assert this core
+ * assumption. To maintain consistency, and to avoid any performance
+ * overhead for thread synchronization, the model read access must
+ * happen in the TCF dispatch thread as well.
+ *
+ * @see ILocator
*/
-public interface IPeerModel extends IContainerModelNode, IDecoratable {
+public interface IPeerModel extends IAdaptable {
/**
- * Returns the parent locator model instance.
- * <p>
- * This method may be called from any thread.
+ * Adds the specified listener to the list of model listener.
+ * If the same listener has been added before, the listener will
+ * not be added again.
*
- * @return The parent locator model instance.
+ * @param listener The listener. Must not be <code>null</code>.
*/
- public ILocatorModel getModel();
+ public void addListener(IModelListener listener);
/**
- * Returns the native {@link IPeer} object.
- * <p>
- * This method may be called from any thread.
+ * Removes the specified listener from the list of model listener.
*
- * @return The native {@link IPeer} instance.
+ * @param listener The listener. Must not be <code>null</code>.
*/
- public IPeer getPeer();
+ public void removeListener(IModelListener listener);
/**
- * Returns the peer id.
- * <p>
- * This method may be called from any thread.
+ * Returns the list of registered model listeners.
*
- * @return The peer id.
+ * @return The list of registered model listeners or an empty list.
*/
- public String getPeerId();
+ public IModelListener[] getListener();
/**
- * Returns the peer id of the remote peer.
- * <p>
- * For dynamically discovered peers, {@link #getPeerId()} and {@link #getRemotePeerId()} are identical.
- * <p>
- * For static peers, {@link #getRemotePeerId()} will return <code>null</code> if the static peer is not
- * associated with an agent. Otherwise it will return the id of the associated agent.
+ * Dispose the locator model instance.
+ */
+ public void dispose();
+
+ /**
+ * Returns if or if not the locator model instance is disposed.
+ *
+ * @return <code>True</code> if the locator model instance is disposed, <code>false/code> otherwise.
+ */
+ public boolean isDisposed();
+
+ /**
+ * Returns the list of known peers.
*
- * @return The remote peer id or <code>null</code>.
+ * @return The list of known peers or an empty list.
*/
- public String getRemotePeerId();
+ public IPeerNode[] getPeers();
/**
- * Returns if or if not the peer attributes are complete to open a channel to it.
+ * Returns an unmodifiable list of known children for the given parent peer.
*
- * @return <code>True</code> if the peer attributes are complete, <code>false</code> otherwise.
+ * @param parentPeerID The parent peer id. Must not be <code>null</code>.
+ * @return The child list.
*/
- public boolean isComplete();
+ public List<IPeerNode> getChildren(String parentPeerID);
/**
- * Returns if or if not the peer model node represents a static peer.
+ * Sets the list of known children for the given parent peer.
+ *
+ * @param parentPeerID The parent peer id. Must not be <code>null</code>.
+ * @param children The list of children or <code>null</code> to remove the parent peer.
+ */
+ public void setChildren(String parentPeerID, List<IPeerNode> children);
+
+ /**
+ * Returns the scanner instance being associated with the
+ * locator model.
+ *
+ * @return The scanner instance.
+ */
+ public IScanner getScanner();
+
+ /**
+ * Starts the scanner.
+ *
+ * @param delay The delay in millisecond before the scanning starts.
+ * @param schedule The time in millisecond between the scanner runs.
+ */
+ public void startScanner(long delay, long schedule);
+
+ /**
+ * Stops the scanner.
+ */
+ public void stopScanner();
+
+ /**
+ * Returns the locator model service, implementing at least the specified
+ * service interface.
+ *
+ * @param serviceInterface The service interface class. Must not be <code>null</code>.
+ * @return The service instance implementing the specified service interface, or <code>null</code>.
+ */
+ public <V extends IPeerModelService> V getService(Class<V> serviceInterface);
+
+ /**
+ * Validate the given peer.
* <p>
- * <b>Note:</b> A peer model node can be both static and remote at the same time.
+ * If the peer is for local host, than only the peer using the loopback address is valid.
*
- * @return <code>True</code> if the node represents a static peer, <code>false</code> otherwise.
+ * @param peer The peer. Must not be <code>null</code>.
+ * @return The peer if the peer is valid, or <code>null</code> if not.
*/
- public boolean isStatic();
+ public IPeer validatePeer(IPeer peer);
/**
- * Returns if or if not the peer model node represents a remote/discovered peer.
+ * Validate the given peer model if or if not it can be added to the locator model as new peer
+ * node.
+ *
+ * @param node The peer model. Must not be <code>null</code>.
+ * @return The peer node if it allowed add it to the model, or <code>null</code> if not.
+ */
+ public IPeerNode validatePeerNodeForAdd(IPeerNode node);
+
+ /**
+ * Validate the given child peer model node if or if not it can be added to the locator model
+ * as new child peer node for the associated parent peer model node.
* <p>
- * <b>Note:</b> A peer model node can be both static and remote at the same time.
+ * <b>Note:</b> The parent peer node is determined by calling {@link IPeerNode#getParentNode()}.
+ * The call has to return a non-null value, otherwise {@link #validateChildPeerNodeForAdd(IPeerNode)}
+ * will do nothing.
*
- * @return <code>True</code> if the node represents a remote peer, <code>false</code> otherwise.
+ * @param node The peer model. Must not be <code>null</code>.
+ * @return The peer node if it allowed add it to the model, or <code>null</code> if not.
*/
- public boolean isRemote();
+ public IPeerNode validateChildPeerNodeForAdd(IPeerNode node);
+
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java
new file mode 100644
index 000000000..7b8f877a4
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNode.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.tcf.locator.interfaces.nodes;
+
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.te.core.interfaces.IConnectable;
+import org.eclipse.tcf.te.core.interfaces.IDecoratable;
+import org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode;
+
+/**
+ * The peer model is an extension to the TCF peer representation, implementing the {@link IPeer}
+ * interface. The peer model provides an offline cache for a peers known list of local and remote
+ * services and is the merge point of peer attributes from custom data storages.
+ * <p>
+ * <b>Note:</b> Read and write access to the peer model must happen within the TCF dispatch thread.
+ */
+public interface IPeerNode extends IContainerModelNode, IDecoratable, IConnectable {
+
+ /**
+ * Returns the parent locator model instance.
+ * <p>
+ * This method may be called from any thread.
+ *
+ * @return The parent locator model instance.
+ */
+ public IPeerModel getModel();
+
+ /**
+ * Returns the native {@link IPeer} object.
+ * <p>
+ * This method may be called from any thread.
+ *
+ * @return The native {@link IPeer} instance.
+ */
+ public IPeer getPeer();
+
+ /**
+ * Returns the peer id.
+ * <p>
+ * This method may be called from any thread.
+ *
+ * @return The peer id.
+ */
+ public String getPeerId();
+
+ /**
+ * Returns if or if not the peer attributes are complete to open a channel to it.
+ *
+ * @return <code>True</code> if the peer attributes are complete, <code>false</code> otherwise.
+ */
+ public boolean isComplete();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java
index d20d9ce0e..3e5491003 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProperties.java
@@ -10,11 +10,17 @@
package org.eclipse.tcf.te.tcf.locator.interfaces.nodes;
import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
/**
- * Default set of custom peer properties.
+ * Default set of peer node properties.
*/
-public interface IPeerModelProperties {
+public interface IPeerNodeProperties {
+
+ /**
+ * Property: The peer node connect state.
+ */
+ public static final String PROP_CONNECT_STATE = "connectState"; //$NON-NLS-1$
/**
* Property: The peer instance. Object stored here must be
@@ -73,63 +79,63 @@ public interface IPeerModelProperties {
public static final int STATE_WAITING_FOR_READY = 4;
/**
- * Property: The peer type.
+ * Property: Reference counter tracking the active channels for this peer.
*/
- public static final String PROP_TYPE = "Type"; //$NON-NLS-1$
+ public static String PROP_CHANNEL_REF_COUNTER = "channelRefCounter.silent"; //$NON-NLS-1$
/**
- * Property: List of TCF services the peer would have when it goes online (comma separated list).
+ * Property: Discovered target for a static peer
*/
- public static final String PROP_OFFLINE_SERVICES = "OfflineServices"; //$NON-NLS-1$
+ public static final String PROP_TARGET = "Target"; //$NON-NLS-1$
/**
- * Property: The peer visible state.
+ * Property: Exclude from scanner process. If set to <code>true</code>, the node will not be scanned
+ * by the scanner.
*/
- public static final String PROP_VISIBLE = "Visible"; //$NON-NLS-1$
+ public static String PROP_SCANNER_EXCLUDE = "scanner.exclude.silent"; //$NON-NLS-1$
/**
- * Property: Reference counter tracking the active channels for this peer.
+ * Property: The last error the scanner encounter trying to open a channel to this peer.
*/
- public static String PROP_CHANNEL_REF_COUNTER = "channelRefCounter.silent"; //$NON-NLS-1$
+ public static String PROP_LAST_SCANNER_ERROR = "lastScannerError"; //$NON-NLS-1$
/**
- * Property: The last error the scanner encounter trying to open a channel to this peer.
+ * Property: The peer type.
*/
- public static String PROP_LAST_SCANNER_ERROR = "lastScannerError"; //$NON-NLS-1$
+ public static final String PROP_TYPE = "Type" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$
/**
- * Property: Launch simulator
+ * Property: List of TCF services the peer would have when it goes online (comma separated list).
*/
- public static final String PROP_SIM_ENABLED = "SimulatorEnabled"; //$NON-NLS-1$
+ public static final String PROP_OFFLINE_SERVICES = "OfflineServices" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$
/**
- * Property: Simulator properties
+ * Property: The peer visible state.
*/
- public static final String PROP_SIM_PROPERTIES = "SimulatorProperties"; //$NON-NLS-1$
+ public static final String PROP_VISIBLE = "Visible" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$
/**
- * Property: Last selected simulator type
+ * Property: Launch simulator
*/
- public static final String PROP_SIM_TYPE = "SimulatorType"; //$NON-NLS-1$
+ public static final String PROP_SIM_ENABLED = "SimulatorEnabled" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$
/**
- * Property: Discovered target for a static peer
+ * Property: Simulator properties
*/
- public static final String PROP_TARGET = "Target"; //$NON-NLS-1$
+ public static final String PROP_SIM_PROPERTIES = "SimulatorProperties" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$
/**
- * Property: Auto-start the debugger after the agent launch.
+ * Property: Last selected simulator type
*/
- public static final String PROP_AUTO_START_DEBUGGER = "autoStartDebugger"; //$NON-NLS-1$
+ public static final String PROP_SIM_TYPE = "SimulatorType" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$
/**
- * Property: Connect after the configuration has been created.
+ * Property: Auto-start the debugger after the agent launch.
*/
- public static final String PROP_AUTO_CONNECT = "autoConnect"; //$NON-NLS-1$
+ public static final String PROP_AUTO_START_DEBUGGER = "autoStartDebugger" + IPropertiesContainer.PERSISTENT_PROPERTY; //$NON-NLS-1$
/**
- * Property: Exclude from scanner process. If set to <code>true</code>, the node will not be scanned
- * by the scanner.
+ * Property: Connect after the configuration has been created.
*/
- public static String PROP_SCANNER_EXCLUDE = "scanner.exclude.silent"; //$NON-NLS-1$
+ public static final String PROP_AUTO_CONNECT = "autoConnect"; //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProvider.java
index f2174b990..82838e8d5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerNodeProvider.java
@@ -1,26 +1,26 @@
-/*******************************************************************************
- * 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.tcf.locator.interfaces.nodes;
-
-import org.eclipse.core.runtime.IAdaptable;
-
-/**
- * Interface to be implemented by nodes providing access to an peer
- * model object instance without being a peer model object itself.
- */
-public interface IPeerModelProvider extends IAdaptable {
-
- /**
- * Returns the associated peer model object.
- *
- * @return The peer model object instance or <code>null</code>.
- */
- public IPeerModel getPeerModel();
-}
+/*******************************************************************************
+ * 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.tcf.locator.interfaces.nodes;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * Interface to be implemented by nodes providing access to an peer
+ * model object instance without being a peer model object itself.
+ */
+public interface IPeerNodeProvider extends IAdaptable {
+
+ /**
+ * Returns the associated peer model object.
+ *
+ * @return The peer model object instance or <code>null</code>.
+ */
+ public IPeerNode getPeerModel();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IDefaultContextService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IDefaultContextService.java
index 4c9b33b4e..939490c63 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IDefaultContextService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IDefaultContextService.java
@@ -10,12 +10,12 @@
package org.eclipse.tcf.te.tcf.locator.interfaces.services;
import org.eclipse.tcf.te.runtime.services.interfaces.IService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* Interface to implement by services providing a default context for others.
* <p>
- * The context type of the service is {@link IPeerModel}.
+ * The context type of the service is {@link IPeerNode}.
*/
public interface IDefaultContextService extends IService {
@@ -32,17 +32,17 @@ public interface IDefaultContextService extends IService {
* If the filter is matched, the peer model node is added to the list
* of possible contexts.
*
- * @param peerModel The peer model node. Must not be <code>null</code>.
+ * @param peerNode The peer model node. Must not be <code>null</code>.
* @return <code>true</code> if the given peer model node is a possible candidate.
*/
- public boolean select(IPeerModel peerModel);
+ public boolean select(IPeerNode peerNode);
}
/**
* Return a list of possible candidates matching the given filter.
* <p>
* If a selection is given and the filter applies, the selection will be added first to the
- * resulting array of candidates. Otherwise, if a default selection was set using {@link #setDefaultContext(IPeerModel)},
+ * resulting array of candidates. Otherwise, if a default selection was set using {@link #setDefaultContext(IPeerNode)},
* and the filter applies, the default selection will added first to the resulting array of
* candidates.
* <p>
@@ -54,16 +54,16 @@ public interface IDefaultContextService extends IService {
*
* @return An array of peer model nodes or an empty array.
*/
- public IPeerModel[] getCandidates(Object selection, IContextFilter filter);
+ public IPeerNode[] getCandidates(Object selection, IContextFilter filter);
/**
* Sets the given peer model node as new default context.
* <p>
* If the given peer model node is <code>null</code>, the default context is reseted.
*
- * @param peerModel The peer model node or <code>null</code>.
+ * @param peerNode The peer model node or <code>null</code>.
*/
- public void setDefaultContext(IPeerModel peerModel);
+ public void setDefaultContext(IPeerNode peerNode);
/**
* Returns the default context matching the given context filter.
@@ -71,5 +71,5 @@ public interface IDefaultContextService extends IService {
* @param filter The context filter or <code>null</code>
* @return The default context if set and the filter applies, <code>null</code> otherwise.
*/
- public IPeerModel getDefaultContext(IContextFilter filter);
+ public IPeerNode getDefaultContext(IContextFilter filter);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelLookupService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelLookupService.java
index 97e425baa..63121f94d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelLookupService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelLookupService.java
@@ -10,12 +10,12 @@
package org.eclipse.tcf.te.tcf.locator.interfaces.services;
import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* The service to lookup/search in the parent locator model.
*/
-public interface ILocatorModelLookupService extends ILocatorModelService {
+public interface IPeerModelLookupService extends IPeerModelService {
/**
* Lookup the peer model for the given peer id.
@@ -23,7 +23,7 @@ public interface ILocatorModelLookupService extends ILocatorModelService {
* @param id The peer id. Must not be <code>null</code>.
* @return The peer model instance, or <code>null</code> if the peer model cannot be found.
*/
- public IPeerModel lkupPeerModelById(String id);
+ public IPeerNode lkupPeerModelById(String id);
/**
* Lookup the peer model for the given peer id from the peers child list of
@@ -33,7 +33,7 @@ public interface ILocatorModelLookupService extends ILocatorModelService {
* @param id The peer id. Must not be <code>null</code>.
* @return The peer model instance, or <code>null</code> if the peer model cannot be found.
*/
- public IPeerModel lkupPeerModelById(String parentId, String id);
+ public IPeerNode lkupPeerModelById(String parentId, String id);
/**
* Lookup the matching peer model instances for the given agent id.
@@ -41,7 +41,7 @@ public interface ILocatorModelLookupService extends ILocatorModelService {
* @param agentId The agent id. Must not be <code>null</code>.
* @return The peer model instances, or an empty list if the given agent id could not be matched.
*/
- public IPeerModel[] lkupPeerModelByAgentId(String agentId);
+ public IPeerNode[] lkupPeerModelByAgentId(String agentId);
/**
* Lookup the matching peer model instances for the given agent id.
@@ -50,7 +50,7 @@ public interface ILocatorModelLookupService extends ILocatorModelService {
* @param agentId The agent id. Must not be <code>null</code>.
* @return The peer model instances, or an empty list if the given agent id could not be matched.
*/
- public IPeerModel[] lkupPeerModelByAgentId(String parentId, String agentId);
+ public IPeerNode[] lkupPeerModelByAgentId(String parentId, String agentId);
/**
* Lookup matching peer model instances for the given name.
@@ -58,7 +58,7 @@ public interface ILocatorModelLookupService extends ILocatorModelService {
* @param name The name. Must not be <code>null</code>.
* @return The peer model instances, or an empty list if the given name could not be matched.
*/
- public IPeerModel[] lkupPeerModelByName(String name);
+ public IPeerNode[] lkupPeerModelByName(String name);
/**
* Lookup matching peer model instances which supports the listed local and remote services.
@@ -70,7 +70,7 @@ public interface ILocatorModelLookupService extends ILocatorModelService {
*
* @return The peer model instances, or an empty list if the listed services are not supported by any of the peers.
*/
- public IPeerModel[] lkupPeerModelBySupportedServices(String[] expectedLocalServices, String[] expectedRemoteServices);
+ public IPeerNode[] lkupPeerModelBySupportedServices(String[] expectedLocalServices, String[] expectedRemoteServices);
/**
* Lookup the matching static peer model instances for the given peer model node.
@@ -78,7 +78,7 @@ public interface ILocatorModelLookupService extends ILocatorModelService {
* @param peerNode The peer model node. Must not be <code>null</code>.
* @return The matching peer model instances or an empty list.
*/
- public IPeerModel[] lkupMatchingStaticPeerModels(IPeerModel peerNode);
+ public IPeerNode[] lkupMatchingStaticPeerModels(IPeerNode peerNode);
/**
* Lookup the matching static peer model instances for the given peer.
@@ -86,5 +86,5 @@ public interface ILocatorModelLookupService extends ILocatorModelService {
* @param peer The peer or <code>null</code>.
* @return The matching peer model instances or an empty list.
*/
- public IPeerModel[] lkupMatchingStaticPeerModels(IPeer peer);
+ public IPeerNode[] lkupMatchingStaticPeerModels(IPeer peer);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelPeerNodeQueryService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelQueryService.java
index 75a5982e3..70c937814 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelPeerNodeQueryService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelQueryService.java
@@ -9,12 +9,12 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.locator.interfaces.services;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* The service to query asynchronous properties of peers.
*/
-public interface ILocatorModelPeerNodeQueryService extends ILocatorModelService {
+public interface IPeerModelQueryService extends IPeerModelService {
/**
* Query the list of available local services for the given peer.
@@ -27,7 +27,7 @@ public interface ILocatorModelPeerNodeQueryService extends ILocatorModelService
* @param node The peer node. Must not be <code>null</code>.
* @param done The client callback. Must not be <code>null</code>.
*/
- public String queryLocalServices(IPeerModel node);
+ public String queryLocalServices(IPeerNode node);
/**
* Query the list of available remote services for the given peer.
@@ -40,7 +40,7 @@ public interface ILocatorModelPeerNodeQueryService extends ILocatorModelService
* @param node The peer node. Must not be <code>null</code>.
* @param done The client callback. Must not be <code>null</code>.
*/
- public String queryRemoteServices(IPeerModel node);
+ public String queryRemoteServices(IPeerNode node);
/**
* Client call back interface for queryServicesAsync(...).
@@ -62,6 +62,6 @@ public interface ILocatorModelPeerNodeQueryService extends ILocatorModelService
* @param node The peer node. Must not be <code>null</code>.
* @param done The client callback. Must not be <code>null</code>.
*/
- public void queryServicesAsync(IPeerModel node, DoneQueryServices done);
+ public void queryServicesAsync(IPeerNode node, DoneQueryServices done);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelRefreshService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelRefreshService.java
index 85e655f97..dc683ea76 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelRefreshService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelRefreshService.java
@@ -10,12 +10,12 @@
package org.eclipse.tcf.te.tcf.locator.interfaces.services;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* The service to refresh the parent locator model from remote.
*/
-public interface ILocatorModelRefreshService extends ILocatorModelService {
+public interface IPeerModelRefreshService extends IPeerModelService {
/**
* Refreshes the list of known peers from the local locator service
@@ -37,5 +37,5 @@ public interface ILocatorModelRefreshService extends ILocatorModelService {
* @param nodes The list of nodes to refresh or <code>null</code> to refresh all.
* @param callback The callback to invoke once the refresh operation finished, or <code>null</code>.
*/
- public void refreshAgentIDs(IPeerModel[] nodes, ICallback callback);
+ public void refreshAgentIDs(IPeerNode[] nodes, ICallback callback);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelService.java
index 2cb869948..553c7f986 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelService.java
@@ -3,25 +3,24 @@
* 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.tcf.locator.interfaces.services;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
-
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
/**
- * Common parent interface for locator model services.
+ * Common parent interface for peer model services.
*/
-public interface ILocatorModelService extends IAdaptable {
+public interface IPeerModelService extends IAdaptable {
/**
- * Returns the parent locator model.
+ * Returns the parent peer model.
*
- * @return The parent locator model.
+ * @return The parent peer model.
*/
- public ILocatorModel getLocatorModel();
+ public IPeerModel getPeerModel();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelUpdateService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelUpdateService.java
index 7b564ce90..ca2734a98 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/ILocatorModelUpdateService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IPeerModelUpdateService.java
@@ -12,13 +12,13 @@ package org.eclipse.tcf.te.tcf.locator.interfaces.services;
import java.util.Collection;
import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* The service to update the properties of given locator model nodes.
*/
-public interface ILocatorModelUpdateService extends ILocatorModelService {
+public interface IPeerModelUpdateService extends IPeerModelService {
/**
* Adds the given peer to the list of know peers.
@@ -27,14 +27,14 @@ public interface ILocatorModelUpdateService extends ILocatorModelService {
*
* @param peer The peer model object. Must not be <code>null</code>.
*/
- public void add(IPeerModel peer);
+ public void add(IPeerNode peer);
/**
* Removes the given peer from the list of known peers.
*
* @param peer The peer model object. Must not be <code>null</code.
*/
- public void remove(IPeerModel peer);
+ public void remove(IPeerNode peer);
/**
* Update the service nodes of the given peer node with the new set of
@@ -44,31 +44,31 @@ public interface ILocatorModelUpdateService extends ILocatorModelService {
* @param localServices The list of local service names or <code>null</code>.
* @param remoteServices The list of remote service names or <code>null</code>.
*/
- public void updatePeerServices(IPeerModel peerNode, Collection<String> localServices, Collection<String> remoteServices);
+ public void updatePeerServices(IPeerNode peerNode, Collection<String> localServices, Collection<String> remoteServices);
/**
* Adds the given child peer to the parent peer.
* <p>
- * <b>Note:</b> The parent peer node is determined by calling {@link IPeerModel#getParentNode()}.
- * The call has to return a non-null value, otherwise {@link #addChild(IPeerModel)}
+ * <b>Note:</b> The parent peer node is determined by calling {@link IPeerNode#getParentNode()}.
+ * The call has to return a non-null value, otherwise {@link #addChild(IPeerNode)}
* will do nothing.
*
* @param parent The parent peer model node. Must not be <code>null</code>.
* @param child The child peer model object. Must not be <code>null</code>.
*/
- public void addChild(IPeerModel child);
+ public void addChild(IPeerNode child);
/**
* Removes the given child peer from the parent peer.
* <p>
- * <b>Note:</b> The parent peer node is determined by calling {@link IPeerModel#getParentNode()}.
- * The call has to return a non-null value, otherwise {@link #removeChild(IPeerModel)}
+ * <b>Note:</b> The parent peer node is determined by calling {@link IPeerNode#getParentNode()}.
+ * The call has to return a non-null value, otherwise {@link #removeChild(IPeerNode)}
* will do nothing.
*
* @param parent The parent peer model node. Must not be <code>null</code>.
* @param child The child peer model object. Must not be <code>null</code>.
*/
- public void removeChild(IPeerModel child);
+ public void removeChild(IPeerNode child);
/**
* Merge user defined peer attributes from the given peer into the given peer node.
@@ -77,5 +77,5 @@ public interface ILocatorModelUpdateService extends ILocatorModelService {
* @param peer The peer. Must not be <code>null</code>.
* @param force If <code>true</code>, the peer attributes are merged even if the peer id's don't match.
*/
- public void mergeUserDefinedAttributes(IPeerModel node, IPeer peer, boolean force);
+ public void mergeUserDefinedAttributes(IPeerNode node, IPeer peer, boolean force);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/ModelNodeFactoryDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/ModelNodeFactoryDelegate.java
index cfc145c60..142c4efed 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/ModelNodeFactoryDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/ModelNodeFactoryDelegate.java
@@ -1,68 +1,61 @@
-/*******************************************************************************
- * 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.tcf.locator.internal;
-
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.runtime.model.factory.AbstractFactoryDelegate2;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.internal.nodes.InvalidPeerModel;
-import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel;
-
-/**
- * Locator model node factory delegate implementation.
- */
-public class ModelNodeFactoryDelegate extends AbstractFactoryDelegate2 {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate#newInstance(java.lang.Class)
- */
- @SuppressWarnings("unchecked")
- @Override
- public <V extends IModelNode> V newInstance(Class<V> nodeInterface) {
- if (IPeerModel.class.equals(nodeInterface)) {
- return (V) new InvalidPeerModel();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate2#newInstance(java.lang.Class, java.lang.Object[])
- */
- @SuppressWarnings("unchecked")
- @Override
- public <V extends IModelNode> V newInstance(final Class<V> nodeInterface, final Object[] args) {
- if (args == null) return newInstance(nodeInterface);
-
- if (IPeerModel.class.equals(nodeInterface)) {
- // Peer model constructor has 2 arguments, ILocatorModel and IPeer
- if (args.length == 2 && args[0] instanceof ILocatorModel && args[1] instanceof IPeer) {
- final AtomicReference<V> node = new AtomicReference<V>();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- node.set((V) new PeerModel((ILocatorModel)args[0], (IPeer)args[1]));
- }
- };
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
-
- return node.get();
- }
- }
-
- return null;
- }
-}
+/*******************************************************************************
+ * 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.tcf.locator.internal;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.model.factory.AbstractFactoryDelegate2;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.nodes.PeerNode;
+
+/**
+ * Locator model node factory delegate implementation.
+ */
+public class ModelNodeFactoryDelegate extends AbstractFactoryDelegate2 {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate#newInstance(java.lang.Class)
+ */
+ @Override
+ public <V extends IModelNode> V newInstance(Class<V> nodeInterface) {
+ return newInstance(nodeInterface, new Object[0]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate2#newInstance(java.lang.Class, java.lang.Object[])
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public <V extends IModelNode> V newInstance(final Class<V> nodeInterface, final Object[] args) {
+ if (IPeerNode.class.equals(nodeInterface)) {
+ // Peer model constructor has 2 arguments, IPeerModel and IPeer
+ if (args != null && args.length == 2 && args[0] instanceof IPeerModel && args[1] instanceof IPeer) {
+ final AtomicReference<V> node = new AtomicReference<V>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ node.set((V) new PeerNode((IPeerModel)args[0], (IPeer)args[1]));
+ }
+ };
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+
+ return node.get();
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/LocatorModelPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java
index 2ea867dfa..572fd793e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/LocatorModelPropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/PeerModelPropertyTester.java
@@ -21,16 +21,16 @@ import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService;
import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector;
/**
* Locator model property tester.
*/
-public class LocatorModelPropertyTester extends PropertyTester {
+public class PeerModelPropertyTester extends PropertyTester {
/* (non-Javadoc)
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
@@ -38,25 +38,25 @@ public class LocatorModelPropertyTester extends PropertyTester {
@Override
public boolean test(Object receiver, final String property, final Object[] args, final Object expectedValue) {
if (receiver instanceof IPeer) {
- receiver = Platform.getAdapterManager().getAdapter(receiver, IPeerModel.class);
+ receiver = Platform.getAdapterManager().getAdapter(receiver, IPeerNode.class);
}
// The receiver is expected to be a peer model node or a peer
- if (receiver instanceof IPeerModel) {
- final IPeerModel peerModel = (IPeerModel)receiver;
+ if (receiver instanceof IPeerNode) {
+ final IPeerNode peerNode = (IPeerNode)receiver;
final AtomicBoolean result = new AtomicBoolean();
// If we have to test for local or remote services, we have to handle it special
if ("hasLocalService".equals(property) || "hasRemoteService".equals(property)) { //$NON-NLS-1$ //$NON-NLS-2$
// This tests must happen outside the TCF dispatch thread's
if (!Protocol.isDispatchThread()) {
- result.set(testServices(peerModel, property, args, expectedValue));
+ result.set(testServices(peerNode, property, args, expectedValue));
}
}
else {
Runnable runnable = new Runnable() {
@Override
public void run() {
- result.set(testPeerModel(peerModel, property, args, expectedValue));
+ result.set(testPeerModel(peerNode, property, args, expectedValue));
}
};
@@ -84,11 +84,11 @@ public class LocatorModelPropertyTester extends PropertyTester {
* @return <code>True</code> if the property to test has the expected value, <code>false</code>
* otherwise.
*/
- protected boolean testPeerModel(IPeerModel peerModel, String property, Object[] args, Object expectedValue) {
- Assert.isNotNull(peerModel);
+ protected boolean testPeerModel(IPeerNode peerNode, String property, Object[] args, Object expectedValue) {
+ Assert.isNotNull(peerNode);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- IPeer peer = peerModel.getPeer();
+ IPeer peer = peerNode.getPeer();
if ("name".equals(property)) { //$NON-NLS-1$
if (peer.getName() != null && peer.getName().equals(expectedValue)) {
@@ -145,7 +145,7 @@ public class LocatorModelPropertyTester extends PropertyTester {
}
if ("isOfType".equals(property)) { //$NON-NLS-1$
- String value = peer.getAttributes().get(IPeerModelProperties.PROP_TYPE);
+ String value = peer.getAttributes().get(IPeerNodeProperties.PROP_TYPE);
if (expectedValue instanceof String) {
return value != null ? ((String)expectedValue).equals(value) : ((String)expectedValue).equalsIgnoreCase("null"); //$NON-NLS-1$
}
@@ -168,8 +168,8 @@ public class LocatorModelPropertyTester extends PropertyTester {
}
if ("hasOfflineService".equals(property)) { //$NON-NLS-1$
- String offlineServices = peer.getAttributes().get(IPeerModelProperties.PROP_OFFLINE_SERVICES);
- String remoteServices = peerModel.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES);
+ String offlineServices = peer.getAttributes().get(IPeerNodeProperties.PROP_OFFLINE_SERVICES);
+ String remoteServices = peerNode.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES);
List<String> offline = offlineServices != null ? Arrays.asList(offlineServices.split(",\\s*")) : Collections.EMPTY_LIST; //$NON-NLS-1$
List<String> remote = remoteServices != null ? Arrays.asList(remoteServices.split(",\\s*")) : null; //$NON-NLS-1$
boolean hasOfflineService = (remote == null) ? offline.contains(expectedValue) : remote.contains(expectedValue);
@@ -195,14 +195,14 @@ public class LocatorModelPropertyTester extends PropertyTester {
* @return <code>True</code> if the property to test has the expected value, <code>false</code>
* otherwise.
*/
- protected boolean testServices(final IPeerModel node, final String property, final Object[] args, final Object expectedValue) {
+ protected boolean testServices(final IPeerNode node, final String property, final Object[] args, final Object expectedValue) {
Assert.isNotNull(node);
Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
String services = null;
- ILocatorModel model = node.getModel();
- ILocatorModelPeerNodeQueryService queryService = model.getService(ILocatorModelPeerNodeQueryService.class);
+ IPeerModel model = node.getModel();
+ IPeerModelQueryService queryService = model.getService(IPeerModelQueryService.class);
if ("hasLocalService".equals(property)) { //$NON-NLS-1$
services = queryService.queryLocalServices(node);
} else {
@@ -211,7 +211,7 @@ public class LocatorModelPropertyTester extends PropertyTester {
if (CoreBundleActivator.getTraceHandler().isSlotEnabled(ITracing.ID_TRACE_PROPERTY_TESTER)) {
CoreBundleActivator.getTraceHandler().trace("testServices: property = " + property + ", expectedValue = " + expectedValue + ", services = " + services, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ITracing.ID_TRACE_PROPERTY_TESTER, LocatorModelPropertyTester.this);
+ ITracing.ID_TRACE_PROPERTY_TESTER, PeerModelPropertyTester.this);
}
if (services != null) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/SimulatorPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/SimulatorPropertyTester.java
index 75cfbfb82..55a11c9c0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/SimulatorPropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/SimulatorPropertyTester.java
@@ -11,7 +11,7 @@
package org.eclipse.tcf.te.tcf.locator.internal;
import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService.State;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils.Result;
@@ -27,9 +27,9 @@ public class SimulatorPropertyTester extends org.eclipse.core.expressions.Proper
*/
@Override
public boolean test(final Object receiver, String property, Object[] args, Object expectedValue) {
- if (receiver instanceof IPeerModel) {
- final IPeerModel peerModel = (IPeerModel) receiver;
- Result result = SimulatorUtils.getSimulatorService(peerModel);
+ if (receiver instanceof IPeerNode) {
+ final IPeerNode peerNode = (IPeerNode) receiver;
+ Result result = SimulatorUtils.getSimulatorService(peerNode);
if (result.service != null) {
if ("isSimulatorState".equals(property) && expectedValue instanceof String) { //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java
index 5f698a49d..cdbede25b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java
@@ -20,10 +20,10 @@ import org.eclipse.tcf.te.core.interfaces.IConnectable;
import org.eclipse.tcf.te.runtime.model.factory.Factory;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService;
import org.eclipse.tcf.te.tcf.locator.model.Model;
/**
@@ -34,7 +34,7 @@ public class AdapterFactory implements IAdapterFactory {
private final IPersistableURIProvider peerModelPersistableURIProvider = new PeerPersistableURIProvider();
private static final Class<?>[] CLASSES = new Class[] {
- IPersistableURIProvider.class, IPeerModel.class, IConnectable.class, ILocatorModel.class
+ IPersistableURIProvider.class, IPeerNode.class, IConnectable.class, IPeerModel.class
};
/* (non-Javadoc)
@@ -52,30 +52,30 @@ public class AdapterFactory implements IAdapterFactory {
return adaptableObject;
}
}
- if (ILocatorModel.class.isAssignableFrom(adapterType)) {
- if (adaptableObject instanceof IPeerModel) {
- return ((IPeerModel)adaptableObject).getModel();
+ if (IPeerModel.class.isAssignableFrom(adapterType)) {
+ if (adaptableObject instanceof IPeerNode) {
+ return ((IPeerNode)adaptableObject).getModel();
}
}
- if (adaptableObject instanceof IPeerModel || adaptableObject instanceof IPeer || adaptableObject instanceof IPeerModelProvider) {
+ if (adaptableObject instanceof IPeerNode || adaptableObject instanceof IPeer || adaptableObject instanceof IPeerNodeProvider) {
if (IPersistableURIProvider.class.equals(adapterType)) {
return peerModelPersistableURIProvider;
}
- if (IPeerModel.class.equals(adapterType)) {
+ if (IPeerNode.class.equals(adapterType)) {
if (adaptableObject instanceof IPeer) {
- final AtomicReference<IPeerModel> node = new AtomicReference<IPeerModel>();
+ final AtomicReference<IPeerNode> node = new AtomicReference<IPeerNode>();
final IPeer peer = (IPeer)adaptableObject;
Runnable runnable = new Runnable() {
@Override
public void run() {
String id = peer.getID();
- ILocatorModel model = Model.getModel();
+ IPeerModel model = Model.getModel();
Assert.isNotNull(model);
- IPeerModel candidate = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(id);
+ IPeerNode candidate = model.getService(IPeerModelLookupService.class).lkupPeerModelById(id);
if (candidate != null) node.set(candidate);
else {
- candidate = Factory.getInstance().newInstance(IPeerModel.class, new Object[] { model, peer });
+ candidate = Factory.getInstance().newInstance(IPeerNode.class, new Object[] { model, peer });
if (candidate != null) node.set(candidate);
}
}
@@ -86,12 +86,12 @@ public class AdapterFactory implements IAdapterFactory {
return node.get();
}
- else if (adaptableObject instanceof IPeerModel) {
+ else if (adaptableObject instanceof IPeerNode) {
return adaptableObject;
}
- else if (adaptableObject instanceof IPeerModelProvider) {
- final AtomicReference<IPeerModel> node = new AtomicReference<IPeerModel>();
- final IPeerModelProvider provider = (IPeerModelProvider)adaptableObject;
+ else if (adaptableObject instanceof IPeerNodeProvider) {
+ final AtomicReference<IPeerNode> node = new AtomicReference<IPeerNode>();
+ final IPeerNodeProvider provider = (IPeerNodeProvider)adaptableObject;
Runnable runnable = new Runnable() {
@Override
@@ -107,8 +107,8 @@ public class AdapterFactory implements IAdapterFactory {
}
}
if (IStepContext.class.equals(adapterType)) {
- if (adaptableObject instanceof IPeerModel) {
- return new PeerModelStepContext((IPeerModel)adaptableObject);
+ if (adaptableObject instanceof IPeerNode) {
+ return new PeerNodeStepContext((IPeerNode)adaptableObject);
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelStepContext.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerNodeStepContext.java
index 440760606..f73e853fd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerModelStepContext.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerNodeStepContext.java
@@ -11,26 +11,26 @@ package org.eclipse.tcf.te.tcf.locator.internal.adapters;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.te.runtime.stepper.context.AbstractStepContext;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* Peer model step context implementation.
*/
-public class PeerModelStepContext extends AbstractStepContext {
+public class PeerNodeStepContext extends AbstractStepContext {
/**
* Constructor
*/
- public PeerModelStepContext(IPeerModel peerModel) {
- super(peerModel);
+ public PeerNodeStepContext(IPeerNode peerNode) {
+ super(peerNode);
}
/**
* Returns the peer model.
* @return The peer model.
*/
- public IPeerModel getPeerModel() {
- return (IPeerModel)getContextObject();
+ public IPeerNode getPeerModel() {
+ return (IPeerNode)getContextObject();
}
/* (non-Javadoc)
@@ -54,7 +54,7 @@ public class PeerModelStepContext extends AbstractStepContext {
*/
@Override
public Object getAdapter(final Class adapter) {
- if (IPeerModel.class.equals(adapter)) {
+ if (IPeerNode.class.equals(adapter)) {
return getPeerModel();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerPersistableURIProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerPersistableURIProvider.java
index eaad3b69a..2ecb42a3f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerPersistableURIProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/PeerPersistableURIProvider.java
@@ -1,109 +1,109 @@
-/*******************************************************************************
- * 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.tcf.locator.internal.adapters;
-
-import java.net.URI;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.core.adapters.ModelNodePersistableURIProvider;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
-import org.eclipse.tcf.te.tcf.locator.model.ModelLocationUtil;
-
-/**
- * Persistable implementation handling peer attributes.
- */
-public class PeerPersistableURIProvider extends ModelNodePersistableURIProvider {
-
- /**
- * Determine the peer from the given context object.
- *
- * @param context The context object or <code>null</code>.
- * @return The peer or <code>null</code>.
- */
- private IPeer getPeer(Object context) {
- IPeer peer = null;
-
- if (context instanceof IPeer) {
- peer = (IPeer)context;
- }
- else if (context instanceof IPeerModel) {
- peer = ((IPeerModel)context).getPeer();
- }
- else if (context instanceof IPeerModelProvider) {
- peer = ((IPeerModelProvider)context).getPeerModel().getPeer();
- }
-
- return peer;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider#getURI(java.lang.Object)
- */
- @Override
- public URI getURI(final Object context) {
- Assert.isNotNull(context);
-
- URI uri = null;
- final IPeer peer = getPeer(context);
-
- if (peer != null) {
- // Get the URI the peer model has been created from
- final AtomicReference<URI> nodeURI = new AtomicReference<URI>();
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- String value = peer.getAttributes().get(IPersistableNodeProperties.PROPERTY_URI);
- if (value != null && !"".equals(value.trim())) { //$NON-NLS-1$
- nodeURI.set(URI.create(value.trim()));
- }
- }
- };
- if (Protocol.isDispatchThread()) {
- runnable.run();
- }
- else {
- Protocol.invokeAndWait(runnable);
- }
-
- if (nodeURI.get() != null) {
- uri = nodeURI.get();
- }
-
- if (uri == null) {
- String name = peer.getName();
- if (name == null) {
- name = peer.getID();
- }
- name = makeValidFileSystemName(name);
- // Get the URI from the name
- uri = getRoot().append(name).toFile().toURI();
-
- }
- }
-
- return uri;
- }
-
- /**
- * Returns the root location of the peers storage.
- *
- * @return The root location or <code>null</code> if it cannot be determined.
- */
- @Override
- public IPath getRoot() {
- return ModelLocationUtil.getStaticPeersRootLocation();
- }
-}
+/*******************************************************************************
+ * 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.tcf.locator.internal.adapters;
+
+import java.net.URI;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.core.adapters.ModelNodePersistableURIProvider;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider;
+import org.eclipse.tcf.te.tcf.locator.model.ModelLocationUtil;
+
+/**
+ * Persistable implementation handling peer attributes.
+ */
+public class PeerPersistableURIProvider extends ModelNodePersistableURIProvider {
+
+ /**
+ * Determine the peer from the given context object.
+ *
+ * @param context The context object or <code>null</code>.
+ * @return The peer or <code>null</code>.
+ */
+ private IPeer getPeer(Object context) {
+ IPeer peer = null;
+
+ if (context instanceof IPeer) {
+ peer = (IPeer)context;
+ }
+ else if (context instanceof IPeerNode) {
+ peer = ((IPeerNode)context).getPeer();
+ }
+ else if (context instanceof IPeerNodeProvider) {
+ peer = ((IPeerNodeProvider)context).getPeerModel().getPeer();
+ }
+
+ return peer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider#getURI(java.lang.Object)
+ */
+ @Override
+ public URI getURI(final Object context) {
+ Assert.isNotNull(context);
+
+ URI uri = null;
+ final IPeer peer = getPeer(context);
+
+ if (peer != null) {
+ // Get the URI the peer model has been created from
+ final AtomicReference<URI> nodeURI = new AtomicReference<URI>();
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ String value = peer.getAttributes().get(IPersistableNodeProperties.PROPERTY_URI);
+ if (value != null && !"".equals(value.trim())) { //$NON-NLS-1$
+ nodeURI.set(URI.create(value.trim()));
+ }
+ }
+ };
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
+
+ if (nodeURI.get() != null) {
+ uri = nodeURI.get();
+ }
+
+ if (uri == null) {
+ String name = peer.getName();
+ if (name == null) {
+ name = peer.getID();
+ }
+ name = makeValidFileSystemName(name);
+ // Get the URI from the name
+ uri = getRoot().append(name).toFile().toURI();
+
+ }
+ }
+
+ return uri;
+ }
+
+ /**
+ * Returns the root location of the peers storage.
+ *
+ * @return The root location or <code>null</code> if it cannot be determined.
+ */
+ @Override
+ public IPath getRoot() {
+ return ModelLocationUtil.getStaticPeersRootLocation();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java
deleted file mode 100644
index 431592035..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/nodes/InvalidPeerModel.java
+++ /dev/null
@@ -1,538 +0,0 @@
-/*******************************************************************************
- * 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.tcf.locator.internal.nodes;
-
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.runtime.model.interfaces.factory.IFactoryDelegate;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.internal.ModelNodeFactoryDelegate;
-
-/**
- * Invalid peer model node implementation. All methods does throw an {@link IllegalStateException}.
- * <p>
- * Objects of this class are returned by the {@link ModelNodeFactoryDelegate} if calling
- * {@link IFactoryDelegate#newInstance(Class)}. All what objects of this class can be used for is
- * loading adapters.
- */
-public final class InvalidPeerModel implements IPeerModel {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#add(org.eclipse.tcf.te.runtime.model.interfaces.IModelNode)
- */
- @Override
- public boolean add(IModelNode child) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#remove(org.eclipse.tcf.te.runtime.model.interfaces.IModelNode, boolean)
- */
- @Override
- public boolean remove(IModelNode node, boolean recursive) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#clear()
- */
- @Override
- public boolean clear() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#removeAll(java.lang.Class)
- */
- @Override
- public <T> boolean removeAll(Class<T> nodeType) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#getChildren()
- */
- @Override
- public IModelNode[] getChildren() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#getChildren(java.lang.Class)
- */
- @Override
- public <T> List<T> getChildren(Class<T> nodeType) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#hasChildren()
- */
- @Override
- public boolean hasChildren() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#size()
- */
- @Override
- public int size() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode#contains(org.eclipse.tcf.te.runtime.model.interfaces.IModelNode)
- */
- @Override
- public boolean contains(IModelNode node) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getParent()
- */
- @Override
- public IContainerModelNode getParent() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getParent(java.lang.Class)
- */
- @Override
- public <V extends IContainerModelNode> V getParent(Class<V> nodeType) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#setParent(org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode)
- */
- @Override
- public void setParent(IContainerModelNode parent) throws IllegalStateException {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#move(org.eclipse.tcf.te.runtime.model.interfaces.IContainerModelNode)
- */
- @Override
- public void move(IContainerModelNode newParent) throws IllegalStateException {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#isVisible()
- */
- @Override
- public boolean isVisible() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getName()
- */
- @Override
- public String getName() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getImageId()
- */
- @Override
- public String getImageId() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getError()
- */
- @Override
- public String getError() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#getDescription()
- */
- @Override
- public String[] getDescription() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#setDirty(boolean)
- */
- @Override
- public void setDirty(boolean dirty) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#isDirty()
- */
- @Override
- public boolean isDirty() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#setPending(boolean)
- */
- @Override
- public void setPending(boolean pending) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#isPending()
- */
- @Override
- public boolean isPending() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.interfaces.IModelNode#find(java.util.UUID)
- */
- @Override
- public IModelNode find(UUID uuid) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getUUID()
- */
- @Override
- public UUID getUUID() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setChangeEventsEnabled(boolean)
- */
- @Override
- public boolean setChangeEventsEnabled(boolean enabled) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#changeEventsEnabled()
- */
- @Override
- public boolean changeEventsEnabled() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#fireChangeEvent(java.lang.String, java.lang.Object, java.lang.Object)
- */
- @Override
- public void fireChangeEvent(String key, Object oldValue, Object newValue) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperties(java.util.Map)
- */
- @Override
- public void setProperties(Map<String, Object> properties) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, java.lang.Object)
- */
- @Override
- public boolean setProperty(String key, Object value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, long)
- */
- @Override
- public boolean setProperty(String key, long value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, int)
- */
- @Override
- public boolean setProperty(String key, int value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, boolean)
- */
- @Override
- public boolean setProperty(String key, boolean value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, float)
- */
- @Override
- public boolean setProperty(String key, float value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#setProperty(java.lang.String, double)
- */
- @Override
- public boolean setProperty(String key, double value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getProperties()
- */
- @Override
- public Map<String, Object> getProperties() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getProperty(java.lang.String)
- */
- @Override
- public Object getProperty(String key) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getStringProperty(java.lang.String)
- */
- @Override
- public String getStringProperty(String key) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getLongProperty(java.lang.String)
- */
- @Override
- public long getLongProperty(String key) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getIntProperty(java.lang.String)
- */
- @Override
- public int getIntProperty(String key) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getBooleanProperty(java.lang.String)
- */
- @Override
- public boolean getBooleanProperty(String key) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getFloatProperty(java.lang.String)
- */
- @Override
- public float getFloatProperty(String key) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#getDoubleProperty(java.lang.String)
- */
- @Override
- public double getDoubleProperty(String key) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#clearProperties()
- */
- @Override
- public void clearProperties() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isEmpty()
- */
- @Override
- public boolean isEmpty() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isPropertyIgnoreCase(java.lang.String, java.lang.String)
- */
- @Override
- public boolean isPropertyIgnoreCase(String key, String value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, java.lang.Object)
- */
- @Override
- public boolean isProperty(String key, Object value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, long)
- */
- @Override
- public boolean isProperty(String key, long value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, int)
- */
- @Override
- public boolean isProperty(String key, int value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, boolean)
- */
- @Override
- public boolean isProperty(String key, boolean value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, float)
- */
- @Override
- public boolean isProperty(String key, float value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#isProperty(java.lang.String, double)
- */
- @Override
- public boolean isProperty(String key, double value) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- @Override
- public Object getAdapter(Class adapter) {
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule)
- */
- @Override
- public boolean contains(ISchedulingRule rule) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule)
- */
- @Override
- public boolean isConflicting(ISchedulingRule rule) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getModel()
- */
- @Override
- public ILocatorModel getModel() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getPeer()
- */
- @Override
- public IPeer getPeer() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getPeerId()
- */
- @Override
- public String getPeerId() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getRemotePeerId()
- */
- @Override
- public String getRemotePeerId() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isComplete()
- */
- @Override
- public boolean isComplete() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isStatic()
- */
- @Override
- public boolean isStatic() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isRemote()
- */
- @Override
- public boolean isRemote() {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#addProperties(java.util.Map)
- */
- @Override
- public void addProperties(Map<String, ?> properties) {
- throw new IllegalStateException();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer#containsKey(java.lang.String)
- */
- @Override
- public boolean containsKey(String key) {
- throw new IllegalStateException();
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java
index f7020a334..9af952156 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/services/PropertiesAccessService.java
@@ -16,7 +16,7 @@ import java.util.Map;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.services.interfaces.constants.IPropertiesAccessServiceConstants;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* Peer model properties access service implementation.
@@ -30,13 +30,22 @@ public class PropertiesAccessService extends org.eclipse.tcf.te.tcf.core.model.s
public Map<String, String> getTargetAddress(Object context) {
final Map<String, String> result = new HashMap<String, String>();
- if (context instanceof IPeerModel) {
- final IPeerModel peerModel = (IPeerModel) context;
+ final IPeer peer;
+ if (context instanceof IPeer) {
+ peer = (IPeer)context;
+ }
+ else if (context instanceof IPeerNode) {
+ peer = ((IPeerNode)context).getPeer();
+ }
+ else {
+ peer = null;
+ }
- Runnable runnable = new Runnable() {
+ if (peer != null) {
+ Protocol.invokeAndWait(new Runnable() {
@Override
public void run() {
- Map<String, String> attributes = peerModel.getPeer().getAttributes();
+ Map<String, String> attributes = peer.getAttributes();
String value = attributes.get(IPeer.ATTR_NAME);
if (value != null && !"".equals(value.trim())) { //$NON-NLS-1$
@@ -52,10 +61,7 @@ public class PropertiesAccessService extends org.eclipse.tcf.te.tcf.core.model.s
result.put(IPropertiesAccessServiceConstants.PROP_PORT, value);
}
}
- };
-
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
+ });
}
return !result.isEmpty() ? Collections.unmodifiableMap(result) : null;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerModelStepGroupIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerNodeStepGroupIterator.java
index 52e840308..254e83209 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerModelStepGroupIterator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/AbstractPeerNodeStepGroupIterator.java
@@ -1,46 +1,46 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.tcf.locator.iterators;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.core.iterators.AbstractPeerStepGroupIterator;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-
-/**
- * Abstract launch stepgroup iterator.
- */
-public abstract class AbstractPeerModelStepGroupIterator extends AbstractPeerStepGroupIterator {
-
- /**
- * Returns the active peer model context that is currently used.
- *
- * @param context The step context. Must not be <code>null</code>.
- * @param data The data giving object. Must not be <code>null</code>.
- * @param fullQualifiedId The full qualfied id for this step. Must not be <code>null</code>.
- * @return The active peer model context.
- */
- protected IPeerModel getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) {
- Object activeContext = getActiveContext(context, data, fullQualifiedId);
- IPeerModel peerModel = null;
- if (activeContext instanceof IPeerModel)
- return (IPeerModel)activeContext;
- if (activeContext instanceof IAdaptable)
- peerModel = (IPeerModel)((IAdaptable)activeContext).getAdapter(IPeerModel.class);
- if (peerModel == null)
- peerModel = (IPeerModel)Platform.getAdapterManager().getAdapter(activeContext, IPeerModel.class);
-
- return peerModel;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2013 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.tcf.locator.iterators;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.tcf.core.iterators.AbstractPeerStepGroupIterator;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+
+/**
+ * Abstract launch stepgroup iterator.
+ */
+public abstract class AbstractPeerNodeStepGroupIterator extends AbstractPeerStepGroupIterator {
+
+ /**
+ * Returns the active peer model context that is currently used.
+ *
+ * @param context The step context. Must not be <code>null</code>.
+ * @param data The data giving object. Must not be <code>null</code>.
+ * @param fullQualifiedId The full qualfied id for this step. Must not be <code>null</code>.
+ * @return The active peer model context.
+ */
+ protected IPeerNode getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) {
+ Object activeContext = getActiveContext(context, data, fullQualifiedId);
+ IPeerNode peerNode = null;
+ if (activeContext instanceof IPeerNode)
+ return (IPeerNode)activeContext;
+ if (activeContext instanceof IAdaptable)
+ peerNode = (IPeerNode)((IAdaptable)activeContext).getAdapter(IPeerNode.class);
+ if (peerNode == null)
+ peerNode = (IPeerNode)Platform.getAdapterManager().getAdapter(activeContext, IPeerNode.class);
+
+ return peerNode;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartDebuggerIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartDebuggerIterator.java
index 2d789a7ce..0acc3cacc 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartDebuggerIterator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartDebuggerIterator.java
@@ -20,13 +20,13 @@ import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
import org.eclipse.tcf.te.tcf.locator.interfaces.IStepAttributes;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
/**
* Step group iterator for debugger attach.
*/
-public class StartDebuggerIterator extends AbstractPeerModelStepGroupIterator {
+public class StartDebuggerIterator extends AbstractPeerNodeStepGroupIterator {
/**
* Constructor.
@@ -44,11 +44,11 @@ public class StartDebuggerIterator extends AbstractPeerModelStepGroupIterator {
final AtomicBoolean autoStartDbg = new AtomicBoolean(false);
- final IPeerModel node = getActivePeerModelContext(context, data, fullQualifiedId);
+ final IPeerNode node = getActivePeerModelContext(context, data, fullQualifiedId);
Runnable runnable = new Runnable() {
@Override
public void run() {
- String value = node.getPeer().getAttributes().get(IPeerModelProperties.PROP_AUTO_START_DEBUGGER);
+ String value = node.getPeer().getAttributes().get(IPeerNodeProperties.PROP_AUTO_START_DEBUGGER);
autoStartDbg.set(value != null ? Boolean.parseBoolean(value) : false);
}
};
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartSimulatorIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartSimulatorIterator.java
index 19188f5bb..945c3de8d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartSimulatorIterator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/iterators/StartSimulatorIterator.java
@@ -1,50 +1,50 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.tcf.locator.iterators;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
-
-/**
- * Step group iterator for simulator start.
- */
-public class StartSimulatorIterator extends AbstractPeerModelStepGroupIterator {
-
- /**
- * Constructor.
- */
- public StartSimulatorIterator() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#initialize(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
- super.initialize(context, data, fullQualifiedId, monitor);
-
- SimulatorUtils.Result result = SimulatorUtils.getSimulatorService(getActivePeerModelContext(context, data, fullQualifiedId));
-
- setIterations(result != null ? 1 : 0);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#internalNext(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void internalNext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2013 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.tcf.locator.iterators;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
+
+/**
+ * Step group iterator for simulator start.
+ */
+public class StartSimulatorIterator extends AbstractPeerNodeStepGroupIterator {
+
+ /**
+ * Constructor.
+ */
+ public StartSimulatorIterator() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#initialize(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void initialize(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ super.initialize(context, data, fullQualifiedId, monitor);
+
+ SimulatorUtils.Result result = SimulatorUtils.getSimulatorService(getActivePeerModelContext(context, data, fullQualifiedId));
+
+ setIterations(result != null ? 1 : 0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.iterators.AbstractStepGroupIterator#internalNext(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void internalNext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java
index afc433394..6a06ca132 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ChannelStateChangeListener.java
@@ -16,10 +16,10 @@ import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener;
import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService;
/**
@@ -27,14 +27,14 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupSer
*/
public class ChannelStateChangeListener implements IChannelStateChangeListener {
// Reference to the parent model
- private final ILocatorModel model;
+ private final IPeerModel model;
/**
* Constructor.
*
* @param model The parent locator model. Must not be <code>null</code>.
*/
- public ChannelStateChangeListener(ILocatorModel model) {
+ public ChannelStateChangeListener(IPeerModel model) {
Assert.isNotNull(model);
this.model = model;
}
@@ -57,14 +57,14 @@ public class ChannelStateChangeListener implements IChannelStateChangeListener {
IPeer peer = channel.getRemotePeer();
if (peer != null && peer.getID() != null) {
// Find the corresponding model node
- IPeerModel node = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peer.getID());
+ IPeerNode node = model.getService(IPeerModelLookupService.class).lkupPeerModelById(peer.getID());
if (node != null) {
// Increase the channel reference counter by 1
- int counter = node.getIntProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER);
+ int counter = node.getIntProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER);
if (counter < 0) counter = 0;
counter++;
- node.setProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER, counter);
- if (counter > 0) node.setProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_CONNECTED);
+ node.setProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER, counter);
+ if (counter > 0) node.setProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_CONNECTED);
}
}
break;
@@ -72,15 +72,15 @@ public class ChannelStateChangeListener implements IChannelStateChangeListener {
peer = channel.getRemotePeer();
if (peer != null && peer.getID() != null) {
// Find the corresponding model node
- IPeerModel node = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peer.getID());
+ IPeerNode node = model.getService(IPeerModelLookupService.class).lkupPeerModelById(peer.getID());
if (node != null) {
// Decrease the channel reference counter by 1
- int counter = node.getIntProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER);
+ int counter = node.getIntProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER);
counter--;
if (counter < 0) counter = 0;
- node.setProperty(IPeerModelProperties.PROP_CHANNEL_REF_COUNTER, counter);
- if (counter == 0 && node.isProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_CONNECTED)) {
- node.setProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_REACHABLE);
+ node.setProperty(IPeerNodeProperties.PROP_CHANNEL_REF_COUNTER, counter);
+ if (counter == 0 && node.isProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_CONNECTED)) {
+ node.setProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_REACHABLE);
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java
index 42476448b..27ba6659f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/LocatorListener.java
@@ -29,13 +29,13 @@ import org.eclipse.tcf.te.tcf.locator.ScannerRunnable;
import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener;
import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService;
-import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService;
+import org.eclipse.tcf.te.tcf.locator.nodes.PeerNode;
import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector;
@@ -44,14 +44,14 @@ import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector;
*/
public final class LocatorListener implements ILocator.LocatorListener {
// Reference to the parent model
- /* default */ final ILocatorModel model;
+ /* default */ final IPeerModel model;
/**
* Constructor.
*
* @param model The parent locator model. Must not be <code>null</code>.
*/
- public LocatorListener(ILocatorModel model) {
+ public LocatorListener(IPeerModel model) {
super();
Assert.isNotNull(model);
@@ -96,28 +96,26 @@ public final class LocatorListener implements ILocator.LocatorListener {
if (model != null && peer != null) {
// find the corresponding model node to remove (expected to be null)
- IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peer.getID());
+ IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(peer.getID());
if (peerNode == null) {
// Double check with "ClientID" if set
String clientID = peer.getAttributes().get("ClientID"); //$NON-NLS-1$
if (clientID != null) {
- peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(clientID);
+ peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(clientID);
}
}
// If not found, create a new peer node instance
if (peerNode == null) {
- peerNode = new PeerModel(model, peer);
+ peerNode = new PeerNode(model, peer);
// Validate the peer node before adding
peerNode = model.validatePeerNodeForAdd(peerNode);
// Add the peer node to the model
if (peerNode != null) {
// If there are reachable static peers without an agent ID associated or
// static peers with unknown link state, refresh the agent ID's first.
- List<IPeerModel> nodes = new ArrayList<IPeerModel>();
+ List<IPeerNode> nodes = new ArrayList<IPeerNode>();
- for (IPeerModel node : model.getPeers()) {
- // Skip static nodes
- if (!node.isStatic()) continue;
+ for (IPeerNode node : model.getPeers()) {
// We expect the agent ID to be set
if (node.getPeer().getAgentID() == null || "".equals(node.getPeer().getAgentID())) { //$NON-NLS-1$
nodes.add(node);
@@ -125,31 +123,31 @@ public final class LocatorListener implements ILocator.LocatorListener {
}
// Create the runnable to execute after the agent ID refresh (if needed)
- final IPeerModel finPeerNode = peerNode;
+ final IPeerNode finPeerNode = peerNode;
final IPeer finPeer = peer;
final Runnable runnable = new Runnable() {
@Override
public void run() {
- IPeerModel[] matches = model.getService(ILocatorModelLookupService.class).lkupMatchingStaticPeerModels(finPeerNode);
+ IPeerNode[] matches = model.getService(IPeerModelLookupService.class).lkupMatchingStaticPeerModels(finPeerNode);
if (matches.length == 0) {
// If the peer node is still in the model, schedule for immediate status update
- if (model.getService(ILocatorModelLookupService.class).lkupPeerModelById(finPeerNode.getPeerId()) != null) {
+ if (model.getService(IPeerModelLookupService.class).lkupPeerModelById(finPeerNode.getPeerId()) != null) {
Runnable runnable2 = new ScannerRunnable(model.getScanner(), finPeerNode);
Protocol.invokeLater(runnable2);
}
} else {
// Remove the preliminary added node from the model again
- model.getService(ILocatorModelUpdateService.class).remove(finPeerNode);
+ model.getService(IPeerModelUpdateService.class).remove(finPeerNode);
- for (IPeerModel match : matches) {
+ for (IPeerNode match : matches) {
IPeer myPeer = model.validatePeer(finPeer);
if (myPeer != null) {
// Update the matching static node
boolean changed = match.setChangeEventsEnabled(false);
// Merge user configured properties between the peers
- model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(match, myPeer, true);
+ model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(match, myPeer, true);
if (changed) match.setChangeEventsEnabled(true);
- match.fireChangeEvent(IPeerModelProperties.PROP_INSTANCE, myPeer, match.getPeer());
+ match.fireChangeEvent(IPeerNodeProperties.PROP_INSTANCE, myPeer, match.getPeer());
// And schedule for immediate status update
Runnable runnable2 = new ScannerRunnable(model.getScanner(), match);
Protocol.invokeLater(runnable2);
@@ -161,11 +159,11 @@ public final class LocatorListener implements ILocator.LocatorListener {
// Preliminary add the node to the model now. If we have to refresh the agent ID,
// this is an asynchronous operation and other peerAdded events might be processed before.
- model.getService(ILocatorModelUpdateService.class).add(peerNode);
+ model.getService(IPeerModelUpdateService.class).add(peerNode);
if (nodes.size() > 0) {
// Refresh the agent ID's first
- model.getService(ILocatorModelRefreshService.class).refreshAgentIDs(nodes.toArray(new IPeerModel[nodes.size()]), new Callback() {
+ model.getService(IPeerModelRefreshService.class).refreshAgentIDs(nodes.toArray(new IPeerNode[nodes.size()]), new Callback() {
@Override
protected void internalDone(Object caller, IStatus status) {
// Ignore errors
@@ -179,26 +177,18 @@ public final class LocatorListener implements ILocator.LocatorListener {
}
} else {
// Peer node found, update the peer instance
- boolean isStatic = peerNode.isStatic();
- if (isStatic) {
// Validate the peer node before updating
IPeer myPeer = model.validatePeer(peer);
if (myPeer != null) {
boolean changed = peerNode.setChangeEventsEnabled(false);
// Merge user configured properties between the peers
- model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, myPeer, true);
+ model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, myPeer, true);
if (changed) peerNode.setChangeEventsEnabled(true);
- peerNode.fireChangeEvent(IPeerModelProperties.PROP_INSTANCE, myPeer, peerNode.getPeer());
+ peerNode.fireChangeEvent(IPeerNodeProperties.PROP_INSTANCE, myPeer, peerNode.getPeer());
// And schedule for immediate status update
Runnable runnable = new ScannerRunnable(model.getScanner(), peerNode);
Protocol.invokeLater(runnable);
}
- } else {
- peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer);
- // And schedule for immediate status update
- Runnable runnable = new ScannerRunnable(model.getScanner(), peerNode);
- Protocol.invokeLater(runnable);
- }
}
}
}
@@ -229,12 +219,12 @@ public final class LocatorListener implements ILocator.LocatorListener {
if (model != null && peer != null) {
// find the corresponding model node to remove
- IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peer.getID());
+ IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(peer.getID());
if (peerNode == null) {
// Double check with "ClientID" if set
String clientID = peer.getAttributes().get("ClientID"); //$NON-NLS-1$
if (clientID != null) {
- peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(clientID);
+ peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(clientID);
}
}
// Update the peer instance
@@ -245,7 +235,7 @@ public final class LocatorListener implements ILocator.LocatorListener {
if (oldPeer != peer) {
// Peers visible to the locator are replaced with the new instance
if (oldPeer instanceof AbstractPeer) {
- peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer);
+ peerNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer);
}
// Non-visible peers are updated
else {
@@ -254,15 +244,15 @@ public final class LocatorListener implements ILocator.LocatorListener {
if (myPeer != null) {
boolean changed = peerNode.setChangeEventsEnabled(false);
// Merge user configured properties between the peers
- model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, myPeer, true);
+ model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, myPeer, true);
if (changed) peerNode.setChangeEventsEnabled(true);
- peerNode.fireChangeEvent(IPeerModelProperties.PROP_INSTANCE, myPeer, peerNode.getPeer());
+ peerNode.fireChangeEvent(IPeerNodeProperties.PROP_INSTANCE, myPeer, peerNode.getPeer());
}
}
}
}
// Refresh static peers and merge attributes if required
- model.getService(ILocatorModelRefreshService.class).refreshStaticPeers();
+ model.getService(IPeerModelRefreshService.class).refreshStaticPeers();
}
// Clean up the guardians
@@ -282,7 +272,7 @@ public final class LocatorListener implements ILocator.LocatorListener {
if (model != null && id != null) {
// find the corresponding model node to remove
- IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(id);
+ IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(id);
// If we cannot find a model node, it is probably because the remove is sent for the
// non-loopback addresses of the localhost. We have to double check this.
@@ -309,12 +299,11 @@ public final class LocatorListener implements ILocator.LocatorListener {
newId.append(id.substring(endIndex + 1));
// Try the lookup again
- peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(newId.toString());
+ peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(newId.toString());
}
// If the model node is found in the model, process the removal.
if (peerNode != null) {
- if (peerNode.isStatic()) {
boolean changed = peerNode.setChangeEventsEnabled(false);
IPeer peer = peerNode.getPeer();
@@ -349,8 +338,8 @@ public final class LocatorListener implements ILocator.LocatorListener {
}
// Remove the attributes stored at peer node level
- peerNode.setProperty(IPeerModelProperties.PROP_LOCAL_SERVICES, null);
- peerNode.setProperty(IPeerModelProperties.PROP_REMOTE_SERVICES, null);
+ peerNode.setProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES, null);
+ peerNode.setProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES, null);
// Check if we have to remote the peer in the underlying locator service too
if (remotePeerID != null) {
@@ -363,11 +352,11 @@ public final class LocatorListener implements ILocator.LocatorListener {
peerNode.getModel().setChildren(peerNode.getPeerId(), null);
if (changed) peerNode.setChangeEventsEnabled(true);
- peerNode.fireChangeEvent(IPeerModelProperties.PROP_INSTANCE, peer, peerNode.getPeer());
+ peerNode.fireChangeEvent(IPeerNodeProperties.PROP_INSTANCE, peer, peerNode.getPeer());
final IModelListener[] listeners = model.getListener();
if (listeners.length > 0) {
- final IPeerModel finPeerNode = peerNode;
+ final IPeerNode finPeerNode = peerNode;
Protocol.invokeLater(new Runnable() {
@Override
public void run() {
@@ -377,10 +366,6 @@ public final class LocatorListener implements ILocator.LocatorListener {
}
});
}
- } else {
- // Dynamic peer -> Remove peer model node from the model
- model.getService(ILocatorModelUpdateService.class).remove(peerNode);
- }
}
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ModelAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ModelAdapter.java
index 2da4ca45c..ecadefe17 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ModelAdapter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/listener/ModelAdapter.java
@@ -10,8 +10,8 @@
package org.eclipse.tcf.te.tcf.locator.listener;
import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* Default model listener implementation.
@@ -19,17 +19,17 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
public class ModelAdapter implements IModelListener {
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, boolean)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener#locatorModelChanged(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, boolean)
*/
@Override
- public void locatorModelChanged(ILocatorModel model, IPeerModel peerModel, boolean added) {
+ public void locatorModelChanged(IPeerModel model, IPeerNode peerNode, boolean added) {
}
/* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.locator.core.interfaces.IModelListener#locatorModelDisposed(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel)
*/
@Override
- public void locatorModelDisposed(ILocatorModel model) {
+ public void locatorModelDisposed(IPeerModel model) {
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/Model.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/Model.java
index cab63d2f2..2af3c5844 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/Model.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/model/Model.java
@@ -11,9 +11,9 @@ package org.eclipse.tcf.te.tcf.locator.model;
import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService;
-import org.eclipse.tcf.te.tcf.locator.nodes.LocatorModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService;
+import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel;
/**
@@ -21,7 +21,7 @@ import org.eclipse.tcf.te.tcf.locator.nodes.LocatorModel;
*/
public final class Model {
// Reference to the locator model
- /* default */ static volatile ILocatorModel locatorModel;
+ /* default */ static volatile IPeerModel peerModel;
/**
* Returns the shared locator model instance.
@@ -31,7 +31,7 @@ public final class Model {
*
* @return The shared locator model.
*/
- public static ILocatorModel getModel() {
+ public static IPeerModel getModel() {
return getModel(false);
}
@@ -48,9 +48,9 @@ public final class Model {
*
* @return The shared locator model.
*/
- public static ILocatorModel getModel(boolean shutdown) {
+ public static IPeerModel getModel(boolean shutdown) {
// Access to the locator model must happen in the TCF dispatch thread
- if (locatorModel == null && !shutdown) {
+ if (peerModel == null && !shutdown) {
if (Protocol.isDispatchThread()) {
initialize();
} else {
@@ -62,7 +62,7 @@ public final class Model {
});
}
}
- return locatorModel;
+ return peerModel;
}
/**
@@ -73,35 +73,35 @@ public final class Model {
// If locator model is set in the mean while, initialize got
// called twice. Return immediately in this case.
- if (locatorModel != null) return;
+ if (peerModel != null) return;
// Create the model instance
- locatorModel = new LocatorModel();
+ peerModel = new PeerModel();
// Refresh the model right away
- locatorModel.getService(ILocatorModelRefreshService.class).refresh(null);
+ peerModel.getService(IPeerModelRefreshService.class).refresh(null);
// Start the scanner
- locatorModel.startScanner(5000, 120000);
+ peerModel.startScanner(5000, 120000);
}
/**
* Dispose the root node.
*/
public static void dispose() {
- if (locatorModel == null) return;
+ if (peerModel == null) return;
// Access to the locator model must happen in the TCF dispatch thread
if (Protocol.isDispatchThread()) {
- locatorModel.dispose();
+ peerModel.dispose();
} else {
Protocol.invokeAndWait(new Runnable() {
@Override
public void run() {
- locatorModel.dispose();
+ peerModel.dispose();
}
});
}
- locatorModel = null;
+ peerModel = null;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java
deleted file mode 100644
index 95b1e989d..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.tcf.locator.nodes;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.core.interfaces.IConnectable;
-import org.eclipse.tcf.te.core.utils.ConnectStateHelper;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService;
-import org.eclipse.tcf.te.runtime.stepper.utils.StepperHelper;
-import org.eclipse.tcf.te.runtime.utils.StatusHelper;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations;
-
-/**
- * ConnectablePeerModel
- */
-public class ConnectablePeerModel extends PeerModel implements IConnectable {
-
- public static final String PROPERTY_CONNECT_STATE = "connectState"; //$NON-NLS-1$
-
- /**
- * Constructor.
- * @param model
- * @param peer
- */
- public ConnectablePeerModel(ILocatorModel model, IPeer peer) {
- super(model, peer);
- setConnectState(STATE_DISCONNECTED);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.core.interfaces.IConnectable#getConnectState()
- */
- @Override
- public int getConnectState() {
- final AtomicInteger state = new AtomicInteger(STATE_UNKNOWN);
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- if (getProperty(PROPERTY_CONNECT_STATE) != null) {
- state.set(getIntProperty(PROPERTY_CONNECT_STATE));
- }
- }
- });
- return state.get();
- }
-
- @Override
- public boolean setConnectState(final int newState) {
- final AtomicBoolean result = new AtomicBoolean(false);
- if (isConnectStateChangeAllowed(newState)) {
- Protocol.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- result.set(setProperty(PROPERTY_CONNECT_STATE, newState));
- }
- });
- }
- return result.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.nodes.PeerModel#postSetProperty(java.lang.String, java.lang.Object, java.lang.Object)
- */
- @Override
- public void postSetProperty(String key, Object value, Object oldValue) {
- if (getConnectState() == STATE_CONNECTED && IPeerModelProperties.PROP_STATE.equals(key)) {
- int state = value instanceof Integer ? ((Integer)value).intValue() : IPeerModelProperties.STATE_UNKNOWN;
- if (state != IPeerModelProperties.STATE_CONNECTED && state != IPeerModelProperties.STATE_REACHABLE) {
- changeConnectState(STATE_DISCONNECTED, null, null);
- }
- }
-
- super.postSetProperty(key, value, oldValue);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.core.interfaces.IConnectable#changeConnectState(int, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void changeConnectState(final int action, ICallback callback, IProgressMonitor monitor) throws IllegalArgumentException {
- final int oldState = getConnectState();
- if (!isConnectStateChangeActionAllowed(action)) {
- IllegalArgumentException e = new IllegalArgumentException("Cannot change state from '" + ConnectStateHelper.getConnectState(oldState) + "' using action '" + ConnectStateHelper.getConnectState(action) + "'."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (callback != null) {
- callback.done(this, StatusHelper.getStatus(e));
- }
- else {
- throw e;
- }
- }
-
- String operation = null;
- int intermediateState = 0;
-
- switch (action) {
- case ACTION_CONNECT:
- operation = IStepperServiceOperations.CONNECT;
- intermediateState = STATE_CONNECT_SCHEDULED;
- break;
- case ACTION_DISCONNECT:
- operation = IStepperServiceOperations.DISCONNECT;
- intermediateState = STATE_DISCONNECT_SCHEDULED;
- break;
- }
-
- IStepperOperationService service = StepperHelper.getService(this, operation);
- if (service != null) {
- setConnectState(intermediateState);
- StepperHelper.scheduleStepperJob(this, operation, service, callback, monitor);
- }
- else if (callback != null) {
- callback.done(this, StatusHelper.getStatus(new NullPointerException("Missing stepper operation service for " + getName() + "."))); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- @Override
- public boolean isConnectStateChangeActionAllowed(int action) {
- int state = getConnectState();
- switch (state) {
- case STATE_CONNECTED:
- case STATE_CONNECT_SCHEDULED:
- case STATE_CONNECTING:
- return isAllowedState(action, ACTION_DISCONNECT);
- case STATE_DISCONNECTED:
- return isAllowedState(action, ACTION_CONNECT);
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.core.interfaces.IConnectable#isConnectStateChangeAllowed(int)
- */
- @Override
- public boolean isConnectStateChangeAllowed(int newState) {
- int state = getConnectState();
- switch (state) {
- case STATE_CONNECTED:
- return isAllowedState(newState, STATE_DISCONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING);
- case STATE_CONNECT_SCHEDULED:
- return isAllowedState(newState, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING);
- case STATE_CONNECTING:
- return isAllowedState(newState, STATE_CONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING, STATE_DISCONNECTED);
- case STATE_DISCONNECTED:
- return isAllowedState(newState, STATE_CONNECTED, STATE_CONNECT_SCHEDULED, STATE_CONNECTING);
- case STATE_DISCONNECT_SCHEDULED:
- return isAllowedState(newState, STATE_DISCONNECTING, STATE_DISCONNECTED);
- case STATE_DISCONNECTING:
- return isAllowedState(newState, STATE_DISCONNECTED);
- case STATE_UNKNOWN:
- return isAllowedState(newState, STATE_DISCONNECTED);
- }
- return false;
- }
-
- private boolean isAllowedState(int state, int... allowedStates) {
- for (int allowedState : allowedStates) {
- if (state == allowedState) {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java
deleted file mode 100644
index 45a47c802..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/LocatorModel.java
+++ /dev/null
@@ -1,785 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.tcf.locator.nodes;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.tcf.protocol.IPeer;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.services.ILocator;
-import org.eclipse.tcf.te.runtime.utils.net.IPAddressUtil;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener;
-import org.eclipse.tcf.te.tcf.locator.Scanner;
-import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener;
-import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner;
-import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService;
-import org.eclipse.tcf.te.tcf.locator.listener.ChannelStateChangeListener;
-import org.eclipse.tcf.te.tcf.locator.listener.LocatorListener;
-import org.eclipse.tcf.te.tcf.locator.services.LocatorModelLookupService;
-import org.eclipse.tcf.te.tcf.locator.services.LocatorModelPeerNodeQueryService;
-import org.eclipse.tcf.te.tcf.locator.services.LocatorModelRefreshService;
-import org.eclipse.tcf.te.tcf.locator.services.LocatorModelUpdateService;
-
-
-/**
- * Default locator model implementation.
- */
-public class LocatorModel extends PlatformObject implements ILocatorModel {
- // The unique model id
- private final UUID uniqueId = UUID.randomUUID();
- // Flag to mark the model disposed
- private boolean disposed;
-
- // The list of known peers
- /* default */ final Map<String, IPeerModel> peers = new HashMap<String, IPeerModel>();
- // The list of "proxied" peers per proxy peer id
- /* default */ final Map<String, List<IPeerModel>> peerChildren = new HashMap<String, List<IPeerModel>>();
-
- // Reference to the scanner
- private IScanner scanner = null;
-
- // Reference to the model locator listener
- private ILocator.LocatorListener locatorListener = null;
- // Reference to the model channel state change listener
- private IChannelStateChangeListener channelStateChangeListener = null;
-
- // The list of registered model listeners
- private final List<IModelListener> modelListener = new ArrayList<IModelListener>();
-
- // Reference to the refresh service
- private final ILocatorModelRefreshService refreshService = new LocatorModelRefreshService(this);
- // Reference to the lookup service
- private final ILocatorModelLookupService lookupService = new LocatorModelLookupService(this);
- // Reference to the update service
- private final ILocatorModelUpdateService updateService = new LocatorModelUpdateService(this);
- // Reference to the query service
- private final ILocatorModelPeerNodeQueryService queryService = new LocatorModelPeerNodeQueryService(this);
-
- /**
- * Constructor.
- */
- public LocatorModel() {
- super();
- disposed = false;
-
- channelStateChangeListener = new ChannelStateChangeListener(this);
- Tcf.addChannelStateChangeListener(channelStateChangeListener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#addListener(org.eclipse.tcf.te.tcf.locator.core.interfaces.IModelListener)
- */
- @Override
- public void addListener(IModelListener listener) {
- Assert.isNotNull(listener);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.addListener( " + listener + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- if (!modelListener.contains(listener)) modelListener.add(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#removeListener(org.eclipse.tcf.te.tcf.locator.core.interfaces.IModelListener)
- */
- @Override
- public void removeListener(IModelListener listener) {
- Assert.isNotNull(listener);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.removeListener( " + listener + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- modelListener.remove(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel#getListener()
- */
- @Override
- public IModelListener[] getListener() {
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- return modelListener.toArray(new IModelListener[modelListener.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#dispose()
- */
- @Override
- public void dispose() {
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.dispose()", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$
- }
-
- // If already disposed, we are done immediately
- if (disposed) return;
-
- disposed = true;
-
- final IModelListener[] listeners = getListener();
- if (listeners.length > 0) {
- Protocol.invokeLater(new Runnable() {
- @Override
- public void run() {
- for (IModelListener listener : listeners) {
- listener.locatorModelDisposed(LocatorModel.this);
- }
- }
- });
- }
- modelListener.clear();
-
- if (locatorListener != null) {
- Protocol.getLocator().removeListener(locatorListener);
- locatorListener = null;
- }
-
- if (channelStateChangeListener != null) {
- Tcf.removeChannelStateChangeListener(channelStateChangeListener);
- channelStateChangeListener = null;
- }
-
- if (scanner != null) {
- stopScanner();
- scanner = null;
- }
-
- peers.clear();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#isDisposed()
- */
- @Override
- public boolean isDisposed() {
- return disposed;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getPeers()
- */
- @Override
- public IPeerModel[] getPeers() {
- final AtomicReference<IPeerModel[]> result = new AtomicReference<IPeerModel[]>();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- result.set(peers.values().toArray(new IPeerModel[peers.values().size()]));
- }
- };
-
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
-
- return result.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel#getChildren(java.lang.String)
- */
- @Override
- public List<IPeerModel> getChildren(final String parentPeerID) {
- Assert.isNotNull(parentPeerID);
-
- final AtomicReference<List<IPeerModel>> result = new AtomicReference<List<IPeerModel>>();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- List<IPeerModel> children = peerChildren.get(parentPeerID);
- if (children == null) children = Collections.emptyList();
- result.set(children);
- }
- };
-
- if (Protocol.isDispatchThread()) runnable.run();
- else Protocol.invokeAndWait(runnable);
-
- return Collections.unmodifiableList(result.get());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel#setChildren(java.lang.String, java.util.List)
- */
- @Override
- public void setChildren(String parentPeerID, List<IPeerModel> children) {
- Assert.isNotNull(parentPeerID);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- if (children == null || children.size() == 0) {
- peerChildren.remove(parentPeerID);
- } else {
- peerChildren.put(parentPeerID, new ArrayList<IPeerModel>(children));
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
- */
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter.isAssignableFrom(ILocator.LocatorListener.class)) {
- return locatorListener;
- }
- if (adapter.isAssignableFrom(IScanner.class)) {
- return scanner;
- }
- if (adapter.isAssignableFrom(ILocatorModelRefreshService.class)) {
- return refreshService;
- }
- if (adapter.isAssignableFrom(ILocatorModelLookupService.class)) {
- return lookupService;
- }
- if (adapter.isAssignableFrom(ILocatorModelUpdateService.class)) {
- return updateService;
- }
- if (adapter.isAssignableFrom(ILocatorModelPeerNodeQueryService.class)) {
- return queryService;
- }
- if (adapter.isAssignableFrom(Map.class)) {
- return peers;
- }
-
- return super.getAdapter(adapter);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return uniqueId.hashCode();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public final boolean equals(Object obj) {
- if (obj instanceof LocatorModel) {
- return uniqueId.equals(((LocatorModel)obj).uniqueId);
- }
- return super.equals(obj);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getService(java.lang.Class)
- */
- @Override
- @SuppressWarnings("unchecked")
- public <V extends ILocatorModelService> V getService(Class<V> serviceInterface) {
- Assert.isNotNull(serviceInterface);
- return (V)getAdapter(serviceInterface);
- }
-
- /**
- * Check if the locator listener has been created and registered
- * to the global locator service.
- * <p>
- * <b>Note:</b> This method is not intended to be call from clients.
- */
- public void checkLocatorListener() {
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- Assert.isNotNull(Protocol.getLocator());
-
- if (locatorListener == null) {
- locatorListener = doCreateLocatorListener(this);
- Protocol.getLocator().addListener(locatorListener);
- }
- }
-
- /**
- * Creates the locator listener instance.
- *
- * @param model The parent model. Must not be <code>null</code>.
- * @return The locator listener instance.
- */
- protected ILocator.LocatorListener doCreateLocatorListener(ILocatorModel model) {
- Assert.isNotNull(model);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- return new LocatorListener(model);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getScanner()
- */
- @Override
- public IScanner getScanner() {
- if (scanner == null) scanner = new Scanner(this);
- return scanner;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#startScanner(long, long)
- */
- @Override
- public void startScanner(long delay, long schedule) {
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.startScanner( " + delay + ", " + schedule + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- IScanner scanner = getScanner();
- Assert.isNotNull(scanner);
-
- // Pass on the schedule parameter
- Map<String, Object> config = new HashMap<String, Object>(scanner.getConfiguration());
- config.put(IScanner.PROP_SCHEDULE, Long.valueOf(schedule));
- scanner.setConfiguration(config);
-
- // The default scanner implementation is a job.
- // -> schedule here if it is a job
- if (scanner instanceof Job) {
- Job job = (Job)scanner;
- job.setSystem(true);
- job.setPriority(Job.DECORATE);
- job.schedule(delay);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#stopScanner()
- */
- @Override
- public void stopScanner() {
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.stopScanner()", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$
- }
-
- if (scanner != null) {
- // Terminate the scanner
- scanner.terminate();
- // Reset the scanner reference
- scanner = null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel#validatePeer(org.eclipse.tcf.protocol.IPeer)
- */
- @Override
- public IPeer validatePeer(IPeer peer) {
- Assert.isNotNull(peer);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeer( " + peer.getID() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- IPeer result = peer;
-
- // Get the loopback address
- String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress();
- // Get the peer IP
- String peerIP = peer.getAttributes().get(IPeer.ATTR_IP_HOST);
-
- // If the peer node is for local host, we ignore all peers not being
- // associated with the loopback address.
- if (IPAddressUtil.getInstance().isLocalHost(peerIP) && !loopback.equals(peerIP)) {
- // Not loopback address -> drop the peer
- result = null;
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeer: local host peer but not loopback address -> peer node dropped" //$NON-NLS-1$
- , ITracing.ID_TRACE_LOCATOR_MODEL, this);
- }
- }
-
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#validatePeerNodeForAdd(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel)
- */
- @Override
- public IPeerModel validatePeerNodeForAdd(IPeerModel node) {
- Assert.isNotNull(node);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- // Get the peer from the peer node
- IPeer peer = node.getPeer();
- if (peer == null) return node;
-
- // Skip static peer IP address validation
- boolean isStatic = node.isStatic();
- if (isStatic) return node;
-
- // Skip validation if the transport type is not TCP or SSL
- String transport = peer.getTransportName();
- if (transport == null || !"TCP".equals(transport) && !"SSL".equals(transport)){ //$NON-NLS-1$ //$NON-NLS-2$
- return node;
- }
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd( " + peer.getID() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- IPeerModel result = node;
-
- // Get the loopback address
- String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress();
- // Get the peer IP
- String peerIP = peer.getAttributes().get(IPeer.ATTR_IP_HOST);
-
- // If the peer node is for local host, we ignore all peers not being
- // associated with the loopback address.
- if (IPAddressUtil.getInstance().isLocalHost(peerIP) && !loopback.equals(peerIP)) {
- boolean drop = true;
-
- // Simulator nodes appears on local host IP addresses too, but does not have
- // a loopback peer available. We have to check the agent ID to determine if
- // a specific node can be dropped
- String agentID = peer.getAgentID();
- if (agentID != null) {
- // Get all discovered peers
- Map<String, IPeer> peers = Protocol.getLocator().getPeers();
- // Sort them by agent id
- Map<String, List<IPeer>> byAgentID = new HashMap<String, List<IPeer>>();
-
- for (IPeer candidate : peers.values()) {
- if (candidate.getAgentID() == null) continue;
-
- List<IPeer> l = byAgentID.get(candidate.getAgentID());
- if (l == null) {
- l = new ArrayList<IPeer>();
- byAgentID.put(candidate.getAgentID(), l);
- }
- Assert.isNotNull(l);
- if (!l.contains(candidate)) l.add(candidate);
- }
-
- // Check all peers found for the same agent ID as the current peer to validate
- List<IPeer> candidates = byAgentID.get(agentID);
- if (candidates != null && candidates.size() > 1) {
- // Check if the found peers contains one with the loopback address
- drop = false;
- for (IPeer candidate : candidates) {
- String ip = candidate.getAttributes().get(IPeer.ATTR_IP_HOST);
- if (IPAddressUtil.getInstance().isLocalHost(ip) && loopback.equals(ip)) {
- drop = true;
- break;
- }
- }
- } else {
- // No other node for this agent ID -> do not drop the peer
- drop = false;
- }
- }
-
-
- if (drop) {
- // Not loopback address -> drop the peer
- result = null;
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: local host peer but not loopback address -> peer node dropped", //$NON-NLS-1$
- ITracing.ID_TRACE_LOCATOR_MODEL, this);
- }
- }
- }
-
- // Continue filtering if the node is not yet dropped
- if (result != null) {
- List<IPeerModel> previousNodes = new ArrayList<IPeerModel>();
-
- // Peers are filtered by agent id. Don't add the peer node if we have another peer
- // node already having the same agent id
- String agentId = peer.getAgentID();
- if (agentId != null) {
- previousNodes.addAll(Arrays.asList(getService(ILocatorModelLookupService.class).lkupPeerModelByAgentId(agentId)));
- }
-
- // Lookup for matching static peer nodes not found by the agent id lookup
- IPeerModel[] candidates = getService(ILocatorModelLookupService.class).lkupMatchingStaticPeerModels(peer);
- for (IPeerModel candidate : candidates) {
- if (!previousNodes.contains(candidate)) previousNodes.add(candidate);
- }
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: agentId=" + agentId + ", Matching peer nodes " //$NON-NLS-1$ //$NON-NLS-2$
- + (previousNodes.size() > 0 ? "found (" + previousNodes.size() +")" : "not found --> DONE") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- , ITracing.ID_TRACE_LOCATOR_MODEL, this);
- }
-
- for (IPeerModel previousNode : previousNodes) {
- // Get the peer for the previous node
- IPeer previousPeer = previousNode.getPeer();
- if (previousPeer != null) {
- // Get the IP address of the previous node
- String previousPeerIP = previousPeer.getAttributes().get(IPeer.ATTR_IP_HOST);
- if (IPAddressUtil.getInstance().isLocalHost(previousPeerIP) && !loopback.equals(previousPeerIP) && loopback.equals(peerIP)) {
- // Remove the previous node from the model
- getService(ILocatorModelUpdateService.class).remove(previousNode);
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: Previous peer removed and replaced by new peer representing the loopback address" //$NON-NLS-1$
- , ITracing.ID_TRACE_LOCATOR_MODEL, this);
- }
-
- continue;
- }
-
- // Get the ports
- String peerPort = peer.getAttributes().get(IPeer.ATTR_IP_PORT);
- String previousPeerPort = previousPeer.getAttributes().get(IPeer.ATTR_IP_PORT);
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: peerIP=" + peerIP //$NON-NLS-1$
- + ", peerPort=" + peerPort + ", previousPeerPort=" + previousPeerPort //$NON-NLS-1$ //$NON-NLS-2$
- , ITracing.ID_TRACE_LOCATOR_MODEL, this);
- }
-
- // If the ports of the agent instances are identical,
- // than try to find the best representation of the agent instance
- if (peerPort != null && peerPort.equals(previousPeerPort)) {
- // Drop the current node
- result = null;
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: Previous peer node kept, new peer node dropped" //$NON-NLS-1$
- , ITracing.ID_TRACE_LOCATOR_MODEL, this);
- }
-
-
- // Break the loop if the ports matched
- break;
- }
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validatePeerNodeForAdd: Previous peer node kept, new peer node added (Port mismatch)" //$NON-NLS-1$
- , ITracing.ID_TRACE_LOCATOR_MODEL, this);
- }
- }
- }
- }
-
- return result;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel#validateChildPeerNodeForAdd(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
- */
- @Override
- public IPeerModel validateChildPeerNodeForAdd(final IPeerModel node) {
- Assert.isNotNull(node);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validateChildPeerNodeForAdd( " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Determine the parent node. If null, the child node is invalid
- // and cannot be added
- final IPeerModel parent = node.getParent(IPeerModel.class);
- if (parent == null) return null;
-
- return validateChildPeerNodeForAdd(parent, node);
- }
-
- /**
- * Validates the given child peer model node in relation to the given parent peer model node
- * hierarchy.
- * <p>
- * The method is recursive.
- *
- * @param parent The parent model node. Must not be <code>null</code>.
- * @param node The child model node. Must not be <code>null</code>.
- *
- * @return The validated child peer model node, or <code>null</code>.
- */
- protected IPeerModel validateChildPeerNodeForAdd(IPeerModel parent, IPeerModel node) {
- Assert.isNotNull(parent);
- Assert.isNotNull(node);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.validateChildPeerNodeForAdd( " + parent.getPeerId() + ", " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- // Validate against the given parent
- if (doValidateChildPeerNodeForAdd(parent, node) == null) {
- return null;
- }
-
- // If the parent node is child node by itself, validate the
- // child node against the parent parent node.
- if (parent.getParent(IPeerModel.class) != null) {
- IPeerModel parentParentNode = parent.getParent(IPeerModel.class);
- if (doValidateChildPeerNodeForAdd(parentParentNode, node) == null) {
- return null;
- }
-
- // And validate the child node against all child nodes of the parent parent.
- List<IPeerModel> childrenList = getChildren(parentParentNode.getPeerId());
- IPeerModel[] children = childrenList.toArray(new IPeerModel[childrenList.size()]);
- for (IPeerModel parentParentChild : children) {
- if (node.equals(parentParentChild) || parent.equals(parentParentChild)) {
- return null;
- }
- if (doValidateChildPeerNodeForAdd(parentParentChild, node) == null) {
- return null;
- }
- }
- }
-
- return node;
- }
-
- /**
- * Validates the given child peer model node in relation to the given parent peer model node.
- * <p>
- * The method is non-recursive.
- *
- * @param parent The parent model node. Must not be <code>null</code>.
- * @param node The child model node. Must not be <code>null</code>.
- *
- * @return The validated child peer model node, or <code>null</code>.
- */
- protected IPeerModel doValidateChildPeerNodeForAdd(IPeerModel parent, IPeerModel node) {
- Assert.isNotNull(parent);
- Assert.isNotNull(node);
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
-
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
- CoreBundleActivator.getTraceHandler().trace("LocatorModel.doValidateChildPeerNodeForAdd( " + parent.getPeerId() + ", " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- // If the child node is already visible as root node, drop the child node
- String id = node.getPeerId();
- if (isRootNode(id)) {
- return null;
- }
-
- int beginIndex = id.indexOf(':');
- int endIndex = id.lastIndexOf(':');
- String ip = beginIndex != -1 && endIndex != -1 ? id.substring(beginIndex+1, endIndex) : ""; //$NON-NLS-1$
-
- // Get the loopback address
- String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress();
- // Empty IP address means loopback
- if ("".equals(ip)) ip = loopback; //$NON-NLS-1$
-
- // If the IP is a localhost IP, try the loopback IP
- if (IPAddressUtil.getInstance().isLocalHost(ip)) {
- // Build up the new id to lookup
- StringBuilder newId = new StringBuilder();
- newId.append(id.substring(0, beginIndex));
- newId.append(':');
- newId.append(loopback);
- newId.append(':');
- newId.append(id.substring(endIndex + 1));
-
- // Try the lookup again
- if (isRootNode(newId.toString())) {
- return null;
- }
- }
-
- // Get the peer from the peer node
- IPeer peer = node.getPeer();
-
- // If the child peer represents the same agent as the parent peer,
- // drop the child peer
- String parentAgentID = parent.getPeer().getAgentID();
- if (parentAgentID != null && parentAgentID.equals(peer.getAgentID())) {
- return null;
- }
- // If the child peer represents the same agent as another child peer,
- // drop the child peer
- String agentID = node.getPeer().getAgentID();
- if (agentID != null) {
- IPeerModel[] matches = getService(ILocatorModelLookupService.class).lkupPeerModelByAgentId(parent.getPeerId(), agentID);
- for (IPeerModel match : matches) {
- if (agentID.equals(match.getPeer().getAgentID())) {
- // Try to keep the peer with the real IP, filter the "127.0.0.1" peer
- if ("127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$
- && !"127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$
- // Keep the other child node
- return null;
- }
-
- if (!"127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$
- && "127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$
- // Keep the node
- getService(ILocatorModelUpdateService.class).removeChild(match);
- }
-
- // If both nodes have a IP different from "127.0.0.1", keep the first node
- if (!"127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$
- && !"127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$
- // Keep the other child node
- return null;
- }
- }
- }
- }
- // If the child peer's IP address and port are the same as the parent's
- // IP address and port, drop the child node
- Map<String, String> parentPeerAttributes = parent.getPeer().getAttributes();
- if (parentPeerAttributes.get(IPeer.ATTR_IP_HOST) != null && parentPeerAttributes.get(IPeer.ATTR_IP_HOST).equals(peer.getAttributes().get(IPeer.ATTR_IP_HOST))) {
- String parentPort = parentPeerAttributes.get(IPeer.ATTR_IP_PORT);
- String port = peer.getAttributes().get(IPeer.ATTR_IP_PORT);
-
- if (parentPort != null && parentPort.equals(port)) return null;
- }
-
- return node;
- }
-
- /**
- * Checks if the given peer id belongs to an already known root node
- * or to one of the discovered nodes.
- *
- * @param id The peer id. Must not be <code>null</code>.
- * @return <code>True</code> if the given id belongs to a root node, <code>false</code> otherwise.
- */
- private boolean isRootNode(String id) {
- Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- Assert.isNotNull(id);
-
- boolean isRoot = false;
-
- if (getService(ILocatorModelLookupService.class).lkupPeerModelById(id) != null) {
- isRoot = true;
- } else {
- Map<String, IPeer> peers = Protocol.getLocator().getPeers();
- if (peers.containsKey(id)) {
- isRoot = true;
- }
- }
-
- return isRoot;
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java
index aae484eec..19d9e40af 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerModel.java
@@ -9,344 +9,775 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.locator.nodes;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.runtime.model.ContainerModelNode;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
+import org.eclipse.tcf.services.ILocator;
+import org.eclipse.tcf.te.runtime.utils.net.IPAddressUtil;
+import org.eclipse.tcf.te.tcf.core.Tcf;
+import org.eclipse.tcf.te.tcf.core.listeners.interfaces.IChannelStateChangeListener;
+import org.eclipse.tcf.te.tcf.locator.Scanner;
+import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener;
+import org.eclipse.tcf.te.tcf.locator.interfaces.IScanner;
+import org.eclipse.tcf.te.tcf.locator.interfaces.ITracing;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService;
+import org.eclipse.tcf.te.tcf.locator.listener.ChannelStateChangeListener;
+import org.eclipse.tcf.te.tcf.locator.listener.LocatorListener;
+import org.eclipse.tcf.te.tcf.locator.services.PeerModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.services.PeerModelQueryService;
+import org.eclipse.tcf.te.tcf.locator.services.PeerModelRefreshService;
+import org.eclipse.tcf.te.tcf.locator.services.PeerModelUpdateService;
/**
- * Default peer model implementation.
+ * Default locator model implementation.
*/
-public class PeerModel extends ContainerModelNode implements IPeerModel {
- // Reference to the parent locator model
- private final ILocatorModel model;
- // Reference to the peer id (cached for performance optimization)
- private String peerId;
+public class PeerModel extends PlatformObject implements IPeerModel {
+ // The unique model id
+ private final UUID uniqueId = UUID.randomUUID();
+ // Flag to mark the model disposed
+ private boolean disposed;
+
+ // The list of known peers
+ /* default */ final Map<String, IPeerNode> peers = new HashMap<String, IPeerNode>();
+ // The list of "proxied" peers per proxy peer id
+ /* default */ final Map<String, List<IPeerNode>> peerChildren = new HashMap<String, List<IPeerNode>>();
+
+ // Reference to the scanner
+ private IScanner scanner = null;
+
+ // Reference to the model locator listener
+ private ILocator.LocatorListener locatorListener = null;
+ // Reference to the model channel state change listener
+ private IChannelStateChangeListener channelStateChangeListener = null;
+
+ // The list of registered model listeners
+ private final List<IModelListener> modelListener = new ArrayList<IModelListener>();
+
+ // Reference to the refresh service
+ private final IPeerModelRefreshService refreshService = new PeerModelRefreshService(this);
+ // Reference to the lookup service
+ private final IPeerModelLookupService lookupService = new PeerModelLookupService(this);
+ // Reference to the update service
+ private final IPeerModelUpdateService updateService = new PeerModelUpdateService(this);
+ // Reference to the query service
+ private final IPeerModelQueryService queryService = new PeerModelQueryService(this);
/**
* Constructor.
- *
- * @param model The parent locator model. Must not be <code>null</code>.
- * @param peer The peer. Must not be <code>null</code>.
*/
- public PeerModel(ILocatorModel model, IPeer peer) {
+ public PeerModel() {
super();
+ disposed = false;
- Assert.isNotNull(model);
- this.model = model;
-
- Assert.isNotNull(peer);
-
- // Set the default properties before enabling the change events.
- // The properties changed listeners should not be called from the
- // constructor.
- setProperty(IPeerModelProperties.PROP_INSTANCE, peer);
-
- // Initialize the peer id
- peerId = peer.getID();
- Assert.isNotNull(peerId);
-
- // Peer model nodes can change the node parent at any time
- allowSetParentOnNonNullParent = true;
- // Peer model nodes does not have a parent by default
- // -> allow change events with null parent
- suppressEventsOnNullParent = false;
-
- // Enable change events
- setChangeEventsEnabled(true);
+ channelStateChangeListener = new ChannelStateChangeListener(this);
+ Tcf.addChannelStateChangeListener(channelStateChangeListener);
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#checkThreadAccess()
+ * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#addListener(org.eclipse.tcf.te.tcf.locator.core.interfaces.IModelListener)
*/
@Override
- protected final boolean checkThreadAccess() {
- return Protocol.isDispatchThread();
- }
+ public void addListener(IModelListener listener) {
+ Assert.isNotNull(listener);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getModel()
- */
- @Override
- public ILocatorModel getModel() {
- return (ILocatorModel)getAdapter(ILocatorModel.class);
- }
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+ CoreBundleActivator.getTraceHandler().trace("PeerModel.addListener( " + listener + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
+ }
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getPeer()
- */
- @Override
- public IPeer getPeer() {
- return (IPeer)getAdapter(IPeer.class);
+ if (!modelListener.contains(listener)) modelListener.add(listener);
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getPeerId()
+ * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#removeListener(org.eclipse.tcf.te.tcf.locator.core.interfaces.IModelListener)
*/
@Override
- public String getPeerId() {
- return peerId;
+ public void removeListener(IModelListener listener) {
+ Assert.isNotNull(listener);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+ CoreBundleActivator.getTraceHandler().trace("PeerModel.removeListener( " + listener + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ modelListener.remove(listener);
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.ModelNode#getName()
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getListener()
*/
@Override
- public String getName() {
- return getPeer().getName();
+ public IModelListener[] getListener() {
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+ return modelListener.toArray(new IModelListener[modelListener.size()]);
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getRemotePeerId()
+ * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#dispose()
*/
@Override
- public String getRemotePeerId() {
- // If the peer is a remote peer by itself, than we return getPeerId()
- if ("RemotePeer".equals(getPeer().getClass().getSimpleName())) { //$NON-NLS-1$
- return getPeerId();
+ public void dispose() {
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+ CoreBundleActivator.getTraceHandler().trace("PeerModel.dispose()", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$
}
- // Try to determine the remote peer ID
- final AtomicReference<String> remotePeerId = new AtomicReference<String>();
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- remotePeerId.set(getPeer().getAttributes().get("remote.id.transient")); //$NON-NLS-1$
- }
- };
+ // If already disposed, we are done immediately
+ if (disposed) return;
+
+ disposed = true;
+
+ final IModelListener[] listeners = getListener();
+ if (listeners.length > 0) {
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ for (IModelListener listener : listeners) {
+ listener.locatorModelDisposed(PeerModel.this);
+ }
+ }
+ });
+ }
+ modelListener.clear();
- if (Protocol.isDispatchThread()) {
- runnable.run();
+ if (locatorListener != null) {
+ Protocol.getLocator().removeListener(locatorListener);
+ locatorListener = null;
}
- else {
- Protocol.invokeAndWait(runnable);
+
+ if (channelStateChangeListener != null) {
+ Tcf.removeChannelStateChangeListener(channelStateChangeListener);
+ channelStateChangeListener = null;
+ }
+
+ if (scanner != null) {
+ stopScanner();
+ scanner = null;
}
- return remotePeerId.get();
+ peers.clear();
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isComplete()
+ * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#isDisposed()
*/
@Override
- public boolean isComplete() {
- Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
-
- boolean complete = true;
-
- // Determine the transport method
- String transport = getPeer().getTransportName();
- // If the transport is not set, the peer attributes are incomplete
- if (transport == null) {
- complete = false;
- } else {
- // For TCP or SSL transport, ATTR_IP_HOST must not be null.
- String ip = getPeer().getAttributes().get(IPeer.ATTR_IP_HOST);
- String port = getPeer().getAttributes().get(IPeer.ATTR_IP_PORT);
- if (("TCP".equals(transport) || "SSL".equals(transport)) && (ip == null || port == null)) { //$NON-NLS-1$ //$NON-NLS-2$
- complete = false;
- }
-
- // Pipe and Loop transport does not require additional attributes
- }
-
- return complete;
+ public boolean isDisposed() {
+ return disposed;
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isStatic()
+ * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getPeers()
*/
@Override
- public boolean isStatic() {
- final AtomicBoolean isStatic = new AtomicBoolean();
+ public IPeerNode[] getPeers() {
+ final AtomicReference<IPeerNode[]> result = new AtomicReference<IPeerNode[]>();
Runnable runnable = new Runnable() {
@Override
public void run() {
- String value = getPeer().getAttributes().get("static.transient"); //$NON-NLS-1$
- isStatic.set(value != null && Boolean.parseBoolean(value.trim()));
+ result.set(peers.values().toArray(new IPeerNode[peers.values().size()]));
}
};
if (Protocol.isDispatchThread()) runnable.run();
else Protocol.invokeAndWait(runnable);
- return isStatic.get();
+ return result.get();
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#isRemote()
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#getChildren(java.lang.String)
*/
@Override
- public boolean isRemote() {
- final AtomicBoolean isRemote = new AtomicBoolean();
+ public List<IPeerNode> getChildren(final String parentPeerID) {
+ Assert.isNotNull(parentPeerID);
+
+ final AtomicReference<List<IPeerNode>> result = new AtomicReference<List<IPeerNode>>();
Runnable runnable = new Runnable() {
@Override
public void run() {
- // Determine the "remote" flag
- String value = getPeer().getAttributes().get("remote.transient"); //$NON-NLS-1$
- boolean bValue = value != null && Boolean.parseBoolean(value.trim());
-
- // The peer model node is considered to be remote if it is a remote peer
- // or the "remote" flag is set.
- isRemote.set("RemotePeer".equals(getPeer().getClass().getSimpleName()) || bValue); //$NON-NLS-1$
+ List<IPeerNode> children = peerChildren.get(parentPeerID);
+ if (children == null) children = Collections.emptyList();
+ result.set(children);
}
};
if (Protocol.isDispatchThread()) runnable.run();
else Protocol.invokeAndWait(runnable);
- return isRemote.get();
+ return Collections.unmodifiableList(result.get());
}
/* (non-Javadoc)
- * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#setChildren(java.lang.String, java.util.List)
*/
@Override
- public Object getAdapter(final Class adapter) {
- // NOTE: The getAdapter(...) method can be invoked from many place and
- // many threads where we cannot control the calls. Therefore, this
- // method is allowed be called from any thread.
- final AtomicReference<Object> object = new AtomicReference<Object>();
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- object.set(doGetAdapter(adapter));
- }
- };
+ public void setChildren(String parentPeerID, List<IPeerNode> children) {
+ Assert.isNotNull(parentPeerID);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- if (Protocol.isDispatchThread()) {
- runnable.run();
+ if (children == null || children.size() == 0) {
+ peerChildren.remove(parentPeerID);
+ } else {
+ peerChildren.put(parentPeerID, new ArrayList<IPeerNode>(children));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (adapter.isAssignableFrom(ILocator.LocatorListener.class)) {
+ return locatorListener;
+ }
+ if (adapter.isAssignableFrom(IScanner.class)) {
+ return scanner;
+ }
+ if (adapter.isAssignableFrom(IPeerModelRefreshService.class)) {
+ return refreshService;
}
- else {
- Protocol.invokeAndWait(runnable);
+ if (adapter.isAssignableFrom(IPeerModelLookupService.class)) {
+ return lookupService;
+ }
+ if (adapter.isAssignableFrom(IPeerModelUpdateService.class)) {
+ return updateService;
+ }
+ if (adapter.isAssignableFrom(IPeerModelQueryService.class)) {
+ return queryService;
+ }
+ if (adapter.isAssignableFrom(Map.class)) {
+ return peers;
}
- return object.get() != null ? object.get() : super.getAdapter(adapter);
+ return super.getAdapter(adapter);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return uniqueId.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public final boolean equals(Object obj) {
+ if (obj instanceof PeerModel) {
+ return uniqueId.equals(((PeerModel)obj).uniqueId);
+ }
+ return super.equals(obj);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getService(java.lang.Class)
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public <V extends IPeerModelService> V getService(Class<V> serviceInterface) {
+ Assert.isNotNull(serviceInterface);
+ return (V)getAdapter(serviceInterface);
}
/**
- * Returns an object which is an instance of the given class associated with this object.
- * Returns <code>null</code> if no such object can be found.
+ * Check if the locator listener has been created and registered
+ * to the global locator service.
* <p>
- * This method must be called within the TCF dispatch thread!
- *
- * @param adapter The adapter class to look up.
- * @return The adapter or <code>null</code>.
+ * <b>Note:</b> This method is not intended to be call from clients.
*/
- protected Object doGetAdapter(Class<?> adapter) {
- Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
+ public void checkLocatorListener() {
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(Protocol.getLocator());
- if (ILocatorModel.class.isAssignableFrom(adapter)) {
- return model;
+ if (locatorListener == null) {
+ locatorListener = doCreateLocatorListener(this);
+ Protocol.getLocator().addListener(locatorListener);
}
+ }
- Object peer = getProperty(IPeerModelProperties.PROP_INSTANCE);
- // Check with adapter.isAssignableFrom(...) to return the peer instance
- // correctly if adapter is IPeer.class.
- if (peer != null && adapter.isAssignableFrom(peer.getClass())) {
- return peer;
- }
+ /**
+ * Creates the locator listener instance.
+ *
+ * @param model The parent model. Must not be <code>null</code>.
+ * @return The locator listener instance.
+ */
+ protected ILocator.LocatorListener doCreateLocatorListener(IPeerModel model) {
+ Assert.isNotNull(model);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- return null;
+ return new LocatorListener(model);
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#toString()
+ * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#getScanner()
*/
@Override
- public String toString() {
- final StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
+ public IScanner getScanner() {
+ if (scanner == null) scanner = new Scanner(this);
+ return scanner;
+ }
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- IPeer peer = getPeer();
- buffer.append(": id=" + peer.getID()); //$NON-NLS-1$
- buffer.append(", name=" + peer.getName()); //$NON-NLS-1$
- }
- };
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#startScanner(long, long)
+ */
+ @Override
+ public void startScanner(long delay, long schedule) {
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+ CoreBundleActivator.getTraceHandler().trace("PeerModel.startScanner( " + delay + ", " + schedule + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
- if (Protocol.isDispatchThread()) {
- runnable.run();
+ IScanner scanner = getScanner();
+ Assert.isNotNull(scanner);
+
+ // Pass on the schedule parameter
+ Map<String, Object> config = new HashMap<String, Object>(scanner.getConfiguration());
+ config.put(IScanner.PROP_SCHEDULE, Long.valueOf(schedule));
+ scanner.setConfiguration(config);
+
+ // The default scanner implementation is a job.
+ // -> schedule here if it is a job
+ if (scanner instanceof Job) {
+ Job job = (Job)scanner;
+ job.setSystem(true);
+ job.setPriority(Job.DECORATE);
+ job.schedule(delay);
}
- else {
- Protocol.invokeAndWait(runnable);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#stopScanner()
+ */
+ @Override
+ public void stopScanner() {
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+ CoreBundleActivator.getTraceHandler().trace("PeerModel.stopScanner()", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$
}
- buffer.append(", " + super.toString()); //$NON-NLS-1$
- return buffer.toString();
+ if (scanner != null) {
+ // Terminate the scanner
+ scanner.terminate();
+ // Reset the scanner reference
+ scanner = null;
+ }
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#equals(java.lang.Object)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#validatePeer(org.eclipse.tcf.protocol.IPeer)
*/
@Override
- public boolean equals(Object obj) {
- if (obj instanceof PeerModel) {
- return getPeerId().equals(((PeerModel)obj).getPeerId());
+ public IPeer validatePeer(IPeer peer) {
+ Assert.isNotNull(peer);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+ CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeer( " + peer.getID() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
}
- return super.equals(obj);
+
+ IPeer result = peer;
+
+ // Get the loopback address
+ String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress();
+ // Get the peer IP
+ String peerIP = peer.getAttributes().get(IPeer.ATTR_IP_HOST);
+
+ // If the peer node is for local host, we ignore all peers not being
+ // associated with the loopback address.
+ if (IPAddressUtil.getInstance().isLocalHost(peerIP) && !loopback.equals(peerIP)) {
+ // Not loopback address -> drop the peer
+ result = null;
+
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+ CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeer: local host peer but not loopback address -> peer node dropped" //$NON-NLS-1$
+ , ITracing.ID_TRACE_LOCATOR_MODEL, this);
+ }
+ }
+
+ return result;
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#hashCode()
+ * @see org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.ILocatorModel#validatePeerNodeForAdd(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel)
*/
@Override
- public int hashCode() {
- return getPeerId().hashCode();
+ public IPeerNode validatePeerNodeForAdd(IPeerNode node) {
+ Assert.isNotNull(node);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ // Get the peer from the peer node
+ IPeer peer = node.getPeer();
+ if (peer == null) return node;
+
+ // Skip static peer IP address validation
+ return node;
+
+// // Skip validation if the transport type is not TCP or SSL
+// String transport = peer.getTransportName();
+// if (transport == null || !"TCP".equals(transport) && !"SSL".equals(transport)){ //$NON-NLS-1$ //$NON-NLS-2$
+// return node;
+// }
+//
+// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd( " + peer.getID() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
+// }
+//
+// IPeerNode result = node;
+//
+// // Get the loopback address
+// String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress();
+// // Get the peer IP
+// String peerIP = peer.getAttributes().get(IPeer.ATTR_IP_HOST);
+//
+// // If the peer node is for local host, we ignore all peers not being
+// // associated with the loopback address.
+// if (IPAddressUtil.getInstance().isLocalHost(peerIP) && !loopback.equals(peerIP)) {
+// boolean drop = true;
+//
+// // Simulator nodes appears on local host IP addresses too, but does not have
+// // a loopback peer available. We have to check the agent ID to determine if
+// // a specific node can be dropped
+// String agentID = peer.getAgentID();
+// if (agentID != null) {
+// // Get all discovered peers
+// Map<String, IPeer> peers = Protocol.getLocator().getPeers();
+// // Sort them by agent id
+// Map<String, List<IPeer>> byAgentID = new HashMap<String, List<IPeer>>();
+//
+// for (IPeer candidate : peers.values()) {
+// if (candidate.getAgentID() == null) continue;
+//
+// List<IPeer> l = byAgentID.get(candidate.getAgentID());
+// if (l == null) {
+// l = new ArrayList<IPeer>();
+// byAgentID.put(candidate.getAgentID(), l);
+// }
+// Assert.isNotNull(l);
+// if (!l.contains(candidate)) l.add(candidate);
+// }
+//
+// // Check all peers found for the same agent ID as the current peer to validate
+// List<IPeer> candidates = byAgentID.get(agentID);
+// if (candidates != null && candidates.size() > 1) {
+// // Check if the found peers contains one with the loopback address
+// drop = false;
+// for (IPeer candidate : candidates) {
+// String ip = candidate.getAttributes().get(IPeer.ATTR_IP_HOST);
+// if (IPAddressUtil.getInstance().isLocalHost(ip) && loopback.equals(ip)) {
+// drop = true;
+// break;
+// }
+// }
+// } else {
+// // No other node for this agent ID -> do not drop the peer
+// drop = false;
+// }
+// }
+//
+//
+// if (drop) {
+// // Not loopback address -> drop the peer
+// result = null;
+//
+// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: local host peer but not loopback address -> peer node dropped", //$NON-NLS-1$
+// ITracing.ID_TRACE_LOCATOR_MODEL, this);
+// }
+// }
+// }
+//
+// // Continue filtering if the node is not yet dropped
+// if (result != null) {
+// List<IPeerNode> previousNodes = new ArrayList<IPeerNode>();
+//
+// // Peers are filtered by agent id. Don't add the peer node if we have another peer
+// // node already having the same agent id
+// String agentId = peer.getAgentID();
+// if (agentId != null) {
+// previousNodes.addAll(Arrays.asList(getService(IPeerModelLookupService.class).lkupPeerModelByAgentId(agentId)));
+// }
+//
+// // Lookup for matching static peer nodes not found by the agent id lookup
+// IPeerNode[] candidates = getService(IPeerModelLookupService.class).lkupMatchingStaticPeerModels(peer);
+// for (IPeerNode candidate : candidates) {
+// if (!previousNodes.contains(candidate)) previousNodes.add(candidate);
+// }
+//
+// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: agentId=" + agentId + ", Matching peer nodes " //$NON-NLS-1$ //$NON-NLS-2$
+// + (previousNodes.size() > 0 ? "found (" + previousNodes.size() +")" : "not found --> DONE") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+// , ITracing.ID_TRACE_LOCATOR_MODEL, this);
+// }
+//
+// for (IPeerNode previousNode : previousNodes) {
+// // Get the peer for the previous node
+// IPeer previousPeer = previousNode.getPeer();
+// if (previousPeer != null) {
+// // Get the IP address of the previous node
+// String previousPeerIP = previousPeer.getAttributes().get(IPeer.ATTR_IP_HOST);
+// if (IPAddressUtil.getInstance().isLocalHost(previousPeerIP) && !loopback.equals(previousPeerIP) && loopback.equals(peerIP)) {
+// // Remove the previous node from the model
+// getService(IPeerModelUpdateService.class).remove(previousNode);
+//
+// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: Previous peer removed and replaced by new peer representing the loopback address" //$NON-NLS-1$
+// , ITracing.ID_TRACE_LOCATOR_MODEL, this);
+// }
+//
+// continue;
+// }
+//
+// // Get the ports
+// String peerPort = peer.getAttributes().get(IPeer.ATTR_IP_PORT);
+// String previousPeerPort = previousPeer.getAttributes().get(IPeer.ATTR_IP_PORT);
+//
+// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: peerIP=" + peerIP //$NON-NLS-1$
+// + ", peerPort=" + peerPort + ", previousPeerPort=" + previousPeerPort //$NON-NLS-1$ //$NON-NLS-2$
+// , ITracing.ID_TRACE_LOCATOR_MODEL, this);
+// }
+//
+// // If the ports of the agent instances are identical,
+// // than try to find the best representation of the agent instance
+// if (peerPort != null && peerPort.equals(previousPeerPort)) {
+// // Drop the current node
+// result = null;
+//
+// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: Previous peer node kept, new peer node dropped" //$NON-NLS-1$
+// , ITracing.ID_TRACE_LOCATOR_MODEL, this);
+// }
+//
+//
+// // Break the loop if the ports matched
+// break;
+// }
+//
+// if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+// CoreBundleActivator.getTraceHandler().trace("PeerModel.validatePeerNodeForAdd: Previous peer node kept, new peer node added (Port mismatch)" //$NON-NLS-1$
+// , ITracing.ID_TRACE_LOCATOR_MODEL, this);
+// }
+// }
+// }
+// }
+//
+// return result;
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#postSetProperties(java.util.Map)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel#validateChildPeerNodeForAdd(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode)
*/
@Override
- protected void postSetProperties(Map<String, ?> properties) {
- Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
- Assert.isNotNull(properties);
- Assert.isNotNull(getPeer());
+ public IPeerNode validateChildPeerNodeForAdd(final IPeerNode node) {
+ Assert.isNotNull(node);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+ CoreBundleActivator.getTraceHandler().trace("PeerModel.validateChildPeerNodeForAdd( " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$
+ }
- // New properties applied. Update the element id
- peerId = getPeer().getID();
- Assert.isNotNull(peerId);
+ // Determine the parent node. If null, the child node is invalid
+ // and cannot be added
+ final IPeerNode parent = node.getParent(IPeerNode.class);
+ if (parent == null) return null;
- super.postSetProperties(properties);
+ return validateChildPeerNodeForAdd(parent, node);
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#postSetProperty(java.lang.String, java.lang.Object, java.lang.Object)
+ /**
+ * Validates the given child peer model node in relation to the given parent peer model node
+ * hierarchy.
+ * <p>
+ * The method is recursive.
+ *
+ * @param parent The parent model node. Must not be <code>null</code>.
+ * @param node The child model node. Must not be <code>null</code>.
+ *
+ * @return The validated child peer model node, or <code>null</code>.
*/
- @Override
- public void postSetProperty(String key, Object value, Object oldValue) {
- Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
- Assert.isNotNull(key);
- Assert.isNotNull(getPeer());
+ protected IPeerNode validateChildPeerNodeForAdd(IPeerNode parent, IPeerNode node) {
+ Assert.isNotNull(parent);
+ Assert.isNotNull(node);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+ CoreBundleActivator.getTraceHandler().trace("PeerModel.validateChildPeerNodeForAdd( " + parent.getPeerId() + ", " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // Validate against the given parent
+ if (doValidateChildPeerNodeForAdd(parent, node) == null) {
+ return null;
+ }
- // If the peer instance changed, update the element id
- if (IPeerModelProperties.PROP_INSTANCE.equals(key)) {
- peerId = getPeer().getID();
- Assert.isNotNull(peerId);
+ // If the parent node is child node by itself, validate the
+ // child node against the parent parent node.
+ if (parent.getParent(IPeerNode.class) != null) {
+ IPeerNode parentParentNode = parent.getParent(IPeerNode.class);
+ if (doValidateChildPeerNodeForAdd(parentParentNode, node) == null) {
+ return null;
+ }
+
+ // And validate the child node against all child nodes of the parent parent.
+ List<IPeerNode> childrenList = getChildren(parentParentNode.getPeerId());
+ IPeerNode[] children = childrenList.toArray(new IPeerNode[childrenList.size()]);
+ for (IPeerNode parentParentChild : children) {
+ if (node.equals(parentParentChild) || parent.equals(parentParentChild)) {
+ return null;
+ }
+ if (doValidateChildPeerNodeForAdd(parentParentChild, node) == null) {
+ return null;
+ }
+ }
}
- super.postSetProperty(key, value, oldValue);
+ return node;
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.model.ModelNode#isVisible()
+ /**
+ * Validates the given child peer model node in relation to the given parent peer model node.
+ * <p>
+ * The method is non-recursive.
+ *
+ * @param parent The parent model node. Must not be <code>null</code>.
+ * @param node The child model node. Must not be <code>null</code>.
+ *
+ * @return The validated child peer model node, or <code>null</code>.
*/
- @Override
- public boolean isVisible() {
- IPeer peer = getPeer();
- return peer != null && peer.getAttributes().containsKey(IPeerModelProperties.PROP_VISIBLE)
- ? Boolean.valueOf(peer.getAttributes().get(IPeerModelProperties.PROP_VISIBLE)).booleanValue() : true;
+ protected IPeerNode doValidateChildPeerNodeForAdd(IPeerNode parent, IPeerNode node) {
+ Assert.isNotNull(parent);
+ Assert.isNotNull(node);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_LOCATOR_MODEL)) {
+ CoreBundleActivator.getTraceHandler().trace("PeerModel.doValidateChildPeerNodeForAdd( " + parent.getPeerId() + ", " + node.getPeerId() + " )", ITracing.ID_TRACE_LOCATOR_MODEL, this); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // If the child node is already visible as root node, drop the child node
+ String id = node.getPeerId();
+ if (isRootNode(id)) {
+ return null;
+ }
+
+ int beginIndex = id.indexOf(':');
+ int endIndex = id.lastIndexOf(':');
+ String ip = beginIndex != -1 && endIndex != -1 ? id.substring(beginIndex+1, endIndex) : ""; //$NON-NLS-1$
+
+ // Get the loopback address
+ String loopback = IPAddressUtil.getInstance().getIPv4LoopbackAddress();
+ // Empty IP address means loopback
+ if ("".equals(ip)) ip = loopback; //$NON-NLS-1$
+
+ // If the IP is a localhost IP, try the loopback IP
+ if (IPAddressUtil.getInstance().isLocalHost(ip)) {
+ // Build up the new id to lookup
+ StringBuilder newId = new StringBuilder();
+ newId.append(id.substring(0, beginIndex));
+ newId.append(':');
+ newId.append(loopback);
+ newId.append(':');
+ newId.append(id.substring(endIndex + 1));
+
+ // Try the lookup again
+ if (isRootNode(newId.toString())) {
+ return null;
+ }
+ }
+
+ // Get the peer from the peer node
+ IPeer peer = node.getPeer();
+
+ // If the child peer represents the same agent as the parent peer,
+ // drop the child peer
+ String parentAgentID = parent.getPeer().getAgentID();
+ if (parentAgentID != null && parentAgentID.equals(peer.getAgentID())) {
+ return null;
+ }
+ // If the child peer represents the same agent as another child peer,
+ // drop the child peer
+ String agentID = node.getPeer().getAgentID();
+ if (agentID != null) {
+ IPeerNode[] matches = getService(IPeerModelLookupService.class).lkupPeerModelByAgentId(parent.getPeerId(), agentID);
+ for (IPeerNode match : matches) {
+ if (agentID.equals(match.getPeer().getAgentID())) {
+ // Try to keep the peer with the real IP, filter the "127.0.0.1" peer
+ if ("127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$
+ && !"127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$
+ // Keep the other child node
+ return null;
+ }
+
+ if (!"127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$
+ && "127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$
+ // Keep the node
+ getService(IPeerModelUpdateService.class).removeChild(match);
+ }
+
+ // If both nodes have a IP different from "127.0.0.1", keep the first node
+ if (!"127.0.0.1".equals(node.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)) //$NON-NLS-1$
+ && !"127.0.0.1".equals(match.getPeer().getAttributes().get(IPeer.ATTR_IP_HOST))) { //$NON-NLS-1$
+ // Keep the other child node
+ return null;
+ }
+ }
+ }
+ }
+ // If the child peer's IP address and port are the same as the parent's
+ // IP address and port, drop the child node
+ Map<String, String> parentPeerAttributes = parent.getPeer().getAttributes();
+ if (parentPeerAttributes.get(IPeer.ATTR_IP_HOST) != null && parentPeerAttributes.get(IPeer.ATTR_IP_HOST).equals(peer.getAttributes().get(IPeer.ATTR_IP_HOST))) {
+ String parentPort = parentPeerAttributes.get(IPeer.ATTR_IP_PORT);
+ String port = peer.getAttributes().get(IPeer.ATTR_IP_PORT);
+
+ if (parentPort != null && parentPort.equals(port)) return null;
+ }
+
+ return node;
+ }
+
+ /**
+ * Checks if the given peer id belongs to an already known root node
+ * or to one of the discovered nodes.
+ *
+ * @param id The peer id. Must not be <code>null</code>.
+ * @return <code>True</code> if the given id belongs to a root node, <code>false</code> otherwise.
+ */
+ private boolean isRootNode(String id) {
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(id);
+
+ boolean isRoot = false;
+
+ if (getService(IPeerModelLookupService.class).lkupPeerModelById(id) != null) {
+ isRoot = true;
+ } else {
+ Map<String, IPeer> peers = Protocol.getLocator().getPeers();
+ if (peers.containsKey(id)) {
+ isRoot = true;
+ }
+ }
+
+ return isRoot;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java
new file mode 100644
index 000000000..8888fa798
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/PeerNode.java
@@ -0,0 +1,405 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2013 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.tcf.locator.nodes;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.core.interfaces.IConnectable;
+import org.eclipse.tcf.te.core.utils.ConnectStateHelper;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.model.ContainerModelNode;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService;
+import org.eclipse.tcf.te.runtime.stepper.utils.StepperHelper;
+import org.eclipse.tcf.te.runtime.utils.StatusHelper;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations;
+
+
+/**
+ * Default peer model implementation.
+ */
+public class PeerNode extends ContainerModelNode implements IPeerNode {
+ // Reference to the parent locator model
+ private final IPeerModel model;
+ // Reference to the peer id (cached for performance optimization)
+ private String peerId;
+
+ /**
+ * Constructor.
+ *
+ * @param model The parent locator model. Must not be <code>null</code>.
+ * @param peer The peer. Must not be <code>null</code>.
+ */
+ public PeerNode(IPeerModel model, IPeer peer) {
+ super();
+
+ Assert.isNotNull(model);
+ this.model = model;
+
+ Assert.isNotNull(peer);
+
+ // Set the default properties before enabling the change events.
+ // The properties changed listeners should not be called from the
+ // constructor.
+ setProperty(IPeerNodeProperties.PROP_INSTANCE, peer);
+ setProperty(IPeerNodeProperties.PROP_CONNECT_STATE, IConnectable.STATE_DISCONNECTED);
+
+ // Initialize the peer id
+ peerId = peer.getID();
+ Assert.isNotNull(peerId);
+
+ // Peer model nodes can change the node parent at any time
+ allowSetParentOnNonNullParent = true;
+ // Peer model nodes does not have a parent by default
+ // -> allow change events with null parent
+ suppressEventsOnNullParent = false;
+
+ // Enable change events
+ setChangeEventsEnabled(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#checkThreadAccess()
+ */
+ @Override
+ protected final boolean checkThreadAccess() {
+ return Protocol.isDispatchThread();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode#getModel()
+ */
+ @Override
+ public IPeerModel getModel() {
+ return (IPeerModel)getAdapter(IPeerModel.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode#getPeer()
+ */
+ @Override
+ public IPeer getPeer() {
+ return (IPeer)getAdapter(IPeer.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode#getPeerId()
+ */
+ @Override
+ public String getPeerId() {
+ return peerId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.model.ModelNode#getName()
+ */
+ @Override
+ public String getName() {
+ return getPeer().getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode#isComplete()
+ */
+ @Override
+ public boolean isComplete() {
+ Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ boolean complete = true;
+
+ // Determine the transport method
+ String transport = getPeer().getTransportName();
+ // If the transport is not set, the peer attributes are incomplete
+ if (transport == null) {
+ complete = false;
+ } else {
+ // For TCP or SSL transport, ATTR_IP_HOST must not be null.
+ String ip = getPeer().getAttributes().get(IPeer.ATTR_IP_HOST);
+ String port = getPeer().getAttributes().get(IPeer.ATTR_IP_PORT);
+ if (("TCP".equals(transport) || "SSL".equals(transport)) && (ip == null || port == null)) { //$NON-NLS-1$ //$NON-NLS-2$
+ complete = false;
+ }
+
+ // Pipe and Loop transport does not require additional attributes
+ }
+
+ return complete;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(final Class adapter) {
+ // NOTE: The getAdapter(...) method can be invoked from many place and
+ // many threads where we cannot control the calls. Therefore, this
+ // method is allowed be called from any thread.
+ final AtomicReference<Object> object = new AtomicReference<Object>();
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ object.set(doGetAdapter(adapter));
+ }
+ };
+
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
+
+ return object.get() != null ? object.get() : super.getAdapter(adapter);
+ }
+
+ /**
+ * Returns an object which is an instance of the given class associated with this object.
+ * Returns <code>null</code> if no such object can be found.
+ * <p>
+ * This method must be called within the TCF dispatch thread!
+ *
+ * @param adapter The adapter class to look up.
+ * @return The adapter or <code>null</code>.
+ */
+ protected Object doGetAdapter(Class<?> adapter) {
+ Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ if (IPeerModel.class.isAssignableFrom(adapter)) {
+ return model;
+ }
+
+ Object peer = getProperty(IPeerNodeProperties.PROP_INSTANCE);
+ // Check with adapter.isAssignableFrom(...) to return the peer instance
+ // correctly if adapter is IPeer.class.
+ if (peer != null && adapter.isAssignableFrom(peer.getClass())) {
+ return peer;
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#toString()
+ */
+ @Override
+ public String toString() {
+ final StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ IPeer peer = getPeer();
+ buffer.append(": id=" + peer.getID()); //$NON-NLS-1$
+ buffer.append(", name=" + peer.getName()); //$NON-NLS-1$
+ }
+ };
+
+ if (Protocol.isDispatchThread()) {
+ runnable.run();
+ }
+ else {
+ Protocol.invokeAndWait(runnable);
+ }
+
+ buffer.append(", " + super.toString()); //$NON-NLS-1$
+ return buffer.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof PeerNode) {
+ return getPeerId().equals(((PeerNode)obj).getPeerId());
+ }
+ return super.equals(obj);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return getPeerId().hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#postSetProperties(java.util.Map)
+ */
+ @Override
+ protected void postSetProperties(Map<String, ?> properties) {
+ Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(properties);
+ Assert.isNotNull(getPeer());
+
+ // New properties applied. Update the element id
+ peerId = getPeer().getID();
+ Assert.isNotNull(peerId);
+
+ super.postSetProperties(properties);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#postSetProperty(java.lang.String, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void postSetProperty(String key, Object value, Object oldValue) {
+ Assert.isTrue(checkThreadAccess(), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(key);
+ Assert.isNotNull(getPeer());
+
+ // If the peer instance changed, update the element id
+ if (IPeerNodeProperties.PROP_INSTANCE.equals(key)) {
+ peerId = getPeer().getID();
+ Assert.isNotNull(peerId);
+ }
+
+ super.postSetProperty(key, value, oldValue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.model.ModelNode#isVisible()
+ */
+ @Override
+ public boolean isVisible() {
+ IPeer peer = getPeer();
+ return peer != null && peer.getAttributes().containsKey(IPeerNodeProperties.PROP_VISIBLE)
+ ? Boolean.valueOf(peer.getAttributes().get(IPeerNodeProperties.PROP_VISIBLE)).booleanValue() : true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.core.interfaces.IConnectable#getConnectState()
+ */
+ @Override
+ public int getConnectState() {
+ final AtomicInteger state = new AtomicInteger(STATE_UNKNOWN);
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ if (getProperty(IPeerNodeProperties.PROP_CONNECT_STATE) != null) {
+ state.set(getIntProperty(IPeerNodeProperties.PROP_CONNECT_STATE));
+ }
+ }
+ });
+ return state.get();
+ }
+
+ @Override
+ public boolean setConnectState(final int newState) {
+ final AtomicBoolean result = new AtomicBoolean(false);
+ if (isConnectStateChangeAllowed(newState)) {
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ result.set(setProperty(IPeerNodeProperties.PROP_CONNECT_STATE, newState));
+ }
+ });
+ }
+ return result.get();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.core.interfaces.IConnectable#changeConnectState(int, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void changeConnectState(final int action, ICallback callback, IProgressMonitor monitor) throws IllegalArgumentException {
+ final int oldState = getConnectState();
+ if (!isConnectStateChangeActionAllowed(action)) {
+ IllegalArgumentException e = new IllegalArgumentException("Cannot change state from '" + ConnectStateHelper.getConnectState(oldState) + "' using action '" + ConnectStateHelper.getConnectState(action) + "'."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (callback != null) {
+ callback.done(this, StatusHelper.getStatus(e));
+ }
+ else {
+ throw e;
+ }
+ }
+
+ String operation = null;
+ int intermediateState = 0;
+
+ switch (action) {
+ case ACTION_CONNECT:
+ operation = IStepperServiceOperations.CONNECT;
+ intermediateState = STATE_CONNECT_SCHEDULED;
+ break;
+ case ACTION_DISCONNECT:
+ operation = IStepperServiceOperations.DISCONNECT;
+ intermediateState = STATE_DISCONNECT_SCHEDULED;
+ break;
+ }
+
+ IStepperOperationService service = StepperHelper.getService(this, operation);
+ if (service != null) {
+ setConnectState(intermediateState);
+ StepperHelper.scheduleStepperJob(this, operation, service, callback, monitor);
+ }
+ else if (callback != null) {
+ callback.done(this, StatusHelper.getStatus(new NullPointerException("Missing stepper operation service for " + getName() + "."))); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ @Override
+ public boolean isConnectStateChangeActionAllowed(int action) {
+ int state = getConnectState();
+ switch (state) {
+ case STATE_CONNECTED:
+ case STATE_CONNECT_SCHEDULED:
+ case STATE_CONNECTING:
+ return isAllowedState(action, ACTION_DISCONNECT);
+ case STATE_DISCONNECTED:
+ return isAllowedState(action, ACTION_CONNECT);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.core.interfaces.IConnectable#isConnectStateChangeAllowed(int)
+ */
+ @Override
+ public boolean isConnectStateChangeAllowed(int newState) {
+ int state = getConnectState();
+ switch (state) {
+ case STATE_CONNECTED:
+ return isAllowedState(newState, STATE_DISCONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING);
+ case STATE_CONNECT_SCHEDULED:
+ return isAllowedState(newState, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING);
+ case STATE_CONNECTING:
+ return isAllowedState(newState, STATE_CONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING, STATE_DISCONNECTED);
+ case STATE_DISCONNECTED:
+ return isAllowedState(newState, STATE_CONNECTED, STATE_CONNECT_SCHEDULED, STATE_CONNECTING);
+ case STATE_DISCONNECT_SCHEDULED:
+ return isAllowedState(newState, STATE_DISCONNECTING, STATE_DISCONNECTED);
+ case STATE_DISCONNECTING:
+ return isAllowedState(newState, STATE_DISCONNECTED);
+ case STATE_UNKNOWN:
+ return isAllowedState(newState, STATE_DISCONNECTED);
+ }
+ return false;
+ }
+
+ private boolean isAllowedState(int state, int... allowedStates) {
+ for (int allowedState : allowedStates) {
+ if (state == allowedState) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
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 ce3aad621..a274f8129 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
@@ -20,11 +20,11 @@ import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
import org.eclipse.tcf.te.runtime.persistence.delegates.GsonMapPersistenceDelegate;
import org.eclipse.tcf.te.tcf.core.peers.Peer;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProvider;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService;
import org.eclipse.tcf.te.tcf.locator.model.Model;
-import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel;
+import org.eclipse.tcf.te.tcf.locator.nodes.PeerNode;
/**
* Peer to string persistence delegate implementation.
@@ -75,8 +75,8 @@ public class GsonPeerPersistenceDelegate extends GsonMapPersistenceDelegate {
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>();
+ else if (context instanceof Class && (((Class<?>)context).isAssignableFrom(IPeerNode.class))) {
+ final AtomicReference<IPeerNode> model = new AtomicReference<IPeerNode>();
Runnable runnable = new Runnable() {
@Override
@@ -85,14 +85,14 @@ public class GsonPeerPersistenceDelegate extends GsonMapPersistenceDelegate {
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) {
+ IPeerNode peerNode = Model.getModel().getService(IPeerModelLookupService.class).lkupPeerModelById(id);
+ if (peerNode == null) {
// Not found in the model -> create a ghost object
- peerModel = new PeerModel(Model.getModel(), peer);
- peerModel.setProperty(IModelNode.PROPERTY_IS_GHOST, true);
+ peerNode = new PeerNode(Model.getModel(), peer);
+ peerNode.setProperty(IModelNode.PROPERTY_IS_GHOST, true);
}
- model.set(peerModel);
+ model.set(peerNode);
}
}
};
@@ -122,11 +122,11 @@ public class GsonPeerPersistenceDelegate extends GsonMapPersistenceDelegate {
if (context instanceof IPeer) {
peer = (IPeer)context;
}
- else if (context instanceof IPeerModel) {
- peer = ((IPeerModel)context).getPeer();
+ else if (context instanceof IPeerNode) {
+ peer = ((IPeerNode)context).getPeer();
}
- else if (context instanceof IPeerModelProvider) {
- peer = ((IPeerModelProvider)context).getPeerModel().getPeer();
+ else if (context instanceof IPeerNodeProvider) {
+ peer = ((IPeerNodeProvider)context).getPeerModel().getPeer();
}
return peer;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractLocatorModelService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractPeerModelService.java
index ea6df29b5..5a3e37ea8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractLocatorModelService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractPeerModelService.java
@@ -11,32 +11,32 @@ package org.eclipse.tcf.te.tcf.locator.services;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelService;
/**
- * Abstract locator model service base implementation.
+ * Abstract peer model service base implementation.
*/
-public abstract class AbstractLocatorModelService extends PlatformObject implements ILocatorModelService {
+public abstract class AbstractPeerModelService extends PlatformObject implements IPeerModelService {
// Reference to the parent locator model
- private final ILocatorModel locatorModel;
+ private final IPeerModel peerModel;
/**
* Constructor.
*
- * @param parentModel The parent locator model instance. Must not be <code>null</code>.
+ * @param parentModel The parent peer model instance. Must not be <code>null</code>.
*/
- public AbstractLocatorModelService(ILocatorModel parentModel) {
+ public AbstractPeerModelService(IPeerModel parentModel) {
Assert.isNotNull(parentModel);
- locatorModel = parentModel;
+ peerModel = parentModel;
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelService#getLocatorModel()
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelService#getPeerModel()
*/
@Override
- public final ILocatorModel getLocatorModel() {
- return locatorModel;
+ public final IPeerModel getPeerModel() {
+ return peerModel;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java
index acffb7f09..9b7c3259f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java
@@ -15,7 +15,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.services.AbstractService;
import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
/**
* Abstract simulator service implementation.
@@ -27,12 +27,12 @@ public abstract class AbstractSimulatorService extends AbstractService implement
*/
@Override
public boolean isValidContext(final Object context, String config) {
- if (context instanceof IPeerModel) {
+ if (context instanceof IPeerNode) {
final AtomicBoolean complete = new AtomicBoolean(false);
Runnable runnable = new Runnable() {
@Override
public void run() {
- complete.set(((IPeerModel)context).isComplete());
+ complete.set(((IPeerNode)context).isComplete());
}
};
Protocol.invokeAndWait(runnable);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelLookupService.java
index d8fb46c8f..b21e4f898 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelLookupService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelLookupService.java
@@ -15,23 +15,23 @@ import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService;
/**
* Default locator model lookup service implementation.
*/
-public class LocatorModelLookupService extends AbstractLocatorModelService implements ILocatorModelLookupService {
+public class PeerModelLookupService extends AbstractPeerModelService implements IPeerModelLookupService {
/**
* Constructor.
*
* @param parentModel The parent locator model instance. Must not be <code>null</code>.
*/
- public LocatorModelLookupService(ILocatorModel parentModel) {
+ public PeerModelLookupService(IPeerModel parentModel) {
super(parentModel);
}
@@ -39,12 +39,12 @@ public class LocatorModelLookupService extends AbstractLocatorModelService imple
* @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelLookupService#lkupPeerModelById(java.lang.String)
*/
@Override
- public IPeerModel lkupPeerModelById(String id) {
+ public IPeerNode lkupPeerModelById(String id) {
Assert.isNotNull(id);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- IPeerModel node = null;
- for (IPeerModel candidate : getLocatorModel().getPeers()) {
+ IPeerNode node = null;
+ for (IPeerNode candidate : getPeerModel().getPeers()) {
IPeer peer = candidate.getPeer();
if (id.equals(peer.getID())) {
node = candidate;
@@ -60,16 +60,16 @@ public class LocatorModelLookupService extends AbstractLocatorModelService imple
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupPeerModelById(java.lang.String, java.lang.String)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupPeerModelById(java.lang.String, java.lang.String)
*/
@Override
- public IPeerModel lkupPeerModelById(String parentId, String id) {
+ public IPeerNode lkupPeerModelById(String parentId, String id) {
Assert.isNotNull(parentId);
Assert.isNotNull(id);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- IPeerModel node = null;
- for (IPeerModel candidate : getLocatorModel().getChildren(parentId)) {
+ IPeerNode node = null;
+ for (IPeerNode candidate : getPeerModel().getChildren(parentId)) {
IPeer peer = candidate.getPeer();
if (id.equals(peer.getID())) {
node = candidate;
@@ -85,75 +85,75 @@ public class LocatorModelLookupService extends AbstractLocatorModelService imple
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupPeerModelByAgentId(java.lang.String)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupPeerModelByAgentId(java.lang.String)
*/
@Override
- public IPeerModel[] lkupPeerModelByAgentId(String agentId) {
+ public IPeerNode[] lkupPeerModelByAgentId(String agentId) {
Assert.isNotNull(agentId);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- List<IPeerModel> nodes = new ArrayList<IPeerModel>();
- for (IPeerModel candidate : getLocatorModel().getPeers()) {
+ List<IPeerNode> nodes = new ArrayList<IPeerNode>();
+ for (IPeerNode candidate : getPeerModel().getPeers()) {
IPeer peer = candidate.getPeer();
if (agentId.equals(peer.getAgentID())) {
nodes.add(candidate);
}
}
- return nodes.toArray(new IPeerModel[nodes.size()]);
+ return nodes.toArray(new IPeerNode[nodes.size()]);
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupPeerModelByAgentId(java.lang.String, java.lang.String)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupPeerModelByAgentId(java.lang.String, java.lang.String)
*/
@Override
- public IPeerModel[] lkupPeerModelByAgentId(String parentId, String agentId) {
+ public IPeerNode[] lkupPeerModelByAgentId(String parentId, String agentId) {
Assert.isNotNull(parentId);
Assert.isNotNull(agentId);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- List<IPeerModel> nodes = new ArrayList<IPeerModel>();
- for (IPeerModel candidate : getLocatorModel().getChildren(parentId)) {
+ List<IPeerNode> nodes = new ArrayList<IPeerNode>();
+ for (IPeerNode candidate : getPeerModel().getChildren(parentId)) {
IPeer peer = candidate.getPeer();
if (agentId.equals(peer.getAgentID())) {
nodes.add(candidate);
}
}
- return nodes.toArray(new IPeerModel[nodes.size()]);
+ return nodes.toArray(new IPeerNode[nodes.size()]);
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupPeerModelByName(java.lang.String)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupPeerModelByName(java.lang.String)
*/
@Override
- public IPeerModel[] lkupPeerModelByName(String name) {
+ public IPeerNode[] lkupPeerModelByName(String name) {
Assert.isNotNull(name);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- List<IPeerModel> nodes = new ArrayList<IPeerModel>();
- for (IPeerModel candidate : getLocatorModel().getPeers()) {
+ List<IPeerNode> nodes = new ArrayList<IPeerNode>();
+ for (IPeerNode candidate : getPeerModel().getPeers()) {
IPeer peer = candidate.getPeer();
if (name.equals(peer.getName())) {
nodes.add(candidate);
}
}
- return nodes.toArray(new IPeerModel[nodes.size()]);
+ return nodes.toArray(new IPeerNode[nodes.size()]);
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupPeerModelBySupportedServices(java.lang.String[], java.lang.String[])
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupPeerModelBySupportedServices(java.lang.String[], java.lang.String[])
*/
@Override
- public IPeerModel[] lkupPeerModelBySupportedServices(String[] expectedLocalServices, String[] expectedRemoteServices) {
+ public IPeerNode[] lkupPeerModelBySupportedServices(String[] expectedLocalServices, String[] expectedRemoteServices) {
Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- ILocatorModel model = getLocatorModel();
- ILocatorModelPeerNodeQueryService queryService = model.getService(ILocatorModelPeerNodeQueryService.class);
+ IPeerModel model = getPeerModel();
+ IPeerModelQueryService queryService = model.getService(IPeerModelQueryService.class);
- List<IPeerModel> nodes = new ArrayList<IPeerModel>();
- for (IPeerModel candidate : model.getPeers()) {
+ List<IPeerNode> nodes = new ArrayList<IPeerNode>();
+ for (IPeerNode candidate : model.getPeers()) {
String services = queryService.queryLocalServices(candidate);
boolean matchesExpectations = true;
@@ -193,33 +193,30 @@ public class LocatorModelLookupService extends AbstractLocatorModelService imple
if (matchesExpectations) nodes.add(candidate);
}
- return nodes.toArray(new IPeerModel[nodes.size()]);
+ return nodes.toArray(new IPeerNode[nodes.size()]);
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupMatchingStaticPeerModels(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupMatchingStaticPeerModels(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode)
*/
@Override
- public IPeerModel[] lkupMatchingStaticPeerModels(IPeerModel peerNode) {
+ public IPeerNode[] lkupMatchingStaticPeerModels(IPeerNode peerNode) {
Assert.isNotNull(peerNode);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
return lkupMatchingStaticPeerModels(peerNode.getPeer());
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService#lkupMatchingStaticPeerModels(org.eclipse.tcf.protocol.IPeer)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService#lkupMatchingStaticPeerModels(org.eclipse.tcf.protocol.IPeer)
*/
@Override
- public IPeerModel[] lkupMatchingStaticPeerModels(IPeer peer) {
+ public IPeerNode[] lkupMatchingStaticPeerModels(IPeer peer) {
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- List<IPeerModel> nodes = new ArrayList<IPeerModel>();
+ List<IPeerNode> nodes = new ArrayList<IPeerNode>();
if (peer != null) {
- for (IPeerModel candidate : getLocatorModel().getPeers()) {
- // Look only at the static peers here
- if (!candidate.isStatic()) continue;
-
+ for (IPeerNode candidate : getPeerModel().getPeers()) {
// If the agent id is available, match up the agent id first.
if (candidate.getPeer().getAgentID() != null && candidate.getPeer().getAgentID().equals(peer.getAgentID())) {
nodes.add(candidate);
@@ -245,6 +242,6 @@ public class LocatorModelLookupService extends AbstractLocatorModelService imple
}
}
- return nodes.toArray(new IPeerModel[nodes.size()]);
+ return nodes.toArray(new IPeerNode[nodes.size()]);
}
}
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/PeerModelQueryService.java
index 356f3536a..51f3cd282 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/PeerModelQueryService.java
@@ -23,31 +23,31 @@ import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.interfaces.IConditionTester;
import org.eclipse.tcf.te.tcf.core.Tcf;
import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService;
/**
* Default locator model peer node query service implementation.
*/
-public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelService implements ILocatorModelPeerNodeQueryService {
+public class PeerModelQueryService extends AbstractPeerModelService implements IPeerModelQueryService {
/**
* Constructor.
*
* @param parentModel The parent locator model instance. Must not be <code>null</code>.
*/
- public LocatorModelPeerNodeQueryService(ILocatorModel parentModel) {
+ public PeerModelQueryService(IPeerModel parentModel) {
super(parentModel);
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService#queryLocalServices(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService#queryLocalServices(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode)
*/
@Override
- public String queryLocalServices(final IPeerModel node) {
+ public String queryLocalServices(final IPeerNode node) {
Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(node);
@@ -56,7 +56,7 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
Protocol.invokeAndWait(new Runnable() {
@Override
public void run() {
- services.set(node.getStringProperty(IPeerModelProperties.PROP_LOCAL_SERVICES));
+ services.set(node.getStringProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES));
}
});
@@ -75,7 +75,7 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
@Override
public void doneQueryServices(Throwable error) {
if (error == null) {
- services.set(node.getStringProperty(IPeerModelProperties.PROP_LOCAL_SERVICES));
+ services.set(node.getStringProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES));
}
completed.set(true);
}
@@ -104,10 +104,10 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService#queryRemoteServices(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService#queryRemoteServices(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode)
*/
@Override
- public String queryRemoteServices(final IPeerModel node) {
+ public String queryRemoteServices(final IPeerNode node) {
Assert.isTrue(!Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(node);
@@ -116,7 +116,7 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
Protocol.invokeAndWait(new Runnable() {
@Override
public void run() {
- services.set(node.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES));
+ services.set(node.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES));
}
});
@@ -135,7 +135,7 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
@Override
public void doneQueryServices(Throwable error) {
if (error == null) {
- services.set(node.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES));
+ services.set(node.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES));
}
completed.set(true);
}
@@ -163,13 +163,13 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
return services.get();
}
- /* default */ final Map<IPeerModel, List<DoneQueryServices>> serviceQueriesInProgress = new HashMap<IPeerModel, List<DoneQueryServices>>();
+ /* default */ final Map<IPeerNode, List<DoneQueryServices>> serviceQueriesInProgress = new HashMap<IPeerNode, List<DoneQueryServices>>();
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService#queryServicesAsync(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService.DoneQueryServices)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService#queryServicesAsync(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService.DoneQueryServices)
*/
@Override
- public void queryServicesAsync(final IPeerModel node, final DoneQueryServices done) {
+ public void queryServicesAsync(final IPeerNode node, final DoneQueryServices done) {
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
Assert.isNotNull(node);
Assert.isNotNull(done);
@@ -204,8 +204,8 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
};
// Do not try to open a channel to peers known to be unreachable
- int state = node.getIntProperty(IPeerModelProperties.PROP_STATE);
- if (state == IPeerModelProperties.STATE_ERROR || state == IPeerModelProperties.STATE_NOT_REACHABLE || !node.isComplete()) {
+ int state = node.getIntProperty(IPeerNodeProperties.PROP_STATE);
+ if (state == IPeerNodeProperties.STATE_ERROR || state == IPeerNodeProperties.STATE_NOT_REACHABLE || !node.isComplete()) {
innerDone.doneQueryServices(null);
return;
}
@@ -234,7 +234,7 @@ public class LocatorModelPeerNodeQueryService extends AbstractLocatorModelServic
Collections.sort(remoteServices);
// Update the services
- ILocatorModelUpdateService updateService = node.getModel().getService(ILocatorModelUpdateService.class);
+ IPeerModelUpdateService updateService = node.getModel().getService(IPeerModelUpdateService.class);
updateService.updatePeerServices(node, localServices, remoteServices);
// Invoke the callback
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelRefreshService.java
index 2894548ce..ba31a6891 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelRefreshService.java
@@ -44,31 +44,29 @@ import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
import org.eclipse.tcf.te.tcf.core.peers.Peer;
import org.eclipse.tcf.te.tcf.locator.ScannerRunnable;
import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
import org.eclipse.tcf.te.tcf.locator.interfaces.preferences.IPreferenceKeys;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelLookupService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService;
import org.eclipse.tcf.te.tcf.locator.model.ModelLocationUtil;
-import org.eclipse.tcf.te.tcf.locator.nodes.ConnectablePeerModel;
-import org.eclipse.tcf.te.tcf.locator.nodes.LocatorModel;
-import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel;
+import org.eclipse.tcf.te.tcf.locator.nodes.PeerNode;
import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector;
/**
* Default locator model refresh service implementation.
*/
-public class LocatorModelRefreshService extends AbstractLocatorModelService implements ILocatorModelRefreshService {
+public class PeerModelRefreshService extends AbstractPeerModelService implements IPeerModelRefreshService {
/**
* Constructor.
*
* @param parentModel The parent locator model instance. Must not be <code>null</code>.
*/
- public LocatorModelRefreshService(ILocatorModel parentModel) {
+ public PeerModelRefreshService(IPeerModel parentModel) {
super(parentModel);
}
@@ -84,21 +82,21 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
Protocol.invokeLater(new Runnable() {
@Override
public void run() {
- callback.done(LocatorModelRefreshService.this, Status.OK_STATUS);
+ callback.done(PeerModelRefreshService.this, Status.OK_STATUS);
}
});
}
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService#refresh(org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService#refresh(org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
*/
@Override
public void refresh(final ICallback callback) {
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
// Get the parent locator model
- ILocatorModel model = getLocatorModel();
+ IPeerModel model = getPeerModel();
// If the parent model is already disposed, the service will drop out immediately
if (model.isDisposed()) {
@@ -113,27 +111,27 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
}
// Get the list of old children (update node instances where possible)
- final List<IPeerModel> oldChildren = new ArrayList<IPeerModel>(Arrays.asList(model.getPeers()));
+ final List<IPeerNode> oldChildren = new ArrayList<IPeerNode>(Arrays.asList(model.getPeers()));
// Refresh the static peer definitions
refreshStaticPeers(oldChildren, model);
- // Get the locator service
- ILocator locatorService = Protocol.getLocator();
- if (locatorService != null) {
- // Check for the locator listener to be created and registered
- if (model instanceof LocatorModel) {
- ((LocatorModel)model).checkLocatorListener();
- }
- // Get the map of peers known to the locator service.
- Map<String, IPeer> peers = locatorService.getPeers();
- // Process the peers
- processPeers(peers, oldChildren, model);
- }
+// // Get the locator service
+// ILocator locatorService = Protocol.getLocator();
+// if (locatorService != null) {
+// // Check for the locator listener to be created and registered
+// if (model instanceof PeerModel) {
+// ((PeerModel)model).checkLocatorListener();
+// }
+// // Get the map of peers known to the locator service.
+// Map<String, IPeer> peers = locatorService.getPeers();
+// // Process the peers
+// processPeers(peers, oldChildren, model);
+// }
// If there are remaining old children, remove them from the model (non-recursive)
- for (IPeerModel oldChild : oldChildren) {
- model.getService(ILocatorModelUpdateService.class).remove(oldChild);
+ for (IPeerNode oldChild : oldChildren) {
+ model.getService(IPeerModelUpdateService.class).remove(oldChild);
}
// Invoke the callback
@@ -147,7 +145,7 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
* @param oldChildren The list of old children. Must not be <code>null</code>.
* @param model The locator model. Must not be <code>null</code>.
*/
- protected void processPeers(Map<String, IPeer> peers, List<IPeerModel> oldChildren, ILocatorModel model) {
+ protected void processPeers(Map<String, IPeer> peers, List<IPeerNode> oldChildren, IPeerModel model) {
Assert.isNotNull(peers);
Assert.isNotNull(oldChildren);
Assert.isNotNull(model);
@@ -156,35 +154,25 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
// Get the peer instance for the current peer id
IPeer peer = entry.getValue();
// Try to find an existing peer node first
- IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(entry.getKey());
+ IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(entry.getKey());
// And create a new one if we cannot find it
if (peerNode == null) {
- String value = peer.getAttributes().get("static.transient"); //$NON-NLS-1$
- if (value != null && Boolean.parseBoolean(value.trim())) {
- peerNode = new ConnectablePeerModel(model, peer);
- }
- else {
- peerNode = new PeerModel(model, peer);
- }
+ peerNode = new PeerNode(model, peer);
}
else {
oldChildren.remove(peerNode);
}
if (peerNode.getPeer() != peer) {
- if (!peerNode.isStatic()) {
- peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer);
- } else {
String value = peerNode.getPeer().getAttributes().get(IPersistableNodeProperties.PROPERTY_URI);
URI uri = value != null ? URI.create(value) : null;
File file = uri != null && "file".equals(uri.getScheme()) ? new File(uri.normalize()) : null; //$NON-NLS-1$
if (file != null && !file.exists()) {
- peerNode.setProperty(IPeerModelProperties.PROP_INSTANCE, peer);
+ peerNode.setProperty(IPeerNodeProperties.PROP_INSTANCE, peer);
} else {
// Merge user configured properties between the peers
- model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, peer, false);
+ model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, peer, false);
}
- }
}
// Validate the peer node before adding
@@ -193,15 +181,14 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
// There is still the chance that the node we add is a static node and
// there exist an dynamically discovered node with a different id but
// for the same peer. Do this check only if the peer to add is a static one.
- if (peerNode.isStatic()) {
- IPeerModel toRemove = null;
- for (IPeerModel candidate : model.getPeers()) {
- if (candidate.isStatic() || candidate.equals(peerNode))continue;
+ IPeerNode toRemove = null;
+ for (IPeerNode candidate : model.getPeers()) {
+ if (candidate.equals(peerNode))continue;
String peerID = peerNode.getPeerId();
String clientID = candidate.getPeer().getAttributes().get("ClientID"); //$NON-NLS-1$
if (clientID != null && clientID.equals(peerID)) {
// Merge user configured properties between the peers
- model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(candidate, peerNode.getPeer(), true);
+ model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(candidate, peerNode.getPeer(), true);
peerNode = null;
break;
}
@@ -215,13 +202,13 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
// Same pipe -> same node
if (name1 != null && name1.equals(name2)) {
// Merge user configured properties between the peers
- model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true);
+ model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true);
toRemove = candidate;
break;
}
} else if ("Loop".equals(candidate.getPeer().getTransportName())) { //$NON-NLS-1$
// Merge user configured properties between the peers
- model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true);
+ model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true);
toRemove = candidate;
break;
} else {
@@ -235,7 +222,7 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
if (port1 != null && port1.equals(port2)) {
// Merge user configured properties between the peers
- model.getService(ILocatorModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true);
+ model.getService(IPeerModelUpdateService.class).mergeUserDefinedAttributes(peerNode, candidate.getPeer(), true);
toRemove = candidate;
break;
}
@@ -245,14 +232,13 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
}
if (toRemove != null) {
- model.getService(ILocatorModelUpdateService.class).remove(toRemove);
+ model.getService(IPeerModelUpdateService.class).remove(toRemove);
toRemove = null;
}
- }
if (peerNode != null) {
// Add the peer node to model
- model.getService(ILocatorModelUpdateService.class).add(peerNode);
+ model.getService(IPeerModelUpdateService.class).add(peerNode);
// And schedule for immediate status update
Runnable runnable = new ScannerRunnable(model.getScanner(), peerNode);
Protocol.invokeLater(runnable);
@@ -264,7 +250,7 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
private final AtomicBoolean REFRESH_STATIC_PEERS_GUARD = new AtomicBoolean(false);
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService#refreshStaticPeers()
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService#refreshStaticPeers()
*/
@Override
public void refreshStaticPeers() {
@@ -278,7 +264,7 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
REFRESH_STATIC_PEERS_GUARD.set(true);
// Get the parent locator model
- ILocatorModel model = getLocatorModel();
+ IPeerModel model = getPeerModel();
// If the parent model is already disposed, the service will drop out immediately
if (model.isDisposed()) {
@@ -286,7 +272,7 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
}
// Get the list of old children (update node instances where possible)
- final List<IPeerModel> oldChildren = new ArrayList<IPeerModel>(Arrays.asList(model.getPeers()));
+ final List<IPeerNode> oldChildren = new ArrayList<IPeerNode>(Arrays.asList(model.getPeers()));
// Refresh the static peer definitions
refreshStaticPeers(oldChildren, model);
@@ -300,7 +286,7 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
* @param oldChildren The list of old children. Must not be <code>null</code>.
* @param model The locator model. Must not be <code>null</code>.
*/
- protected void refreshStaticPeers(List<IPeerModel> oldChildren, ILocatorModel model) {
+ protected void refreshStaticPeers(List<IPeerNode> oldChildren, IPeerModel model) {
Assert.isNotNull(oldChildren);
Assert.isNotNull(model);
@@ -367,19 +353,19 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
}
// If the redirect property is not set, create the peer right away
- if (attrs.get(IPeerModelProperties.PROP_REDIRECT_PROXY) == null) {
+ if (attrs.get(IPeerNodeProperties.PROP_REDIRECT_PROXY) == null) {
// Construct the peer from the attributes
IPeer peer = new Peer(attrs);
// Add the constructed peer to the peers map
peers.put(peer.getID(), peer);
} else {
// Try to get the peer proxy
- String proxyId = attrs.get(IPeerModelProperties.PROP_REDIRECT_PROXY);
+ String proxyId = attrs.get(IPeerNodeProperties.PROP_REDIRECT_PROXY);
IPeer proxy = peers.get(proxyId);
if (proxy == null) {
- IPeerModel peerModel = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(proxyId);
- if (peerModel != null) {
- proxy = peerModel.getPeer();
+ IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(proxyId);
+ if (peerNode != null) {
+ proxy = peerNode.getPeer();
}
}
@@ -403,12 +389,12 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
// Process postponed peers if there are any
if (!postponed.isEmpty()) {
for (Map<String, String> attrs : postponed) {
- String proxyId = attrs.get(IPeerModelProperties.PROP_REDIRECT_PROXY);
+ String proxyId = attrs.get(IPeerNodeProperties.PROP_REDIRECT_PROXY);
IPeer proxy = proxyId != null ? peers.get(proxyId) : null;
if (proxy == null) {
- IPeerModel peerModel = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(proxyId);
- if (peerModel != null) {
- proxy = peerModel.getPeer();
+ IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(proxyId);
+ if (peerNode != null) {
+ proxy = peerNode.getPeer();
}
}
@@ -419,7 +405,7 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
peers.put(redirector.getID(), redirector);
} else {
// Proxy not available -> reset redirection
- attrs.remove(IPeerModelProperties.PROP_REDIRECT_PROXY);
+ attrs.remove(IPeerNodeProperties.PROP_REDIRECT_PROXY);
// Construct the peer from the attributes
IPeer peer = new Peer(attrs);
// Add the constructed peer to the peers map
@@ -441,16 +427,16 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
}
// Get the peers peer model object
- IPeerModel peerModel = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(entry.getKey());
- Assert.isNotNull(peerModel);
+ IPeerNode peerNode = model.getService(IPeerModelLookupService.class).lkupPeerModelById(entry.getKey());
+ Assert.isNotNull(peerNode);
// The peer is a peer redirector -> get the proxy peer id and proxy peer model
String proxyPeerId = ((PeerRedirector)peer).getParent().getID();
- IPeerModel proxy = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(proxyPeerId);
+ IPeerNode proxy = model.getService(IPeerModelLookupService.class).lkupPeerModelById(proxyPeerId);
Assert.isNotNull(proxy);
- peerModel.setParent(proxy);
- model.getService(ILocatorModelUpdateService.class).addChild(peerModel);
+ peerNode.setParent(proxy);
+ model.getService(IPeerModelUpdateService.class).addChild(peerNode);
}
}
}
@@ -493,10 +479,10 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
/* default */ final List<ICallback> refreshAgentIDCallbacks = new ArrayList<ICallback>();
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService#refreshAgentIDs(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel[], org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelRefreshService#refreshAgentIDs(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode[], org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
*/
@Override
- public void refreshAgentIDs(IPeerModel[] nodes, final ICallback callback) {
+ public void refreshAgentIDs(IPeerNode[] nodes, final ICallback callback) {
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
// This method might be called reentrant while processing. Add
@@ -508,7 +494,7 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
refreshAgentIDCallbacks.add(callback);
// Get the parent locator model
- ILocatorModel model = getLocatorModel();
+ IPeerModel model = getPeerModel();
// If the parent model is already disposed, the service will drop out immediately
if (model.isDisposed()) {
@@ -530,11 +516,11 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
}, new CallbackInvocationDelegate());
// Make a copy of the current list of static peers before processing
- List<IPeerModel> nodesToProcess = new ArrayList<IPeerModel>(Arrays.asList(nodes != null ? nodes : model.getPeers()));
+ List<IPeerNode> nodesToProcess = new ArrayList<IPeerNode>(Arrays.asList(nodes != null ? nodes : model.getPeers()));
// Loop the list of static peers and try to get the agent ID
- for (IPeerModel node : nodesToProcess) {
+ for (IPeerNode node : nodesToProcess) {
// If not static or not complete --> ignore
- if (!node.isStatic() || !node.isComplete()) continue;
+ if (!node.isComplete()) continue;
// Refresh the agent ID
refreshAgentID(node, new AsyncCallbackCollector.SimpleCollectorCallback(collector));
}
@@ -549,18 +535,11 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
* @param node The peer model node. Must not be <code>null</code>.
* @param callback The callback. Must not be <code>null</code>.
*/
- protected void refreshAgentID(final IPeerModel node, final ICallback callback) {
+ protected void refreshAgentID(final IPeerNode node, final ICallback callback) {
Assert.isNotNull(node);
Assert.isNotNull(callback);
- // If the peer is not static or associated with an remote peer
- // --> skip the node
- if (!node.isStatic() || node.isRemote()) {
- callback.done(LocatorModelRefreshService.this, Status.OK_STATUS);
- return;
- }
-
- Assert.isTrue(node.getPeer() instanceof Peer);
+ if (!(node.getPeer() instanceof Peer)) return;
// Try to open a channel to the node
Map<String, Boolean> flags = new HashMap<String, Boolean>();
@@ -588,30 +567,30 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl
// Remove the old agent ID
Map<String, String> attrs = new HashMap<String, String>(channel.getRemotePeer().getAttributes());
attrs.remove(IPeer.ATTR_AGENT_ID);
- node.setProperty(IPeerModelProperties.PROP_INSTANCE, new Peer(attrs));
+ node.setProperty(IPeerNodeProperties.PROP_INSTANCE, new Peer(attrs));
}
} else if (node.getPeer().getAgentID() == null || !agentID.equals(node.getPeer().getAgentID())){
// Set the new agent ID
Map<String, String> attrs = new HashMap<String, String>(channel.getRemotePeer().getAttributes());
attrs.put(IPeer.ATTR_AGENT_ID, agentID);
- node.setProperty(IPeerModelProperties.PROP_INSTANCE, new Peer(attrs));
+ node.setProperty(IPeerNodeProperties.PROP_INSTANCE, new Peer(attrs));
}
// Invoke the callback
- callback.done(LocatorModelRefreshService.this, Status.OK_STATUS);
+ callback.done(PeerModelRefreshService.this, Status.OK_STATUS);
}
});
} else {
// Close the channel
Tcf.getChannelManager().closeChannel(channel);
// Invoke the callback
- callback.done(LocatorModelRefreshService.this, Status.OK_STATUS);
+ callback.done(PeerModelRefreshService.this, Status.OK_STATUS);
}
} else {
// Close the channel in any case
if (channel != null) Tcf.getChannelManager().closeChannel(channel);
// Invoke the callback
- callback.done(LocatorModelRefreshService.this, Status.OK_STATUS);
+ callback.done(PeerModelRefreshService.this, Status.OK_STATUS);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelUpdateService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelUpdateService.java
index f55587249..0f4684ca4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelUpdateService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/PeerModelUpdateService.java
@@ -21,24 +21,24 @@ import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableNodeProperties;
import org.eclipse.tcf.te.tcf.core.peers.Peer;
import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService;
import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector;
/**
* Default locator model update service implementation.
*/
-public class LocatorModelUpdateService extends AbstractLocatorModelService implements ILocatorModelUpdateService {
+public class PeerModelUpdateService extends AbstractPeerModelService implements IPeerModelUpdateService {
/**
* Constructor.
*
* @param parentModel The parent locator model instance. Must not be <code>null</code>.
*/
- public LocatorModelUpdateService(ILocatorModel parentModel) {
+ public PeerModelUpdateService(IPeerModel parentModel) {
super(parentModel);
}
@@ -46,21 +46,21 @@ public class LocatorModelUpdateService extends AbstractLocatorModelService imple
* @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelUpdateService#add(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel)
*/
@Override
- public void add(final IPeerModel peer) {
+ public void add(final IPeerNode peer) {
Assert.isNotNull(peer);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- Map<String, IPeerModel> peers = (Map<String, IPeerModel>)getLocatorModel().getAdapter(Map.class);
+ Map<String, IPeerNode> peers = (Map<String, IPeerNode>)getPeerModel().getAdapter(Map.class);
Assert.isNotNull(peers);
peers.put(peer.getPeerId(), peer);
- final IModelListener[] listeners = getLocatorModel().getListener();
+ final IModelListener[] listeners = getPeerModel().getListener();
if (listeners.length > 0) {
Protocol.invokeLater(new Runnable() {
@Override
public void run() {
for (IModelListener listener : listeners) {
- listener.locatorModelChanged(getLocatorModel(), peer, true);
+ listener.locatorModelChanged(getPeerModel(), peer, true);
}
}
});
@@ -71,23 +71,23 @@ public class LocatorModelUpdateService extends AbstractLocatorModelService imple
* @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelUpdateService#remove(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel)
*/
@Override
- public void remove(final IPeerModel peer) {
+ public void remove(final IPeerNode peer) {
Assert.isNotNull(peer);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- Map<String, IPeerModel> peers = (Map<String, IPeerModel>)getLocatorModel().getAdapter(Map.class);
+ Map<String, IPeerNode> peers = (Map<String, IPeerNode>)getPeerModel().getAdapter(Map.class);
Assert.isNotNull(peers);
peers.remove(peer.getPeerId());
- getLocatorModel().setChildren(peer.getPeerId(), null);
+ getPeerModel().setChildren(peer.getPeerId(), null);
- final IModelListener[] listeners = getLocatorModel().getListener();
+ final IModelListener[] listeners = getPeerModel().getListener();
if (listeners.length > 0) {
Protocol.invokeLater(new Runnable() {
@Override
public void run() {
for (IModelListener listener : listeners) {
- listener.locatorModelChanged(getLocatorModel(), peer, false);
+ listener.locatorModelChanged(getPeerModel(), peer, false);
}
}
});
@@ -98,12 +98,12 @@ public class LocatorModelUpdateService extends AbstractLocatorModelService imple
* @see org.eclipse.tcf.te.tcf.locator.core.interfaces.services.ILocatorModelUpdateService#updatePeerServices(org.eclipse.tcf.te.tcf.locator.core.interfaces.nodes.IPeerModel, java.util.Collection, java.util.Collection)
*/
@Override
- public void updatePeerServices(IPeerModel peerNode, Collection<String> localServices, Collection<String> remoteServices) {
+ public void updatePeerServices(IPeerNode peerNode, Collection<String> localServices, Collection<String> remoteServices) {
Assert.isNotNull(peerNode);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- peerNode.setProperty(IPeerModelProperties.PROP_LOCAL_SERVICES, localServices != null ? makeString(localServices) : null);
- peerNode.setProperty(IPeerModelProperties.PROP_REMOTE_SERVICES, remoteServices != null ? makeString(remoteServices) : null);
+ peerNode.setProperty(IPeerNodeProperties.PROP_LOCAL_SERVICES, localServices != null ? makeString(localServices) : null);
+ peerNode.setProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES, remoteServices != null ? makeString(remoteServices) : null);
}
/**
@@ -124,15 +124,15 @@ public class LocatorModelUpdateService extends AbstractLocatorModelService imple
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService#addChild(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService#addChild(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode)
*/
@Override
- public void addChild(final IPeerModel child) {
+ public void addChild(final IPeerNode child) {
Assert.isNotNull(child);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
// Determine the parent node
- final IPeerModel parent = child.getParent(IPeerModel.class);
+ final IPeerNode parent = child.getParent(IPeerNode.class);
if (parent == null) return;
// Determine the peer id of the parent
@@ -140,10 +140,10 @@ public class LocatorModelUpdateService extends AbstractLocatorModelService imple
Assert.isNotNull(parentPeerId);
// Get the list of existing children
- List<IPeerModel> children = new ArrayList<IPeerModel>(getLocatorModel().getChildren(parentPeerId));
+ List<IPeerNode> children = new ArrayList<IPeerNode>(getPeerModel().getChildren(parentPeerId));
if (!children.contains(child)) {
children.add(child);
- getLocatorModel().setChildren(parentPeerId, children);
+ getPeerModel().setChildren(parentPeerId, children);
}
// Notify listeners
@@ -151,15 +151,15 @@ public class LocatorModelUpdateService extends AbstractLocatorModelService imple
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService#removeChild(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService#removeChild(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode)
*/
@Override
- public void removeChild(final IPeerModel child) {
+ public void removeChild(final IPeerNode child) {
Assert.isNotNull(child);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
// Determine the parent node
- final IPeerModel parent = child.getParent(IPeerModel.class);
+ final IPeerNode parent = child.getParent(IPeerNode.class);
if (parent == null) return;
// Determine the peer id of the parent
@@ -167,10 +167,10 @@ public class LocatorModelUpdateService extends AbstractLocatorModelService imple
Assert.isNotNull(parentPeerId);
// Get the list of existing children
- List<IPeerModel> children = new ArrayList<IPeerModel>(getLocatorModel().getChildren(parentPeerId));
+ List<IPeerNode> children = new ArrayList<IPeerNode>(getPeerModel().getChildren(parentPeerId));
if (children.contains(child)) {
children.remove(child);
- getLocatorModel().setChildren(parentPeerId, children);
+ getPeerModel().setChildren(parentPeerId, children);
}
// Notify listeners
@@ -178,10 +178,10 @@ public class LocatorModelUpdateService extends AbstractLocatorModelService imple
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService#mergeUserDefinedAttributes(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel, org.eclipse.tcf.protocol.IPeer, boolean)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelUpdateService#mergeUserDefinedAttributes(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, org.eclipse.tcf.protocol.IPeer, boolean)
*/
@Override
- public void mergeUserDefinedAttributes(IPeerModel node, IPeer peer, boolean force) {
+ public void mergeUserDefinedAttributes(IPeerNode node, IPeer peer, boolean force) {
Assert.isNotNull(node);
Assert.isNotNull(peer);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java
index 70fabdaaf..f1ff8984e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java
@@ -12,7 +12,7 @@ package org.eclipse.tcf.te.tcf.locator.services;
import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.te.core.interfaces.IConnectable;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations;
/**
@@ -40,7 +40,7 @@ public class StepperOperationService extends org.eclipse.tcf.te.runtime.stepper.
*/
@Override
public String getStepGroupId(Object context, String operation) {
- Assert.isTrue(context instanceof IPeerModel);
+ Assert.isTrue(context instanceof IPeerNode);
if (IStepperServiceOperations.CONNECT.equals(operation)) {
return "org.eclipse.tcf.te.tcf.locator.connectStepGroup"; //$NON-NLS-1$
@@ -57,13 +57,13 @@ public class StepperOperationService extends org.eclipse.tcf.te.runtime.stepper.
*/
@Override
public String getStepGroupName(Object context, String operation) {
- Assert.isTrue(context instanceof IPeerModel);
+ Assert.isTrue(context instanceof IPeerNode);
if (IStepperServiceOperations.CONNECT.equals(operation)) {
- return "Connect "+((IPeerModel)context).getName(); //$NON-NLS-1$
+ return "Connect "+((IPeerNode)context).getName(); //$NON-NLS-1$
}
if (IStepperServiceOperations.DISCONNECT.equals(operation)) {
- return "Disconnect "+((IPeerModel)context).getName(); //$NON-NLS-1$
+ return "Disconnect "+((IPeerNode)context).getName(); //$NON-NLS-1$
}
return null;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/selection/RuntimeServiceContextFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/selection/RuntimeServiceContextFilter.java
index e23d2f3d6..9cf2ffa15 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/selection/RuntimeServiceContextFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/selection/RuntimeServiceContextFilter.java
@@ -17,8 +17,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService;
/**
@@ -51,19 +51,19 @@ public class RuntimeServiceContextFilter implements IDefaultContextService.ICont
}
/* (non-Javadoc)
- * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService.IContextFilter#select(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
+ * @see org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService.IContextFilter#select(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode)
*/
@Override
- public boolean select(final IPeerModel peerModel) {
- Assert.isNotNull(peerModel);
+ public boolean select(final IPeerNode peerNode) {
+ Assert.isNotNull(peerNode);
- final IPeer peer = peerModel.getPeer();
+ final IPeer peer = peerNode.getPeer();
final AtomicBoolean result = new AtomicBoolean(false);
Protocol.invokeAndWait(new Runnable() {
@Override
public void run() {
List<String> list;
- String services = peerModel.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES);
+ String services = peerNode.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES);
if (services != null) {
list = Arrays.asList(services.split(",\\s*")); //$NON-NLS-1$
boolean containsAll = true;
@@ -78,7 +78,7 @@ public class RuntimeServiceContextFilter implements IDefaultContextService.ICont
}
if (useDisconnectedContexts) {
- services = peer.getAttributes().get(IPeerModelProperties.PROP_OFFLINE_SERVICES);
+ services = peer.getAttributes().get(IPeerNodeProperties.PROP_OFFLINE_SERVICES);
list = services != null ? Arrays.asList(services.split(",\\s*")) : Collections.EMPTY_LIST; //$NON-NLS-1$
boolean containsAll = true;
for (String serviceName : serviceNames) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerModelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerNodeStep.java
index 3effd5fbf..98fdd69c4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerModelStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/AbstractPeerNodeStep.java
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.tcf.locator.steps;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.core.steps.AbstractPeerStep;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-
-/**
- * Abstract peer model context step
- */
-public abstract class AbstractPeerModelStep extends AbstractPeerStep {
-
- /**
- * Returns the active peer model context that is currently used.
- *
- * @param context The step context. Must not be <code>null</code>.
- * @param data The data giving object. Must not be <code>null</code>.
- * @param fullQualifiedId The full qualfied id for this step. Must not be <code>null</code>.
- * @return The active peer model context.
- */
- protected IPeerModel getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) {
- Object activeContext = getActiveContext(context, data, fullQualifiedId);
- IPeerModel peerModel = null;
- if (activeContext instanceof IPeerModel)
- return (IPeerModel)activeContext;
- if (activeContext instanceof IAdaptable)
- peerModel = (IPeerModel)((IAdaptable)activeContext).getAdapter(IPeerModel.class);
- if (peerModel == null)
- peerModel = (IPeerModel)Platform.getAdapterManager().getAdapter(activeContext, IPeerModel.class);
-
- return peerModel;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2013 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.tcf.locator.steps;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.tcf.core.steps.AbstractPeerStep;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+
+/**
+ * Abstract peer model context step
+ */
+public abstract class AbstractPeerNodeStep extends AbstractPeerStep {
+
+ /**
+ * Returns the active peer model context that is currently used.
+ *
+ * @param context The step context. Must not be <code>null</code>.
+ * @param data The data giving object. Must not be <code>null</code>.
+ * @param fullQualifiedId The full qualfied id for this step. Must not be <code>null</code>.
+ * @return The active peer model context.
+ */
+ protected IPeerNode getActivePeerModelContext(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId) {
+ Object activeContext = getActiveContext(context, data, fullQualifiedId);
+ IPeerNode peerNode = null;
+ if (activeContext instanceof IPeerNode)
+ return (IPeerNode)activeContext;
+ if (activeContext instanceof IAdaptable)
+ peerNode = (IPeerNode)((IAdaptable)activeContext).getAdapter(IPeerNode.class);
+ if (peerNode == null)
+ peerNode = (IPeerNode)Platform.getAdapterManager().getAdapter(activeContext, IPeerNode.class);
+
+ return peerNode;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/CheckServiceStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/CheckServiceStep.java
index 69b562ec4..2af3fb0ab 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/CheckServiceStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/CheckServiceStep.java
@@ -27,12 +27,12 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
import org.eclipse.tcf.te.tcf.core.interfaces.steps.ITcfStepAttributes;
import org.eclipse.tcf.te.tcf.locator.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
/**
* Check service step implementation.
*/
-public class CheckServiceStep extends AbstractPeerModelStep {
+public class CheckServiceStep extends AbstractPeerNodeStep {
public static final String PARAMETER_REMOTE_SERVICE = "remoteService"; //$NON-NLS-1$
public static final String PARAMETER_LOCAL_SERVICE = "localService"; //$NON-NLS-1$
@@ -88,7 +88,7 @@ public class CheckServiceStep extends AbstractPeerModelStep {
}
String offlineService = getParameters().get(PARAMETER_OFFLINE_SERVICE);
- String services = getActivePeerContext(context, data, fullQualifiedId).getAttributes().get(IPeerModelProperties.PROP_OFFLINE_SERVICES);
+ String services = getActivePeerContext(context, data, fullQualifiedId).getAttributes().get(IPeerNodeProperties.PROP_OFFLINE_SERVICES);
List<String> list = services != null ? Arrays.asList(services.split(",\\s*")) : Collections.EMPTY_LIST; //$NON-NLS-1$
if (offlineService != null && !list.contains(offlineService)) {
throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing offline service '" + offlineService + "'")); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java
index 023622795..df40c6157 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java
@@ -23,7 +23,7 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService
/**
* Set the active context as default context.
*/
-public class SetAsDefaultContextStep extends AbstractPeerModelStep {
+public class SetAsDefaultContextStep extends AbstractPeerNodeStep {
/**
* Constructor.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetWaitForReadyStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetWaitForReadyStep.java
index 386d936ea..369a2b4e1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetWaitForReadyStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetWaitForReadyStep.java
@@ -19,12 +19,12 @@ import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
/**
* Set the waiting_for_ready state.
*/
-public class SetWaitForReadyStep extends AbstractPeerModelStep {
+public class SetWaitForReadyStep extends AbstractPeerNodeStep {
/**
* Constructor.
@@ -47,9 +47,9 @@ public class SetWaitForReadyStep extends AbstractPeerModelStep {
Protocol.invokeAndWait(new Runnable() {
@Override
public void run() {
- int state = getActivePeerModelContext(context, data, fullQualifiedId).getIntProperty(IPeerModelProperties.PROP_STATE);
- if (state == IPeerModelProperties.STATE_UNKNOWN || state == IPeerModelProperties.STATE_NOT_REACHABLE || state == IPeerModelProperties.STATE_ERROR) {
- getActivePeerModelContext(context, data, fullQualifiedId).setProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_WAITING_FOR_READY);
+ int state = getActivePeerModelContext(context, data, fullQualifiedId).getIntProperty(IPeerNodeProperties.PROP_STATE);
+ if (state == IPeerNodeProperties.STATE_UNKNOWN || state == IPeerNodeProperties.STATE_NOT_REACHABLE || state == IPeerNodeProperties.STATE_ERROR) {
+ getActivePeerModelContext(context, data, fullQualifiedId).setProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_WAITING_FOR_READY);
}
}
});
@@ -72,7 +72,7 @@ public class SetWaitForReadyStep extends AbstractPeerModelStep {
Protocol.invokeAndWait(new Runnable() {
@Override
public void run() {
- getActivePeerModelContext(context, data, fullQualifiedId).setProperty(IPeerModelProperties.PROP_STATE, IPeerModelProperties.STATE_NOT_REACHABLE);
+ getActivePeerModelContext(context, data, fullQualifiedId).setProperty(IPeerNodeProperties.PROP_STATE, IPeerNodeProperties.STATE_NOT_REACHABLE);
}
});
super.rollback(context, data, status, fullQualifiedId, monitor, callback);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SignalPeerDisconnectedStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SignalPeerDisconnectedStep.java
index cbf2a034e..f29164fca 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SignalPeerDisconnectedStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SignalPeerDisconnectedStep.java
@@ -19,14 +19,14 @@ import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
import org.eclipse.tcf.te.tcf.locator.interfaces.IModelListener;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.model.Model;
/**
* Signal peer disconnected step.
*/
-public class SignalPeerDisconnectedStep extends AbstractPeerModelStep {
+public class SignalPeerDisconnectedStep extends AbstractPeerNodeStep {
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
@@ -46,14 +46,14 @@ public class SignalPeerDisconnectedStep extends AbstractPeerModelStep {
Assert.isNotNull(monitor);
Assert.isNotNull(callback);
- final IPeerModel peerModel = getActivePeerModelContext(context, data, fullQualifiedId);
- if (peerModel != null) {
+ final IPeerNode peerNode = getActivePeerModelContext(context, data, fullQualifiedId);
+ if (peerNode != null) {
Protocol.invokeLater(new Runnable() {
@Override
public void run() {
- ILocatorModel model = Model.getModel();
+ IPeerModel model = Model.getModel();
for (IModelListener listener : model.getListener()) {
- listener.locatorModelChanged(model, peerModel, false);
+ listener.locatorModelChanged(model, peerNode, false);
}
callback.done(SignalPeerDisconnectedStep.this, Status.OK_STATUS);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java
index 73ae17f02..58b66d40c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartDebuggerStep.java
@@ -30,14 +30,14 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
import org.eclipse.tcf.te.runtime.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.locator.interfaces.IStepAttributes;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
-import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelPeerNodeQueryService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.IPeerModelQueryService;
/**
* Start debugger step implementation.
*/
-public class StartDebuggerStep extends AbstractPeerModelStep {
+public class StartDebuggerStep extends AbstractPeerNodeStep {
/**
* Interface to be implemented by start debugger step delegates.
@@ -51,7 +51,7 @@ public class StartDebuggerStep extends AbstractPeerModelStep {
* @param monitor The progress monitor. Must not be <code>null</code>.
* @param callback The callback to invoke if finished. Must not be <code>null</code>.
*/
- public void postAttachDebugger(IPeerModel node, IProgressMonitor monitor, ICallback callback);
+ public void postAttachDebugger(IPeerNode node, IProgressMonitor monitor, ICallback callback);
}
/**
@@ -72,7 +72,7 @@ public class StartDebuggerStep extends AbstractPeerModelStep {
*/
@Override
public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
- final IPeerModel node = getActivePeerModelContext(context, data, fullQualifiedId);
+ final IPeerNode node = getActivePeerModelContext(context, data, fullQualifiedId);
Assert.isNotNull(node);
String value = getParameters().get("autoAttachAll"); //$NON-NLS-1$
final boolean autoAttachAll = value != null ? Boolean.parseBoolean(value) : false;
@@ -82,14 +82,14 @@ public class StartDebuggerStep extends AbstractPeerModelStep {
@Override
public void run() {
// Don't attach the debugger if no run control is provided by the target
- final ILocatorModelPeerNodeQueryService queryService = node.getModel().getService(ILocatorModelPeerNodeQueryService.class);
+ final IPeerModelQueryService queryService = node.getModel().getService(IPeerModelQueryService.class);
Assert.isNotNull(queryService);
- queryService.queryServicesAsync(node, new ILocatorModelPeerNodeQueryService.DoneQueryServices() {
+ queryService.queryServicesAsync(node, new IPeerModelQueryService.DoneQueryServices() {
@Override
public void doneQueryServices(Throwable error) {
if (error == null) {
// Get the list of available remote services
- String remoteServices = node.getStringProperty(IPeerModelProperties.PROP_REMOTE_SERVICES);
+ String remoteServices = node.getStringProperty(IPeerNodeProperties.PROP_REMOTE_SERVICES);
Assert.isNotNull(remoteServices);
boolean canAttachDbg = false;
StringTokenizer tokenizer = new StringTokenizer(remoteServices, ","); //$NON-NLS-1$
@@ -157,7 +157,7 @@ public class StartDebuggerStep extends AbstractPeerModelStep {
*/
@Override
public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) {
- final IPeerModel node = getActivePeerModelContext(context, data, fullQualifiedId);
+ final IPeerNode node = getActivePeerModelContext(context, data, fullQualifiedId);
IDebugService dbgService = ServiceManager.getInstance().getService(node, IDebugService.class, false);
if (dbgService != null) {
IPropertiesContainer props = new PropertiesContainer();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java
index cde08c7d6..905d0830e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java
@@ -21,7 +21,7 @@ import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
/**
* Start simulator step implementation.
*/
-public class StartSimulatorStep extends AbstractPeerModelStep {
+public class StartSimulatorStep extends AbstractPeerNodeStep {
/**
* Constructor.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopDebuggerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopDebuggerStep.java
index 3fe928a33..d6ea6557c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopDebuggerStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopDebuggerStep.java
@@ -1,55 +1,55 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.tcf.locator.steps;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
-import org.eclipse.tcf.te.runtime.services.ServiceManager;
-import org.eclipse.tcf.te.runtime.services.interfaces.IDebugService;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-
-/**
- * Stop debugger step implementation.
- */
-public class StopDebuggerStep extends AbstractPeerModelStep {
-
- /**
- * Constructor.
- */
- public StopDebuggerStep() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void validateExecute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor) throws CoreException {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
- IDebugService dbgService = ServiceManager.getInstance().getService(getActivePeerModelContext(context, data, fullQualifiedId), IDebugService.class, false);
- if (dbgService != null) {
- IPropertiesContainer props = new PropertiesContainer();
- dbgService.detach(getActivePeerModelContext(context, data, fullQualifiedId), props, monitor, callback);
- }
- else {
- callback.done(this, Status.OK_STATUS);
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2013 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.tcf.locator.steps;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IDebugService;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+
+/**
+ * Stop debugger step implementation.
+ */
+public class StopDebuggerStep extends AbstractPeerNodeStep {
+
+ /**
+ * Constructor.
+ */
+ public StopDebuggerStep() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void validateExecute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor) throws CoreException {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
+ IDebugService dbgService = ServiceManager.getInstance().getService(getActivePeerModelContext(context, data, fullQualifiedId), IDebugService.class, false);
+ if (dbgService != null) {
+ IPropertiesContainer props = new PropertiesContainer();
+ dbgService.detach(getActivePeerModelContext(context, data, fullQualifiedId), props, monitor, callback);
+ }
+ else {
+ callback.done(this, Status.OK_STATUS);
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopSimulatorStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopSimulatorStep.java
index 3edf32507..0f91d460a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopSimulatorStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StopSimulatorStep.java
@@ -1,45 +1,45 @@
-/*******************************************************************************
- * Copyright (c) 2013 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.tcf.locator.steps;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
-
-/**
- * Stop simulator step implementation.
- */
-public class StopSimulatorStep extends AbstractPeerModelStep {
-
- /**
- * Constructor.
- */
- public StopSimulatorStep() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void validateExecute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor) throws CoreException {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
- SimulatorUtils.stop(getActivePeerModelContext(context, data, fullQualifiedId), monitor, callback);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2013 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.tcf.locator.steps;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
+
+/**
+ * Stop simulator step implementation.
+ */
+public class StopSimulatorStep extends AbstractPeerNodeStep {
+
+ /**
+ * Constructor.
+ */
+ public StopSimulatorStep() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void validateExecute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor) throws CoreException {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
+ SimulatorUtils.stop(getActivePeerModelContext(context, data, fullQualifiedId), monitor, callback);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java
index d5e635fe1..f1c79cc7a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/WaitForReadyStep.java
@@ -27,13 +27,13 @@ import org.eclipse.tcf.te.runtime.utils.ProgressHelper;
import org.eclipse.tcf.te.runtime.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.core.Tcf;
import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
import org.eclipse.tcf.te.tcf.locator.nls.Messages;
/**
* WaitForReadyStep
*/
-public class WaitForReadyStep extends AbstractPeerModelStep {
+public class WaitForReadyStep extends AbstractPeerNodeStep {
/**
* Constructor.
@@ -53,9 +53,9 @@ public class WaitForReadyStep extends AbstractPeerModelStep {
*/
@Override
public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
- final IPeerModel peerModel = getActivePeerModelContext(context, data, fullQualifiedId);
+ final IPeerNode peerNode = getActivePeerModelContext(context, data, fullQualifiedId);
- if (peerModel != null && !Boolean.getBoolean("WaitForReadyStep.skip")) { //$NON-NLS-1$
+ if (peerNode != null && !Boolean.getBoolean("WaitForReadyStep.skip")) { //$NON-NLS-1$
Protocol.invokeLater(new Runnable() {
final Runnable thisRunnable = this;
int refreshCount = 0;
@@ -71,7 +71,7 @@ public class WaitForReadyStep extends AbstractPeerModelStep {
}
else {
// Try to open a channel to the target and check for errors
- Tcf.getChannelManager().openChannel(peerModel.getPeer(), null, new IChannelManager.DoneOpenChannel() {
+ Tcf.getChannelManager().openChannel(peerNode.getPeer(), null, new IChannelManager.DoneOpenChannel() {
@Override
public void doneOpenChannel(final Throwable error, final IChannel channel) {
if (ProgressHelper.isCancel(WaitForReadyStep.this, monitor, callback)) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java
index c58c09538..e9a3520f8 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/utils/SimulatorUtils.java
@@ -23,8 +23,8 @@ import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
import org.eclipse.tcf.te.runtime.services.interfaces.IService;
import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNodeProperties;
/**
* Simulator related utilities.
@@ -43,18 +43,18 @@ public final class SimulatorUtils {
/**
* Returns if or if the given peer model has the simulator enabled or not.
*
- * @param peerModel The peer model node. Must not be <code>null</code>.
+ * @param peerNode The peer model node. Must not be <code>null</code>.
* @return <code>True</code> if the simulator is enabled, <code>false</code> otherwise.
*/
- public static boolean isSimulatorEnabled(final IPeerModel peerModel) {
- Assert.isNotNull(peerModel);
+ public static boolean isSimulatorEnabled(final IPeerNode peerNode) {
+ Assert.isNotNull(peerNode);
final AtomicBoolean isEnabled = new AtomicBoolean(false);
Runnable runnable = new Runnable() {
@Override
public void run() {
- String value = peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_ENABLED);
+ String value = peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_ENABLED);
if (value != null) {
isEnabled.set(Boolean.parseBoolean(value));
}
@@ -72,11 +72,11 @@ public final class SimulatorUtils {
* If no simulator service is configured in the peer
* or the configured service is not available, <code>null</code> will be returned.
*
- * @param peerModel The peer model node. Must not be <code>null</code>.
+ * @param peerNode The peer model node. Must not be <code>null</code>.
* @return The {@link Result} containing the simulator service and the settings or <code>null</code>.
*/
- public static Result getSimulatorService(final IPeerModel peerModel) {
- Assert.isNotNull(peerModel);
+ public static Result getSimulatorService(final IPeerNode peerNode) {
+ Assert.isNotNull(peerNode);
final AtomicBoolean isEnabled = new AtomicBoolean(false);
final AtomicReference<String> type = new AtomicReference<String>();
@@ -85,13 +85,13 @@ public final class SimulatorUtils {
Runnable runnable = new Runnable() {
@Override
public void run() {
- String value = peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_ENABLED);
+ String value = peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_ENABLED);
if (value != null) {
isEnabled.set(Boolean.parseBoolean(value));
}
- type.set(peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_TYPE));
- properties.set(peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_PROPERTIES));
+ type.set(peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_TYPE));
+ properties.set(peerNode.getPeer().getAttributes().get(IPeerNodeProperties.PROP_SIM_PROPERTIES));
}
};
@@ -101,7 +101,7 @@ public final class SimulatorUtils {
Result result = null;
if (isEnabled.get()) {
- IService[] services = ServiceManager.getInstance().getServices(peerModel, ISimulatorService.class, false);
+ IService[] services = ServiceManager.getInstance().getServices(peerNode, ISimulatorService.class, false);
for (IService service : services) {
Assert.isTrue(service instanceof ISimulatorService);
// Get the UI service which is associated with the simulator service
@@ -123,25 +123,25 @@ public final class SimulatorUtils {
* model node and the configured simulator service type is available. In any
* other cases, the given callback is invoked immediately.
*
- * @param peerModel The peer model node. Must not be <code>null</code>.
+ * @param peerNode The peer model node. Must not be <code>null</code>.
* @param monitor The progress monitor.
* @param callback The callback to invoke if finished. Must not be <code>null</code>.
*/
- public static void start(final IPeerModel peerModel, final IProgressMonitor monitor, final ICallback callback) {
- Assert.isNotNull(peerModel);
+ public static void start(final IPeerNode peerNode, final IProgressMonitor monitor, final ICallback callback) {
+ Assert.isNotNull(peerNode);
Assert.isNotNull(callback);
// Determine if we have to start a simulator first
- final Result result = getSimulatorService(peerModel);
+ final Result result = getSimulatorService(peerNode);
if (result != null && result.service != null) {
// Check if the simulator is already running
- result.service.isRunning(peerModel, result.settings, new Callback() {
+ result.service.isRunning(peerNode, result.settings, new Callback() {
@Override
protected void internalDone(Object caller, IStatus status) {
Object cbResult = getResult();
if (cbResult instanceof Boolean && !((Boolean)cbResult).booleanValue()) {
// Start the simulator
- result.service.start(peerModel, result.settings, new Callback() {
+ result.service.start(peerNode, result.settings, new Callback() {
@Override
protected void internalDone(Object caller, IStatus status) {
callback.setResult(new Boolean(status.isOK()));
@@ -165,25 +165,25 @@ public final class SimulatorUtils {
* model node and the configured simulator service type is available. In any
* other cases, the given callback is invoked immediately.
*
- * @param peerModel The peer model node. Must not be <code>null</code>.
+ * @param peerNode The peer model node. Must not be <code>null</code>.
* @param monitor The progress monitor.
* @param callback The callback to invoke if finished. Must not be <code>null</code>.
*/
- public static void stop(final IPeerModel peerModel, final IProgressMonitor monitor, final ICallback callback) {
- Assert.isNotNull(peerModel);
+ public static void stop(final IPeerNode peerNode, final IProgressMonitor monitor, final ICallback callback) {
+ Assert.isNotNull(peerNode);
Assert.isNotNull(callback);
// Get the associated simulator service
- final Result result = getSimulatorService(peerModel);
+ final Result result = getSimulatorService(peerNode);
if (result != null && result.service != null) {
// Determine if the simulator is at all running
- result.service.isRunning(peerModel, result.settings, new Callback() {
+ result.service.isRunning(peerNode, result.settings, new Callback() {
@Override
protected void internalDone(Object caller, IStatus status) {
Object cbResult = getResult();
if (cbResult instanceof Boolean && ((Boolean)cbResult).booleanValue()) {
// Stop the simulator
- result.service.stop(peerModel, result.settings, new Callback(callback) {
+ result.service.stop(peerNode, result.settings, new Callback(callback) {
@Override
protected void internalDone(Object caller, IStatus status) {
callback.done(caller, status);

Back to the top