View | Details | Raw Unified | Return to bug 257861 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ecf/provider/discovery/SingletonDiscoveryContainer.java (-5 / +47 lines)
Lines 14-20 Link Here
14
import org.eclipse.ecf.core.identity.ID;
14
import org.eclipse.ecf.core.identity.ID;
15
import org.eclipse.ecf.core.identity.Namespace;
15
import org.eclipse.ecf.core.identity.Namespace;
16
import org.eclipse.ecf.core.security.IConnectContext;
16
import org.eclipse.ecf.core.security.IConnectContext;
17
import org.eclipse.ecf.core.util.ECFException;
17
import org.eclipse.ecf.core.util.IFutureStatus;
18
import org.eclipse.ecf.discovery.*;
18
import org.eclipse.ecf.discovery.*;
19
import org.eclipse.ecf.discovery.identity.IServiceID;
19
import org.eclipse.ecf.discovery.identity.IServiceID;
20
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
20
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
Lines 112-119 Link Here
112
	/* (non-Javadoc)
112
	/* (non-Javadoc)
113
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
113
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
114
	 */
114
	 */
115
	public void registerService(IServiceInfo serviceInfo) throws ECFException {
115
	public IFutureStatus registerService(IServiceInfo serviceInfo) {
116
		discovery.registerService(serviceInfo);
116
		return discovery.registerService(serviceInfo);
117
	}
117
	}
118
118
119
	/* (non-Javadoc)
119
	/* (non-Javadoc)
Lines 133-140 Link Here
133
	/* (non-Javadoc)
133
	/* (non-Javadoc)
134
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
134
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
135
	 */
135
	 */
136
	public void unregisterService(IServiceInfo serviceInfo) throws ECFException {
136
	public IFutureStatus unregisterService(IServiceInfo serviceInfo) {
137
		discovery.unregisterService(serviceInfo);
137
		return discovery.unregisterService(serviceInfo);
138
	}
138
	}
139
139
140
	/* (non-Javadoc)
140
	/* (non-Javadoc)
Lines 199-202 Link Here
199
	public void removeServiceListener(IServiceListener listener) {
199
	public void removeServiceListener(IServiceListener listener) {
200
		discovery.removeServiceListener(listener);
200
		discovery.removeServiceListener(listener);
201
	}
201
	}
202
203
	/* (non-Javadoc)
204
	 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServiceInfo(org.eclipse.ecf.discovery.identity.IServiceID)
205
	 */
206
	public IFutureStatus getAsyncServiceInfo(IServiceID service) {
207
		return discovery.getAsyncServiceInfo(service);
208
	}
209
210
	/* (non-Javadoc)
211
	 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServiceTypes()
212
	 */
213
	public IFutureStatus getAsyncServiceTypes() {
214
		return discovery.getAsyncServiceTypes();
215
	}
216
217
	/* (non-Javadoc)
218
	 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServices()
219
	 */
220
	public IFutureStatus getAsyncServices() {
221
		return discovery.getAsyncServices();
222
	}
223
224
	/* (non-Javadoc)
225
	 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServices(org.eclipse.ecf.discovery.identity.IServiceTypeID)
226
	 */
227
	public IFutureStatus getAsyncServices(IServiceTypeID type) {
228
		return discovery.getAsyncServices(type);
229
	}
230
231
	/* (non-Javadoc)
232
	 * @see org.eclipse.ecf.discovery.IDiscoveryAdvertiser#unregisterAllServices()
233
	 */
234
	public IFutureStatus unregisterAllServices() {
235
		return discovery.unregisterAllServices();
236
	}
237
238
	/* (non-Javadoc)
239
	 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#purgeCache()
240
	 */
241
	public IServiceInfo[] purgeCache() {
242
		return discovery.purgeCache();
243
	}
202
}
244
}
(-)src/org/eclipse/ecf/provider/discovery/CompositeDiscoveryContainer.java (-9 / +28 lines)
Lines 17-23 Link Here
17
import org.eclipse.ecf.core.events.*;
17
import org.eclipse.ecf.core.events.*;
18
import org.eclipse.ecf.core.identity.*;
18
import org.eclipse.ecf.core.identity.*;
19
import org.eclipse.ecf.core.security.IConnectContext;
19
import org.eclipse.ecf.core.security.IConnectContext;
20
import org.eclipse.ecf.core.util.ECFException;
20
import org.eclipse.ecf.core.util.IFutureStatus;
21
import org.eclipse.ecf.core.util.Trace;
21
import org.eclipse.ecf.core.util.Trace;
22
import org.eclipse.ecf.discovery.*;
22
import org.eclipse.ecf.discovery.*;
23
import org.eclipse.ecf.discovery.identity.*;
23
import org.eclipse.ecf.discovery.identity.*;
Lines 280-286 Link Here
280
	/* (non-Javadoc)
280
	/* (non-Javadoc)
281
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
281
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
282
	 */
