Package org.apache.tuscany.sca.assembly

Examples of org.apache.tuscany.sca.assembly.SCABinding


            interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
            reference.setInterfaceContract(interfaceContract);
            component.getReferences().add(reference);
            reference.setComponent(component);
            SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
            SCABinding binding = scaBindingFactory.createSCABinding();
            binding.setURI(targetURI);
            reference.getBindings().add(binding);
            return new ServiceReferenceImpl<B>(businessInterface, component, reference, binding, runtime
                .getProxyFactory(), runtime.getCompositeActivator());
        } catch (Exception e) {
            throw new ServiceRuntimeException(e);
View Full Code Here


        this.reference = reference;
    }

    @Override
    public String getBeanName() {
        SCABinding binding = reference.getBinding(SCABinding.class);
        String name = binding.getURI();
        if (name.startsWith("/")) {
            name = name.substring(1);
        }
        int s = name.lastIndexOf('/');
        if (s != -1) {
View Full Code Here

    private Invoker getInvoker(RuntimeWire wire, Operation operation) {
        EndpointReference target = wire.getTarget();
        if (target != null) {
            RuntimeComponentService service = (RuntimeComponentService)target.getContract();
            if (service != null) { // not a callback wire
                SCABinding scaBinding = service.getBinding(SCABinding.class);
                InvocationChain chain =
                    service.getInvocationChain(scaBinding, wire.getSource().getInterfaceContract(), operation);
                return chain == null ? null : new SCABindingInvoker(chain);
            }
        }
View Full Code Here

        }
       
        if (distributedBinding != null) {
            // reset the binding URI to null so that if the composite containing the component
            // with the service/binding is restarted the binding will have the correct URI set
            SCABinding scaBinding = distributedBinding.getSCABinding();
            try {
                URI tempURI = new URI(scaBinding.getURI());
                if (!tempURI.isAbsolute()){
                    scaBinding.setURI(null);
                }
            } catch (Exception ex){
                scaBinding.setURI(null);
            }
        }
       
    }
View Full Code Here

    public Class<SCABinding> getModelType() {
        return SCABinding.class;
    }

    public SCABinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        SCABinding scaBinding = scaBindingFactory.createSCABinding();
        IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
        bindingType.setName(getArtifactType());
        bindingType.setUnresolved(true);
        ((PolicySetAttachPoint)scaBinding).setType(bindingType);
       
        // Read policies
        policyProcessor.readPolicies(scaBinding, reader);
       
        // Read binding name
        String name = reader.getAttributeValue(null, NAME);
        if (name != null) {
            scaBinding.setName(name);
        }

        // Read binding URI
        String uri = reader.getAttributeValue(null, URI);
        if (uri != null) {
            scaBinding.setURI(uri);
        }

        // Skip to end element
        while (reader.hasNext()) {
            if (reader.next() == END_ELEMENT && BINDING_SCA_QNAME.equals(reader.getName())) {
View Full Code Here

                    componentServices.put(component.getName(), componentService);
                }
                i++;

                // Create and configure an SCA binding for the service
                SCABinding scaBinding = componentService.getBinding(SCABinding.class);
                if (scaBinding == null) {
                    scaBinding = scaBindingFactory.createSCABinding();
                    scaBinding.setName(componentService.getName());
                    componentService.getBindings().add(scaBinding);
                }
                scaBinding.setURI(uri);
                scaBinding.setComponent(component);
            }
            for (ComponentReference componentReference : component.getReferences()) {
                String uri = component.getName() + '/' + componentReference.getName();
                componentReferences.put(uri, componentReference);

                // Create and configure an SCA binding for the reference
                SCABinding scaBinding = componentReference.getBinding(SCABinding.class);
                if (scaBinding == null) {
                    scaBinding = scaBindingFactory.createSCABinding();
                    scaBinding.setName(componentReference.getName());
                    componentReference.getBindings().add(scaBinding);
                }
                scaBinding.setURI(uri);
                scaBinding.setComponent(component);
            }
        }

    }
