173.3. OSGi デプロイメントの設定


org.apache.camel.component.swagger.DefaultCamelSwaggerServlet は、「サーブレット設定パラメーター」 で説明されているオプションをサポートします。
OSGi デプロイメントの場合、blueprint.xml ファイルでサーブレットオプションと REST 設定を設定する必要があります。以下に例を示します。
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
             http://www.osgi.org/xmlns/blueprint/v1.0.0 
             https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
             http://camel.apache.org/schema/blueprint 
             http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">


    <service interface="javax.servlet.http.HttpServlet">
        <service-properties>
            <entry key="alias" value="/api-docs/*"/>
            <entry key="init-prefix" value="init."/>
            <entry key="init.base.path" value="//localhost:8080/"/>
            <entry key="init.api.path" value="//localhost:8181/api-docs"/>
            <entry key="init.api.title" value="Camel Rest Example API"/>
            <entry key="init.api.version" value="1.2"/>
            <entry key="init.api.description"
                value="Camel Rest Example with Swagger that provides an User REST service"/>
        </service-properties>
        <bean class="org.apache.camel.component.swagger.DefaultCamelSwaggerServlet" />
    </service>

    <!--
      The namespace for the camelContext element in Blueprint 
      is 'http://camel.apache.org/schema/blueprint'.

      While it is not required to assign id's to the <camelContext/> and <route/> elements, 
      it is a good idea to set those for runtime management purposes (logging, JMX MBeans, ...)
    -->
    
    <camelContext id="log-example-context"
        xmlns="http://camel.apache.org/schema/blueprint">

        <restConfiguration component="jetty" port="8080"/>
        <rest path="/say">
            <get uri="/hello">
                <to uri="direct:hello"/>
            </get>
            <get uri="/bye" consumes="application/json">
                <to uri="direct:bye"/>
            </get>
            <post uri="/bye">
                <to uri="mock:update"/>
            </post>
        </rest>
        <route id="rte1-log-example">
            <from uri="direct:hello"/>
            <transform>
                <constant>Hello World</constant>
            </transform>
        </route>
        <route id="rte2-log-example">
            <from uri="direct:bye"/>
            <transform>
                <constant>Bye World</constant>
            </transform>
        </route>

    </camelContext>

</blueprint>
Copy to Clipboard Toggle word wrap
service
service 要素は camel swagger サーブレット(<bean class="org.apache.camel.component.swagger.DefaultCamelSwaggerServlet"/>)を公開し、複数のサーブレットプロパティーを初期化します。
alias
alias プロパティーは、camel swagger サーブレットを /api-docs/* にバインドします
init-prefix
init-prefix プロパティーは、すべての camel swagger サーブレットプロパティーの接頭辞を init に設定します。これは、WAR 実装で web.xml 設定で init-param 要素を使用するのと似ています。
restConfiguration
camelContext では、restConfiguration 要素はポート 8080 の Web サーブレットとして Jetty を指定します。
rest
camelContext では、rest 要素は 2 つの REST エンドポイントを設定し、それらを以下の 2 つの route 要素で定義された camel エンドポイントにルーティングします。
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat