Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A8A46200AC9 for ; Sun, 22 May 2016 08:40:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id A27F0160A07; Sun, 22 May 2016 06:40:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EC307160A06 for ; Sun, 22 May 2016 08:40:43 +0200 (CEST) Received: (qmail 9864 invoked by uid 500); 22 May 2016 06:40:42 -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 9852 invoked by uid 99); 22 May 2016 06:40:42 -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, 22 May 2016 06:40:42 +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 3E7281804AF for ; Sun, 22 May 2016 06:40:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.802 X-Spam-Level: X-Spam-Status: No, score=-0.802 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] 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 EiKiWybQgKbu for ; Sun, 22 May 2016 06:40:39 +0000 (UTC) Received: from mail-io0-f170.google.com (mail-io0-f170.google.com [209.85.223.170]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 9930B5F393 for ; Sun, 22 May 2016 06:40:39 +0000 (UTC) Received: by mail-io0-f170.google.com with SMTP id 190so175149041iow.1 for ; Sat, 21 May 2016 23:40:39 -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; bh=JtIM7xRswKlY0J2hXPJZBbkLaKITFIDGjMW/6aInXs0=; b=f2ZzKhqw7SeiZZqAaLJuxdIevE5336G/2RAJOB90vAExWzbUfSD6MPMxfvQdlGr6US 8JTYCYHr+SIezpd2ytRIR6xVrtxKCgwbm95mPjJX+GXw/99HCRuyCBHeggcdW4fFPHpY YgWAbVeHSfW7GtWYQaH0Srv/Gc5k9lF0RNscrqmfalrMaOiztq3IV6/viCJSHSWfLrSu W3dZ+XE/kHUcWEHmrhvlxXkABlOOfMhnHZDgFvD5GzuzGLH5P1FWgqLtUV15Krzoyc6f Q1aDqcii6I07HE7P2NIR80fjaxWtdJq3NmxrHZ2iHAx2J4K8Z1yPd9b6YuScaqtjtcpd 2bGw== 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; bh=JtIM7xRswKlY0J2hXPJZBbkLaKITFIDGjMW/6aInXs0=; b=HUPNt0XMmvrRFazaEeLeZNkuiBuBGT66jBgcflJNWQHVMSZHyLtxuH1HRpKuZRNxgE e6IhtM4rK14eR8b3M0mUAjg++jchiG9AzPmENJjo9CXSehFTBAUqrRW2ZwPz2tVIBaCZ eU/gxLvZbY75tyFc1cCz/PIeRaZ9FaWtqEIvnYY77PheA3HWsPq1fwCSgeCL3qpLRmt0 HOcdPnRazBuZ1zlhmbbTBFGCICntqlLyc+KY5TlX6Ul9yTUhtv8ABI30z0iuiw7s3xza +FHIvcamScfkmmrWYvYsypGew47dF21Uxkf2HZxq8vWBzUP/ga6CfRyUV4TNm6JXnVVQ zqFg== X-Gm-Message-State: AOPr4FVqGlGuJDdrNRTm4Qg+CVaCyvgXVAMknSozS/wE6QwrNZS1BHysruRX4eBq77uCptR/vXtf4eVNfpzMdg== X-Received: by 10.107.159.84 with SMTP id i81mr7795832ioe.29.1463899232756; Sat, 21 May 2016 23:40:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.8.194 with HTTP; Sat, 21 May 2016 23:40:13 -0700 (PDT) In-Reply-To: References: From: Claus Ibsen Date: Sun, 22 May 2016 08:40:13 +0200 Message-ID: Subject: Re: Custom component and retrieving UriParam values To: "users@camel.apache.org" Content-Type: text/plain; charset=UTF-8 archived-at: Sun, 22 May 2016 06:40:44 -0000 The option query is not a parameter value but a path value, so you should use @UriPath. On Sat, May 21, 2016 at 7:27 PM, Anton wrote: > Hello > > I am trying to build custom camel component, and have annotated several > properties with @UriParam. > > However, these do not seem to get bound to the endpoint class. > > What is the recommended way of accessing parameter values? > > I am testing my component with the following. > > public void configure() { > from("jsoup://foo") //TODO: pass i html dock > .routeId(this.getClass().getSimpleName()) > > .log("body is ${body}") > .to("jsoup://bar&query=myQuery&baseurl=www.test.com") > //.to("jsoup://bar?option=2")/ > .to("mock:result"); > } > > This is my Endpoint class: > > > > import org.apache.camel.Consumer; > import org.apache.camel.Processor; > import org.apache.camel.Producer; > import org.apache.camel.impl.DefaultEndpoint; > import org.apache.camel.spi.Metadata; > import org.apache.camel.spi.UriEndpoint; > import org.apache.camel.spi.UriParam; > import org.apache.camel.spi.UriPath; > > /** > * Represents a jsoup endpoint. > */ > @UriEndpoint(scheme = "jsoup", title = "jsoup", syntax="jsoup:query", > consumerClass = jsoupConsumer.class, label = "jsoup") > public class jsoupEndpoint extends DefaultEndpoint { > @UriParam > @Metadata(required = "true") > private String query; > @UriParam > private String baseurl; > > > @UriParam(defaultValue = "10") > private int option = 10; > > public jsoupEndpoint() { > } > > public jsoupEndpoint(String uri, jsoupComponent component) { > super(uri, component); > } > > public jsoupEndpoint(String endpointUri) { > super(endpointUri); > } > > public Producer createProducer() throws Exception { > return new jsoupProducer(this); > } > > public Consumer createConsumer(Processor processor) throws Exception { > return new jsoupConsumer(this, processor); > } > > public boolean isSingleton() { > return true; > } > > > public String getBaseurl() { > return baseurl; > } > > /** > * Sets the base url as used by JSoup > * @param baseUrl for fetching content > */ > public void setBaseUrl(String baseUrl) { > this.baseurl = baseUrl; > } > > /** > * Some description of this option, and what it does > * @param query for use with jsoup > */ > public void setQuery(String query) { > this.query = query; > } > > public String getQuery() { > return query; > } > > /** > * Some description of this option, and what it does > * @param option for use with jsoup > */ > public void setOption(int option) { > this.option = option; > } > > public int getOption() { > return option; > } > } -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2