Package org.apache.tuscany.model.assembly

Examples of org.apache.tuscany.model.assembly.Wire


                ConfiguredReference configuredReference = entryPoint.getConfiguredReference();
                ServiceURI sourceURI = factory.createServiceURI(null, entryPoint, configuredReference);
                for (String target : configuredReference.getTargets()) {
                    ServiceURI targetURI = factory.createServiceURI(null, target);
                    Wire wire = factory.createWire();
                    wire.setSource(sourceURI);
                    wire.setTarget(targetURI);
                    getWires().add(wire);
                }
            }
            for (ExternalService externalService : getExternalServices()) {
                if (externalService.getOverrideOption() == null || externalService.getOverrideOption() == OverrideOption.NO)
                    continue;
                Reference reference = factory.createReference();
                reference.setName(externalService.getName());
                ServiceContract serviceContract = externalService.getConfiguredService().getPort().getServiceContract();
                if (serviceContract != null)
                    reference.setServiceContract(serviceContract);
                componentType.getReferences().add(reference);
            }
            for (Component<Implementation> component : getComponents()) {
                for (ConfiguredProperty configuredProperty : component.getConfiguredProperties()) {
                    if (configuredProperty.getOverrideOption() == null || configuredProperty.getOverrideOption() == OverrideOption.NO)
                        continue;
                    componentType.getProperties().add(configuredProperty.getProperty());
                }

                for (ConfiguredReference configuredReference : component.getConfiguredReferences()) {
                    // Create a wire
                    ServiceURI sourceURI = factory.createServiceURI(null, component, configuredReference);
                    for (String target : configuredReference.getTargets()) {
                        ServiceURI targetURI = factory.createServiceURI(null, target);
                        Wire wire = factory.createWire();
                        wire.setSource(sourceURI);
                        wire.setTarget(targetURI);
                        getWires().add(wire);
                    }
                }
            }
        }
View Full Code Here


public class WireLoaderTestCase extends LoaderTestSupport {

    public void testMinimal() throws XMLStreamException, ConfigurationLoadException {
        String xml = "<wire xmlns='http://www.osoa.org/xmlns/sca/0.9'><source.uri>foo/fooService</source.uri><target.uri>bar</target.uri></wire>";
        XMLStreamReader reader = getReader(xml);
        Wire wire = (Wire) registry.load(reader, loaderContext);
        reader.require(XMLStreamConstants.END_ELEMENT, AssemblyConstants.WIRE.getNamespaceURI(), AssemblyConstants.WIRE.getLocalPart());
        assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next());
        assertNotNull(wire);
        assertEquals("foo", wire.getSource().getPartName());
        assertEquals("fooService", wire.getSource().getServiceName());
        assertEquals("bar", wire.getTarget().getPartName());
    }
View Full Code Here

    }

    public void testCompound() throws XMLStreamException, ConfigurationLoadException {
        String xml = "<wire xmlns='http://www.osoa.org/xmlns/sca/0.9'><source.uri>foo/fooService</source.uri><target.uri>bar/bazService</target.uri></wire>";
        XMLStreamReader reader = getReader(xml);
        Wire wire = (Wire) registry.load(reader, loaderContext);
        reader.require(XMLStreamConstants.END_ELEMENT, AssemblyConstants.WIRE.getNamespaceURI(), AssemblyConstants.WIRE.getLocalPart());
        assertEquals(XMLStreamConstants.END_DOCUMENT, reader.next());
        assertNotNull(wire);
        assertEquals("foo", wire.getSource().getPartName());
        assertEquals("fooService", wire.getSource().getServiceName());
        assertEquals("bar", wire.getTarget().getPartName());
        assertEquals("bazService", wire.getTarget().getServiceName());
    }
View Full Code Here

        return AssemblyConstants.WIRE;
    }

    public Wire load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
        assert AssemblyConstants.WIRE.equals(reader.getName());
        Wire wire = factory.createWire();
        while (true) {
            switch (reader.next()) {
                case START_ELEMENT:
                    QName qname = reader.getName();
                    if (AssemblyConstants.WIRE_SOURCE.equals(qname)) {
                        String uri = reader.getElementText();
                        int pos = uri.indexOf('/');
                        if (pos < 1) {
                            throw new ConfigurationLoadException("Invalid source wire");
                        }
                        String partName = uri.substring(0, pos);
                        String portName = uri.substring(pos + 1);
                        wire.setSource(factory.createServiceURI(null, partName, portName));
                    } else if (AssemblyConstants.WIRE_TARGET.equals(qname)) {
                        String uri = reader.getElementText();
                        int pos = uri.indexOf('/');
                        if (pos < 1) {
                            wire.setTarget(factory.createServiceURI(null, uri));
                        }else{
                            String partName = uri.substring(0, pos);
                            String portName = uri.substring(pos + 1);
                            wire.setTarget(factory.createServiceURI(null, partName, portName));
                        }
                    }
                    break;
                case END_ELEMENT:
                    return wire;
View Full Code Here

TOP

Related Classes of org.apache.tuscany.model.assembly.Wire

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.