private Template getTemplate(TopLevelTemplate template) throws IOException {

        // Create a new FreeMarker config for each top-level template, so that
        // they don't share the same macro namespace
        Configuration fmConfig = newFreeMarkerConfig();

        // Common child templates
        importChildTemplates(fmConfig, templateConfig.getCommonChildTemplates());
        // Child templates declared for the top-level template
        importChildTemplates(fmConfig, template.getChildTemplates());

        return fmConfig.getTemplate(template.getMainTemplate());
    }
Util class that sets up the freemarker configuration and loads the templates.
aws-java-sdk-code-generator/src/main/java/com/amazonaws/codegen/internal/Freemarker.java