282
	 */
283
	public void registerService(IServiceInfo serviceInfo) throws ECFException {
283
	public IFutureStatus registerService(IServiceInfo serviceInfo) {
284
		Assert.isNotNull(serviceInfo);
284
		Assert.isNotNull(serviceInfo);
285
		synchronized (registeredServices) {
285
		synchronized (registeredServices) {
286
			Assert.isTrue(registeredServices.add(serviceInfo));
286
			Assert.isTrue(registeredServices.add(serviceInfo));
Lines 294-305 Link Here
294
						+ serviceInfo.toString());
294
						+ serviceInfo.toString());
295
			}
295
			}
296
		}
296
		}
297
		//TODO-mkuppe https://bugs.eclipse.org/258875 instantiated a real IFutureStatus
298
		return null;
297
	}
299
	}
298
300
299
	/* (non-Javadoc)
301
	/* (non-Javadoc)
300
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
302
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
301
	 */
303
	 */
302
	public void unregisterService(IServiceInfo serviceInfo) throws ECFException {
304
	public IFutureStatus unregisterService(IServiceInfo serviceInfo) {
303
		Assert.isNotNull(serviceInfo);
305
		Assert.isNotNull(serviceInfo);
304
		synchronized (registeredServices) {
306
		synchronized (registeredServices) {
305
			// no assert as unregisterService might be called with an non-existing ISI
307
			// no assert as unregisterService might be called with an non-existing ISI
Lines 312-317 Link Here
312
				idca.unregisterService(isi);
314
				idca.unregisterService(isi);
313
			}
315
			}
314
		}
316
		}
317
		//TODO-mkuppe https://bugs.eclipse.org/258875 instantiated a real IFutureStatus
318
		return null;
315
	}
319
	}
316
320
317
	/**
321
	/**
Lines 325-336 Link Here
325
			IDiscoveryContainerAdapter idca = (IDiscoveryContainerAdapter) object;
329
			IDiscoveryContainerAdapter idca = (IDiscoveryContainerAdapter) object;
326
			for (Iterator itr = registeredServices.iterator(); itr.hasNext();) {
330
			for (Iterator itr = registeredServices.iterator(); itr.hasNext();) {
327
				IServiceInfo serviceInfo = (IServiceInfo) itr.next();
331
				IServiceInfo serviceInfo = (IServiceInfo) itr.next();
328
				try {
332
				idca.registerService(serviceInfo);
329
					idca.registerService(serviceInfo);
330
				} catch (ECFException e) {
331
					// we eat the exception here since the original registerService call is long done
332
					Trace.catching(Activator.PLUGIN_ID, METHODS_CATCHING, this.getClass(), "addContainer(Object)", e); //$NON-NLS-1$
333
				}
334
			}
333
			}
335
		}
334
		}
336
		synchronized (containers) {
335
		synchronized (containers) {
Lines 352-355 Link Here
352
			return containers.remove(object);
351
			return containers.remove(object);
353
		}
352
		}
354
	}
353
	}
354
355
	public IFutureStatus getAsyncServiceInfo(IServiceID service) {
356
		// TODO Auto-generated method stub
357
		return null;
358
	}
359
360
	public IFutureStatus getAsyncServiceTypes() {
361
		// TODO Auto-generated method stub
362
		return null;
363
	}
364
365
	public IFutureStatus getAsyncServices() {
366
		// TODO Auto-generated method stub
367
		return null;
368
	}
369
370
	public IFutureStatus getAsyncServices(IServiceTypeID type) {
371
		// TODO Auto-generated method stub
372
		return null;
373
	}
355
}
374
}
(-)src/org/eclipse/ecf/core/util/IFutureStatus.java (+64 lines)
Added Link Here
1
package org.eclipse.ecf.core.util;
2
3
import org.eclipse.core.runtime.IProgressMonitor;
4
import org.eclipse.core.runtime.IStatus;
5
6
public interface IFutureStatus extends IStatus {
7
8
	/**
9
	 * State representing that the computation is still being done.
10
	 */
11
	public static final int IN_PROGRESS = 0x10;
12
13
	/**
14
	 * Return progress monitor for this future status.  Will not
15
	 * return <code>null</code>.
16
	 *
17
	 */
18
	public IProgressMonitor getProgressMonitor();
