Package com.alibaba.citrus.springext

Examples of com.alibaba.citrus.springext.ConfigurationPoint


    @Test
    public void test12_contributionSchemas_versionRecognition() {
        createConfigurationPoints("TEST-INF/test12/cps");

        ConfigurationPoint cp = cps.getConfigurationPointByName("my/services");
        assertEquals(3, cp.getContributions().size());

        Contribution myservice = cp.getContribution("myservice", BEAN_DEFINITION_PARSER);
        Contribution myservice_abc = cp.getContribution("myservice-abc", BEAN_DEFINITION_PARSER);
        Contribution myservice_abc_xyz = cp.getContribution("myservice-abc-xyz", BEAN_DEFINITION_DECORATOR);

        assertThat(myservice.getSchemas().toString(),
                   containsAll("Schemas[my/services/myservice.xsd, 0 versioned schemas]"));

        assertThat(
View Full Code Here


        this.cps = assertNotNull(cps, "configurationPoints");
        this.defaultResolver = defaultResolver;
    }

    public NamespaceHandler resolve(String namespaceUri) {
        ConfigurationPoint cp = cps.getConfigurationPointByNamespaceUri(namespaceUri);

        if (cp != null) {
            return cp.getNamespaceHandler();
        } else if (defaultResolver != null) {
            return defaultResolver.resolve(namespaceUri);
        } else {
            return null;
        }
View Full Code Here

            items.put(namespace, item);
            independentItems.put(namespace, item);
        }

        private void buildConfigurationPointItem(String namespace, Set<Schema> schemas, ConfigurationPointSchemaSourceInfo schema) {
            ConfigurationPoint configurationPoint = (ConfigurationPoint) schema.getParent();
            ConfigurationPointItem item = createConfigurationPointItem(namespace, schemas, configurationPoint);
            items.put(namespace, item);

            // build contributions
            if (includingAllContributions) {
                for (Contribution contribution : configurationPoint.getContributions()) {
                    ContributionItem contributionItem = createContributionItem(contribution);
                    addChildItem(item, contribution.getName(), contributionItem);
                }
            }

            // build depending contributions
            int count = 0;

            for (Contribution contribution : configurationPoint.getDependingContributions()) {
                String dependingNamespace = contribution.getConfigurationPoint().getNamespaceUri();

                if (buildNamespaceItemRecursively(dependingNamespace)) {
                    count++;
                    NamespaceItem parentItem = assertNotNull(items.get(dependingNamespace), "no item for namespace %s", namespace);
View Full Code Here

                }

                String defaultElementName = params.get(DEFAULT_ELEMENT_KEY);
                String preferredNsPrefix = params.get(PREFERRED_NS_PREFIX);

                ConfigurationPoint cp = new ConfigurationPointImpl(
                        ConfigurationPointsImpl.this, settings, name, namespaceUri, defaultElementName, preferredNsPrefix,
                        new SourceInfoSupport<SourceInfo<?>>().setSource(source, lineNumber));

                namespaceUriToConfigurationPoints.put(namespaceUri, cp);
                nameToConfigurationPoints.put(name, cp);
View Full Code Here

    public static ConfigurationPoint getSiblingConfigurationPoint(String configurationPointName, ConfigurationPoint cp) {
        assertNotNull(configurationPointName, "configurationPointName");
        assertNotNull(cp, "configurationPoint");

        ConfigurationPoint siblingCp = cp.getConfigurationPoints().getConfigurationPointByName(configurationPointName);

        assertNotNull(siblingCp, "could not find configuration point of name: %s", configurationPointName);

        return siblingCp;
    }
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

                                                      + "].  This configuration point is located at " + configurationPointsLocation + ".");
            }

            String defaultElementName = params.get(DEFAULT_ELEMENT_KEY);
            String preferredNsPrefix = params.get(PREFERRED_NS_PREFIX);
            ConfigurationPoint cp = new ConfigurationPointImpl(this, settings, name, namespaceUri, defaultElementName,
                                                               preferredNsPrefix);

            namespaceUriToConfigurationPoints.put(namespaceUri, cp);
            nameToConfigurationPoints.put(name, cp);
        }
View Full Code Here

    public static ConfigurationPoint getSiblingConfigurationPoint(String configurationPointName, ConfigurationPoint cp) {
        assertNotNull(configurationPointName, "configurationPointName");
        assertNotNull(cp, "configurationPoint");

        ConfigurationPoint siblingCp = cp.getConfigurationPoints().getConfigurationPointByName(configurationPointName);

        assertNotNull(siblingCp, "could not find configuration point of name: %s", configurationPointName);

        return siblingCp;
    }
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

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.