private IComponent instantiateComponent()

in tapestry-framework/src/org/apache/tapestry/pageload/PageLoader.java [589:645]


    private IComponent instantiateComponent(
        IPage page,
        IComponent container,
        String id,
        IComponentSpecification spec,
        INamespace namespace,
        ILocation location)
    {
        IComponent result = null;
        String className = spec.getComponentClassName();

        if (Tapestry.isBlank(className))
            className = BaseComponent.class.getName();

        Class componentClass = _enhancer.getEnhancedClass(spec, className);
        String enhancedClassName = componentClass.getName();

        try
        {
            result = (IComponent) componentClass.newInstance();

        }
        catch (ClassCastException ex)
        {
            throw new ApplicationRuntimeException(
                Tapestry.format("PageLoader.class-not-component", enhancedClassName),
                container,
                spec.getLocation(),
                ex);
        }
        catch (Throwable ex)
        {
            throw new ApplicationRuntimeException(
                Tapestry.format("PageLoader.unable-to-instantiate", enhancedClassName),
                container,
                spec.getLocation(),
                ex);
        }

        if (result instanceof IPage)
            throw new ApplicationRuntimeException(
                Tapestry.format("PageLoader.page-not-allowed", result.getExtendedId()),
                result,
                null,
                null);

        result.setNamespace(namespace);
        result.setSpecification(spec);
        result.setPage(page);
        result.setContainer(container);
        result.setId(id);
        result.setLocation(location);

        _count++;

        return result;
    }