19
20
	/**
21
	 * Returns <tt>true</tt> if this task completed.
22
	 * 
23
	 * Completion may be due to normal termination, an exception, or
24
	 * cancellation -- in all of these cases, this method will return
25
	 * <tt>true</tt>.
26
	 * 
27
	 * @return <tt>true</tt> if this task completed
28
	 */
29
	boolean isDone();
30
31
	/**
32
	 * Waits if necessary for the computation to complete, and then retrieves
33
	 * its result.
34
	 * 
35
	 * @return Object that is the result of the asynchronous computation
36
	 *         represented by this future status. This method will block until a
37
	 *         result is available or the computation completes with some
38
	 *         exception.
39
	 * @throws InterruptedException
40
	 *             if thread waiting for result is interrupted.
41
	 * @throws CanceledException
42
	 *             if {@link #cancel(boolean)} has been called to cancel the
43
	 *             operation.
44
	 */
45
	Object get() throws InterruptedException, CanceledException;
46
47
	/**
48
	 * Waits if necessary for at most the given time for the computation to
49
	 * complete, and then retrieves its result, if available.
50
	 * 
51
	 * @param waitTimeInMilliseconds
52
	 *            the maximum time to wait
53
	 * @return the computed result
54
	 * @throws InterruptedException
55
	 *             if the current thread was interrupted while waiting.
56
	 * @throws TimeoutException
57
	 *             if the given wait time is exceeded without getting result.
58
	 * @throws CanceledException
59
	 *             if {@link #cancel(boolean)} has been called to cancel the
60
	 *             operation.
61
	 */
62
	Object get(long waitTimeInMillis) throws InterruptedException, TimeoutException, CanceledException;
63
64
}
(-)src/org/eclipse/ecf/core/util/CanceledException.java (+14 lines)
Added Link Here
1
package org.eclipse.ecf.core.util;
2
3
import org.eclipse.core.runtime.CoreException;
4
import org.eclipse.core.runtime.IStatus;
5
6
public class CanceledException extends CoreException {
7
8
	private static final long serialVersionUID = -2545133268982994587L;
9
10
	public CanceledException(IStatus status) {
11
		super(status);
12
	}
13
14
}
(-)src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java (-7 / +16 lines)
Lines 22-29 Link Here
22
import org.eclipse.ecf.core.events.*;
22
import org.eclipse.ecf.core.events.*;
23
import org.eclipse.ecf.core.identity.*;
23
import org.eclipse.ecf.core.identity.*;
24
import org.eclipse.ecf.core.security.IConnectContext;
24
import org.eclipse.ecf.core.security.IConnectContext;
25
import org.eclipse.ecf.core.util.ECFException;
25
import org.eclipse.ecf.core.util.*;
26
import org.eclipse.ecf.core.util.Trace;
27
import org.eclipse.ecf.discovery.*;
26
import org.eclipse.ecf.discovery.*;
28
import org.eclipse.ecf.discovery.identity.*;
27
import org.eclipse.ecf.discovery.identity.*;
29
import org.eclipse.ecf.discovery.service.IDiscoveryService;
28
import org.eclipse.ecf.discovery.service.IDiscoveryService;
Lines 222-250 Link Here
222
	/* (non-Javadoc)
221
	/* (non-Javadoc)
223
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
222
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
224
	 */
223
	 */
225
	public void registerService(IServiceInfo serviceInfo) throws ECFException {
224
	public IFutureStatus registerService(IServiceInfo serviceInfo) {
226
		Assert.isNotNull(serviceInfo);
225
		Assert.isNotNull(serviceInfo);
226
		Exception ex = null;
227
		final ServiceInfo svcInfo = createServiceInfoFromIServiceInfo(serviceInfo);
227
		final ServiceInfo svcInfo = createServiceInfoFromIServiceInfo(serviceInfo);
228
		checkServiceInfo(svcInfo);
228
		try {
229
			checkServiceInfo(svcInfo);
230
		} catch (ECFException e1) {
231
			ex = e1;
232
		}
229
		JmDNS localJmDNS = null;
233
		JmDNS localJmDNS = null;
230
		synchronized (lock) {
234
		synchronized (lock) {
231
			if (jmdns == null)
235
			if (jmdns == null)
232
				throw new ECFException(Messages.JMDNSDiscoveryContainer_DISCOVERY_NOT_INITIALIZED);
236
				ex = new ECFException(Messages.JMDNSDiscoveryContainer_DISCOVERY_NOT_INITIALIZED);
233
			localJmDNS = jmdns;
237
			localJmDNS = jmdns;
234
		}
238
		}
235
		if (localJmDNS != null) {
239
		if (localJmDNS != null) {
236
			try {
240
			try {
237
				localJmDNS.registerService(svcInfo);
241
				localJmDNS.registerService(svcInfo);
238
			} catch (final IOException e) {
242
			} catch (final IOException e) {
239
				throw new ECFException(Messages.JMDNSDiscoveryContainer_EXCEPTION_REGISTER_SERVICE, e);
243
				ex = new ECFException(Messages.JMDNSDiscoveryContainer_EXCEPTION_REGISTER_SERVICE, e);
240
			}
244
			}
241
		}
245
		}
246
		//TODO-mkuppe https://bugs.eclipse.org/258875 instantiated a real IFutureStatus
247
		// use ex!!!
248
		return null;
242
	}
249
	}
