01: /*******************************************************************************
02: * Copyright (c) 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.ui.services;
11:
12: /**
13: * <p>
14: * A component with which one or more services are registered. The services can
15: * be retrieved from this locator using some key -- typically the class
16: * representing the interface the service must implement. For example:
17: * </p>
18: *
19: * <pre>
20: * IHandlerService service = (IHandlerService) workbenchWindow
21: * .getService(IHandlerService.class);
22: * </pre>
23: *
24: * <p>
25: * This interface is not to be implemented or extended by clients.
26: * </p>
27: *
28: * @since 3.2
29: */
30: public interface IServiceLocator {
31:
32: /**
33: * Retrieves the service corresponding to the given API.
34: *
35: * @param api
36: * This is the interface that the service implements. Must not be
37: * <code>null</code>.
38: * @return The service, or <code>null</code> if no such service could be
39: * found.
40: */
41: public Object getService(Class api);
42:
43: /**
44: * Whether this service exists within the scope of this service locator.
45: * This does not include looking for the service within the scope of the
46: * parents. This method can be used to determine whether a particular
47: * service supports nesting in this scope.
48: *
49: * @param api
50: * This is the interface that the service implements. Must not be
51: * <code>null</code>.
52: * @return <code>true</code> iff the service locator can find a service
53: * for the given API; <code>false</code> otherwise.
54: */
55: public boolean hasService(Class api);
56: }
|