【问题标题】:Camel UriPath annotation inaccesibilityCamel Uri Path 注释无法访问
【发布时间】:2016-12-19 07:14:24
【问题描述】:

我正在为特定技术编写自定义组件,但带有 @UriPath 注释的变量未初始化。 @UriParam 不过还可以。

我检查了 Kafka 和 Servlet 组件的端点源代码,但无法弄清楚它们与我的真正区别。

骆驼版本是:2.18.1

Endpont 是这样的:

@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;
    }

}

组件是由spring创建的:

<bean id="elastic" class="elasticsearch.ElasticSearchComponent" />

有什么想法吗?

【问题讨论】:

    标签: apache-camel endpoint


    【解决方案1】:

    您需要从组件类中设置它,并从组件中显式调用 setUri。

    只有 UriParam 是自动设置的。

    看看所有现有的 Camel 组件是如何做到的。

    顺便说一句,您的端点应该是 singleton = true。

    【讨论】:

    • 嗨克劳斯,我在这里有一个疑问,当我明确设置uri时,UriPath注释在这里的作用是什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-16
    • 2016-09-29
    • 1970-01-01
    • 2015-04-25
    相关资源
    最近更新 更多