View Full Code Here

                                componentService.setInterfaceContract(promotedService.getInterfaceContract());
                            }
                           
                            // Create a new component service to represent this composite
                            // service on the promoted component
                            SCABinding scaBinding = promotedService.getBinding(SCABinding.class);
                            if (scaBinding != null) {
                                Component promotedComponent = scaBinding.getComponent();
                                ComponentService newComponentService = assemblyFactory.createComponentService();
                                newComponentService.setName("$promoted$." + compositeService.getName());
                                //newComponentService.setService(compositeService);
                                promotedComponent.getServices().add(newComponentService);
                                newComponentService.getBindings().add(scaBinding);
                                newComponentService.getBindings().addAll(compositeService.getBindings());
                                newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
                                newComponentService.setCallback(compositeService.getCallback());
                               
                                // FIXME: [rfeng] Set the service to promoted
                                 newComponentService.setService(promotedService.getService());

                                // Change the composite service to now promote the newly
                                // created component service directly
                                compositeService.setPromotedService(newComponentService);
                               
                            } else {
                                warning("Promoted component service not found: " + promotedService.getName(), composite);
                            }
                        }
                    }
                }
            }
        }

        // Process composite services declared in this composite
        for (Service service : composite.getServices()) {
            CompositeService compositeService = (CompositeService)service;

            // Get the inner most promoted service
            ComponentService promotedService = getPromotedComponentService(compositeService);
            if (promotedService != null) {

                // Default to use the interface from the promoted service
                if (compositeService.getInterfaceContract() == null && promotedService.getInterfaceContract() != null) {
                    compositeService.setInterfaceContract(promotedService.getInterfaceContract());
                }
               
                // Create a new component service to represent this composite
                // service on the promoted component
                SCABinding scaBinding = promotedService.getBinding(SCABinding.class);
                if (scaBinding != null) {
                    Component promotedComponent = scaBinding.getComponent();
                    ComponentService newComponentService = assemblyFactory.createComponentService();
                    newComponentService.setName("$promoted$." + compositeService.getName());
                    //newComponentService.setService(compositeService);
                    promotedComponent.getServices().add(newComponentService);
                    newComponentService.getBindings().add(scaBinding);
View Full Code Here

            CompositeReference compositeReference = (CompositeReference)reference;
            List<ComponentReference> promotedReferences = getPromotedComponentReferences(compositeReference);
            for (ComponentReference promotedReference : promotedReferences) {

                // Override the configuration of the promoted reference
                SCABinding scaBinding = promotedReference.getBinding(SCABinding.class);
                promotedReference.getBindings().clear();
                promotedReference.getBindings().add(scaBinding);
                promotedReference.getBindings().addAll(compositeReference.getBindings());
            }
        }

        // Process the component references declared on components
        // in this composite
        for (Component component : composite.getComponents()) {
            Implementation implementation = component.getImplementation();
            if (implementation instanceof Composite) {
                for (ComponentReference componentReference : component.getReferences()) {
                    CompositeReference compositeReference = (CompositeReference)componentReference.getReference();
                    if (compositeReference != null) {
                        List<ComponentReference> promotedReferences = getPromotedComponentReferences(compositeReference);
                        for (ComponentReference promotedReference : promotedReferences) {

                            // Override the configuration of the promoted
                            // reference
                            SCABinding scaBinding = promotedReference.getBinding(SCABinding.class);
                            promotedReference.getBindings().clear();
                            promotedReference.getBindings().add(scaBinding);
                            promotedReference.getBindings().addAll(componentReference.getBindings());

                            // Wire the promoted reference to the actual
View Full Code Here

                            for (ComponentReference promotedReference : promotedReferences) {
                                ReferenceConfigurationUtil.reconcileReferenceBindings(
                                        componentReference, promotedReference, assemblyFactory, endpointFactory, monitor);
                                if (componentReference.getInterfaceContract() != null && // can be null in unit tests
                                    componentReference.getInterfaceContract().getCallbackInterface() != null) {
                                    SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
                                    if (promotedReference.getCallback() != null) {
                                        promotedReference.getCallback().getBindings().clear();
                                    } else {
                                        promotedReference.setCallback(assemblyFactory.createCallback());
                                    }
View Full Code Here

                for (ComponentReference promotedReference : promotedReferences) {
                    ReferenceConfigurationUtil.reconcileReferenceBindings(
                            compositeReference, promotedReference, assemblyFactory, endpointFactory, monitor);
                    if (compositeReference.getInterfaceContract() != null && // can be null in unit tests
                        compositeReference.getInterfaceContract().getCallbackInterface() != null) {
                        SCABinding scaCallbackBinding = promotedReference.getCallbackBinding(SCABinding.class);
                        if (promotedReference.getCallback() != null) {
                            promotedReference.getCallback().getBindings().clear();
                        } else {
                            promotedReference.setCallback(assemblyFactory.createCallback());
                        }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.assembly.SCABinding

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.