Package com.alibaba.citrus.springext

Examples of com.alibaba.citrus.springext.Schema


        // <xsd:include schemaLocation="contribution schema" />
        Set<String> includings = createTreeSet();

        for (Contribution contrib : configurationPoint.getContributions()) {
            Schema contribSchema = contrib.getSchemas().getVersionedSchema(version);

            if (contribSchema == null) {
                contribSchema = contrib.getSchemas().getMainSchema();
            }

            if (contribSchema != null) {
                includings.add(contribSchema.getName());
            }
        }

        for (String including : includings) {
            Element includeElement = schemaRoot.addElement("xsd:include");
View Full Code Here


            }

            private String getNewSchemaLocation(String schemaLocation, String namespace, String systemId) {
                // 根据指定的schemaLocation判断
                if (schemaLocation != null) {
                    Schema schema = schemas.findSchema(schemaLocation);

                    if (schema != null) {
                        return normalizedPrefix + schema.getName();
                    } else {
                        return schemaLocation; // 返回原本的location,但可能是错误的!
                    }
                }

                // 再根据namespace判断
                if (namespace != null) {
                    Set<Schema> nsSchemas = schemas.getNamespaceMappings().get(namespace);

                    if (nsSchemas != null && !nsSchemas.isEmpty()) {
                        // 首先,在所有相同ns的schema中查找版本相同的schema。
                        String versionedExtension = getVersionedExtension(systemId);

                        if (versionedExtension != null) {
                            for (Schema schema : nsSchemas) {
                                if (schema.getName().endsWith(versionedExtension)) {
                                    return normalizedPrefix + schema.getName();
                                }
                            }
                        }

                        // 其次,选择第一个默认的schema,其顺序是:beans.xsd、beans-2.5.xsd、beans-2.0.xsd
View Full Code Here

    public String getName() {
        return key.getName();
    }

    public String getAnnotation() {
        Schema schema = getSchemas().getMainSchema();

        if (schema != null) {
            Element element = schema.getElement(getName());

            if (element != null) {
                return element.getAnnotation();
            }
        }
View Full Code Here

    }

    public VersionableSchemas getSchemas() {
        if (schemas == null) {
            String mainName = configurationPoint.getName() + "/" + getName(); // configurationPointName/contributionName
            Schema mainSchema = loadMainSchema(mainName);
            Schema[] versionedSchemas = loadVersionedSchemas(mainName);

            schemas = new VersionableSchemasImpl(mainSchema, versionedSchemas);
        }
View Full Code Here

    public String getName() {
        return key.getName();
    }

    public String getAnnotation() {
        Schema schema = getSchemas().getMainSchema();

        if (schema != null) {
            Element element = schema.getElement(getName());

            if (element != null) {
                return element.getAnnotation();
            }
        }
View Full Code Here

    }

    public VersionableSchemas getSchemas() {
        if (schemas == null) {
            String mainName = configurationPoint.getName() + "/" + getName(); // configurationPointName/contributionName
            Schema mainSchema = loadMainSchema(mainName);
            Schema[] versionedSchemas = loadVersionedSchemas(mainName);

            schemas = new VersionableSchemasImpl(mainSchema, versionedSchemas);
        }
View Full Code Here

        assertArrayEquals(new String[] { "testa" }, getElements(set2, "a"));
        assertArrayEquals(new String[] { "testb" }, getElements(set2, "b"));
    }

    private String[] getElements(Schemas schemas, String name) {
        Schema schema = schemas.getNamedMappings().get("schema/" + name + ".xsd");
        Collection<Element> elements = schema.getElements();
        String[] elementNames = new String[elements.size()];

        int i = 0;
        for (Element element : elements) {
            String elementName = element.getName();
View Full Code Here

            assertEquals("services", contribution.getConfigurationPoint().getName());
            assertTrue("s1".equals(contribution.getName()) || "s2".equals(contribution.getName()));
        }

        // 测试included-schema.xsd中的anyElement是否被替换。
        Schema includedSchema = schemas.getNamedMappings().get("localhost/included-schema.xsd");
        Document doc = includedSchema.getDocument();
        Namespace xsd = DocumentHelper.createNamespace("xsd", W3C_XML_SCHEMA_NS_URI);
        Element choice = doc.getRootElement()
                            .element(QName.get("group", xsd))
                            .element(QName.get("sequence", xsd))
                            .element(QName.get("choice", xsd));
View Full Code Here

    @Test
    public void test15_includeWithRelativePath() {
        schemas = new SpringExtSchemaSet("TEST-INF/test15/cps");

        Schema schema = schemas.getNamedMappings().get("localhost/transports/http/configuration/http-conf.xsd");

        List<Schema.Element> elements = createArrayList(schema.getElements());

        sort(elements, new Comparator<Schema.Element>() {
            @Override
            public int compare(Schema.Element o1, Schema.Element o2) {
                return o1.getName().compareTo(o2.getName());
View Full Code Here

    @Test
    public void getVersion() {
        Map<String, Schema> names = sps.getNamedMappings();

        Schema beansSchema = names.get("www.springframework.org/schema/beans/spring-beans.xsd");
        assertEquals(null, beansSchema.getVersion());

        Schema beansSchema25 = names.get("www.springframework.org/schema/beans/spring-beans-2.5.xsd");
        assertEquals("2.5", beansSchema25.getVersion());
    }
View Full Code Here

TOP

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

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.