Package org.apache.tuscany.sca.assembly

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


    /**
     * Convert a Java class to a service.
     */
    static Service service(final Class<?> c, final JavaInterfaceFactory jif, final AssemblyFactory af) throws InvalidInterfaceException {
        Service s = af.createService();
        s.setName(c.getSimpleName());
        s.setInterfaceContract(contract(c, jif));
        return s;
    }
View Full Code Here


    /**
     * Convert a WSDL interface to a service.
     */
    static Service service(final WSDLInterface wi, final WSDLFactory wf, final AssemblyFactory af) {
        Service s = af.createService();
        s.setName(wi.getName().getLocalPart());
        s.setInterfaceContract(contract(wi, wf));
        return s;
    }
View Full Code Here

           
        } else {
           
            // We have no component type description, simply introspect the POJO and
            // create a single Service for it
            Service service = assemblyFactory.createService();
            service.setName(pojoClass.getSimpleName());
            JavaInterface javaInterface;
            try {
                javaInterface = javaFactory.createJavaInterface(pojoClass);
            } catch (InvalidInterfaceException e) {
                throw new ContributionResolveException(e);
            }
            JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
            interfaceContract.setInterface(javaInterface);
            service.setInterfaceContract(interfaceContract);
            implementation.getServices().add(service);
        }
       
        // Mark the implementation resolved now
        implementation.setUnresolved(false);
View Full Code Here

        // Propagate interfaces from inner composite components' services to
        // their component services
        for (Component component : composite.getComponents()) {
            if (component.getImplementation() instanceof Composite) {
                for (ComponentService componentService : component.getServices()) {
                    Service service = componentService.getService();
                    if (service != null) {
                        if (componentService.getInterfaceContract() == null) {
                            componentService.setInterfaceContract(service.getInterfaceContract());
                        }
                    }
                }
            }
        }
View Full Code Here

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

            for (ComponentService componentService : component.getServices()) {
                Service service = componentService.getService();
                if (service != null) {
                    // reconcile intents and policysets from componentType
                     addInheritedIntents(service.getRequiredIntents(), componentService.getRequiredIntents());
                     addInheritedPolicySets(service.getPolicySets(), componentService.getPolicySets(), true);
                    
                     //reconcile intents and policysets for operations
                     boolean notFound;
                     List<ConfiguredOperation> opsFromComponentType = new ArrayList<ConfiguredOperation>();
                     for ( ConfiguredOperation ctsConfOp : service.getConfiguredOperations() ) {
                         notFound = true;
                         for ( ConfiguredOperation csConfOp : componentService.getConfiguredOperations() ) {
                             if ( csConfOp.getName().equals(ctsConfOp.getName()) ) {
                                 addInheritedIntents(ctsConfOp.getRequiredIntents(), csConfOp.getRequiredIntents());
                                 addInheritedPolicySets(ctsConfOp.getPolicySets(), csConfOp.getPolicySets(), true);
View Full Code Here

      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 InterfaceImpl() {
            @Override
            public boolean isDynamic() {
                return true;
            }
        };
        Operation dynamicOperation = assemblyFactory.createOperation();
        dynamicOperation.setDynamic(true);
        dynamicInterface.getOperations().add(dynamicOperation);
        dynamicInterfaceContract.setInterface(dynamicInterface);
        dynamicService.setInterfaceContract(dynamicInterfaceContract);

        return dynamicService;
    }
View Full Code Here

        componentReference.getPolicySets().addAll(service.getPolicySets());
        componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
        componentReference.getBindings().add(endpoint.getBinding());

        InterfaceContract interfaceContract = service.getInterfaceContract();
        Service componentTypeService = service.getService();
        if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
            interfaceContract = componentTypeService.getInterfaceContract();
        }
        interfaceContract = getInterfaceContract(javaInterfaceFactory, 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

                                   Map<String, Service> services,
                                   Map<String, ComponentService> componentServices) {

        // Connect each component service to the corresponding service
        for (ComponentService componentService : component.getServices()) {
            Service service = services.get(componentService.getName());
            if (service != null) {
                componentService.setService(service);
            } else {
                warning("Service not found for component service: " + component.getName()
                    + "/"
                    + componentService.getName(), component);
            }
        }

        // Create a component service for each service
        if (component.getImplementation() != null) {
            for (Service service : component.getImplementation().getServices()) {
                if (!componentServices.containsKey(service.getName())) {
                    ComponentService componentService = assemblyFactory.createComponentService();
                    componentService.setIsCallback(service.isCallback());
                    String name = service.getName();
                    componentService.setName(name);
                    componentService.setService(service);
                    component.getServices().add(componentService);
                    componentServices.put(name, componentService);
                }
            }
        }

        //Reconcile each component service with its service
        for (ComponentService componentService : component.getServices()) {
            Service service = componentService.getService();
            if (service != null) {
                // Reconcile interface
                if (componentService.getInterfaceContract() != null) {
                    if (!componentService.getInterfaceContract().equals(service
                        .getInterfaceContract())) {
                        if (!interfaceContractMapper.isCompatible(componentService
                            .getInterfaceContract(), service.getInterfaceContract())) {
                            warning("Component service interface incompatible with service interface: " + component
                                        .getName()
                                        + "/"
                                        + componentService.getName(),
                                    component);
                        }
                    }
                } else {
                    componentService.setInterfaceContract(service.getInterfaceContract());
                }

                // Reconcile bindings
                if (componentService.getBindings().isEmpty()) {
                    componentService.getBindings().addAll(service.getBindings());
                }
               
                // Reconcile callback bindings
                if (componentService.getCallback() == null) {
                    componentService.setCallback(service.getCallback());
                    if (componentService.getCallback() == null) {
                        // Create an empty callback to avoid null check
                        componentService.setCallback(assemblyFactory.createCallback());
                    }
                } else if (componentService.getCallback().getBindings().isEmpty() && service
                    .getCallback() != null) {
                    componentService.getCallback().getBindings().addAll(service.getCallback()
                        .getBindings());
                }
            }
        }
    }
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.