Package org.apache.tuscany.model.assembly

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


        reference.setMultiplicity(multiplicity);
        return reference;
    }

     public ConfiguredReference createConfiguredReference(String name, String... targets) {
        ConfiguredReference ref = createConfiguredReference();
        ref.setName(name);
        for (String target : targets) {
            ref.getTargets().add(target);
        }
        return ref;
    }
View Full Code Here


        // create and configure a reference to target
        Reference reference = createReference();
        reference.setMultiplicity(Multiplicity.ONE_ONE);
        reference.setServiceContract(serviceContract);
        ConfiguredReference configuredReference = createConfiguredReference(null, targetName);
        configuredReference.setPort(reference);

        return createEntryPoint(entryPointName, configuredService, binding, configuredReference);
    }
View Full Code Here

            } else {
                address = "sca:///" + moduleComponentName + '/' + partName;
            }

        } else if (configuredPort instanceof ConfiguredReference) {
            ConfiguredReference configuredReference = (ConfiguredReference) configuredPort;
            partName = part.getName();
            serviceName = configuredReference.getPort().getName();
            if (serviceName!=null)
                address = "sca:///" + moduleComponentName + '/' + partName + '/' + serviceName;
            else
                address = "sca:///" + moduleComponentName + '/' + partName;
        }
View Full Code Here

    public void build(AssemblyObject modelObject) throws BuilderException {
        if (source) {
            if (!(modelObject instanceof ConfiguredReference)) {
                return;
            } else {
                ConfiguredReference cref = (ConfiguredReference) modelObject;
                // /xcv WireFactory pFactory = (WireFactory) cref.getProxyFactory();
                for (ConfiguredService configuredService : cref.getTargetConfiguredServices()) {
                    SourceWireFactory pFactory = (SourceWireFactory) configuredService.getProxyFactory();
                    for (InvocationConfiguration config : pFactory.getConfiguration().getInvocationConfigurations().values()) {
                        if (request) {
                            config.addRequestHandler(handler);
                        } else {
View Full Code Here

                ServiceContract serviceContract = entryPoint.getConfiguredService().getPort().getServiceContract();
                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

            configuredService.initialize(modelContext);
        }

        // Derive the configured references from the references on the component info
        for (Reference reference : componentType.getReferences()) {
            ConfiguredReference configuredReference = configuredReferencesMap.get(reference.getName());
            if (configuredReference==null) {
                configuredReference=factory.createConfiguredReference();
                configuredReference.setPort(reference);
                configuredReferences.add(configuredReference);
                configuredReference.initialize(modelContext);
            } else {
                configuredReference.setPort(reference);
                configuredReference.initialize(modelContext);
            }
        }
        for (ConfiguredReference configuredReference : configuredReferences) {
            if (configuredReference.getPort()==null) {
                throw new AssemblyInitializationException("Undefined reference ["+configuredReference.getName()+"]");
            }
        }

        // Derive the configured properties from the properties on the component info
        for (Property property : componentType.getProperties()) {
View Full Code Here

        JavaServiceContract inter = factory.createJavaServiceContract();
        inter.setInterface(GenericComponent.class);
        ref.setServiceContract(inter);
        sourceComponent.getImplementation().getComponentType().getReferences().add(ref);

        ConfiguredReference cref = factory.createConfiguredReference("setGenericComponent", "target");
        cref.initialize(assemblyContext);
        sourceComponent.getConfiguredReferences().add(cref);
        sourceComponent.initialize(assemblyContext);

        Module module = factory.createModule();
        module.setName("test.module");
View Full Code Here

        JavaServiceContract inter = factory.createJavaServiceContract();
        inter.setInterface(HelloWorldService.class);
        ref.setServiceContract(inter);
        sourceComponent.getImplementation().getComponentType().getReferences().add(ref);

        ConfiguredReference cref = factory.createConfiguredReference(ref.getName(), "target");
        cref.initialize(assemblyContext);
        sourceComponent.getConfiguredReferences().add(cref);
        sourceComponent.initialize(assemblyContext);

        Module module = factory.createModule();
        module.setName("test.module");
View Full Code Here

        cTargetService.setPort(targetService);
        targetComponent.getConfiguredServices().add(cTargetService);
        targetComponent.initialize(assemblyContext);

        Reference ref = factory.createReference();
        ConfiguredReference cref = factory.createConfiguredReference();
        ref.setName("setHelloWorldService");
        JavaServiceContract inter = factory.createJavaServiceContract();
        inter.setInterface(HelloWorldService.class);
        ref.setServiceContract(inter);
        cref.setPort(ref);
        cref.getTargetConfiguredServices().add(cTargetService);
        cref.initialize(assemblyContext);

        EntryPoint sourceEP = createFooBindingEntryPoint("source", HelloWorldService.class);
        sourceEP.setConfiguredReference(cref);
        sourceEP.getConfiguredService().getPort().setName("HelloWorldService");
        sourceEP.initialize(assemblyContext);
View Full Code Here

TOP

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

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.