Package org.apache.tuscany.sca.assembly

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


      addSideFileComponentType(model.getURI(), model, resolver);

      if (model instanceof DynamicImplementation) {
          // if no services have been defined then add a dynamic one
          if (model.getServices().size() < 1) {
              Service dynamicService = createDynamicService();
              model.getServices().add(dynamicService);
          }
      }
     
      // Allow implementation classes to resolve themselves
View Full Code Here


            }
        }
    }

    protected Service createDynamicService() {
        Service dynamicService = assemblyFactory.createService();
        dynamicService.setName("$dynamic$");
        InterfaceContract dynamicInterfaceContract = new InterfaceContractImpl() {};
        Interface dynamicInterface = new DynamicInterfaceImpl();
        Operation dynamicOperation = new OperationImpl();
        dynamicOperation.setDynamic(true);
        dynamicInterface.getOperations().add(dynamicOperation);
        dynamicInterfaceContract.setInterface(dynamicInterface);
        dynamicService.setInterfaceContract(dynamicInterfaceContract);

        return dynamicService;
    }
View Full Code Here

        componentReference.getTargets().add(service);
        componentReference.getPolicySets().addAll(service.getPolicySets());
        componentReference.getRequiredIntents().addAll(service.getRequiredIntents());

        InterfaceContract interfaceContract = service.getInterfaceContract();
        Service componentTypeService = service.getService();
        if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
            interfaceContract = componentTypeService.getInterfaceContract();
        }
        interfaceContract = getInterfaceContract(interfaceContract, businessInterface);
        componentReference.setInterfaceContract(interfaceContract);
        componentReference.setMultiplicity(Multiplicity.ONE_ONE);
        // component.getReferences().add(componentReference);
View Full Code Here

        componentReference.getTargets().add(service);
        componentReference.getPolicySets().addAll(service.getPolicySets());
        componentReference.getRequiredIntents().addAll(service.getRequiredIntents());

        InterfaceContract interfaceContract = service.getInterfaceContract();
        Service componentTypeService = service.getService();
        if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
            interfaceContract = componentTypeService.getInterfaceContract();
        }
        interfaceContract = getInterfaceContract(interfaceContract, businessInterface);
        componentReference.setInterfaceContract(interfaceContract);
        componentReference.setMultiplicity(Multiplicity.ONE_ONE);
        // component.getReferences().add(componentReference);
View Full Code Here

            return null;
        }
        RuntimeComponentService runtimeService = (RuntimeComponentService)service;

        // FIXME: [rfeng] We might need a better way to get the impl interface contract
        Service targetService = service.getService();
        if (targetService == null) {
            targetService = service;
        }
        InterfaceContract targetContract = targetService.getInterfaceContract().makeUnidirectional(false);

        InterfaceContract sourceContract = getInterfaceContract(service, serviceBinding);

        EndpointReference wireSource = new EndpointReferenceImpl(null, null, serviceBinding, sourceContract);
View Full Code Here

        ref2.setInterfaceContract(new TestInterfaceContract(factory));
        ref2.setMultiplicity(Multiplicity.ONE_ONE);
        ctype.getReferences().add(ref2);
        ref2.getBindings().add(new TestBinding(factory));

        Service s = factory.createService();
        s.setName("AccountService");
        s.setInterfaceContract(new TestInterfaceContract(factory));
        ctype.getServices().add(s);
        s.getBindings().add(new TestBinding(factory));

        return ctype;
    }
