Search in sources :

Example 1 with ApplicationContextAccessor

use of org.craftercms.engine.util.spring.ApplicationContextAccessor in project engine by craftercms.

the class GroovyScriptUtils method addJobScriptVariables.

public static void addJobScriptVariables(Map<String, Object> variables, ServletContext servletContext) {
    SiteContext siteContext = SiteContext.getCurrent();
    if (siteContext != null && siteContext.getApplicationContext() != null) {
        ApplicationContextAccessor appContext = new ApplicationContextAccessor();
        appContext.setApplicationContext(siteContext.getApplicationContext());
        variables.put(VARIABLE_APPLICATION_CONTEXT, appContext);
    }
    variables.put(VARIABLE_APPLICATION, servletContext);
    variables.put(VARIABLE_LOGGER, GROOVY_SCRIPT_LOGGER);
    addSiteContextVariable(variables);
    addSiteConfigVariable(variables);
}
Also used : ApplicationContextAccessor(org.craftercms.engine.util.spring.ApplicationContextAccessor) SiteContext(org.craftercms.engine.service.context.SiteContext)

Example 2 with ApplicationContextAccessor

use of org.craftercms.engine.util.spring.ApplicationContextAccessor in project engine by craftercms.

the class CrafterFreeMarkerView method initServletContext.

@Override
protected void initServletContext(ServletContext servletContext) throws BeansException {
    super.initServletContext(servletContext);
    servletContextHashModel = new ServletContextHashModel(servletContext, getObjectWrapper());
    applicationContextAccessor = new ApplicationContextAccessor(getApplicationContext());
}
Also used : ApplicationContextAccessor(org.craftercms.engine.util.spring.ApplicationContextAccessor) ServletContextHashModel(org.craftercms.engine.freemarker.ServletContextHashModel)

Aggregations

ApplicationContextAccessor (org.craftercms.engine.util.spring.ApplicationContextAccessor)2 ServletContextHashModel (org.craftercms.engine.freemarker.ServletContextHashModel)1 SiteContext (org.craftercms.engine.service.context.SiteContext)1