Package org.springframework.web.context

Examples of org.springframework.web.context.WebApplicationContext


     *
     * @param servletContext the servlet context.
     */
    private void initContainer(ServletContext servletContext) {

        WebApplicationContext springContext = (WebApplicationContext)
                servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);

        // Retrieve the driver configuration from servlet context.
        DriverConfiguration driverConfig = (DriverConfiguration)
                servletContext.getAttribute(DRIVER_CONFIG_KEY);

        try {
            LOG.info("Initializing Portlet Container. . .");

            LOG.debug(" [1] Loading RequiredContainerServices. . .");
            RequiredContainerServices required =
                    (RequiredContainerServices) springContext.getBean("RequiredContainerServices");

            LOG.debug(" [2] Loading OptionalContainerServices. . .");
            OptionalContainerServices optional =
                    (OptionalContainerServices) springContext.getBean("OptionalContainerServices");


            // Create portlet container.
            LOG.debug(" [3] Creating portlet container...");
            PortletContainerFactory factory =
View Full Code Here


    /**
     * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
     */
    public void contextInitialized( ServletContextEvent sce )
    {
        WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext( sce
            .getServletContext() );

        // to simulate Plexus load on start with Spring
        Continuum continuum = (Continuum) wac.getBean( PlexusToSpringUtils.buildSpringId( Continuum.class ) );

        BuildsManager buildsManager = (BuildsManager) wac.getBean( PlexusToSpringUtils.buildSpringId( BuildsManager.class, "parallel" ) );

        TaskQueueExecutor prepareRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
            .buildSpringId( TaskQueueExecutor.class, "prepare-release" ) );

        TaskQueueExecutor performRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
            .buildSpringId( TaskQueueExecutor.class, "perform-release" ) );

        TaskQueueExecutor rollbackRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
            .buildSpringId( TaskQueueExecutor.class, "rollback-release" ) );       
       
        TaskQueueExecutor purge = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
            .buildSpringId( TaskQueueExecutor.class, "purge" ) );

        TaskQueueExecutor prepareBuildProject = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
            .buildSpringId( TaskQueueExecutor.class, "prepare-build-project" ) );

        DistributedBuildManager distributedBuildManager = (DistributedBuildManager) wac.getBean( PlexusToSpringUtils
            .buildSpringId( DistributedBuildManager.class ) );
    }
View Full Code Here

      return invokeBeanDefiningMethod(name, args);
    }
    else if (args.length > 1 && args[args.length -1] instanceof Closure) {
      return invokeBeanDefiningMethod(name, args);
    }
        WebApplicationContext ctx = springConfig.getUnrefreshedApplicationContext();
        MetaClass mc = DefaultGroovyMethods.getMetaClass(ctx);
        if(!mc.respondsTo(ctx, name, args).isEmpty()){
            return mc.invokeMethod(ctx,name, args);
        }
        return this;
View Full Code Here

        binding.setVariable("securityComponents", sc);
        binding.setVariable("securityRealm",this);
        BeanBuilder builder = new BeanBuilder();
        builder.parse(filterConfig.getServletContext().getResourceAsStream("/WEB-INF/security/SecurityFilters.groovy"),binding);
       
        WebApplicationContext context = builder.createApplicationContext();
       
        return (Filter) context.getBean("legacy");
    }
