Package org.apache.tuscany.sca.assembly

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


        StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
        staxProcessors.addArtifactProcessor(new TestPolicyProcessor());

        URL url = BuildPolicyTestCase.class.getResource("CalculatorComponent.constrainingType");
        URI uri = URI.create("CalculatorComponent.constrainingType");
        ConstrainingType constrainingType = (ConstrainingType)documentProcessor.read(null, uri, url);
        assertNotNull(constrainingType);
        resolver.addModel(constrainingType);

        url = BuildPolicyTestCase.class.getResource("TestAllPolicyCalculator.composite");
        uri = URI.create("TestAllCalculator.composite");
View Full Code Here


    @Test
    public void testResolveConstrainingType() throws Exception {
        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        ConstrainingType constrainingType = (ConstrainingType)staxProcessor.read(reader);
        is.close();
        assertNotNull(constrainingType);
        resolver.addModel(constrainingType);

        is = getClass().getResourceAsStream("TestAllCalculator.composite");
View Full Code Here

    @Test
    public void testReadConstrainingType() throws Exception {
        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        ConstrainingType constrainingType = (ConstrainingType)staxProcessor.read(reader);
        assertNotNull(constrainingType);
    }
View Full Code Here

    }

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

    @Test
    public void testResolveConstrainingType() throws Exception {
        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
        StAXArtifactProcessor<ConstrainingType> constrainingTypeReader = staxProcessors.getProcessor(Constants.CONSTRAINING_TYPE_QNAME);
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        ConstrainingType constrainingType = constrainingTypeReader.read(reader);
        is.close();
        assertNotNull(constrainingType);
        resolver.addModel(constrainingType);

        is = getClass().getResourceAsStream("TestAllCalculator.composite");
View Full Code Here

    }

    @Test
    public void testReadWriteConstrainingType() throws Exception {
        InputStream is = getClass().getResourceAsStream("CalculatorComponent.constrainingType");
        ConstrainingType constrainingType = staxProcessor.read(is, ConstrainingType.class);
        staxProcessor.resolve(constrainingType, resolver);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        staxProcessor.write(constrainingType, bos);
    }
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

                                     Monitor monitor) {
        super(modelFactories, extensionProcessor, monitor);
    }
   
    public ConstrainingType read(XMLStreamReader reader) throws ContributionReadException {
        ConstrainingType constrainingType = null;
        AbstractService abstractService = null;
        AbstractReference abstractReference = null;
        AbstractProperty abstractProperty = null;
        AbstractContract abstractContract = null;
        QName name = null;
       
        try {
            // Read the constrainingType document
            while (reader.hasNext()) {
                int event = reader.getEventType();
                switch (event) {
   
                    case START_ELEMENT:
                        name = reader.getName();
                       
                        // Read a <constrainingType>
                        if (Constants.CONSTRAINING_TYPE_QNAME.equals(name)) {
                            constrainingType = assemblyFactory.createConstrainingType();
                            constrainingType.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME)));
                            policyProcessor.readPolicies(constrainingType, reader);
   
                        } else if (Constants.SERVICE_QNAME.equals(name)) {
                           
                            // Read a <service>
                            abstractService = assemblyFactory.createAbstractService();
                            abstractContract = abstractService;
                            abstractService.setName(getString(reader, Constants.NAME));
                            constrainingType.getServices().add(abstractService);
                            policyProcessor.readPolicies(abstractService, reader);
   
                        } else if (Constants.REFERENCE_QNAME.equals(name)) {
                           
                            // Read a <reference>
                            abstractReference = assemblyFactory.createAbstractReference();
                            abstractContract = abstractReference;
                            abstractReference.setName(getString(reader, Constants.NAME));
                            readMultiplicity(abstractReference, reader);
                            constrainingType.getReferences().add(abstractReference);
                            policyProcessor.readPolicies(abstractReference, reader);
   
                        } else if (Constants.PROPERTY_QNAME.equals(name)) {
                           
                            // Read a <property>
                            abstractProperty = assemblyFactory.createAbstractProperty();
                            readAbstractProperty(abstractProperty, reader);
                           
                            // Read the property value
                            Document value = readPropertyValue(abstractProperty.getXSDElement(), abstractProperty.getXSDType(), reader);
                            abstractProperty.setValue(value);
                           
                            constrainingType.getProperties().add(abstractProperty);
                            policyProcessor.readPolicies(abstractProperty, reader);
                           
                        } else if (OPERATION_QNAME.equals(name)) {
   
                            // Read an <operation>
                            Operation operation = new OperationImpl();
                            operation.setName(getString(reader, NAME));
                            operation.setUnresolved(true);
                            policyProcessor.readPolicies(abstractContract, operation, reader);
                           
                        } else {
   
                            // Read an extension element
                            Object extension = extensionProcessor.read(reader);
                            if (extension instanceof InterfaceContract) {
                               
                                // <service><interface> and <reference><interface>
                                abstractContract.setInterfaceContract((InterfaceContract)extension);
                            } else {
   
                                // Add the extension element to the current element
                                if (abstractContract != null) {
                                    abstractContract.getExtensions().add(extension);
                                } else {
                                    constrainingType.getExtensions().add(extension);
                                }
                               
                            }
                        }
                        break;
View Full Code Here

    }

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

        // Resolve constraining type
        ConstrainingType constrainingType = composite.getConstrainingType();
        if (constrainingType != null) {
            constrainingType = resolver.resolveModel(ConstrainingType.class, constrainingType);
            composite.setConstrainingType(constrainingType);
        }
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.