Package org.apache.tuscany.sca.assembly

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


   
    public <T> T resolveModel(Class<T> modelClass, T unresolved) {
       
        // Lookup a definition for the given namespace
        QName qname = ((ConstrainingType)unresolved).getName();
        ConstrainingType resolved = (ConstrainingType) map.get(qname);
        if (resolved != null) {
            return modelClass.cast(resolved);
        }
       
        // No definition found, delegate the resolution to the imports
        for (Import import_ : this.contribution.getImports()) {
            if (import_ instanceof NamespaceImport) {
                NamespaceImport namespaceImport = (NamespaceImport)import_;
                if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) {
                   
                    // Delegate the resolution to the import resolver
                    resolved = namespaceImport.getModelResolver().resolveModel(ConstrainingType.class, (ConstrainingType)unresolved);
                    if (!resolved.isUnresolved()) {
                        return modelClass.cast(resolved);
                    }
                }
            }
        }
View Full Code Here


     * @return
     */
    protected ConstrainingType readConstrainingType(XMLStreamReader reader) {
        QName constrainingTypeName = getQName(reader, Constants.CONSTRAINING_TYPE);
        if (constrainingTypeName != null) {
            ConstrainingType constrainingType = assemblyFactory.createConstrainingType();
            constrainingType.setName(constrainingTypeName);
            constrainingType.setUnresolved(true);
            return constrainingType;
        } else {
            return null;
        }
    }
View Full Code Here

     * Returns a constrainingType attribute.
     * @param componentType
     * @return
     */
    protected XAttr writeConstrainingType(ComponentType componentType) {
        ConstrainingType constrainingType = componentType.getConstrainingType();
        if (constrainingType != null)
            return new XAttr(Constants.CONSTRAINING_TYPE, constrainingType.getName());
        else
            return null;
    }
View Full Code Here

        staxProcessor.write(componentType, bos);
    }

    public void testReadWriteConstrainingType() throws Exception {
        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
        ConstrainingType constrainingType = staxProcessor.read(is, ConstrainingType.class);
        assertNotNull(constrainingType);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        staxProcessor.write(constrainingType, bos);
    }
View Full Code Here

    public void resolve(Composite composite, ModelResolver resolver)
            throws ContributionResolveException, PolicyValidationException {

        // Resolve constraining type
        ConstrainingType constrainingType = composite.getConstrainingType();
        if (constrainingType != null) {
            constrainingType = resolver.resolveModel(ConstrainingType.class,
                    constrainingType);
            composite.setConstrainingType(constrainingType);
        }
View Full Code Here

    }

    public void resolve(Component component, ModelResolver resolver)
            throws ContributionResolveException {
        // Resolve component implementations, services and references
        ConstrainingType constrainingType = component.getConstrainingType();
        if (constrainingType != null) {
            constrainingType = resolver.resolveModel(ConstrainingType.class,
                    constrainingType);
            component.setConstrainingType(constrainingType);
        }
View Full Code Here

    public void testReadConstrainingType() throws Exception {
        ConstrainingTypeProcessor constrainingTypeProcessor = new ConstrainingTypeProcessor(assemblyFactory, policyFactory, staxProcessor);
        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        ConstrainingType constrainingType = constrainingTypeProcessor.read(reader);
        assertNotNull(constrainingType);

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

    public void testReadConstrainingType() throws Exception {
        ConstrainingTypeProcessor constrainingTypeProcessor = new ConstrainingTypeProcessor(assemblyFactory, policyFactory, staxProcessor);
        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        ConstrainingType constrainingType = constrainingTypeProcessor.read(reader);
        assertNotNull(constrainingType);

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

        staxProcessor.write(componentType, bos);
    }

    public void testReadWriteConstrainingType() throws Exception {
        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
        ConstrainingType constrainingType = staxProcessor.read(is, ConstrainingType.class);
        assertNotNull(constrainingType);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        staxProcessor.write(constrainingType, bos);
    }
View Full Code Here

     */
    Component createComponent(String name) {
        Component c = factory.createComponent();
        c.setName(name);

        ConstrainingType constraint = createConstrainingType();
        c.setConstrainingType(constraint);

        Implementation i = new TestImplementation(factory);
        c.setImplementation(i);

View Full Code Here

TOP

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

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.