Search in sources :

Example 1 with DeprecatedContext

use of com.xpn.xwiki.api.DeprecatedContext in project xwiki-platform by xwiki.

the class DefaultVelocityManager method getVelocityContext.

@Override
public VelocityContext getVelocityContext() {
    ScriptVelocityContext velocityContext;
    // Make sure the velocity context support ScriptContext synchronization
    VelocityContext currentVelocityContext = getCurrentVelocityContext();
    if (currentVelocityContext instanceof ScriptVelocityContext) {
        velocityContext = (ScriptVelocityContext) currentVelocityContext;
    } else {
        velocityContext = new ScriptVelocityContext(currentVelocityContext, this.reservedBindings);
        this.execution.getContext().setProperty(VelocityExecutionContextInitializer.VELOCITY_CONTEXT_ID, velocityContext);
    }
    // Synchronize with ScriptContext
    ScriptContext scriptContext = this.scriptContextManager.getScriptContext();
    velocityContext.setScriptContext(scriptContext);
    // Velocity specific bindings
    XWikiContext xcontext = this.xcontextProvider.get();
    // Add the "context" binding which is deprecated since 1.9.1.
    velocityContext.put("context", new DeprecatedContext(xcontext));
    return velocityContext;
}
Also used : VelocityContext(org.apache.velocity.VelocityContext) ScriptContext(javax.script.ScriptContext) XWikiContext(com.xpn.xwiki.XWikiContext) DeprecatedContext(com.xpn.xwiki.api.DeprecatedContext)

Aggregations

XWikiContext (com.xpn.xwiki.XWikiContext)1 DeprecatedContext (com.xpn.xwiki.api.DeprecatedContext)1 ScriptContext (javax.script.ScriptContext)1 VelocityContext (org.apache.velocity.VelocityContext)1