6.4. camel-rest

rest コンポーネントを使用すると、Rest DSL を使用して REST エンドポイントを定義して、REST トランスポートとして他の Camel コンポーネントにプラグインできます。

注記

Camel on EAP サブシステムは、REST DSL で使用する camel-servlet および camel-undertow コンポーネントのみをサポートします。ただし、他のコンポーネントの設定を試みると、サブシステムは機能しません。

CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
    @Override
    public void configure() throws Exception {
        restConfiguration().component("servlet").contextPath("camel/rest").port(8080);
        rest("/hello").get("/{name}").to("direct:hello");
        from("direct:hello").transform(simple("Hello ${header.name}"));
    }
});