Package org.apache.tuscany.sca.binding.http

Examples of org.apache.tuscany.sca.binding.http.HTTPBinding


    public Class<HTTPBinding> getModelType() {
        return HTTPBinding.class;
    }

    public HTTPBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
        HTTPBinding httpBinding = httpBindingFactory.createHTTPBinding();

        while(reader.hasNext()) {
            QName elementName = null;
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    elementName = reader.getName();

                    if (HTTPBinding.TYPE.equals(elementName)) {
                        String name = getString(reader, NAME);
                        if(name != null) {
                            httpBinding.setName(name);
                        }

                        String uri = getURIString(reader, URI);
                        if (uri != null) {
                            httpBinding.setURI(uri);
                        }
                    } else {
                        // Read an extension element
                        Object extension = extensionProcessor.read(reader, context);
                        if (extension != null) {
                            if (extension instanceof WireFormat) {
                                httpBinding.setRequestWireFormat((WireFormat)extension);
                            } else if(extension instanceof OperationSelector) {
                                httpBinding.setOperationSelector((OperationSelector)extension);
                            }
                        }
                    }
            }
View Full Code Here


    @Test
    public void testWireFormat() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_WITH_OPERATION_SELECTOR));
       
        Composite composite = (Composite)staxProcessor.read(reader);
        HTTPBinding binding = (HTTPBinding)   composite.getComponents().get(0).getServices().get(0).getBindings().get(0);       
        assertNotNull(binding);
       
        OperationSelector operationSelector = binding.getOperationSelector();
        assertEquals(JSONRPCOperationSelector.class, operationSelector.getClass().getInterfaces()[0]);
    }
View Full Code Here

    @Test
    public void testWireFormat() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_WITH_WIRE_FORMAT));
       
        Composite composite = (Composite)staxProcessor.read(reader);
        HTTPBinding binding = (HTTPBinding)   composite.getComponents().get(0).getServices().get(0).getBindings().get(0);       
        assertNotNull(binding);
       
        WireFormat requestWireFormat = binding.getRequestWireFormat();
        assertEquals(JSONRPCWireFormat.class, requestWireFormat.getClass().getInterfaces()[0]);
       
        WireFormat responseWireFormat = binding.getResponseWireFormat();
        assertEquals(JSONRPCWireFormat.class, responseWireFormat.getClass().getInterfaces()[0]);
    }
View Full Code Here

    @Test
    public void testWireFormat() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_WITH_WIRE_FORMAT));
       
        Composite composite = (Composite)staxProcessor.read(reader);
        HTTPBinding binding = (HTTPBinding)   composite.getComponents().get(0).getServices().get(0).getBindings().get(0);       
        assertNotNull(binding);
       
        WireFormat requestWireFormat = binding.getRequestWireFormat();
        assertEquals(JSONRPCWireFormat.class, requestWireFormat.getClass().getInterfaces()[0]);
       
        WireFormat responseWireFormat = binding.getResponseWireFormat();
        assertEquals(JSONRPCWireFormat.class, responseWireFormat.getClass().getInterfaces()[0]);
    }   
View Full Code Here

    @Test
    public void testWireFormat() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_WITH_OPERATION_SELECTOR));
       
        Composite composite = (Composite)staxProcessor.read(reader);
        HTTPBinding binding = (HTTPBinding)   composite.getComponents().get(0).getServices().get(0).getBindings().get(0);       
        assertNotNull(binding);
       
        OperationSelector operationSelector = binding.getOperationSelector();
        assertEquals(JSONRPCOperationSelector.class, operationSelector.getClass().getInterfaces()[0]);
    }
View Full Code Here

    public Class<HTTPBinding> getModelType() {
        return HTTPBinding.class;
    }

    public HTTPBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        HTTPBinding httpBinding = httpBindingFactory.createHTTPBinding();
       
        while(reader.hasNext()) {
            QName elementName = null;
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    elementName = reader.getName();
                    
                     if (BINDING_HTTP_QNAME.equals(elementName)) {
                         String name = getString(reader, NAME);
                         if(name != null) {
                             httpBinding.setName(name);
                         }
                        
                         String uri = getString(reader, URI);
                         if (uri != null) {
                             httpBinding.setURI(uri);
                         }
                     } else {
                         // Read an extension element
                         Object extension = extensionProcessor.read(reader);
                         if (extension != null) {
                             if (extension instanceof WireFormat) {
                                 httpBinding.setRequestWireFormat((WireFormat)extension);
                             } else if(extension instanceof OperationSelector) {
                                 httpBinding.setOperationSelector((OperationSelector)extension);
                             }
                         }
                     }
            }