View Full Code Here

                               "]");
       
        String nodeURI = SERVICE_NOT_KNOWN;
       
        for (NodeModel node : domainModel.getNodes().values()){
            Service service = null;
            for (CompositeModel compositeModel : node.getDeployedComposites().values()){
                service = domainBuilder.findServiceForReference(compositeModel.getComposite(), serviceName);
                if (service != null) {
                    nodeURI = node.getNodeURI();
                    break;
View Full Code Here

        return null;
    }
   
    public Service findDomainLevelService(Composite composite, String referenceName){
        Service service = null;
       
        for (Composite tmpComposite : composite.getIncludes()) {
            service = findServiceForReference(tmpComposite, referenceName);
            if (service != null) {
                break;
View Full Code Here

       
        String componentName = getComponentNameFromReference(referenceName);
        String serviceName = getServiceNameFromReference(referenceName);
       
        // get the named service
        Service service = null;
        for(Composite composite : domainLevelComposite.getIncludes()) {
            service = findServiceForReference(composite, referenceName);               
            if (service != null){
                break;
            }
        }

        if (service != null) {
            // find the named binding
            for (Binding binding : service.getBindings()){
                if (binding.getClass().getName().equals(bindingClassName)){
                    binding.setURI(URI);
                    break;
                }
            }       
View Full Code Here

                    for (ComponentService targetService : reference.getTargets()){
                        String targetName = targetService.getName();
                        String componentName = getComponentNameFromReference(targetName);
                        String serviceName = getServiceNameFromReference(targetName);
                       
                        Service service = null;
                        Component serviceComponent = null;
                       
                        // find the real target service in the domain
                        for(Composite tmpComposite : domainLevelComposite.getIncludes()) {
                            for (Component tmpComponent: tmpComposite.getComponents()) {
                                if (tmpComponent.getName().equals(componentName)){
                                    serviceComponent = tmpComponent;
                                    if (tmpComponent.getServices().size() > 1) {
                                        for (Service tmpService: tmpComponent.getServices()) {
                                            if (tmpService.getName().equals(serviceName)){
                                                service = tmpService;
                                                break;
                                            }
                                        }
                                    } else if (tmpComponent.getServices().size() == 1) {
                                        service = tmpComponent.getServices().get(0);
                                        break;
                                    }
                                }
                            }
                        }
                       
                        if ( targetService.isUnresolved()){
                           
                            if (service != null){
                                // Find the binding already in use for this target
                                Binding binding = null;
                               
                                for (Binding tmpBinding : reference.getBindings()){
                                    if ((tmpBinding.getName() != null) &&
                                        (tmpBinding.getName().startsWith(reference.getName() + "#" + targetName))){
                                        binding = tmpBinding;
                                    }
                                }

                                // Resolve the binding that should be used for this target
                                // TODO - hang onto the old bindings at the domain level, i.e.
                                //        don't rely on the target objects as we still need the
                                //        bindings if we are going to do autowiring
                                List<Binding> source = targetService.getBindings();
                                List<Binding> target = service.getBindings();
                                Binding newBinding = BindingUtil.matchBinding(serviceComponent, (ComponentService)service, source, target);
                               
                                // update the existing binding to the new binding if required
                                if (newBinding != null) {
                                    if (binding != null){
                                        // there is a binding already so see if the URI has changed
                                        if ((binding.getURI() == null) ||
                                            (!binding.getURI().equals(newBinding.getURI()))){
                                            binding.setURI(newBinding.getURI());
                                            compositeChanged = true;
                                        }
                                    } else {
                                        // this is a newly configured binding so add it
                                        reference.getBindings().add(newBinding);
                                        compositeChanged = true;
                                    }
                                }
                            } else {
                                // Do nothing - the target service hasn't been contributed yet
                            }
                        } else {
                            // find the reference binding with the right name
                            for (Binding refBinding : reference.getBindings()){
                                if ((refBinding.getName() != null) &&
                                    (refBinding.getName().startsWith(reference.getName() + "#" + targetName))){
                                    // find the matching service binding
                                    for (Binding serviceBinding : service.getBindings()){
                                        if (refBinding.getClass() == serviceBinding.getClass()){
                                            refBinding.setURI(serviceBinding.getURI());
                                        }
                                    }
                                } 
View Full Code Here

TOP

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

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.