Package org.springframework.web.context

Examples of org.springframework.web.context.WebApplicationContext


     * auto-injected from request parameter values etc) so that it can be
     * accessed easily from inside JSP EL (or other expression languages in
     * other view technologies).
     */
    protected Map createRequestContextWrapper(final ServletRequest request) {
        final WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
        Map wrapper = new AbstractMap() {

            public WebApplicationContext getContext() {
                return context;
            }

            public Object get(Object key) {
                if (key == null) {
                    return null;
                }
                return bindRequestBean(context.getBean(key.toString()), request);
            }

            public Set entrySet() {
                return Collections.EMPTY_SET;
            }
View Full Code Here


   *
   * @param name bean name
   * @return the bean
   */
  protected Object getBean(String name) {
    WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
    if( applicationContext == null ) {
      throw new IllegalStateException("No Spring web application context found");
    }
    if( !applicationContext.containsBean(name) ) {
      {
        throw new IllegalArgumentException("Spring bean not found: " + name);
      }
    }
    return applicationContext.getBean(name);
  }
View Full Code Here

    @Before
    public void setup() throws JspException {
        context = new RenderContext();
        service = createNiceMock(RenderService.class);
        scriptManager = createMock(ScriptManager.class);
        WebApplicationContext wContext = createNiceMock(WebApplicationContext.class);
        expect(wContext.getBean(RenderService.class)).andReturn(service).anyTimes();
        expect(wContext.getBean(ScriptManager.class)).andReturn(scriptManager).anyTimes();
        replay(wContext);
        ServletContext servletContext = createNiceMock(ServletContext.class);
        expect(servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)).andReturn(wContext).anyTimes();
        replay(servletContext);
        ServletRequest request = new MockHttpServletRequest();
View Full Code Here

                            .append("'\n");
                }
                logger.debug("[init] parameters: " + sb);
            }

            WebApplicationContext rootContext = prepareRootApplicationContext();

            if (logger.isInfoEnabled()) {
                logger.info("[init] exits from 'init/rootContext'");
                logger.info("[init] call 'init/module'");
            }
View Full Code Here

        return false;
    }

    @Override
    public void destroy() {
        WebApplicationContext rootContext = WebApplicationContextUtils
                .getWebApplicationContext(getServletContext());
        if (rootContext != null) {
            try {
                if (rootContext instanceof AbstractApplicationContext) {
                    ((AbstractApplicationContext) rootContext).close(); // rose.root
View Full Code Here

   */
  public WebApplication createApplication(final WicketFilter filter)
  {
    ServletContext sc = filter.getFilterConfig().getServletContext();

    WebApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(sc);

    if (getContextConfigLocation(filter) != null)
    {
      additionalContext = createWebApplicationContext(ac, filter);
    }
View Full Code Here

   * global context has been found
   */
  public static WebApplicationContext getWebApplicationContext(
      ServletRequest request, ServletContext servletContext) throws IllegalStateException {

    WebApplicationContext webApplicationContext = (WebApplicationContext) request.getAttribute(
        DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    if (webApplicationContext == null) {
      if (servletContext == null) {
        throw new IllegalStateException("No WebApplicationContext found: not in a DispatcherServlet request?");
      }
View Full Code Here

    }
    if (servletRequest == null && tilesApplicationContext == null) {
      throw new IllegalStateException("SpringBeanPreparerFactory requires either a " +
          "ServletRequest or a ServletTilesApplicationContext to operate on");
    }
    WebApplicationContext webApplicationContext = RequestContextUtils.getWebApplicationContext(
        servletRequest, tilesApplicationContext.getServletContext());
    return getPreparer(name, webApplicationContext);
  }
View Full Code Here

   * @throws BeansException if the context couldn't be initialized
   * @see #setContextClass
   * @see #setContextConfigLocation
   */
  protected WebApplicationContext initWebApplicationContext() throws BeansException {
    WebApplicationContext wac = findWebApplicationContext();
    if (wac == null) {
      // No fixed context defined for this servlet - create a local one.
      WebApplicationContext parent =
          WebApplicationContextUtils.getWebApplicationContext(getServletContext());
      wac = createWebApplicationContext(parent);
    }

    if (!this.refreshEventReceived) {
View Full Code Here

  protected WebApplicationContext findWebApplicationContext() {
    String attrName = getContextAttribute();
    if (attrName == null) {
      return null;
    }
    WebApplicationContext wac =
        WebApplicationContextUtils.getWebApplicationContext(getServletContext(), attrName);
    if (wac == null) {
      throw new IllegalStateException("No WebApplicationContext found: initializer not registered?");
    }
    return wac;
View Full Code Here

TOP

Related Classes of org.springframework.web.context.WebApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.