View Full Code Here

    public Class<HTTPBinding> getModelType() {
        return HTTPBinding.class;
    }

    public HTTPBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException,XMLStreamException {
        HTTPBinding httpBinding = httpBindingFactory.createHTTPBinding();

        /**
         *    <tuscany:binding.http uri="http://localhost:8085/Customer">
         *          <tuscany:wireFormat.json />
         *          <tuscany:operationSelector.default />
         *          <tuscany:response>
         *             <tuscany:wireFormat.xml />
         *          </tuscany:response>
         *   </tuscany:binding.http>
         *
         */
       
        while (reader.hasNext()) {
            QName elementName = null;
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    elementName = reader.getName();

                    if (HTTPBinding.TYPE.equals(elementName)) {
                        String name = getString(reader, NAME);
                        if (name != null) {
                            httpBinding.setName(name);
                        }

                        String uri = getURIString(reader, URI);
                        if (uri != null) {
                            httpBinding.setURI(uri);
                        }
                    } else if (RESPONSE_QNAME.equals(elementName)) {

                        // skip response
                        reader.next();
                        // and position to the next start_element event
                        while (reader.hasNext()) {
                            int sub_event = reader.getEventType();
                            switch (sub_event) {
                                case START_ELEMENT:
                                    elementName = reader.getName();
                                    break;
                                default:
                                    reader.next();
                            }
                            break;
                        }

                        // dispatch to read wire format for the response
                        Object extension = extensionProcessor.read(reader, context);
                        if (extension != null) {
                            if (extension instanceof WireFormat) {
                                httpBinding.setResponseWireFormat((WireFormat)extension);
                            }
                        }
                        break;
                    } else {
                        // Read an extension element
                        Object extension = extensionProcessor.read(reader, context);
                        if (extension != null) {
                            if (extension instanceof WireFormat) {
                                httpBinding.setRequestWireFormat((WireFormat)extension);
                            } else if (extension instanceof OperationSelector) {
                                httpBinding.setOperationSelector((OperationSelector)extension);
                            }
                        }
                    }
            }

View Full Code Here

    @Test
    public void testLoadValidComposite() throws Exception {
        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE));
       
        Composite composite = (Composite)staxProcessor.read(reader, context);
        HTTPBinding binding = (HTTPBinding)   composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
       
        Assert.assertNotNull(binding);
        Assert.assertNotNull(binding.getOperationSelector());
        Assert.assertNotNull(binding.getRequestWireFormat());
        Assert.assertNotNull(binding.getResponseWireFormat());

    }
View Full Code Here

        }
        JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
        interfaceContract.setInterface(javaInterface);
        widgetService.setInterfaceContract(interfaceContract);

        HTTPBinding binding = httpBindingFactory.createHTTPBinding();
        binding.setURI(implementation.getWidgetUri());
        widgetService.getBindings().add(binding);

        implementation.getServices().add(widgetService);
       
    }
View Full Code Here

    public Class<HTTPBinding> getModelType() {
        return HTTPBinding.class;
    }

    public HTTPBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
        HTTPBinding httpBinding = httpBindingFactory.createHTTPBinding();
       
        // Read policies
        policyProcessor.readPolicies(httpBinding, reader);
       
        while(reader.hasNext()) {
            QName elementName = null;
            int event = reader.getEventType();
            switch (event) {
                case START_ELEMENT:
                    elementName = reader.getName();
                    
                     if (BINDING_HTTP_QNAME.equals(elementName)) {
                         String name = getString(reader, NAME);
                         if(name != null) {
                             httpBinding.setName(name);
                         }
                        
                         String uri = getString(reader, URI);
                         if (uri != null) {
                             httpBinding.setURI(uri);
                         }
                     } else {
                         // Read an extension element
                         Object extension = extensionProcessor.read(reader);
                         if (extension != null) {
                             if (extension instanceof WireFormat) {
                                 httpBinding.setRequestWireFormat((WireFormat)extension);
                             } else if(extension instanceof OperationSelector) {
                                 httpBinding.setOperationSelector((OperationSelector)extension);
                             }
                         }
                     }
            }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.binding.http.HTTPBinding

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.