Example usage for org.springframework.web.context.support AbstractRefreshableWebApplicationContext getServletContext

List of usage examples for org.springframework.web.context.support AbstractRefreshableWebApplicationContext getServletContext

Introduction

In this page you can find the example usage for org.springframework.web.context.support AbstractRefreshableWebApplicationContext getServletContext.

Prototype

@Override
    @Nullable
    public ServletContext getServletContext() 

Source Link

Usage

From source file:no.dusken.common.plugin.velocity.RenderPluginDirective.java

private VelocityEngine getVelocityEngine(InternalContextAdapter context) {
    if (velocityEngine == null) {
        InternalContextAdapter ica = context.getBaseContext();
        AbstractRefreshableWebApplicationContext webApplicationContext = (AbstractRefreshableWebApplicationContext) ica
                .get("org.springframework.web.servlet.DispatcherServlet.CONTEXT");
        ServletContext sc = webApplicationContext.getServletContext();
        WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
        velocityEngine = wac.getBean(VelocityEngine.class);
    }//ww w .ja v  a 2s  . com
    return velocityEngine;
}

From source file:no.dusken.common.plugin.velocity.RenderPluginDirective.java

private List<PluginManager<DuskenPlugin>> getPluginManagers(InternalContextAdapter context) {
    if (pluginManagers == null) {
        InternalContextAdapter ica = context.getBaseContext();
        AbstractRefreshableWebApplicationContext webApplicationContext = (AbstractRefreshableWebApplicationContext) ica
                .get("org.springframework.web.servlet.DispatcherServlet.CONTEXT");
        ServletContext sc = webApplicationContext.getServletContext();
        WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
        Map<String, PluginManager> beans = wac.getBeansOfType(PluginManager.class);
        pluginManagers = new LinkedList<PluginManager<DuskenPlugin>>();
        //This do seem a bit strange. But I did not manage to get the casting right.
        for (String name : beans.keySet()) {
            PluginManager<DuskenPlugin> pluginManager = (PluginManager<DuskenPlugin>) wac.getBean(name);
            pluginManagers.add(pluginManager);

        }//from   ww  w.j  a v  a2s  .c o  m
    }
    return pluginManagers;
}