243
250
244
	/* (non-Javadoc)
251
	/* (non-Javadoc)
245
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
252
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
246
	 */
253
	 */
247
	public void unregisterService(IServiceInfo serviceInfo) {
254
	public IFutureStatus unregisterService(IServiceInfo serviceInfo) {
248
		Assert.isNotNull(serviceInfo);
255
		Assert.isNotNull(serviceInfo);
249
		final ServiceInfo si = createServiceInfoFromIServiceInfo(serviceInfo);
256
		final ServiceInfo si = createServiceInfoFromIServiceInfo(serviceInfo);
250
		JmDNS localJmDNS = null;
257
		JmDNS localJmDNS = null;
Lines 254-259 Link Here
254
		if (localJmDNS != null) {
261
		if (localJmDNS != null) {
255
			localJmDNS.unregisterService(si);
262
			localJmDNS.unregisterService(si);
256
		}
263
		}
264
		//TODO-mkuppe https://bugs.eclipse.org/258875 instantiated a real IFutureStatus
265
		return null;
257
	}
266
	}
258
267
259
	/**************************** JMDNS listeners ***********************************/
268
	/**************************** JMDNS listeners ***********************************/
(-)src/org/eclipse/ecf/tests/discovery/DiscoveryTest.java (-18 / +27 lines)
Lines 21-27 Link Here
21
import org.eclipse.ecf.core.IContainer;
21
import org.eclipse.ecf.core.IContainer;
22
import org.eclipse.ecf.core.identity.IDFactory;
22
import org.eclipse.ecf.core.identity.IDFactory;
23
import org.eclipse.ecf.core.identity.Namespace;
23
import org.eclipse.ecf.core.identity.Namespace;
24
import org.eclipse.ecf.core.util.ECFException;
24
import org.eclipse.ecf.core.util.CanceledException;
25
import org.eclipse.ecf.core.util.IFutureStatus;
25
import org.eclipse.ecf.discovery.IDiscoveryContainerAdapter;
26
import org.eclipse.ecf.discovery.IDiscoveryContainerAdapter;
26
import org.eclipse.ecf.discovery.IServiceEvent;
27
import org.eclipse.ecf.discovery.IServiceEvent;
27
import org.eclipse.ecf.discovery.IServiceInfo;
28
import org.eclipse.ecf.discovery.IServiceInfo;
Lines 162-178 Link Here
162
163
163
	protected void registerService() {
164
	protected void registerService() {
164
		try {
165
		try {
165
			discoveryContainer.registerService(serviceInfo);
166
			IFutureStatus futureStatus = discoveryContainer.registerService(serviceInfo);
166
		} catch (final ECFException e) {
167
			assertNotNull(futureStatus.getMessage(), futureStatus.get());
168
		} catch (CanceledException e) {
169
			fail("IServiceInfo may be valid with this IDCA");
170
		} catch (InterruptedException e) {
167
			fail("IServiceInfo may be valid with this IDCA");
171
			fail("IServiceInfo may be valid with this IDCA");
168
		}
172
		}
169
	}
173
	}
170
174
171
	protected void unregisterService() {
175
	protected void unregisterService() {
172
		try {
176
		try {
173
			discoveryContainer.unregisterService(serviceInfo);
177
			IFutureStatus futureStatus = discoveryContainer.unregisterService(serviceInfo);
174
		} catch (final ECFException e) {
178
			assertNotNull(futureStatus.getMessage(), futureStatus.get());
175
			fail("unregistering of " + serviceInfo + " should just work");
179
		} catch (CanceledException e) {
180
			fail("IServiceInfo may be valid with this IDCA");
181
		} catch (InterruptedException e) {
182
			fail("IServiceInfo may be valid with this IDCA");
176
		}
183
		}
177
	}
184
	}
