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 <[email protected]> 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
