/* JFox, the OpenSource J2EE Application Server
 *
 * Distributable under GNU LGPL license by gun.org
 * more details please visit http://www.huihoo.org/jfox
 */

package org.jfox.framework;

import java.lang.reflect.Constructor;

/**
 * Constructor injector, default
 *
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */

public class ConstrComponentFactory extends InstantiatingComponentFactory {

    public ConstrComponentFactory(Class implementation, Parameter[] constrParams) throws ComponentException {
        super(implementation, constrParams);
    }

    public ConstrComponentFactory(ComponentName name, Parameter[] constrParams) throws ComponentException {
        super(name, constrParams);
    }

    protected Component instantiateComponent(Constructor constructor, Object[] params) throws ComponentException {
        try {
            Object comp = constructor.newInstance(params);
            return (Component) comp;
        }
        catch(Exception e) {
            throw new ComponentException("instantiate component error " + getImplementation().getName(), e);
        }
    }

    public static void main(String[] args) {

    }

}

