Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2F50918C37 for ; Sun, 21 Feb 2016 07:02:27 +0000 (UTC) Received: (qmail 85217 invoked by uid 500); 21 Feb 2016 07:02:26 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 85163 invoked by uid 500); 21 Feb 2016 07:02:26 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 85151 invoked by uid 99); 21 Feb 2016 07:02:26 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Feb 2016 07:02:26 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id EDFFB1800EC for ; Sun, 21 Feb 2016 07:02:25 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.492 X-Spam-Level: * X-Spam-Status: No, score=1.492 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id hTqTO4eSXYno for ; Sun, 21 Feb 2016 07:02:23 +0000 (UTC) Received: from mail-ig0-f182.google.com (mail-ig0-f182.google.com [209.85.213.182]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 964575FABF for ; Sun, 21 Feb 2016 07:02:23 +0000 (UTC) Received: by mail-ig0-f182.google.com with SMTP id g6so66568324igt.1 for ; Sat, 20 Feb 2016 23:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=EiihvtsCpxC6lGv4OYaa8vEN6k8mS/2f/8HxCPuby4g=; b=G3XaxFpUz1a+hCBm21xk7jCCDMEflk+u/dYIazmd2lvLsD/T3Kk5hptWnoT8Q331Es inshb1Y/Jw3d2W07obkvZl/Wy2+h1q9UgzUa3uFZaPp9t8s7vfpya+2KS2yU48sLXs34 5dSkpaL+d0cihdOs8++C+OsRBrJIj0tCxnaOOIYflPOXASvAeLWfxyz1b618/xdBP8UH zaGs3uOj2oqTDLthUYJWDP07wu088TT+lSyCJ+IEgcFzgr7DLE2Or76R52GpL5830McG iFe4/R8mAwLPVE0fDBx2ctuebxryJ+voEyaYtwssu906nzxkjheVUlMVvV4eRjUYH1YE wYIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=EiihvtsCpxC6lGv4OYaa8vEN6k8mS/2f/8HxCPuby4g=; b=SomVJdYn19anz/DSWdea9I+Yz7tkwMhYD62d10LeqIeLiJ29fHN5GMWCn1aKB5kx1y ehfBQ9uMp1FwkitgG/zOsF2tLUY1vFmZjc+3vnFhXnYSVYNRC9nliPtG07rl71i9JiKx pTYOscwWizkZR1AiqvAYJdxGt8rGPwjZCyyR1eWxglhLv/SSzrpz+JQhSAkCmyJywqYb x/OsuMRqjJk761yhPRLa/1BylcCbqbFAeAemruQNu+v9NkFRJyjut1+Ya/l+e7XK1z/N dY0IlSLEOyInGuBb7/A8KpFr4jpAJ107SW/evnsIAfLIKE8i7OKDTh9tDz3tSsUZenRq UWkQ== X-Gm-Message-State: AG10YORHvJgimbqr7qqml07VyRxxk/EWZe1ukO6OMITZ2P3AXIPMMffdKSadgyVUp8AwP0I+bVcNFOAuWD83dw== X-Received: by 10.50.77.43 with SMTP id p11mr1328698igw.46.1456037836881; Sat, 20 Feb 2016 22:57:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.0.211 with HTTP; Sat, 20 Feb 2016 22:56:57 -0800 (PST) In-Reply-To: <1456020706494-5777992.post@n5.nabble.com> References: <1456020706494-5777992.post@n5.nabble.com> From: Claus Ibsen Date: Sun, 21 Feb 2016 07:56:57 +0100 Message-ID: Subject: Re: camel rest route To: "users@camel.apache.org" Content-Type: text/plain; charset=UTF-8 See the rest examples that can help you on the way, such as https://github.com/apache/camel/tree/master/examples/camel-example-cdi-rest-servlet Since you use JEE then you can use CDI to kick-start as that example does. Or you can kick-start using war http://camel.apache.org/tutorial-on-using-camel-in-a-web-application.html Or use the camel servletlistener http://camel.apache.org/servlet-tomcat-no-spring-example.html Q2 you configure this on the rest configuration, or if you use servlet component then on the servlet itself. Q3 see the json binding at http://camel.apache.org/rest-dsl and add camel-jackson to the classpath. On Sun, Feb 21, 2016 at 3:11 AM, zappee wrote: > Hi, > > Currently I am learning how to use Apache Camel Rest and I would like to ask > some questions about it. I would greatly appreciate any answer. > > I have a rest camel route which is packed in a jar. This jar locates in an > ear file and deployed on GlassFish app. server. > *Q1:* I am not able to figure out how I can start/bootstrap this route. > > I want to use localhost:port/api/user/generate url for my route. It > generates a simple json answer based on my java pojo with getters/setters. > *Q2:* How to configure the base url of my route OR figure out the correct > path of my deployed route? > *Q3:* How I can send back a json response based on a java object (object is > automatically convert to json by camel on the fly)? Is my code correct (i am > not able to test my code till it is not bootstrapped)? > > My ear is deployed on server, stateless ejb service and web application are > working but my camel rest api is not available. > > *Structure of my ear:* > *.EAR > |-lib/ > | |- dependencies, ex.: camel jars > | |- my-common.jar > | |- my-camel-restapi.jar <- it contains my camel rest route > | > |- my-web-ui.war > |- my-stateless-ejb.jar > > > *Camel route java:* > public class UserServiceRouteBuilder extends RouteBuilder { > private static final String APPLICATION_JSON_UTF_8 = > "application/json;charset=UTF-8"; > > @Override > public void configure() throws Exception { > restConfiguration().component("jetty") > .bindingMode(RestBindingMode.json) > .dataFormatProperty("prettyPrint", "true"); > > User user = new User(); > user.setEmail("abc@gmail.com"); > user.setFirstName("John"); > user.setLastName("Connor"); > > rest("/user") > .description("user rest service") > .produces(APPLICATION_JSON_UTF_8) > > .get("/generate").route().routeId("GET@/generate").transform().constant(user).endRest(); > } > } > > > > > > -- > View this message in context: http://camel.465427.n5.nabble.com/camel-rest-route-tp5777992.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2