Examples of WebApplicationContext


Examples of org.springframework.web.context.WebApplicationContext

    public <T, U extends T> U newClassInstance(AtmosphereFramework framework,
                                               Class<T> classType,
                                               Class<U> classToInstantiate)
            throws InstantiationException, IllegalAccessException {

        WebApplicationContext parent = WebApplicationContextUtils.getWebApplicationContext(framework.getServletContext());
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.setParent(parent);
        context.register(classToInstantiate);
        context.refresh();
        U t = context.getBean(classToInstantiate);
View Full Code Here

Examples of org.springframework.web.context.WebApplicationContext

  @Test
  public void injectsPagedResourcesAssembler() {

    assumeThat(SpringVersion.getVersion(), startsWith("3.2"));

    WebApplicationContext context = WebTestUtils.createApplicationContext(Config.class);
    SampleController controller = context.getBean(SampleController.class);

    assertThat(controller.assembler, is(notNullValue()));

    PagedResources<Resource<Person>> resources = controller.sample(new PageRequest(1, 1));
View Full Code Here

Examples of org.springframework.web.context.WebApplicationContext

    @Override
    protected void servletInitialized() throws ServletException {
        getService().addSessionInitListener(new SessionInitListener() {
            @Override
            public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException {
                WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
                SpringAwareUIProvider uiProvider = new SpringAwareUIProvider(webApplicationContext);
                sessionInitEvent.getSession().addUIProvider(uiProvider);
            }
        });
    }
View Full Code Here

Examples of org.springframework.web.context.WebApplicationContext

    if (logger.isDebugEnabled()) {
      logger.debug("Using session factory '"
          + getSessionFactoryBeanName()
          + "' for OpenSessionInViewFilter");
    }
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
    return (SessionFactory) wac.getBean(getSessionFactoryBeanName(), SessionFactory.class);
  }
View Full Code Here

Examples of org.springframework.web.context.WebApplicationContext

   public <T> Collection<Class<T>> locate(Class<T> clazz)
   {
      Set<Class<T>> result = new LinkedHashSet<Class<T>>();

      // use the Spring API to obtain the WebApplicationContext
      WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();

      // may be null if Spring hasn't started yet
      if (context != null) {

         // ask spring about SPI implementations
         Map<String, T> beans = context.getBeansOfType(clazz);

         // add the implementations Class objects to the result set
         for (T type : beans.values()) {
            result.add((Class<T>) type.getClass());
         }
View Full Code Here

Examples of org.springframework.web.context.WebApplicationContext

   @Override
   public String getBeanName(Class<?> clazz)
   {

      // try to obtain the WebApplicationContext using ContextLoader
      WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
      if (context == null) {
         throw new IllegalStateException("Unable to get current WebApplicationContext");
      }

      // obtain a map of bean names
View Full Code Here

Examples of org.springframework.web.context.WebApplicationContext

     * The bean is resolved by type (org.springmodules.commons.validator.ValidatorFactory).
     *
     * @return ValidatorResources from a ValidatorFactory
     */
    private ValidatorResources getValidatorResources() {
        WebApplicationContext ctx = (WebApplicationContext)
            pageContext.getRequest().getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        if (ctx == null) {
            // look in main application context (i.e. applicationContext.xml)
            ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(pageContext.getServletContext());
        }
View Full Code Here

Examples of org.springframework.web.context.WebApplicationContext

                    return EVAL_PAGE;
                }
            }
            JspWriter out = pageContext.getOut();
            Locale locale = getRequestContext().getLocale();
            WebApplicationContext webApplicationContext = getRequestContext().getWebApplicationContext();
            MessageSourceAccessor messages = new MessageSourceAccessor(webApplicationContext, locale);

            out.write("<script type=\"text/javascript\" id=\"" + commandName + "ValangValidator\">\n");
            cotvc.writeJS(commandName, commandObj, globalVar, validateOnSubmit, out, messages);
            out.write("\n</script>");
View Full Code Here

Examples of org.springframework.web.context.WebApplicationContext

        assertEquals("I'm SomeServiceActive", someService.whoAreYou());

    }

    private Object getSpringBean(String name) {
        WebApplicationContext applicationContext = ContextLoader.getCurrentWebApplicationContext();
        return applicationContext.getBean(name);
    }
View Full Code Here

Examples of org.springframework.web.context.WebApplicationContext

    public <T> Collection<T> find(Class<T> clazz, Object context) {

        Collection<T> result = new ArrayList<T>();

        // use the Spring API to obtain the WebApplicationContext
        WebApplicationContext applicationContext = null;
        if (context instanceof ServletContext) {
            applicationContext = WebApplicationContextUtils.getWebApplicationContext((ServletContext) context);
        }
        if (applicationContext == null) {
            applicationContext = ContextLoader.getCurrentWebApplicationContext();
        }

        // may be null if Spring hasn't started yet
        if (applicationContext != null) {

            // ask spring about beans of this type
            result.addAll(applicationContext.getBeansOfType(clazz).values());

        }

        return result;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.