Package org.apache.tuscany.model.assembly

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


                if (serviceContract != null)
                    service.setServiceContract(serviceContract);
                componentType.getServices().add(service);

                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


     */
    protected void wire(AssemblyContext modelContext) {
        for (Wire wire : getWires()) {

            // Get the source reference
            ServiceURI sourceURI = wire.getSource();
            ConfiguredReference configuredReference = null;
            String partName = sourceURI.getPartName();
            String referenceName = sourceURI.getServiceName();
            if (referenceName != null) {
                //Component<?> component = (Component<?>)getPart(partName);
//                if (component != null) {
                Part part = getPart(partName);
                if (part instanceof Component) {
                    configuredReference = ((Component) part).getConfiguredReference(referenceName);
                } else if (part instanceof EntryPoint) {
                    configuredReference = ((EntryPoint) part).getConfiguredReference();
                }
            } else {
                EntryPoint entryPoint = (EntryPoint) getPart(partName);
                if (entryPoint != null) {
                    configuredReference = entryPoint.getConfiguredReference();
                }
            }
            if (configuredReference == null) {
                throw new IllegalArgumentException("Cannot find wire source " + sourceURI.getPath());
            } else {

                // Resolve the target service endpoint
                ServiceURI targetURI = wire.getTarget();
                ConfiguredService configuredService = getConfiguredService(targetURI);
                if (configuredService != null) {

                    // Wire the reference to the target
                    Multiplicity multiplicity = configuredReference.getPort().getMultiplicity();
                    if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) {
                        configuredReference.getTargetConfiguredServices().add(configuredService);
                    } else {
                        configuredReference.getTargetConfiguredServices().clear();
                        configuredReference.getTargetConfiguredServices().add(configuredService);
                    }
                } else {
                    throw new IllegalArgumentException("Cannot find service '" + targetURI.getPath() +"'.");
                }
            }
        }
    }
View Full Code Here

TOP

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

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.