in tapestry-framework/src/org/apache/tapestry/pageload/PageLoader.java [661:718]
private IPage instantiatePage(String name, INamespace namespace, IComponentSpecification spec)
{
IPage result = null;
String pageName = namespace.constructQualifiedName(name);
String className = spec.getComponentClassName();
ILocation location = spec.getLocation();
if (Tapestry.isBlank(className))
{
if (LOG.isDebugEnabled())
LOG.debug(
"Page "
+ namespace.constructQualifiedName(name)
+ " does not specify a component class.");
className =
_engine.getPropertySource().getPropertyValue(
"org.apache.tapestry.default-page-class");
if (className == null)
className = BasePage.class.getName();
if (LOG.isDebugEnabled())
LOG.debug("Defaulting to class " + className);
}
Class pageClass = _enhancer.getEnhancedClass(spec, className);
String enhancedClassName = pageClass.getName();
try
{
result = (IPage) pageClass.newInstance();
result.setNamespace(namespace);
result.setSpecification(spec);
result.setPageName(pageName);
result.setPage(result);
result.setLocale(_locale);
result.setLocation(location);
}
catch (ClassCastException ex)
{
throw new ApplicationRuntimeException(
Tapestry.format("PageLoader.class-not-page", enhancedClassName),
location,
ex);
}
catch (Exception ex)
{
throw new ApplicationRuntimeException(
Tapestry.format("PageLoader.unable-to-instantiate", enhancedClassName),
location,
ex);
}
return result;
}