Package com.alibaba.citrus.springext

Examples of com.alibaba.citrus.springext.ConfigurationPoint


                }
            }
        }

        private boolean isContributionElement(String uri, String name) {
            ConfigurationPoint cp = schemas.getConfigurationPoints().getConfigurationPointByNamespaceUri(uri);

            if (cp != null) {
                return name.equals(cp.getDefaultElementName()) // default element
                       || cp.getContribution(name, ContributionType.BEAN_DEFINITION_PARSER) != null // contribution
                       || cp.getContribution(name, ContributionType.BEAN_DEFINITION_DECORATOR) != null; // contribution
            }

            return false;
        }
View Full Code Here


            int index = 0;

            for (Element subElement : elements) {
                if (subElement.getQName().equals(XSD_ANY) && subElement.attribute("namespace") != null) {
                    String ns = subElement.attribute("namespace").getValue();
                    ConfigurationPoint cp = cps.getConfigurationPointByNamespaceUri(ns);

                    if (cp != null) {
                        indexes.add(index);
                        importings.put(ns, cp);
                    }
View Full Code Here

        }

        private void visitAnyElement(List<Element> elements, int index) {
            Element anyElement = elements.get(index);
            String ns = anyElement.attribute("namespace").getValue();
            ConfigurationPoint cp = cps.getConfigurationPointByNamespaceUri(ns);

            if (cp != null) {
                Element choiceElement = DocumentHelper.createElement(XSD_CHOICE);
                String nsPrefix = getNamespacePrefix(cp.getPreferredNsPrefix(), ns);

                // <xsd:schema xmlns:prefix="ns">
                // 注意:必须将ns定义加在顶层element,否则低版本的xerces会报错。
                root.addNamespace(nsPrefix, ns);

                // <xsd:choice minOccurs="?" maxOccurs="?" />
                if (anyElement.attribute("minOccurs") != null) {
                    choiceElement.addAttribute("minOccurs", anyElement.attribute("minOccurs").getValue());
                }

                if (anyElement.attribute("maxOccurs") != null) {
                    choiceElement.addAttribute("maxOccurs", anyElement.attribute("maxOccurs").getValue());
                }

                // <xsd:element ref="prefix:contrib" />
                for (Contribution contrib : cp.getContributions()) {
                    Element elementElement = DocumentHelper.createElement(XSD_ELEMENT);
                    elementElement.addAttribute("ref", nsPrefix + ":" + contrib.getName());
                    choiceElement.add(elementElement);
                }

                // <xsd:element ref="prefix:defaultName" />
                if (cp.getDefaultElementName() != null) {
                    Element elementElement = DocumentHelper.createElement(XSD_ELEMENT);
                    elementElement.addAttribute("ref", nsPrefix + ":" + cp.getDefaultElementName());
                    choiceElement.add(elementElement);
                }

                // 用choice取代any
                elements.set(index, choiceElement);
View Full Code Here

        return list;
    }

    private String[] getParentConfigurationPoints(String cpName) {
        ConfigurationPoint cp = schemas.getConfigurationPoints().getConfigurationPointByName(cpName);
        List<String> depList = createLinkedList();

        for (Contribution contribution : cp.getDependingContributions()) {
            depList.add(contribution.getConfigurationPoint().getName());
        }

        return depList.toArray(new String[0]);
    }
View Full Code Here

        // services/s2 includes included-schema.xsd
        // services/s3 no includes
        schemas = new SpringExtSchemaSet("TEST-INF/test15/cps");

        // 测试interceptors是否被s1和s2依赖
        ConfigurationPoint interceptors = schemas.getConfigurationPoints().getConfigurationPointByName("interceptors");
        Collection<Contribution> contributions = interceptors.getDependingContributions();

        assertEquals(2, contributions.size());

        for (Contribution contribution : contributions) {
            assertEquals("services", contribution.getConfigurationPoint().getName());
View Full Code Here

    @Test
    public void unqualifiedStyleContribution() throws Exception {
        cps = new ConfigurationPointsImpl((ClassLoader) null, null);

        ConfigurationPoint cp1 = cps.getConfigurationPointByName("my/cp1");
        Contribution contrib1 = cp1.getContribution("test1", BEAN_DEFINITION_PARSER);
        Schema schema = contrib1.getSchemas().getMainSchema();

        // my/cp1/test1.xsd包含elementFormDefault,转换后被强制去除。
        assertQualified(schema, false);
    }
View Full Code Here

                    return super.getResource(location);
                }
            }
        });

        ConfigurationPoint cp1 = cps.getConfigurationPointByName("my/cp1");
        Contribution contrib1 = cp1.getContribution("test1", BEAN_DEFINITION_PARSER);
        Schema schema = contrib1.getSchemas().getMainSchema();

        // my/cp1/test1.xsd包含elementFormDefault。此处摸拟老版本,故qualified被保留。
        assertQualified(schema, true);
    }
View Full Code Here

    @Test
    public void expandConfigurationPointElements() throws Exception {
        createConfigurationPoints(null);

        ConfigurationPoint cp1 = cps.getConfigurationPointByName("my/cp1");
        ConfigurationPoint cp2 = cps.getConfigurationPointByName("my/cp2");

        String test1 = getSchemaText(cp1.getContribution("test1", BEAN_DEFINITION_PARSER));
        String test2 = getSchemaText(cp1.getContribution("test2", BEAN_DEFINITION_PARSER));
        String test3 = getSchemaText(cp2.getContribution("test3", BEAN_DEFINITION_PARSER));
        String test4 = getSchemaText(cp2.getContribution("test4", BEAN_DEFINITION_PARSER));

        // 假如ns已经import了,确保不重复import;确保不import自己所在的cp。
        assertSchemaText(test1, 1);
        assertSchemaText(test2, 2);
        assertSchemaText(test3, 3);
View Full Code Here

    @Test
    public void getAnnotation() {
        createConfigurationPoints("TEST-INF/test9/cps");

        ConfigurationPoint cp = cps.getConfigurationPointByName("my/services");
        Contribution service1 = cp.getContribution("service1", ContributionType.BEAN_DEFINITION_PARSER);
        Contribution service2 = cp.getContribution("service2", ContributionType.BEAN_DEFINITION_PARSER);

        assertEquals("this\n" +
                     "is\n" +
                     "service1", service1.getAnnotation());
View Full Code Here

    @Test
    public void test1_getContributions_noContributions() {
        createConfigurationPoints("TEST-INF/test1/cps");

        ConfigurationPoint cp = cps.getConfigurationPointByName("cp1");

        assertTrue(cp.getContributions().isEmpty());
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.springext.ConfigurationPoint

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.