Package org.apache.tuscany.sca.assembly

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


     */
    @Override
    public void start() {
        String deployedURI = ServletFactory.registerServlet(this.servletHost);
        endpoint.setDeployedURI(deployedURI);
        final ComponentService service = this.endpoint.getService();
        final Interface serviceInterface = service.getInterfaceContract().getInterface();
        JavascriptGenerator.generateServiceProxy(service);
        for (final Operation operation : serviceInterface.getOperations()) {
            final String url = "/" + endpoint.getService().getName() + "/" + operation.getName();
            CometEndpointManager.add(url, endpoint);
            CometOperationManager.add(url, operation);
View Full Code Here


    /**
     * @param component
     */
    public static ComponentService getSingleService(Component component) {
        ComponentService targetService;
        List<ComponentService> services = component.getServices();
        List<ComponentService> regularServices = new ArrayList<ComponentService>();
        for (ComponentService service : services) {
            if (service.isForCallback()) {
                continue;
View Full Code Here

        targetService = regularServices.get(0);
        return targetService;
    }

    public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface) {
        ComponentService service = getSingleService(component);
        try {
            return createSelfReference(businessInterface, service);
        } catch (IllegalArgumentException iae) {
            throw iae;
        } catch (Exception e) {
View Full Code Here

    }

    private EndpointReference createEndpointReference(Endpoint endpoint, Class<?> businessInterface)
        throws CloneNotSupportedException, InvalidInterfaceException {
        Component component = endpoint.getComponent();
        ComponentService service = endpoint.getService();
        ComponentReference componentReference = assemblyFactory.createComponentReference();
        componentReference.setName("$self$." + service.getName());

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

        // For the self-reference, allows pass by reference
        componentReference.setAllowsPassByReference(true);

        InterfaceContract interfaceContract = service.getInterfaceContract();
        Service componentTypeService = service.getService();
        if (componentTypeService != null && componentTypeService.getInterfaceContract() != null) {
            interfaceContract = componentTypeService.getInterfaceContract();
        }
        interfaceContract = getInterfaceContract(interfaceContract, businessInterface);
        componentReference.setInterfaceContract(interfaceContract);
View Full Code Here

            // will not happen
        } // end try
        endpoint.setComponent(fakeComponent);

        // Create pseudo-service
        ComponentService service = assemblyFactory.createComponentService();
        ExtensionPointRegistry registry = compositeContext.getExtensionPointRegistry();
        FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
        JavaInterfaceFactory javaInterfaceFactory =
            (JavaInterfaceFactory)modelFactories.getFactory(JavaInterfaceFactory.class);
        JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
        try {
            interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(AsyncResponseService.class));
        } catch (InvalidInterfaceException e1) {
            // Nothing to do here - will not happen
        } // end try
        service.setInterfaceContract(interfaceContract);
        String serviceName = epr.getReference().getName() + "_asyncCallback";
        service.setName(serviceName);
        // MJE 06/12/2010 - fixup for JMS binding code which looks at the implementation service
        // as well as the component service...
        // Create a pseudo implementation service...
        Service implService = assemblyFactory.createService();
        implService.setName(serviceName);
        implService.setInterfaceContract(interfaceContract);
        service.setService(implService);
        //
        endpoint.setService(service);
        // Set pseudo-service onto the pseudo-component
        List<ComponentService> services = fakeComponent.getServices();
        services.clear();
View Full Code Here

        this.compositeActivator = CompositeContext.getCurrentCompositeActivator();

        // Get the target Component and Service from the URI
        final String uri = in.readUTF();
        final Component targetComponent = super.resolveComponentURI(uri);
        final ComponentService targetService = super.resolveServiceURI(uri, targetComponent);
        final InterfaceContract targetServiceIfaceContract = targetService.getInterfaceContract();

        // Re-create the resolved Endpoint
        this.resolvedEndpoint = new EndpointReferenceImpl(
                (RuntimeComponent) targetComponent, targetService, null,
                targetServiceIfaceContract);
View Full Code Here

        // if the target service is a promoted service then find the
        // service it promotes
        if (endpoint.getTargetComponentService().getService() instanceof CompositeService) {
            CompositeService compositeService = (CompositeService) endpoint.getTargetComponentService().getService();
            // Find the promoted component service
            ComponentService promotedComponentService = ServiceConfigurationUtil.getPromotedComponentService(compositeService);
            if (promotedComponentService != null && !promotedComponentService.isUnresolved()) {
                endpoint.setTargetComponentService(promotedComponentService);
            }
        }
       
        try  {
View Full Code Here

       
                                        // Wire to the actual component service
                                        // promoted by a composite service
                                        CompositeService compositeService = (CompositeService)target.getService();
                                        // Find the promoted component service
                                        ComponentService componentService =
                                            ServiceConfigurationUtil.getPromotedComponentService(compositeService);
                                        if (componentService != null) {
                                            promotedReference.getTargets().add(componentService);
                                        }
                                    } else {
       
                                        // Wire to a non-composite target service
                                        promotedReference.getTargets().add(target);
                                    }
                                }
                            }
                        }
                    }
                }
            } else {
                for (ComponentReference componentReference : component.getReferences()) {
   
                    // Wire the component reference to the actual
                    // non-composite component services
                    List<ComponentService> targets = componentReference.getTargets();
                    for (int i = 0, n = targets.size(); i < n; i++) {
                        ComponentService target = targets.get(i);
                        if (target.getService() instanceof CompositeService) {
   
                            // Wire to the actual component service
                            // promoted by a composite service
                            CompositeService compositeService = (CompositeService)target.getService();
                            ComponentService componentService = compositeService.getPromotedService();
                            if (componentService != null) {
                                targets.set(i, componentService);
                            }
                        }
                    }
View Full Code Here

                    Service implService = componentService.getService();
                    if (implService != null && implService instanceof CompositeService) {
                        CompositeService compositeService = (CompositeService)implService;

                        // Get the innermost promoted service
                        ComponentService promotedService =
                            ServiceConfigurationUtil.getPromotedComponentService(compositeService);
                        if (promotedService != null) {
                            Component promotedComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService);

                            // Create a new component service to represent this
                            // component service on the promoted component
                            ComponentService newComponentService = assemblyFactory.createComponentService();
                            newComponentService.setName("$promoted$" + component.getName() + "$slash$" + componentService.getName());
                            promotedComponent.getServices().add(newComponentService);
                            newComponentService.setService(promotedService.getService());
                            newComponentService.getBindings().addAll(componentService.getBindings());
                            newComponentService.setInterfaceContract(componentService.getInterfaceContract());
                           
                            if (componentService.getInterfaceContract() != null &&
                                componentService.getInterfaceContract().getCallbackInterface() != null) {
                                newComponentService.setCallback(assemblyFactory.createCallback());
                                newComponentService.getCallback().getBindings()
                                        .addAll(componentService.getCallback().getBindings());
                            }

                            // Change the composite service to now promote the
                            // newly created component service directly
View Full Code Here

        List<Wire> wires = composite.getWires();
        for (int i = 0, n = wires.size(); i < n; i++) {
            Wire wire = wires.get(i);
   
            ComponentReference resolvedReference;
            ComponentService resolvedService;
   
            // Resolve the source reference
            ComponentReference source = wire.getSource();
            if (source != null && source.isUnresolved()) {
                resolvedReference = componentReferences.get(source.getName());
                if (resolvedReference != null) {
                    wire.setSource(resolvedReference);
                } else {
                    warning(monitor, "WireSourceNotFound", composite, source.getName());
                }
            } else {
                resolvedReference = wire.getSource();
            }
   
            // Resolve the target service
            ComponentService target = wire.getTarget();
            if (target != null && target.isUnresolved()) {
                resolvedService = componentServices.get(target.getName());
                if (resolvedService != null) {
                    wire.setTarget(target);
                } else {
                    warning(monitor, "WireTargetNotFound", composite, source.getName());
                }
            } else {
                resolvedService = wire.getTarget();
            }
   
            // Add the target service to the list of targets of the
            // reference
            if (resolvedReference != null && resolvedService != null) {
                // Check that the target component service provides
                // a superset of
                // the component reference interface
                if (resolvedReference.getInterfaceContract() == null || interfaceContractMapper
                    .isCompatible(resolvedReference.getInterfaceContract(), resolvedService.getInterfaceContract())) {
   
                    //resolvedReference.getTargets().add(resolvedService);
                    resolvedReference.getTargets().add(wire.getTarget());
                } else {
                    warning(monitor, "WireIncompatibleInterface", composite, source.getName(), target.getName());
                }
            }
        }
   
        // Clear the list of wires
View Full Code Here

TOP

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

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.