Package org.apache.tuscany.sca.assembly

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


                extensionProcessor.resolve(interfaceContract, resolver);
            }

            // Resolve bindings
            for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
                Binding binding = contract.getBindings().get(i);
                extensionProcessor.resolve(binding, resolver);
                if (binding instanceof IntentAttachPoint) {
                    IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                    resolveIntents(policiedBinding.getRequiredIntents(), resolver);
                }
                if (binding instanceof PolicySetAttachPoint) {
                    PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
                    resolvePolicySets(policiedBinding.getPolicySets(), resolver);
                    //validate if attached policysets apply to the binding
                    validatePolicySets(contract, policiedBinding);
                }
                if (binding instanceof OperationsConfigurator) {
                    OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
                    for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
                        resolveIntents(confOp.getRequiredIntents(), resolver);
                        resolvePolicySets(confOp.getPolicySets(), resolver);
                    }
                }
            }

            // Resolve callback bindings
            if (contract.getCallback() != null) {
                resolveIntents(contract.getCallback().getRequiredIntents(), resolver);
                resolvePolicySets(contract.getCallback().getPolicySets(), resolver);
                //inherit the contract's policy intents and policysets
                addInheritedIntents(contract.getRequiredIntents(), contract.getCallback().getRequiredIntents());
                addInheritedPolicySets(contract.getPolicySets(), contract.getCallback().getPolicySets());
               
                for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
                    Binding binding = contract.getCallback().getBindings().get(i);
                    extensionProcessor.resolve(binding, resolver);

                    if (binding instanceof IntentAttachPoint) {
                        IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                        resolveIntents(policiedBinding.getRequiredIntents(), resolver);
View Full Code Here


    private void writeJavaScriptReferenceFunction (ServletOutputStream os) throws IOException {
       
        os.println("var referenceMap = new Object();");
        for(ComponentReference reference : component.getReferences()) {
            String referenceName = reference.getName();
            Binding binding = reference.getBindings().get(0);
            if (binding != null) {
               
                String proxyClient = WidgetProxyHelper.getJavaScriptProxyClient(binding.getClass().getName());
                if(proxyClient != null) {
                   
                    //FIXME Eventually the binding URI should be initialized from the SCA domain
                    // for now point to the target binding model directly, assuming that it's available
                    // in the same node
                    String targetURI = null;
                    if (binding instanceof OptimizableBinding) {
                        Binding targetBinding = ((OptimizableBinding)binding).getTargetBinding();
                        if (targetBinding != null) {
                            targetURI = URI.create(targetBinding.getURI()).getPath();
                        }
                    }
                    if (targetURI == null) {
                        targetURI = URI.create(binding.getURI()).getPath();
                        if (!targetURI.startsWith("/")) {
View Full Code Here

        Contract source = wireSource.getContract();
        if (source instanceof RuntimeComponentReference) {
            // It's the reference wire
            RuntimeComponentReference reference = (RuntimeComponentReference)wireSource.getContract();
            Binding refBinding = wireSource.getBinding();
            for (Operation operation : sourceContract.getInterface().getOperations()) {
                Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
                if (targetOperation == null) {
                    throw new ServiceRuntimeException("No matching operation for " + operation.getName()
                        + " is found in reference "
View Full Code Here

        }

        // create wire if binding has an endpoint
        Component targetComponent = null;
        ComponentService targetComponentService = null;
        Binding targetBinding = null;
        if (binding instanceof OptimizableBinding) {
            OptimizableBinding endpoint = (OptimizableBinding)binding;
            targetComponent = endpoint.getTargetComponent();
            targetComponentService = endpoint.getTargetComponentService();
            targetBinding = endpoint.getTargetBinding();
View Full Code Here

        EndpointReference wireSource =
            new EndpointReferenceImpl((RuntimeComponent)refComponent, reference, refBinding, sourceContract);
        ComponentService callbackService = reference.getCallbackService();
        if (callbackService != null) {
            // select a reference callback binding to pass with invocations on this wire
            Binding callbackBinding = null;
            for (Binding binding : callbackService.getBindings()) {
                // first look for a callback binding whose name matches the reference binding name
              if (refBinding.getName().startsWith(binding.getName())) {
                    callbackBinding = binding;
                    break;
View Full Code Here

        wire.getSource().getBinding().setURI(epr.getURI());

        // also need to set the target contract as it varies for the sca binding depending on
        // whether it is local or remote
        RuntimeComponentReference ref = (RuntimeComponentReference)wire.getSource().getContract();
        Binding binding = wire.getSource().getBinding();
        wire.getTarget().setInterfaceContract(ref.getBindingProvider(binding).getBindingInterfaceContract());

        //FIXME: can we use the same code as JDKInvocationHandler to select the chain?
        InvocationChain chain = getInvocationChain(method, wire);
        if (chain == null) {
View Full Code Here

                    warning("Theres been an exception relation to policies... " + e, e);
                    //throw new RuntimeException(e);
                }

                // Match the binding against the bindings of the target service
                Binding selected = BindingUtil.resolveBindings(componentReference, targetComponent, targetComponentService);
                if (selected == null) {
                    warning("Component reference doesn't have a matching binding", componentReference);
                } else {
                    selectedBindings.add(selected);
                }
                if (bidirectional) {
                    Binding selectedCallback = BindingUtil.resolveCallbackBindings(componentReference, targetComponent, targetComponentService);
                    if (selectedCallback != null) {
                        selectedCallbackBindings.add(selectedCallback);
                    }
                }
            }
View Full Code Here

                    extensionProcessor.resolve(interfaceContract, resolver);
                }
   
                // Resolve bindings
                for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
                    Binding binding = contract.getBindings().get(i);
                    extensionProcessor.resolve(binding, resolver);
                   
                    if (binding instanceof IntentAttachPoint) {
                        IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                       
                        if ( policiedBinding.getType() != null && policiedBinding.getType().isUnresolved() ) {
                            IntentAttachPointType resolved =
                                resolver.resolveModel(IntentAttachPointType.class,
                                                      policiedBinding.getType());
                            policiedBinding.setType(resolved);
                        }
                       
                        resolveIntents(policiedBinding.getRequiredIntents(), resolver);
                        PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
                    }
                   
                    if (binding instanceof PolicySetAttachPoint) {
                        PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
                        resolvePolicySets(policiedBinding.getPolicySets(), resolver);
                        //validate if attached policysets apply to the binding
                        resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
                        //inherit the applicable policysets from parent contract as whatever applies to that
                        //applies to the binding as well
                        addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets());
                        PolicyValidationUtils.validatePolicySets(policiedBinding);
                    }
                   
                    if (binding instanceof OperationsConfigurator) {
                        OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
                        for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
                            resolveIntents(confOp.getRequiredIntents(), resolver);
                            PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType());
                           
                            resolvePolicySets(confOp.getPolicySets(), resolver);
                            resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
                            //inherit the applicable policysets from parent binding as whatever applies to that
                            //applies to the binding as well
                            addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
                                                   confOp.getApplicablePolicySets());
                            PolicyValidationUtils.validatePolicySets(confOp, ((PolicySetAttachPoint)binding).getType());
                        }
                    }
                }
   
                // Resolve callback bindings
                if (contract.getCallback() != null) {
                    resolveIntents(contract.getCallback().getRequiredIntents(), resolver);
                    resolvePolicySets(contract.getCallback().getPolicySets(), resolver);
                    resolvePolicySets(contract.getCallback().getApplicablePolicySets(), resolver);
                    //inherit the contract's policy intents and policysets
                    addInheritedPolicySets(contract.getApplicablePolicySets(), contract.getCallback().getApplicablePolicySets());
                   
                    for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
                        Binding binding = contract.getCallback().getBindings().get(i);
                        extensionProcessor.resolve(binding, resolver);
   
                        if (binding instanceof IntentAttachPoint) {
                            IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                           
View Full Code Here

        ComponentReference componentRef = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3a".equals(reference.getName())) {
                componentRef = reference;
                assertTrue(reference.getBindings().size() == 2);
                Binding binding1 = reference.getBindings().get(0);
                assertTrue(binding1 instanceof SCABinding);
                assertTrue(reference.getInterfaceContract(binding1) instanceof JavaInterfaceContract);
                Binding binding2 = reference.getBindings().get(1);
                assertTrue(binding2 instanceof WebServiceBinding);
                assertTrue(reference.getInterfaceContract(binding2) instanceof WSDLInterfaceContract);
            }
        }
        assertTrue(componentRef != null);
View Full Code Here

        reference.setReference(implReference);
        // Set the created ComponentReference into the EPR
        epr.setReference(reference);
       
        // Create a binding
    Binding binding = createMatchingBinding( endpoint.getBinding(), (RuntimeComponent)endpoint.getComponent(), reference, registry );     
    epr.setBinding(binding);
   
    // Need to establish policies here (binding has some...)
    epr.getRequiredIntents().addAll( endpoint.getRequiredIntents() );
    epr.getPolicySets().addAll( endpoint.getPolicySets() );
View Full Code Here

TOP

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

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.