List allTemplates = ListUtil.list();
Map alreadyParsedTemplates = MapUtil.map();
List allResources = resourceManager().allResources();
for (int index = 0, length = allResources.size(); index < length; index++) {
AWResource resource = (AWResource)allResources.get(index);
String relativePath = resource.relativePath();
if (relativePath == null) {
logWarning("**** Skipping malformed resource: " + resource);
}
else if (!relativePath.equals(alreadyParsedTemplates.get(relativePath))) {
alreadyParsedTemplates.put(relativePath, relativePath);
if (relativePath.endsWith("AXEtd.awl")) {
logString("*** Skipping parse of AXEtd.awl");
continue;
}
if (relativePath.endsWith(".awl") || relativePath.endsWith(".htm") || relativePath.endsWith(".html")) {
try {
if (instantiateDefinitions) {
String componentName = (new File(relativePath).getName());
componentName = AWUtil.substringTo(componentName, '.');
logString("-Loading " + relativePath + " (" + componentName + ")");
AWComponentDefinition componentDefinition = null;
try {
componentDefinition = componentDefinitionForName(componentName);
}
catch (AWGenericException e) {
// fall through to test below...
}
if (componentDefinition == null) {
logWarning(" *** null component definition");
continue;
}
AWComponentReference sharedComponentReference = componentDefinition.sharedComponentReference();
// AWComponent instance = componentDefinition.createComponent(sharedComponentReference, null, requestContext);
AWComponent instance = componentDefinition.newComponentInstance();
instance._setup(sharedComponentReference, new AWPage(instance, requestContext));
if (instance == null) {
logWarning(" *** null component instance");
continue;
}
if (StringUtil.nullOrEmptyString(instance.name())) {
logWarning(" *** null component name");
continue;
}
if (AWConcreteApplication.IsDebuggingEnabled) {
instance.validate(requestContext.validationContext());
}
allTemplates.add(instance.loadTemplate());
}
else {
InputStream inputStream = resource.inputStream();
String templateString = AWComponent.readTemplateString(inputStream);
logString("-Parsing " + relativePath);
AWTemplate template = AWComponent.defaultTemplateParser().templateFromString(templateString, relativePath);
allTemplates.add(template);
}