Menu Close
12.4.7. Blueprint ファイルの作成
Blueprint 設定ファイルは、クラスパスの OSGI-INF/blueprint
ディレクトリーに保存されている XML ファイルです。Blueprint ファイルをプロジェクトに追加するには、まず以下のサブディレクトリーを作成します。
ProjectDir/osgi-service/src/main/resources ProjectDir/osgi-service/src/main/resources/OSGI-INF ProjectDir/osgi-service/src/main/resources/OSGI-INF/blueprint
src/main/resources
は、すべての JAR リソースの標準 Maven 場所です。このディレクトリーにあるリソースファイルは、生成されたバンドル JAR のルートスコープに自動的にパッケージ化されます。
例12.5「サービスをエクスポートするための Blueprint ファイル」 は、bean 要素を使用して HelloWorldSvc
Bean を作成するブループリントファイルの例になります。次に、service 要素を使用して
Bean を OSGi サービスとしてエクスポートします 。
ProjectDir/osgi-service/src/main/resources/OSGI-INF/blueprint
ディレクトリーで、お気に入りのテキストエディターを使用してファイル config.xml
を作成し、例12.5「サービスをエクスポートするための Blueprint ファイル」 から XML コードを追加します。
例12.5 サービスをエクスポートするための Blueprint ファイル
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <bean id="hello" class="org.fusesource.example.service.impl.HelloWorldSvcImpl"/> <service ref="hello" interface="org.fusesource.example.service.HelloWorldSvc"/> </blueprint>