178
185
Lines 302-314 Link Here
302
	public void testRegisterServiceWithNull() {
309
	public void testRegisterServiceWithNull() {
303
		testConnect();
310
		testConnect();
304
		try {
311
		try {
305
			discoveryContainer.registerService(null);
312
			IFutureStatus futureStatus = discoveryContainer.registerService(null);
306
		} catch (final ECFException e) {
313
			assertNotNull(futureStatus.getMessage(), futureStatus.get());
307
			fail("null must cause AssertionFailedException");
314
			assertTrue(futureStatus.getException() instanceof AssertionFailedException);
308
		} catch (final AssertionFailedException e) {
315
		} catch (CanceledException e) {
309
			return;
316
			fail("IServiceInfo may be valid with this IDCA");
317
		} catch (InterruptedException e) {
318
			fail("IServiceInfo may be valid with this IDCA");
310
		}
319
		}
311
		fail("null must cause AssertionFailedException");
312
	}
320
	}
313
321
314
	/**
322
	/**
Lines 334-346 Link Here
334
	public void testUnregisterServiceWithNull() {
342
	public void testUnregisterServiceWithNull() {
335
		testConnect();
343
		testConnect();
336
		try {
344
		try {
337
			discoveryContainer.unregisterService(null);
345
			IFutureStatus futureStatus = discoveryContainer.unregisterService(null);
338
		} catch (final ECFException e) {
346
			assertNotNull(futureStatus.getMessage(), futureStatus.get());
339
			fail("null must cause AssertionFailedException");
347
			assertTrue(futureStatus.getException() instanceof AssertionFailedException);
340
		} catch (final AssertionFailedException e) {
348
		} catch (CanceledException e) {
341
			return;
349
			fail("IServiceInfo may be valid with this IDCA");
350
		} catch (InterruptedException e) {
351
			fail("IServiceInfo may be valid with this IDCA");
342
		}
352
		}
343
		fail("null must cause AssertionFailedException");
344
	}
353
	}
345
354
346
	public void testDispose() {
355
	public void testDispose() {
(-)src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java (-4 / +7 lines)
Lines 18-24 Link Here
18
import org.eclipse.ecf.core.events.*;
18
import org.eclipse.ecf.core.events.*;
19
import org.eclipse.ecf.core.identity.*;
19
import org.eclipse.ecf.core.identity.*;
20
import org.eclipse.ecf.core.security.IConnectContext;
20
import org.eclipse.ecf.core.security.IConnectContext;
21
import org.eclipse.ecf.core.util.ECFException;
21
import org.eclipse.ecf.core.util.IFutureStatus;
22
import org.eclipse.ecf.core.util.Trace;
22
import org.eclipse.ecf.core.util.Trace;
23
import org.eclipse.ecf.discovery.*;
23
import org.eclipse.ecf.discovery.*;
24
import org.eclipse.ecf.discovery.identity.IServiceID;
24
import org.eclipse.ecf.discovery.identity.IServiceID;
Lines 177-183 Link Here
177
	/* (non-Javadoc)
177
	/* (non-Javadoc)
178
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
178
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
179
	 */
179
	 */
180
	public void registerService(IServiceInfo aServiceInfo) throws ECFException {
180
	public IFutureStatus registerService(IServiceInfo aServiceInfo) {
181
		Assert.isNotNull(aServiceInfo);
181
		Assert.isNotNull(aServiceInfo);
182
		try {
182
		try {
183
			JSLPServiceInfo si = new JSLPServiceInfo(aServiceInfo);
183
			JSLPServiceInfo si = new JSLPServiceInfo(aServiceInfo);
Lines 185-198 Link Here
185
			Activator.getDefault().getAdvertiser().register(si.getServiceURL(), Arrays.asList(stid.getScopes()), new ServicePropertiesAdapter(si).toProperties());
185
			Activator.getDefault().getAdvertiser().register(si.getServiceURL(), Arrays.asList(stid.getScopes()), new ServicePropertiesAdapter(si).toProperties());
186
		} catch (ServiceLocationException e) {
186
		} catch (ServiceLocationException e) {
187
			Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "registerService(IServiceInfo)", e); //$NON-NLS-1$
187
			Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "registerService(IServiceInfo)", e); //$NON-NLS-1$
188
			throw new ECFException(e.getMessage(), e);
189
		}
188
		}
189
		//TODO-mkuppe https://bugs.eclipse.org/258875 instantiated a real IFutureStatus
190
		return null;
190
	}
191
	}
191
192
192
	/* (non-Javadoc)
193
	/* (non-Javadoc)
193
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
194
	 * @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
194
	 */
195
	 */
