Package org.apache.camel.component.http

Examples of org.apache.camel.component.http.HttpExchange


            final Continuation continuation = ContinuationSupport.getContinuation(request, null);
            if (continuation.isNew()) {

                // Have the camel process the HTTP exchange.
                final HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
                boolean sync = consumer.getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean sync) {
                        if (sync) {
                            return;
                        }
                        continuation.setObject(exchange);
                        continuation.resume();
                    }
                });

                if (!sync) {
                    // Wait for the exchange to get processed.
                    // This might block until it completes or it might return via an exception and
                    // then this method is re-invoked once the the exchange has finished processing
                    continuation.suspend(0);
                }

                // HC: The getBinding() is interesting because it illustrates the
                // impedance miss-match between HTTP's stream oriented protocol, and
                // Camels more message oriented protocol exchanges.

                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }

            if (continuation.isResumed()) {
                HttpExchange exchange = (HttpExchange)continuation.getObject();
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }
View Full Code Here


            final Continuation continuation = ContinuationSupport.getContinuation(request, null);
            if (continuation.isNew()) {

                // Have the camel process the HTTP exchange.
                final HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
               
                boolean sync = consumer.getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean sync) {
                        if (sync) {
                            return;
                        }
                        continuation.setObject(exchange);
                        continuation.resume();
                    }
                });

                if (!sync) {
                    // Wait for the exchange to get processed.
                    // This might block until it completes or it might return via an exception and
                    // then this method is re-invoked once the the exchange has finished processing
                    continuation.suspend(0);
                }

                // HC: The getBinding() is interesting because it illustrates the
                // impedance miss-match between HTTP's stream oriented protocol, and
                // Camels more message oriented protocol exchanges.
               
                // set the header value from endpoint
                if (exchange.getOut().getHeader(Exchange.HTTP_CHUNKED) == null) {
                    exchange.getOut().setHeader(Exchange.HTTP_CHUNKED, consumer.getEndpoint().isChunked());
                }
               
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }

            if (continuation.isResumed()) {
                HttpExchange exchange = (HttpExchange)continuation.getObject();
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }
View Full Code Here

            final Continuation continuation = ContinuationSupport.getContinuation(request, null);
            if (continuation.isNew()) {

                // Have the camel process the HTTP exchange.
                final HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
                boolean sync = consumer.getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean sync) {
                        if (sync) {
                            return;
                        }
                        continuation.setObject(exchange);
                        continuation.resume();
                    }
                });

                if (!sync) {
                    // Wait for the exchange to get processed.
                    // This might block until it completes or it might return via an exception and
                    // then this method is re-invoked once the the exchange has finished processing
                    continuation.suspend(0);
                }

                // HC: The getBinding() is interesting because it illustrates the
                // impedance miss-match between HTTP's stream oriented protocol, and
                // Camels more message oriented protocol exchanges.

                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }

            if (continuation.isResumed()) {
                HttpExchange exchange = (HttpExchange)continuation.getObject();
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }
View Full Code Here

        };
    }

    private class MyParamsProcessor implements Processor {
        public void process(Exchange exchange) throws Exception {
            HttpExchange http = (HttpExchange) exchange;
            Assert.assertNotNull(http.getRequest());
            Assert.assertEquals("uno", http.getRequest().getParameter("one"));
            Assert.assertEquals("dos", http.getRequest().getParameter("two"));

            exchange.getOut(true).setBody("Bye World");
            exchange.getOut(true).setHeader("one", "einz");
            exchange.getOut(true).setHeader("two", "twei");
        }
View Full Code Here

        };
    }

    private class MyParamsProcessor implements Processor {
        public void process(Exchange exchange) throws Exception {
            HttpExchange http = (HttpExchange) exchange;
            Assert.assertNotNull(http.getRequest());
            Assert.assertEquals("uno", http.getRequest().getParameter("one"));
            Assert.assertEquals("dos", http.getRequest().getParameter("two"));

            exchange.getOut(true).setBody("Bye World");
            exchange.getOut(true).setHeader("one", "einz");
            exchange.getOut(true).setHeader("two", "twei");
        }
View Full Code Here

                //consumer.getBinding().writeResponse(exchange, response);
                return;
            }

            if (continuation.isResumed()) {
                HttpExchange exchange = (HttpExchange)continuation.getObject();
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }
View Full Code Here

        };
    }

    private class MyParamsProcessor implements Processor {
        public void process(Exchange exchange) throws Exception {
            HttpExchange http = (HttpExchange) exchange;
            Assert.assertNotNull(http.getRequest());
            Assert.assertEquals("uno", http.getRequest().getParameter("one"));
            Assert.assertEquals("dos", http.getRequest().getParameter("two"));

            exchange.getOut().setBody("Bye World");
            exchange.getOut().setHeader("one", "einz");
            exchange.getOut().setHeader("two", "twei");
        }
View Full Code Here

            final Continuation continuation = ContinuationSupport.getContinuation(request, null);
            if (continuation.isNew()) {

                // Have the camel process the HTTP exchange.
                final HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
                boolean sync = consumer.getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean sync) {
                        if (sync) {
                            return;
                        }
                        continuation.setObject(exchange);
                        continuation.resume();
                    }
                });

                if (!sync) {
                    // Wait for the exchange to get processed.
                    // This might block until it completes or it might return via an exception and
                    // then this method is re-invoked once the the exchange has finished processing
                    continuation.suspend(0);
                }

                // HC: The getBinding() is interesting because it illustrates the
                // impedance miss-match between HTTP's stream oriented protocol, and
                // Camels more message oriented protocol exchanges.

                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }

            if (continuation.isResumed()) {
                HttpExchange exchange = (HttpExchange)continuation.getObject();
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }
View Full Code Here

        };
    }

    private class MyParamsProcessor implements Processor {
        public void process(Exchange exchange) throws Exception {
            HttpExchange http = (HttpExchange) exchange;
            Assert.assertNotNull(http.getRequest());
            Assert.assertEquals("uno", http.getRequest().getParameter("one"));
            Assert.assertEquals("dos", http.getRequest().getParameter("two"));

            exchange.getOut(true).setBody("Bye World");
            exchange.getOut(true).setHeader("one", "einz");
            exchange.getOut(true).setHeader("two", "twei");
        }
View Full Code Here

            final Continuation continuation = ContinuationSupport.getContinuation(request, null);
            if (continuation.isNew()) {

                // Have the camel process the HTTP exchange.
                final HttpExchange exchange = new HttpExchange(consumer.getEndpoint(), request, response);
                boolean sync = consumer.getAsyncProcessor().process(exchange, new AsyncCallback() {
                    public void done(boolean sync) {
                        if (sync) {
                            return;
                        }
                        continuation.setObject(exchange);
                        continuation.resume();
                    }
                });

                if (!sync) {

                    // Wait for the exchange to get processed.
                    // This might block until it completes or it might return via an exception and
                    // then this method is re-invoked once the the exchange has finished processing
                    continuation.suspend(0);

                }

                // HC: The getBinding() is interesting because it illustrates the
                // impedance miss-match between
                // HTTP's stream oriented protocol, and Camels more message oriented
                // protocol exchanges.

                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }

            if (continuation.isResumed()) {
                HttpExchange exchange = (HttpExchange)continuation.getObject();
                // now lets output to the response
                consumer.getBinding().writeResponse(exchange, response);
                return;
            }
View Full Code Here

TOP

Related Classes of org.apache.camel.component.http.HttpExchange

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.