package org.seasar.framework.container.impl;

import java.util.ArrayList;
import java.util.List;

import org.seasar.framework.container.TooManyRegistrationRuntimeException;

/**
 * @author higa
 *
 * 1つのキーに複数のコンポーネントが登録された場合に使用されます。
 */
public class TooManyRegistrationComponentDef extends SimpleComponentDef {

	private Object key_;
	private List componentClasses_ = new ArrayList();

	/**
	 * 
	 */
	public TooManyRegistrationComponentDef(Object key) {
		key_ = key;
	}

	public void addComponentClass(Class componentClass) {
		componentClasses_.add(componentClass);
	}

	/**
	 * @see org.seasar.framework.container.ComponentDef#getComponent()
	 */
	public Object getComponent() throws TooManyRegistrationRuntimeException {
		throw new TooManyRegistrationRuntimeException(
			key_,
			(Class[]) componentClasses_.toArray(
				new Class[componentClasses_.size()]));
	}
}
