blob: 40febe65a467b3c0edeafc2084b8029852dd8cd0 (
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
|
/*******************************************************************************
* Copyright (c) 2014 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.te.runtime.services;
import org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService;
import org.eclipse.tcf.te.runtime.services.interfaces.IService;
import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
/**
* ServiceUtils
*/
public final class ServiceUtils {
public static <V extends Object> V getUIServiceDelegate(Object context, Object delegateContext, Class<? extends V> delegateClass) {
IService[] services = ServiceManager.getInstance().getServices(context, IUIService.class, false);
for (IService service : services) {
V delegate = ((IUIService)service).getDelegate(delegateContext, delegateClass);
if (delegate != null) {
return delegate;
}
}
return null;
}
public static <V extends Object> V getDelegateServiceDelegate(Object context, Object delegateContext, Class<? extends V> delegateClass) {
IService[] services = ServiceManager.getInstance().getServices(context, IDelegateService.class, false);
for (IService service : services) {
V delegate = ((IDelegateService)service).getDelegate(delegateContext, delegateClass);
if (delegate != null) {
return delegate;
}
}
return null;
}
}
|