KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > services > IServiceLocator


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
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  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.ui.services;
13
14 /**
15  * <p>
16  * A component with which one or more services are registered. The services can
17  * be retrieved from this locator using some key -- typically the class
18  * representing the interface the service must implement. For example:
19  * </p>
20  *
21  * <pre>
22  * IHandlerService service = (IHandlerService) workbenchWindow
23  * .getService(IHandlerService.class);
24  * </pre>
25  *
26  * <p>
27  * This interface is not to be implemented or extended by clients.
28  * </p>
29  *
30  * @since 3.2
31  */

32 public interface IServiceLocator {
33
34     /**
35      * Retrieves the service corresponding to the given API.
36      *
37      * @param api
38      * This is the interface that the service implements. Must not be
39      * <code>null</code>.
40      * @return The service, or <code>null</code> if no such service could be
41      * found.
42      */

43     public Object JavaDoc getService(Class JavaDoc api);
44
45     /**
46      * Whether this service exists within the scope of this service locator.
47      * This does not include looking for the service within the scope of the
48      * parents. This method can be used to determine whether a particular
49      * service supports nesting in this scope.
50      *
51      * @param api
52      * This is the interface that the service implements. Must not be
53      * <code>null</code>.
54      * @return <code>true</code> iff the service locator can find a service
55      * for the given API; <code>false</code> otherwise.
56      */

57     public boolean hasService(Class JavaDoc api);
58 }
59
Popular Tags