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 3FE581786D for ; Wed, 8 Apr 2015 04:58:54 +0000 (UTC) Received: (qmail 99716 invoked by uid 500); 8 Apr 2015 04:58:53 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 99670 invoked by uid 500); 8 Apr 2015 04:58:53 -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 99658 invoked by uid 99); 8 Apr 2015 04:58:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Apr 2015 04:58:53 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of claus.ibsen@gmail.com designates 209.85.213.174 as permitted sender) Received: from [209.85.213.174] (HELO mail-ig0-f174.google.com) (209.85.213.174) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Apr 2015 04:58:49 +0000 Received: by igblo3 with SMTP id lo3so29708515igb.0 for ; Tue, 07 Apr 2015 21:58:29 -0700 (PDT) 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=/NHYu2VFZ2+BdU3MTFptTOZltkpSmbCmCEJV0Wvt2qY=; b=uG803hRXwR/nQfue0OqYfLLLBQ0s9He7R9jE6TaQ5u5ni5JWVkq9MjBFh/ImbZuSqH MC9V6HGvkdx8qXCRhI5VFD1C3FqUdx1BtF3VtLdMZgH7ICbnqgb7hqr0+UBIROsFbisO 5bnlsh6VCvPzJC97NPS9ObiO1LzDK3QAohQNk64WlBUuuXIoc53xKGqbqYpo/6dogJTh bSEc5Qu0YLddF1xPIs1i7xI3hlWS+4HNMyLaJZbwhquIG3cLMqsjIJuWJYfL8Zxvioe6 QDurdThlB8i5sWhbVi+eTgar72KCvXCWIIrsom+K5fwh9OChflEZrXHgLPxDm2q+/Fp+ Gl6g== X-Received: by 10.107.151.73 with SMTP id z70mr36941222iod.41.1428469109450; Tue, 07 Apr 2015 21:58:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.149.2 with HTTP; Tue, 7 Apr 2015 21:58:09 -0700 (PDT) In-Reply-To: References: From: Claus Ibsen Date: Wed, 8 Apr 2015 06:58:09 +0200 Message-ID: Subject: Re: @UriPath and @UriSyntax To: "users@camel.apache.org" Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org For any values in the path you need to set them from the component class in the createEndpoint method. The values are from the remaining parameter. Though in the future we may be able to let Camel do this mapping a bit more automatic since we now have the syntax option. But that was just recently introduced in 2.15.0. But historically this mapping is done manually in the component. On Wed, Apr 8, 2015 at 2:49 AM, Christopher Piggott wrote: > OK that hellped. What I ended up doing was: > > * Component extends UriEndpointComponent > * Endpoint extends DefaultEndpoint and is marked @ManagedResource and > @UriEndpoint. It also has a @UriParam for 'baud' and another one for > 'path' -- that last one is a problem (will explain in a second) > * Consumer extends DefaultConsumer and uses a processor to launch events > > The endpoint is marked like this: > > @UriEndpoint(scheme = "jssc", > syntax = "jssc:path", > consumerClass = JsscConsumer.class, > title = "JSSC Component") > > > I would like to be able to do this: > > > from("jssc:com10?baud=19200") > > > but THIS still does not work: > > > @UriPath > @Metadata(required="true") > private String path > > > so I end up having to do this: > > from("jssc:com10?path=com10&baud=19200") > > > What is wrong with specifying it as a path parameter whose name > matches the 'syntax' in the @UriEndpoint annotation - shouldn't that > work? > > > *https://github.com/wz2b/camel-jssc/blob/master/src/main/java/com/autofrog/camel/JsscEndpoint.java > * > > > --Chris > > > > > > > > > On Tue, Apr 7, 2015 at 10:59 AM, Claus Ibsen wrote: > >> A component must have a default no-arg constructor. >> >> So add that, and call super(JsscEndpoint.class) and remove the other >> constructors as they are not really needed. >> >> On Tue, Apr 7, 2015 at 4:55 PM, Christopher Piggott >> wrote: >> > I will try that, thanks. >> > >> > For a test, I just tried getting back to basics, and getting rid of all >> the >> > Uri configuration entirely - just to see what happens. I still have >> > META-INF/services/org/apache/camel/component/jssc (a text file) which >> > allows me to do: >> > >> > from("jssc:com10?baud=19200") ... >> > >> > and it locates the component just fine. The next thing I did was change >> > the Component to extend UriEndpointComponent rather than >> DefaultComponent. >> > That broke it as follows: >> > >> > 2015-04-07 10:15:41,550 [main] ERROR app.tasks.CamelTask - Failed to >> start >> > camel >> > org.apache.camel.FailedToCreateRouteException: Failed to create route >> > route1: Route(route1)[[From[jssc:com10?baud=19200]] -> [To[xmpp://cl... >> > because of Failed to resolve endpoint: jssc://com10?baud=19200 due to: >> > Cannot auto create component: jssc >> > >> > So something, by doing that, just broke its ability to locate the >> endpoint >> > by name using the entry in META-INF. The stack trace it gives me is not >> > exceptionally helpful; what it's really telling me is that it can't >> locate >> > my component. What's especially confusing is that a UriEndpointComponent >> > extends DefaultComponent so it seems like, as far as camel is concerned, >> > they should be the same thing. >> > >> > >> > I checked in what I have so far ... >> > >> > >> https://github.com/wz2b/camel-jssc/tree/master/src/main/java/com/autofrog/camel >> > >> > >> > >> > >> > On Tue, Apr 7, 2015 at 9:36 AM, Claus Ibsen >> wrote: >> > >> >> Hi >> >> >> >> Oh if you have this as a component outside Camel, then you need to add >> >> the apt plugin >> >> >> https://github.com/apache/activemq/blob/master/activemq-camel/pom.xml#L63 >> >> >> >> And this plugin if you want to include a .properties file in the JAR >> >> with a list of components it contains >> >> >> https://github.com/apache/activemq/blob/master/activemq-camel/pom.xml#L217 >> >> >> >> Then you do the same as all the components in Apache Camel. >> >> >> >> On Tue, Apr 7, 2015 at 3:34 PM, Claus Ibsen >> wrote: >> >> > Hi >> >> > >> >> > All the 150+ components is an example of this. Just pick a similar / >> >> > simple component and see its source code. >> >> > >> >> > On Tue, Apr 7, 2015 at 3:12 PM, Christopher Piggott < >> cpiggott@gmail.com> >> >> wrote: >> >> >> Hi, >> >> >> >> >> >> According to >> >> >> >> https://cwiki.apache.org/confluence/display/CAMEL/Camel+2.15.0+Release >> >> >> >> >> >> >> >> >> - Custom components using @UriEndpoint must now include a syntax >> >> >> attribute to document the uri syntax of the endpoint, when using >> the >> >> apt >> >> >> compiler plugin to generate documentation. >> >> >> >> >> >> >> >> >> I'm looking for documentation on this and not really finding how to >> use >> >> it >> >> >> or simple examples: >> >> >> >> >> >> >> >> >> - http://camel.apache.org/endpoint-annotations.html says what it >> >> is, >> >> >> but not how to use it >> >> >> - >> >> >> >> >> >> https://github.com/sigrist/camel-rxtx/blob/master/src/main/java/org/apache/camel/rxtx/RxTxEndpoint.java >> >> >> is an example soembody wrote that uses @UriParam ... that works >> >> fine, but >> >> >> when I try to add a @UriPath parameter it silently ends up null >> >> >> - Tons of examples in git but most of them don't have a 'syntax=' >> so >> >> I >> >> >> must be looking at old source >> >> >> >> >> >> >> >> >> Trying to piece all this together from scarce examples and >> >> documentation: >> >> >> >> >> >> >> >> >> - It doesn't seem like I really need to extend >> >> UriComponentConfiguration >> >> >> at all, do I? If I declare my component a @ManagedResource it >> seems >> >> to >> >> >> bind all the @UriParam just fine. It doesn't bind the @UriPath >> >> parameters, >> >> >> though, and fails to do so silently, despite the fact that they >> are >> >> marked >> >> >> @Meadata(required = "true"). >> >> >> - Are there any simple examples out there using >> >> >> @UriComponentConfiguration ? >> >> >> >> >> >> >> >> >> --Chris >> >> > >> >> > >> >> > >> >> > -- >> >> > Claus Ibsen >> >> > ----------------- >> >> > Red Hat, Inc. >> >> > Email: cibsen@redhat.com >> >> > Twitter: davsclaus >> >> > Blog: http://davsclaus.com >> >> > Author of Camel in Action: http://www.manning.com/ibsen >> >> > hawtio: http://hawt.io/ >> >> > fabric8: http://fabric8.io/ >> >> >> >> >> >> >> >> -- >> >> Claus Ibsen >> >> ----------------- >> >> Red Hat, Inc. >> >> Email: cibsen@redhat.com >> >> Twitter: davsclaus >> >> Blog: http://davsclaus.com >> >> Author of Camel in Action: http://www.manning.com/ibsen >> >> hawtio: http://hawt.io/ >> >> fabric8: http://fabric8.io/ >> >> >> >> >> >> -- >> Claus Ibsen >> ----------------- >> Red Hat, Inc. >> Email: cibsen@redhat.com >> Twitter: davsclaus >> Blog: http://davsclaus.com >> Author of Camel in Action: http://www.manning.com/ibsen >> hawtio: http://hawt.io/ >> fabric8: http://fabric8.io/ >> -- Claus Ibsen ----------------- Red Hat, Inc. Email: cibsen@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/