195
	public void unregisterService(IServiceInfo aServiceInfo) throws ECFException {
196
	public IFutureStatus unregisterService(IServiceInfo aServiceInfo) {
196
		Assert.isNotNull(aServiceInfo);
197
		Assert.isNotNull(aServiceInfo);
197
		JSLPServiceInfo si = new JSLPServiceInfo(aServiceInfo);
198
		JSLPServiceInfo si = new JSLPServiceInfo(aServiceInfo);
198
		try {
199
		try {
Lines 200-205 Link Here
200
		} catch (ServiceLocationException e) {
201
		} catch (ServiceLocationException e) {
201
			Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "unregisterService(IServiceInfo)", e); //$NON-NLS-1$
202
			Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "unregisterService(IServiceInfo)", e); //$NON-NLS-1$
202
		}
203
		}
204
		//TODO-mkuppe https://bugs.eclipse.org/258875 instantiated a real IFutureStatus
205
		return null;
203
	}
206
	}
204
207
205
	private IServiceInfo[] convertToIServiceInfo(Map serviceURLs) {
208
	private IServiceInfo[] convertToIServiceInfo(Map serviceURLs) {
(-)src/org/eclipse/ecf/discovery/IDiscoveryContainerAdapter.java (-52 / +1 lines)
Lines 11-17 Link Here
11
11
12
import org.eclipse.core.runtime.IAdaptable;
12
import org.eclipse.core.runtime.IAdaptable;
13
import org.eclipse.ecf.core.identity.Namespace;
13
import org.eclipse.ecf.core.identity.Namespace;
14
import org.eclipse.ecf.core.util.ECFException;
15
import org.eclipse.ecf.discovery.identity.*;
14
import org.eclipse.ecf.discovery.identity.*;
16
15
17
/**
16
/**
Lines 28-34 Link Here
28
 * implementation.
27
 * implementation.
29
 * 
28
 * 
30
 */
29
 */
31
public interface IDiscoveryContainerAdapter extends IAdaptable {
30
public interface IDiscoveryContainerAdapter extends IDiscoveryAdvertiser, IDiscoveryLocator, IAdaptable {
32
31
33
	/** ECF Service Property Names **/
32
	/** ECF Service Property Names **/
34
	public static final String CONTAINER_FACTORY_NAME_PROPERTY = "org.eclipse.ecf.containerFactoryName"; //$NON-NLS-1$
33
	public static final String CONTAINER_FACTORY_NAME_PROPERTY = "org.eclipse.ecf.containerFactoryName"; //$NON-NLS-1$
Lines 80-104 Link Here
80
	public IServiceInfo getServiceInfo(IServiceID service);
79
	public IServiceInfo getServiceInfo(IServiceID service);
81
80
82
	/**
81
	/**
83
	 * Synchronously get service info about all known services
84
	 * 
85
	 * @return IServiceInfo[] the resulting array of service info instances.
86
	 *         Will not be <code>null</code>. May be of length 0.
87
	 */
88
	public IServiceInfo[] getServices();
89
90
	/**
91
	 * Synchronously get service info about all known services of given service type
92
	 * 
93
	 * @param type
94
	 *            IServiceTypeID defining the type of service we are interested in
95
	 *            getting service info about. Must not be <code>null</code>
96
	 * @return IServiceInfo[] the resulting array of service info instances.
97
	 *         Will not be <code>null</code>. May be of length 0.
98
	 */
99
	public IServiceInfo[] getServices(IServiceTypeID type);
100
101
	/**
102
	 * Get a Namespace for services associated with this discovery container adapter.  The given Namespace
82
	 * Get a Namespace for services associated with this discovery container adapter.  The given Namespace
103
	 * may be used via {@link ServiceIDFactory} to create IServiceIDs rather than simple IDs.  For example:
83
	 * may be used via {@link ServiceIDFactory} to create IServiceIDs rather than simple IDs.  For example:
104
	 * <pre>
84
	 * <pre>
Lines 110-135 Link Here
110
	public Namespace getServicesNamespace();
90
	public Namespace getServicesNamespace();
111
91
112
	/**
92
	/**
113
	 * Synchronously get service info about all known services of given service type
114
	 * 
115
	 * @return IServiceTypeID[] the resulting array of service type IDs.
116
	 *         Will not be <code>null</code>. May be of length 0.
117
	 */
118
	public IServiceTypeID[] getServiceTypes();
119
120
	/**
121
	 * Register the given service. This publishes the service defined by the
122
	 * first parameter to the underlying publishing mechanism
123
	 * 
124
	 * @param serviceInfo
125
	 *            IServiceInfo of the service to be published. Must not be
126
	 *            <code>null</code>.
127
	 * @throws ECFException
128
	 *             if service info cannot be registered with this service
129
	 */
130
	public void registerService(IServiceInfo serviceInfo) throws ECFException;
131
132
	/**
133
	 * Remove a service listener. Remove the listener from this container
93
	 * Remove a service listener. Remove the listener from this container
134
	 * 
94
	 * 
135
	 * @param listener
95
	 * @param listener
Lines 160-174 Link Here
160
	 *            <code>null</code>.
120
	 *            <code>null</code>.
161
	 */
121
	 */
162
	public void removeServiceTypeListener(IServiceTypeListener listener);
122
	public void removeServiceTypeListener(IServiceTypeListener listener);
163
164
	/**
165
	 * Unregister a previously registered service defined by serviceInfo.
166
	 * 
167
	 * @param serviceInfo
168
	 *            IServiceInfo defining the service to unregister. Must not be
169
	 *            <code>null</code>.
170
	 * @throws ECFException
171
	 *             if service info cannot be unregistered with this service
172
	 */
173
	public void unregisterService(IServiceInfo serviceInfo) throws ECFException;
174
}
123
}
(-)src/org/eclipse/ecf/discovery/AbstractDiscoveryContainerAdapter.java (+44 lines)
Lines 14-20 Link Here
14
import org.eclipse.core.runtime.Assert;
14
import org.eclipse.core.runtime.Assert;
15
import org.eclipse.ecf.core.AbstractContainer;
15
import org.eclipse.ecf.core.AbstractContainer;
16
import org.eclipse.ecf.core.identity.*;
16
import org.eclipse.ecf.core.identity.*;
17
import org.eclipse.ecf.core.util.IFutureStatus;
17
import org.eclipse.ecf.core.util.Trace;
18
import org.eclipse.ecf.core.util.Trace;
19
import org.eclipse.ecf.discovery.identity.IServiceID;
18
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
20
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
19
import org.eclipse.ecf.internal.discovery.DiscoveryDebugOption;
21
import org.eclipse.ecf.internal.discovery.DiscoveryDebugOption;
20
import org.eclipse.ecf.internal.discovery.DiscoveryPlugin;
22
import org.eclipse.ecf.internal.discovery.DiscoveryPlugin;
Lines 235-238 Link Here
235
		Assert.isNotNull(aListener);
237
		Assert.isNotNull(aListener);
236
		serviceTypeListeners.remove(aListener);
238
		serviceTypeListeners.remove(aListener);
237
	}
239
	}
