protected Context createToolManagedVelocityContext()

in doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java [475:518]


    protected Context createToolManagedVelocityContext(SiteRenderingContext siteRenderingContext) {
        Locale locale = siteRenderingContext.getLocale();
        String dateFormat = siteRenderingContext.getSiteModel().getPublishDate().getFormat();
        String timeZoneId = siteRenderingContext.getSiteModel().getPublishDate().getTimezone();
        TimeZone timeZone =
                "system".equalsIgnoreCase(timeZoneId) ? TimeZone.getDefault() : TimeZone.getTimeZone(timeZoneId);

        EasyFactoryConfiguration config = new EasyFactoryConfiguration(false);
        config.property("safeMode", Boolean.FALSE);
        config.toolbox(Scope.REQUEST)
                .tool(ContextTool.class)
                .tool(LinkTool.class)
                .tool(LoopTool.class)
                .tool(RenderTool.class);
        config.toolbox(Scope.APPLICATION)
                .property("locale", locale)
                .tool(AlternatorTool.class)
                .tool(ClassTool.class)
                .tool(ComparisonDateTool.class)
                .property("format", dateFormat)
                .property("timezone", timeZone)
                .tool(ConversionTool.class)
                .property("dateFormat", dateFormat)
                .tool(DisplayTool.class)
                .tool(EscapeTool.class)
                .tool(FieldTool.class)
                .tool(MathTool.class)
                .tool(NumberTool.class)
                .tool(ResourceTool.class)
                .property("bundles", new String[] {"site-renderer"})
                .tool(SortTool.class)
                .tool(XmlTool.class);

        FactoryConfiguration customConfig = ConfigurationUtils.findInClasspath(TOOLS_LOCATION);

        if (customConfig != null) {
            config.addConfiguration(customConfig);
        }

        ToolManager manager = new ToolManager(false, false);
        manager.configure(config);

        return manager.createContext();
    }