Package org.apache.tuscany.sca.assembly

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


     * Return a component builder.
     */
    static Builder<Component> component(final String name, final Builder<Implementation> impl, final Builder<ComponentReference>... references) {
        return new Builder<Component>() {
            public Component build(final Context ec) {
                final Component c = ec.af.createComponent();
                c.setName(name);
                c.setImplementation(impl.build(ec));
                for(Builder<ComponentReference> r: references)
                    c.getReferences().add(r.build(ec));
                return c;
            }
        };
    }
View Full Code Here


                                                             CompositeContext compositeContext,
                                                             AssemblyFactory assemblyFactory,
                                                             Endpoint endpoint,
                                                             Class<?> businessInterface)
        throws CloneNotSupportedException, InvalidInterfaceException {
        Component component = endpoint.getComponent();
        ComponentService service = endpoint.getService();
        ComponentReference componentReference = assemblyFactory.createComponentReference();
        componentReference.setName("sca.client." + service.getName());

        componentReference.setCallback(service.getCallback());
View Full Code Here

            componentName = name;
            serviceName = null;
        }

        // Lookup the component
        Component component = null;

        for (Component compositeComponent : domainComposite.getComponents()) {
            if (compositeComponent.getName().equals(componentName)) {
                component = compositeComponent;
                break;
View Full Code Here

        Assert.assertEquals(expectedStructure, structure);
       
        // Test that generated WSDL matches expected
        // Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
        // No other services on ComponentB should have <binding.ws>
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        WebServiceBinding wsBinding = null;
   
        for (ComponentService service : componentB.getServices()) {
            WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
            if ("Service2".equals(service.getName())) {
                wsBinding = wsb;
            } else {
                assert wsb == null;
View Full Code Here

                return component;
            }
            // process implementation composites recursively
            Implementation impl = component.getImplementation();
            if (impl instanceof Composite) {
                Component comp = getComponent((Composite)impl, name);
                if (comp != null) {
                    return comp;
                }
            }
        }
View Full Code Here

        if (!(reference instanceof RuntimeComponentReference)) {
            return;
        }

        // 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();
View Full Code Here

        this.domainComposite = domainComposite;
    }

    public Component resolve(String componentURI) {
        for (Composite composite : domainComposite.getIncludes()) {
            Component component = resolve(composite, componentURI);
            if (component != null) {
                return component;
            }
        }
        return null;
View Full Code Here

            componentName = name;
            serviceName = null;
        }

        // Lookup the component in the domain
        Component component = components.get(componentName);
        if (component == null) {
            // The component is not local in the partition, try to create a remote service ref
            return createServiceReference(businessInterface, name);
        }
        RuntimeComponentContext componentContext = null;

        // If the component is a composite, then we need to find the
        // non-composite component that provides the requested service
        if (component.getImplementation() instanceof Composite) {
            for (ComponentService componentService : component.getServices()) {
                if (serviceName == null || serviceName.equals(componentService.getName())) {
                    CompositeService compositeService = (CompositeService)componentService.getService();
                    if (compositeService != null) {
                        if (serviceName != null) {
                            serviceName = "$promoted$." + serviceName;
View Full Code Here

        }
        return null;
    }

    public void startComponent(String componentName) throws ActivationException {
        Component component = getComponent(componentName);
        if (component == null) {
            throw new IllegalArgumentException("no component: " + componentName);
        }
        CompositeActivator compositeActivator = runtime.getCompositeActivator();
        compositeActivator.start(component);
View Full Code Here

     */

    public Composite read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        Composite composite = null;
        Composite include = null;
        Component component = null;
        Property property = null;
        ComponentService componentService = null;
        ComponentReference componentReference = null;
        ComponentProperty componentProperty = null;
        CompositeService compositeService = null;
        CompositeReference compositeReference = null;
        Contract contract = null;
        Wire wire = null;
        Callback callback = null;
        QName name = null;

        // Read the composite document
        while (reader.hasNext()) {
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    name = reader.getName();

                    if (COMPOSITE_QNAME.equals(name)) {

                        // Read a <composite>
                        composite = assemblyFactory.createComposite();
                        composite.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
                        if(isSet(reader, AUTOWIRE)) {
                            composite.setAutowire(getBoolean(reader, AUTOWIRE));
                        }
                        composite.setLocal(getBoolean(reader, LOCAL));
                        composite.setConstrainingType(readConstrainingType(reader));
                        policyProcessor.readPolicies(composite, reader);

                    } else if (INCLUDE_QNAME.equals(name)) {

                        // Read an <include>
                        include = assemblyFactory.createComposite();
                        include.setName(getQName(reader, "name"));
                        include.setUnresolved(true);
                        composite.getIncludes().add(include);

                    } else if (SERVICE_QNAME.equals(name)) {
                        if (component != null) {

                            // Read a <component><service>
                            componentService = assemblyFactory.createComponentService();
                            contract = componentService;
                            componentService.setName(getString(reader, NAME));
                            component.getServices().add(componentService);
                            policyProcessor.readPolicies(contract, reader);
                        } else {

                            // Read a <composite><service>
                            compositeService = assemblyFactory.createCompositeService();
                            contract = compositeService;
                            compositeService.setName(getString(reader, NAME));

                            String promoted = getString(reader, PROMOTE);
                            String promotedComponentName;
                            String promotedServiceName;
                            int s = promoted.indexOf('/');
                            if (s == -1) {
                                promotedComponentName = promoted;
                                promotedServiceName = null;
                            } else {
                                promotedComponentName = promoted.substring(0, s);
                                promotedServiceName = promoted.substring(s + 1);
                            }

                            Component promotedComponent = assemblyFactory.createComponent();
                            promotedComponent.setUnresolved(true);
                            promotedComponent.setName(promotedComponentName);
                            compositeService.setPromotedComponent(promotedComponent);

                            ComponentService promotedService = assemblyFactory.createComponentService();
                            promotedService.setUnresolved(true);
                            promotedService.setName(promotedServiceName);
View Full Code Here

TOP

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

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.