240
241
	/* (non-Javadoc)
242
	 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServiceInfo(org.eclipse.ecf.discovery.identity.IServiceID)
243
	 */
244
	public IFutureStatus getAsyncServiceInfo(IServiceID service) {
245
		throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
246
	}
247
248
	/* (non-Javadoc)
249
	 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServiceTypes()
250
	 */
251
	public IFutureStatus getAsyncServiceTypes() {
252
		throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
253
	}
254
255
	/* (non-Javadoc)
256
	 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServices()
257
	 */
258
	public IFutureStatus getAsyncServices() {
259
		throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
260
	}
261
262
	/* (non-Javadoc)
263
	 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServices(org.eclipse.ecf.discovery.identity.IServiceTypeID)
264
	 */
265
	public IFutureStatus getAsyncServices(IServiceTypeID type) {
266
		throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
267
	}
268
269
	/* (non-Javadoc)
270
	 * @see org.eclipse.ecf.discovery.IDiscoveryAdvertiser#unregisterAllServices()
271
	 */
272
	public IFutureStatus unregisterAllServices() {
273
		throw new UnsupportedOperationException("Not yet implemeted"); //$NON-NLS-1$
274
	}
275
276
	/* (non-Javadoc)
277
	 * @see org.eclipse.ecf.discovery.IDiscoveryLocator#purgeCache()
278
	 */
279
	public IServiceInfo[] purgeCache() {
280
		return new IServiceInfo[] {};
281
	}
238
}
282
}
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %plugin.name
3
Bundle-Name: %plugin.name
4
Bundle-SymbolicName: org.eclipse.ecf.discovery;singleton:=true
4
Bundle-SymbolicName: org.eclipse.ecf.discovery;singleton:=true
5
Bundle-Version: 2.1.0.qualifier
5
Bundle-Version: 3.0.0.qualifier
6
Bundle-Activator: org.eclipse.ecf.internal.discovery.DiscoveryPlugin
6
Bundle-Activator: org.eclipse.ecf.internal.discovery.DiscoveryPlugin
7
Bundle-Vendor: %plugin.provider
7
Bundle-Vendor: %plugin.provider
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
(-)src/org/eclipse/ecf/discovery/IDiscoveryAdvertiser.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ecf.discovery;
13
14
import org.eclipse.ecf.core.util.IFutureStatus;
15
16
/**
17
 * @since 3.0
18
 */
