I am writing a custom component for a specific tech but the variable with @UriPath annotation is not initializing. @UriParam is ok though.
I have checked both Kafka and Servlet components' endpoint source codes but could not figure out what really makes the difference between them and mine.
Camel version is : 2.18.1
The Endpont is like:
@UriEndpoint(scheme = "elastic", title = "ElasticSearch", syntax = "elastic:url", label = "elastic")
public class ElasticSearchEndpoint extends DefaultEndpoint {
@UriPath
private String url;
@UriParam
private String searchType;
public ElasticSearchEndpoint(String endpointUri, ElasticSearchComponent component) {
super(endpointUri, component);
}
public Producer createProducer() throws Exception {
return new ElasticSearchProducer(this);
}
public Consumer createConsumer(Processor processor) throws Exception {
return null;
}
public boolean isSingleton() {
return false;
}
public String getUrl() {
return url;
}
public String getSearchType() {
return searchType;
}
public void setUrl(String url) {
this.url = url;
}
public void setSearchType(String searchType) {
this.searchType = searchType;
}
}
And component is created by spring :
<bean id="elastic" class="elasticsearch.ElasticSearchComponent" />
Any ideas?
You need to set it from the component class, and call the setUri explicit from the component.
Only the UriParam are set automatic.
See how all the existing Camel component does it.
And btw your endpoint should be singleton = true.