Java 类org.apache.velocity.tools.view.servlet.ServletToolboxManager 实例源码

项目:spring-velocity-adapter    文件:VelocityToolboxView.java   
/**
 * Overridden to create a ChainedContext, which is part of the view package
 * of Velocity Tools, as special context. ChainedContext is needed for
 * initialization of ViewTool instances.
 * @see #initTool
 */
@Override
protected Context createVelocityContext(
        Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {

    // Create a ChainedContext instance.
    ChainedContext velocityContext = new ChainedContext(
            new VelocityContext(model), getVelocityEngine(), request, response, getServletContext());

    // Load a Velocity Tools toolbox, if necessary.
    if (getToolboxConfigLocation() != null) {
        ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
                getServletContext(), getToolboxConfigLocation());
        Map<String, Object> toolboxContext = toolboxManager.getToolbox(velocityContext);
        velocityContext.setToolbox(toolboxContext);
    }

    return velocityContext;
}
项目:spring4-understanding    文件:VelocityToolboxView.java   
/**
 * Overridden to create a ChainedContext, which is part of the view package
 * of Velocity Tools, as special context. ChainedContext is needed for
 * initialization of ViewTool instances.
 * @see #initTool
 */
@Override
protected Context createVelocityContext(
        Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {

    // Create a ChainedContext instance.
    ChainedContext velocityContext = new ChainedContext(
            new VelocityContext(model), getVelocityEngine(), request, response, getServletContext());

    // Load a Velocity Tools toolbox, if necessary.
    if (getToolboxConfigLocation() != null) {
        ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
                getServletContext(), getToolboxConfigLocation());
        Map<?, ?> toolboxContext = toolboxManager.getToolbox(velocityContext);
        velocityContext.setToolbox(toolboxContext);
    }

    return velocityContext;
}
项目:class-guard    文件:VelocityToolboxView.java   
/**
 * Overridden to create a ChainedContext, which is part of the view package
 * of Velocity Tools, as special context. ChainedContext is needed for
 * initialization of ViewTool instances.
 * @see #initTool
 */
@Override
protected Context createVelocityContext(
        Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {

    // Create a ChainedContext instance.
    ChainedContext velocityContext = new ChainedContext(
            new VelocityContext(model), getVelocityEngine(), request, response, getServletContext());

    // Load a Velocity Tools toolbox, if necessary.
    if (getToolboxConfigLocation() != null) {
        ToolboxManager toolboxManager = ServletToolboxManager.getInstance(
                getServletContext(), getToolboxConfigLocation());
        Map toolboxContext = toolboxManager.getToolbox(velocityContext);
        velocityContext.setToolbox(toolboxContext);
    }

    return velocityContext;
}
项目:struts2    文件:VelocityManager.java   
/**
 * Initializes the ServletToolboxManager for this servlet's
 * toolbox (if any).
 *
 * @param context the servlet context
 */
protected void initToolbox(ServletContext context) {
    /* if we have a toolbox, get a manager for it */
    if (StringUtils.isNotBlank(toolBoxLocation)) {
        toolboxManager = ServletToolboxManager.getInstance(context, toolBoxLocation);
    } else {
        Velocity.info("VelocityViewServlet: No toolbox entry in configuration.");
    }
}