View Full Code Here

    @Before
    @SuppressWarnings("rawtypes")
    public void setup() {
        SecurityContextHolder.getContext().setAuthentication(bob);
        tag = new AccessControlListTag();
        WebApplicationContext ctx = mock(WebApplicationContext.class);

        pe = mock(PermissionEvaluator.class);

        Map beanMap = new HashMap();
        beanMap.put("pe", pe);
        when(ctx.getBeansOfType(PermissionEvaluator.class)).thenReturn(beanMap);

        MockServletContext servletCtx = new MockServletContext();
        servletCtx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
        pageContext = new MockPageContext(servletCtx, new MockHttpServletRequest(), new MockHttpServletResponse());
        tag.setPageContext(pageContext);
View Full Code Here

        return (CsrfTokenRepository) ReflectionTestUtils.getField(filter, "tokenRepository");
    }

    @SuppressWarnings("unchecked")
    private static <T extends Filter> T findFilter(HttpServletRequest request, Class<T> filterClass) {
        WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(request.getServletContext());
        if(webApplicationContext == null) {
            return null;
        }
        FilterChainProxy springSecurityFilterChain = null;
        try {
            springSecurityFilterChain = webApplicationContext.getBean(FilterChainProxy.class);
        } catch(NoSuchBeanDefinitionException notFound) {
            return null;
        }
        List<Filter> filters = (List<Filter>) ReflectionTestUtils.invokeMethod(springSecurityFilterChain,"getFilters", request);
        for(Filter filter : filters) {
View Full Code Here

        return getAppContext().getBean(beanName);
    }

    protected final WebApplicationContext getAppContext() {
        ServletContext servletCtx = ((WebAppContext)server.getHandler()).getServletContext();
        WebApplicationContext appCtx =
                WebApplicationContextUtils.getRequiredWebApplicationContext(servletCtx);
        return appCtx;
    }
View Full Code Here

    @Test
    public void failure_getting_bean_from_context()
    {
        Log log = mockLog();
        WebApplicationContext webContext = newWebApplicationContext();
        ObjectLocator locator = mockObjectLocator();
        Throwable t = new RuntimeException("Simulated failure.");
        AnnotationProvider annotationProvider = mockAnnotationProvider();
        SpringBean annotation = newSpringBean(BEAN_NAME);

        train_getBeanDefinitionNames(webContext, BEAN_NAME);

        log.info(STARTUP_MESSAGE + BEAN_NAME);

        train_getAnnotation(annotationProvider, SpringBean.class, annotation);

        expect(webContext.getBean(BEAN_NAME, SampleBean.class)).andThrow(t);

        replay();

        ObjectProvider provider = new SpringObjectProvider(log, webContext);
View Full Code Here

    @Test
    public void get_bean_from_context()
    {
        Log log = mockLog();
        WebApplicationContext webContext = newWebApplicationContext();
        ObjectLocator locator = mockObjectLocator();
        AnnotationProvider annotationProvider = mockAnnotationProvider();
        SpringBean annotation = newSpringBean(BEAN_NAME);

        SampleBean bean = newMock(SampleBean.class);

        train_getBeanDefinitionNames(webContext, "fred", "barney", BEAN_NAME);

        log.info(STARTUP_MESSAGE + "barney, fred, " + BEAN_NAME);

        train_getAnnotation(annotationProvider, SpringBean.class, annotation);

        expect(webContext.getBean(BEAN_NAME, SampleBean.class)).andReturn(bean);

        replay();

        ObjectProvider provider = new SpringObjectProvider(log, webContext);
View Full Code Here

    @Test
    public void bean_name_is_case_insensitive_if_in_bean_definitions()
    {
        Log log = mockLog();
        WebApplicationContext webContext = newWebApplicationContext();
        ObjectLocator locator = mockObjectLocator();
        SampleBean bean = newMock(SampleBean.class);
        AnnotationProvider annotationProvider = mockAnnotationProvider();
        SpringBean annotation = newSpringBean(BEAN_NAME.toUpperCase());

        train_getBeanDefinitionNames(webContext, "fred", "barney", BEAN_NAME);

        log.info(STARTUP_MESSAGE + "barney, fred, " + BEAN_NAME);

        train_getAnnotation(annotationProvider, SpringBean.class, annotation);

        expect(webContext.getBean(BEAN_NAME, SampleBean.class)).andReturn(bean);

        replay();

        ObjectProvider provider = new SpringObjectProvider(log, webContext);
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.