1 /******************************************************************************* 2 * Copyright (c) 2005 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 package org.eclipse.ui.internal.components.framework; 12 13 14 /** 15 * An <code>IServiceProvider</code> returns services given identifying keys. 16 * Most service providers will lazily each service the first time it is requested, 17 * and will return the same instance thereafter. Component factories will typically use a 18 * service provider to locate the dependencies for a component when it is first 19 * created, and the component itself will usually not need to use the service provider 20 * once it is constructed. 21 * 22 * <p> 23 * Not intended to be implemented by clients. 24 * </p> 25 * 26 * <p>EXPERIMENTAL: The components framework is currently under active development. All 27 * aspects of this class including its existence, name, and public interface are likely 28 * to change during the development of Eclipse 3.1</p> 29 * 30 * @since 3.1 31 */ 32 public interface IServiceProvider { 33 /** 34 * Returns a component for the given key. Returns null if the given key is not known. 35 * Components returned by this method are managed by the component provider. The 36 * caller does not need to dispose it when done. 37 * 38 * @param key identifier for the service 39 * @return a component that is assignable to the given type, such that 40 * toQuery.isAssignable(container.getComponent(toQuery)). 41 * @throws ComponentException if unable to create the component 42 */ 43 Object getService(Object key) throws ComponentException; 44 45 /** 46 * Returns true iff this component provider recognises the given key. If this method 47 * returns true, then getComponent(...) will not return null when given the same 48 * key. 49 * 50 * @param key identifier for the service 51 * @return true iff this provider contains the given service 52 */ 53 boolean hasService(Object key); 54 } 55