19
public interface IDiscoveryAdvertiser {
20
	/**
21
	 * Register the given service. This publishes the service defined by the
22
	 * first parameter to the underlying publishing mechanism
23
	 * 
24
	 * @param serviceInfo
25
	 *            IServiceInfo of the service to be published. Must not be
26
	 *            <code>null</code>.
27
	 * @return IFutureStatus indicates whether service registration has been successfully 
28
	 */
29
	public IFutureStatus registerService(IServiceInfo serviceInfo);
30
31
	/**
32
	 * Unregister a previously registered service defined by serviceInfo.
33
	 * 
34
	 * @param serviceInfo
35
	 *            IServiceInfo defining the service to unregister. Must not be
36
	 *            <code>null</code>.
37
	 * @return IFutureStatus indicates whether service deregistration has been successfully 
38
	 */
39
	public IFutureStatus unregisterService(IServiceInfo serviceInfo);
40
41
	/**
42
	 * Unregister all previously registered service.
43
	 * 
44
	 * @return IFutureStatus indicates whether service deregistration has been successfully 
45
	 */
46
	public IFutureStatus unregisterAllServices();
47
}
(-)src/org/eclipse/ecf/discovery/IDiscoveryLocator.java (+105 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Versant Corp.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Markus Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ecf.discovery;
13
14
import org.eclipse.ecf.core.util.IFutureStatus;
15
import org.eclipse.ecf.discovery.identity.IServiceID;
16
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
17
18
/**
19
 * @since 3.0
20
 */
21
public interface IDiscoveryLocator {
22
23
	/**
24
	 * Synchronously retrieve info about the service
25
	 * 
26
	 * @param service
27
	 *            IServiceID of the service to get info about. Must not be
28
	 *            <code>null</code>.
29
	 * @return IServiceInfo the service info retrieved. <code>null</code> if
30
	 *         no information retrievable.
31
	 */
32
	public IServiceInfo getServiceInfo(IServiceID service);
33
34
	/**
35
	 * Synchronously get service info about all known services
36
	 * 
37
	 * @return IServiceInfo[] the resulting array of service info instances.
38
	 *         Will not be <code>null</code>. May be of length 0.
39
	 */
40
	public IServiceInfo[] getServices();
41
42
	/**
43
	 * Synchronously get service info about all known services of given service type
44
	 * 
45
	 * @param type
46
	 *            IServiceTypeID defining the type of service we are interested in
47
	 *            getting service info about. Must not be <code>null</code>
48
	 * @return IServiceInfo[] the resulting array of service info instances.
49
	 *         Will not be <code>null</code>. May be of length 0.
50
	 */
51
	public IServiceInfo[] getServices(IServiceTypeID type);
52
53
	/**
54
	 * Synchronously get service info about all known services of given service type
55
	 * 
56
	 * @return IServiceTypeID[] the resulting array of service type IDs.
57
	 *         Will not be <code>null</code>. May be of length 0.
58
	 */
59
	public IServiceTypeID[] getServiceTypes();
60
61
	/**
62
	 * Asynchronously retrieve info about the service
63
	 * 
64
	 * @param service
65
	 *            IServiceID of the service to get info about. Must not be
66
	 *            <code>null</code>.
67
	 * @return IFutureStatus a future status wrapping an IServiceInfo or <code>null</code> if
68
	 *         no information retrievable.
69
	 */
70
	public IFutureStatus getAsyncServiceInfo(IServiceID service);
71
72
	/**
73
	 * Asynchronously get service info about all known services
74
	 * 
75
	 * @return IFutureStatus wrapping an IServiceTypeID[]. The resulting array of 
76
	 * 	service type IDs will not be <code>null</code>. May be of length 0.
77
	 */
78
	public IFutureStatus getAsyncServices();
79
80
	/**
81
	 * Asynchronously get service info about all known services of given service type
82
	 * 
83
	 * @param type
84
	 *            IServiceTypeID defining the type of service we are interested in
85
	 *            getting service info about. Must not be <code>null</code>
86
	 * @return IFutureStatus wrapping an IServiceTypeID[]. The resulting array of 
87
	 * 	service type IDs will not be <code>null</code>. May be of length 0.
88
	 */
89
	public IFutureStatus getAsyncServices(IServiceTypeID type);
90
91
	/**
92
	 * Asynchronously get service info about all known services of given service type
93
	 * 
94
	 * @return IFutureStatus wrapping an IServiceTypeID[]. The resulting array of 
95
	 * 	service type IDs will not be <code>null</code>. May be of length 0.
96
	 */
97
	public IFutureStatus getAsyncServiceTypes();
98
99
	/**
100
	 * Purges the underlying IServiceInfo cache if available in the current provider
101
	 * 
102
	 * @return The previous cache content
103
	 */
104
	public IServiceInfo[] purgeCache();
105
}
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>

Return to bug 257861