Package org.apache.tuscany.sca.assembly

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


        staxProcessors.addArtifactProcessor(javaProcessor);
    }

    public void testReadWriteComponentType() throws Exception {
        InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
        ComponentType componentType = staxProcessor.read(is, ComponentType.class);
        assertNotNull(componentType);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        staxProcessor.write(componentType, bos);
    }
View Full Code Here


     * Create a new component type
     *
     * @return
     */
    ComponentType createComponentType() {
        ComponentType ctype = factory.createComponentType();

        Property p = factory.createProperty();
        p.setName("currency");
        p.setValue("USD");
        p.setMustSupply(true);
        p.setXSDType(new QName("", ""));
        ctype.getProperties().add(p);

        Reference ref1 = factory.createReference();
        ref1.setName("accountDataService");
        ref1.setInterfaceContract(new TestInterfaceContract(factory));
        ref1.setMultiplicity(Multiplicity.ONE_ONE);
        ctype.getReferences().add(ref1);
        ref1.getBindings().add(new TestBinding(factory));

        Reference ref2 = factory.createReference();
        ref2.setName("stockQuoteService");
        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

    public void testReadComponentType() throws Exception {
        ComponentTypeProcessor componentTypeProcessor = new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor);
        InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        ComponentType componentType = componentTypeProcessor.read(reader);
        assertNotNull(componentType);

        //new PrintUtil(System.out).print(componentType);
    }
View Full Code Here

            urlStream = connection.getInputStream();
            XMLStreamReader reader = inputFactory.createXMLStreamReader(url.toString(), urlStream);
            reader.nextTag();
           
            // Reader the componentType model
            ComponentType componentType = (ComponentType)extensionProcessor.read(reader);
            if (componentType != null) {
                componentType.setURI(uri.toString());
            }

            // For debugging purposes, write it back to XML
//            if (componentType != null) {
//                try {
View Full Code Here

    public void tearDown() throws Exception {
    }

    public void testReadWriteComponentType() throws Exception {
        InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
        ComponentType componentType = staxProcessor.read(is, ComponentType.class);
        assertNotNull(componentType);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        staxProcessor.write(componentType, bos);
    }
View Full Code Here

            if (reader.next() == END_ELEMENT && IMPLEMENTATION_NOTIFICATION.equals(reader.getName())) {
                break;
            }
        }
       
        ComponentType componentType = new DefaultAssemblyFactory().createComponentType();
        componentType.setURI(componentTypeName + ".componentType");
        componentType.setUnresolved(true);
        implementation.setComponentType(componentType);
       
        return implementation;
    }
View Full Code Here

       
        return implementation;
    }

    public void resolve(NotificationImplementationImpl impl, ModelResolver resolver) throws ContributionResolveException {
        ComponentType componentType = resolver.resolveModel(ComponentType.class, impl.getComponentType());
       
        if (componentType.isUnresolved()) {
            throw new ContributionResolveException("ComponentType still unresolved");
        }
        impl.setComponentType(componentType);
        impl.setUnresolved(false);
    }
View Full Code Here

        assertNotNull(composite);
       
        ComponentTypeProcessor ctProcessor = new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor);
        is = getClass().getClassLoader().getResourceAsStream("OSGiTestService.componentType");
        reader = inputFactory.createXMLStreamReader(is);
        ComponentType ct = ctProcessor.read(reader);

        ModelResolver resolver = new TestModelResolver(getClass().getClassLoader());
        ctProcessor.resolve(ct, resolver);
        resolver.addModel(ct);
       
View Full Code Here

    public void resolve(EJBImplementation implementation, ModelResolver resolver) throws ContributionResolveException {
       
        // Resolve the component type
        String uri = implementation.getURI();
        if (uri != null) {
            ComponentType componentType = assemblyFactory.createComponentType();
            componentType.setURI(uri + ".componentType");
            componentType = resolver.resolveModel(ComponentType.class, componentType);
            if (!componentType.isUnresolved()) {
               
                // Initialize the implementation's services, references and properties
                implementation.getServices().addAll(componentType.getServices());
                implementation.getReferences().addAll(componentType.getReferences());
                implementation.getProperties().addAll(componentType.getProperties());
            }
        }
        implementation.setUnresolved(false);
    }
View Full Code Here

        staxProcessor.write(composite, bos);
    }
   
    public void testReadWriteComponentType() throws Exception {
        InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
        ComponentType componentType = staxProcessor.read(is, ComponentType.class);
        staxProcessor.resolve(componentType, resolver);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        staxProcessor.write(componentType, bos);
    }
View Full Code Here

TOP

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

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.