/**********************************************************************************
 * $URL: https://source.sakaiproject.org/svn/component/tags/sakai_2-3-1/component-api/component/src/java/org/sakaiproject/component/api/ComponentManager.java $
 * $Id: ComponentManager.java 8039 2006-04-20 17:01:39Z ggolden@umich.edu $
 ***********************************************************************************
 *
 * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
 * 
 * Licensed under the Educational Community License, Version 1.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at
 * 
 *      http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 *
 **********************************************************************************/

package org.sakaiproject.component.api;

import java.util.Properties;
import java.util.Set;

/**
 * <p>
 * ...
 * </p>
 */
public interface ComponentManager
{
	/** The java system property name where the full path to the components packages. */
	public static final String SAKAI_COMPONENTS_ROOT_SYS_PROP = "sakai.components.root";

	/**
	 * Find a component that is registered to provide this interface.
	 * 
	 * @param iface
	 *        The interface Class.
	 * @return a component instance, or null if not found.
	 */
	Object get(Class iface);

	/**
	 * Find a component that is registered to provide this interface.
	 * 
	 * @param ifaceName
	 *        The fully qualified interface Class name.
	 * @return a component instance, or null if not found.
	 */
	Object get(String ifaceName);

	/**
	 * Check if this interface Class has a registered component.
	 * 
	 * @param iface
	 *        The interface Class.
	 * @return <strong>true</strong> if this interface Class has a registered component, <strong>false</strong> if not.
	 */
	boolean contains(Class iface);

	/**
	 * Check if this interface Class name has a registered component.
	 * 
	 * @param ifaceName
	 *        The fully qualified interface Class name.
	 * @return <strong>true</strong> if this interface has a registered component, <strong>false</strong> if not.
	 */
	boolean contains(String ifaceName);

	/**
	 * Get all interfaces registered in the component manager.
	 * 
	 * @return A Set (String class name) of all interfaces registered in the component manager.
	 */
	Set getRegisteredInterfaces();

	/**
	 * Load a singleton already created component for this interface class as a singleton.
	 * 
	 * @param iface
	 *        The interface class.
	 * @param component
	 *        The alread created component.
	 */
	void loadComponent(Class iface, Object component);

	/**
	 * Load a singleton already created component for this interface class as a singleton.
	 * 
	 * @param ifaceName
	 *        The fully qualified interface Class name.
	 * @param component
	 *        The alread created component.
	 */
	void loadComponent(String ifaceName, Object component);

	/**
	 * Close the component manager, shutting down any created singletons.
	 */
	void close();

	/**
	 * Access the configuration properties used when configuring components.
	 * 
	 * @return The Properties with the configuration values used when configuring components.
	 */
	Properties getConfig();

	/**
	 * Wait right here till the component manager is fully configured.
	 */
	void waitTillConfigured();
	
	/**
	 * Check if the ComponentManager has already been or is in the processing of being closed.
	 * @return true if closed, false if not.
	 */
	boolean hasBeenClosed();
}
