Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: daf6d8218bb2f9899d58e84e321604b37f9faa41 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*******************************************************************************
 * 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.IPeerModelService;


/**
 * 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 IPeerModel 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 IPeerNode[] getPeerNodes();

	/**
	 * 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<IPeerNode> 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<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>
	 * 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 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> 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.
	 *
	 * @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 validateChildPeerNodeForAdd(IPeerNode node);

}

Back to the top