Package com.alibaba.citrus.webx

Examples of com.alibaba.citrus.webx.WebxComponent


        // 创建turbine rundata
        TurbineUtil.getTurbineRunData(newRequest, true);

        // 设置当前component
        WebxComponent component = createMock(WebxComponent.class);
        GenericWebApplicationContext webAppContext = new GenericWebApplicationContext();
        webAppContext.setParent(factory);
        expect(component.getApplicationContext()).andReturn(webAppContext).anyTimes();
        expect(component.getName()).andReturn("app1").anyTimes();
        replay(component);
        WebxUtil.setCurrentComponent(newRequest, component);
    }
View Full Code Here


    @Test
    public void getComponent() throws Exception {
        assertNull(components.getComponent("notexist"));

        // root component
        WebxComponent rootComponent = components.getComponent(null);

        assertNull(rootComponent.getName());
        assertEquals("", rootComponent.getComponentPath());
        assertSame(components.getParentWebxConfiguration(), rootComponent.getWebxConfiguration());
        assertSame(components.getParentApplicationContext(), rootComponent.getApplicationContext());
        assertSame(components, rootComponent.getWebxComponents());
        assertEquals(components.toString(), rootComponent.toString());

        try {
            rootComponent.getWebxController();
            fail();
        } catch (UnsupportedOperationException e) {
            assertThat(e, exception("RootComponent.getWebxController()"));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void findComponent() throws Exception {
        WebxComponent app1 = components.getComponent("app1");
        WebxComponent app4 = components.getComponent("app4");
        WebxComponent app5 = components.getComponent("app5");

        assertEquals("/app1", app1.getComponentPath());
        assertEquals("", app4.getComponentPath());
        assertEquals("/my/app5", app5.getComponentPath());

        assertSame(app1, components.findMatchedComponent("app1"));
        assertSame(app1, components.findMatchedComponent("app1/"));
        assertSame(app1, components.findMatchedComponent("/app1"));
        assertSame(app1, components.findMatchedComponent("/app1/test"));
View Full Code Here

    @Test
    public void components() throws Exception {
        assertArrayEquals(new String[] { "a", "b" }, components.getComponentNames());

        WebxComponent a = components.getComponent("a");
        WebxComponent b = components.getComponent("b");

        Method m = getAccessibleMethod(a.getApplicationContext().getClass(), "getConfigLocations", null);

        assertArrayEquals(new String[] { "classpath:META-INF/mycomponent/a.xml" },
                          String[].class.cast(m.invoke(a.getApplicationContext())));

        assertArrayEquals(new String[] { "classpath:META-INF/mycomponent/b.xml" },
                          String[].class.cast(m.invoke(b.getApplicationContext())));

        assertEquals("hello", a.getApplicationContext().getBean("s1"));
        assertEquals("world", b.getApplicationContext().getBean("s2"));
    }
View Full Code Here

        // 创建turbine rundata
        TurbineUtil.getTurbineRunData(newRequest, true);

        // 设置当前component
        WebxComponent component = createMock(WebxComponent.class);
        GenericWebApplicationContext webAppContext = new GenericWebApplicationContext();
        webAppContext.setParent(factory);
        expect(component.getApplicationContext()).andReturn(webAppContext).anyTimes();
        expect(component.getName()).andReturn("app1").anyTimes();
        replay(component);
        WebxUtil.setCurrentComponent(newRequest, component);
    }
View Full Code Here

        public AbstractExplorerVisitor(RequestHandlerContext context) {
            super(context);

            // 取得当前的component信息
            String contextName = trimToNull(context.getRequest().getParameter("context"));
            WebxComponent component = getWebxComponents().getComponent(contextName);

            if (component == null) {
                currentContextName = null;
            } else {
                currentContextName = component.getName();
            }

            currentComponent = getWebxComponents().getComponent(currentContextName);

            // 取得当前的功能
View Full Code Here

    private String normalizeComponentName(String componentName) {
        componentName = trimToNull(componentName);

        if (componentName != null) {
            WebxComponent currentComponent = getCurrentComponent();

            if (componentName.equals(currentComponent.getName())) {
                componentName = null;
            }
        }

        return componentName;
View Full Code Here

    private PullService getPullService(String componentName) {
        componentName = normalizeComponentName(componentName);

        if (!pullServices.containsKey(componentName)) {
            WebxComponent component;

            if (componentName == null) {
                component = getCurrentComponent();
            } else {
                component = assertNotNull(getCurrentComponent().getWebxComponents().getComponent(componentName),
                                          "could not find webx component: %s", componentName);
            }

            ApplicationContext context = component.getApplicationContext();
            PullService pullService;

            try {
                pullService = (PullService) context.getBean("pullService", PullService.class);
            } catch (NoSuchBeanDefinitionException e) {
View Full Code Here

        public WebxComponent findMatchedComponent(String path) {
            if (!path.startsWith("/")) {
                path = "/" + path;
            }

            WebxComponent defaultComponent = getDefaultComponent();
            WebxComponent matched = null;

            // 前缀匹配componentPath。
            for (WebxComponent component : this) {
                if (component == defaultComponent) {
                    continue;
View Full Code Here

        //
        // 对于前缀匹配,取其pathInfo;对于后缀匹配,取其servletPath。
        String path = ServletUtil.getResourcePath(request);

        // 再根据path查找component
        WebxComponent component = getComponents().findMatchedComponent(path);
        boolean served = false;

        if (component != null) {
            try {
                WebxUtil.setCurrentComponent(request, component);
                served = component.getWebxController().service(requestContext);
            } finally {
                WebxUtil.setCurrentComponent(request, null);
            }
        }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.webx.WebxComponent

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.