Package org.springframework.web.context

Examples of org.springframework.web.context.WebApplicationContext


     *
     * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
     */
    @SuppressWarnings("unchecked")
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        WebApplicationContext webApplicationContext = (WebApplicationContext) applicationContext;
        ServletContext servletContext = webApplicationContext.getServletContext();
        this.blockContexts = (Map<String, String>) servletContext
                .getAttribute(BlockDeploymentServletContextListener.BLOCK_CONTEXT_MAP);
    }
View Full Code Here


     *
     * @return ValidatorResources from a ValidatorFactory.
     */
    private ValidatorResources getValidatorResources() {
        // look in servlet beans definition (i.e. action-servlet.xml)
        WebApplicationContext ctx = (WebApplicationContext) pageContext.getRequest()
                .getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        ValidatorFactory factory = null;
        try {
            factory = (ValidatorFactory) BeanFactoryUtils
                    .beanOfTypeIncludingAncestors(ctx, ValidatorFactory.class, true, true);
View Full Code Here

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

    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

  @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

    @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

    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

   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

   @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

     * 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

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.