Package org.apache.tuscany.sca.assembly

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


    }

    private void checkScenario10And11Results() {
        Composite domainComposite = customBuilder.getDomainComposite();

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        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);
View Full Code Here


    }

    private void checkScenario12Results() {
        Composite domainComposite = customBuilder.getDomainComposite();

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        ComponentReference componentRef = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3a".equals(reference.getName())) {
                componentRef = reference;
                assertTrue(reference.getBindings().size() == 2);
                assertTrue(reference.getBindings().get(0) instanceof WebServiceBinding);
                assertTrue(reference.getBindings().get(1) instanceof WebServiceBinding);
View Full Code Here

    }

    private void checkScenario13Results() {
        Composite domainComposite = customBuilder.getDomainComposite();

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        ComponentReference componentRef = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3a".equals(reference.getName())) {
                componentRef = reference;
                assertTrue(reference.getBindings().size() == 1);
                assertTrue(reference.getBindings().get(0) instanceof WebServiceBinding);
            }
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, TARGET_NAMESPACE)){
                            // spec says that a composite must have a namespace
                            warning("NoCompositeNamespace", composite, composite.getName().toString());  
                        }
                       
                        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.setURI(getString(reader, URI));
                        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);
                            if (promoted != null) {
                                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

        }

        // Write <service> elements
        for (Service service : composite.getServices()) {
            CompositeService compositeService = (CompositeService)service;
            Component promotedComponent = compositeService.getPromotedComponent();
            ComponentService promotedService = compositeService.getPromotedService();
            String promote;
            if (promotedService != null) {
                if (promotedService.getName() != null) {
                    promote = promotedComponent.getName() + '/' + promotedService.getName();
                } else {
                    promote = promotedComponent.getName();
                }
            } else {
                promote = null;
            }
            writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), new XAttr(PROMOTE, promote),
View Full Code Here

        }

        // Add model resolver to promoted components
        for (Service service : composite.getServices()) {
            CompositeService compositeService = (CompositeService)service;
            Component promotedComponent = compositeService.getPromotedComponent();
            if (promotedComponent instanceof ResolverExtension) {
                ((ResolverExtension)promotedComponent).setModelResolver(resolver);
            }
        }
    }
View Full Code Here

            componentName = name;
            serviceName = null;
        }

        // Lookup the component
        Component component = null;

        for (Component compositeComponent : composite.getComponents()) {
            if (compositeComponent.getName().equals(componentName)) {
                component = compositeComponent;
            }
        }

        if (component == null) {
            throw new ServiceRuntimeException("The service " + name + " has not been contributed to the domain");
        }
        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$." + component.getName() + "." + serviceName;
                        }
                        componentContext =
                            ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
                        return componentContext.createSelfReference(businessInterface, compositeService
                            .getPromotedService());
View Full Code Here

        CompositeImpl clone = (CompositeImpl)super.clone();

        // clone the child components
        clone.components = new ArrayList<Component>();
        for (Component component : getComponents()) {
            Component clonedComponent = (Component)component.clone();
            clone.components.add(clonedComponent);
        }
       
        // reset the references and services so the get re-resolved
        for (Service service : clone.getServices()) {
View Full Code Here

    public List<Component> getComponents() {
        return components;
    }
   
    public Component getComponent(String name) {
        Component component = null;
       
        for (Component tmp : getComponents()){
            if (tmp.getName().equals(name)){
                component = tmp;
                break;
View Full Code Here

    }
   
    private void verifyComposite(Composite c) {
      assertEquals("Calculator", c.getName().getLocalPart());
      assertEquals(1, c.getComponents().size());
      Component component = c.getComponents().get(0);
      assertEquals("AddServiceComponent", component.getName());
      assertEquals(1, component.getAttributeExtensions().size());
      Extension extension = component.getAttributeExtensions().get(0);
      assertEquals("customAttribute", extension.getQName().getLocalPart());
      assertEquals("http://test", extension.getQName().getNamespaceURI());
      assertEquals("customValue", extension.getValue());
    }
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.