拥有自己的URI的http4 Camel组件

时间:2014-11-17 11:46:59

标签: java apache-camel

我想创建自己的Camel组件。基于组件http4。我只想默认插入服务器和端口。所以我可以写:

from("myhttp://test1.php")
 .to("myhttp://test2.php")

我的组件将URI更改为“http:// myhost:8080 / test1.php”和“http:// myhost:8080 / test2.php”,但我无法创建自己的方案名称。我在类

中测试@UriEndpoint(scheme =“myhttp”)
public class myhttpEndpoint extends org.apache.camel.component.http4.HttpEndpoint {
}

你能帮助我吗?

我的所作所为:

public class myhttpComponent extends org.apache.camel.component.http4.HttpComponent {

    @Override
    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    ...
    ...
    HttpEndpoint endpoint = new myhttpEndpoint(endpointUriString, this, clientBuilder, localConnectionManager, configurer);
    ...
    ...
    }
}

@UriEndpoint(scheme = "myhttp")
public class myhttpEndpoint extends org.apache.camel.component.http4.HttpEndpoint {

    public myhttpEndpoint(String endpointUriString,
            cacheComponent cacheComponent, HttpClientBuilder clientBuilder,
            HttpClientConnectionManager localConnectionManager,
            HttpClientConfigurer configurer) throws URISyntaxException {
        super(endpointUriString, cacheComponent, clientBuilder, localConnectionManager, configurer);
    }

1 个答案:

答案 0 :(得分:0)

在创建自定义Camel组件时,@ UriEndpoint注释实际上是可选的,我认为只有在您希望自动生成配置文档时才使用它。更多信息:http://camel.apache.org/endpoint-annotations.html

要将组件类绑定到组件名称&#34; myhttp&#34;,您需要在项目的META-INF文件夹下添加一个文件。更多详情:http://camel.apache.org/writing-components.html