Show Table of Contents
15.2. Football アプリケーションのビルド
次の手順では、Red Hat JBoss Data Grid の REST、Hot Rod、および memcached エンドポイントの例としてフットボールマネージャーアプリケーションをビルドする方法を説明します。
重要
JBoss Data Grid はアプリケーションのデプロイメントをサポートしないため、このクイックスタートをデプロイメントとしてインストールすることはできません。
前提条件
この手順の前提条件は次のとおりです。
- サポートされる最新の JBoss Data Grid リモートクライアントサーバーモードディストリビューションファイルを Red Hat から取得します。
- JBoss Data Grid および JBoss Enterprise Application Platform Maven リポジトリーがインストールされ、設定されているようにしてください。詳細は 3章Maven リポジトリーのインストールおよび使用 を参照してください。
手順15.1 Football アプリケーションのビルド
設定の追加
$JDG_HOME/standalone/configuration/にあるstandalone.xmlファイルを編集し、データソースおよび infinispan サブシステムの定義を追加します。- データソースに対する次のサブシステム定義を追加します。
<subsystem xmlns="urn:jboss:domain:datasources:1.0"> <!-- Define this Datasource with jndi name java:jboss/datasources/ExampleDS --> <datasources> <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true"> <!-- The connection URL uses H2 Database Engine with in-memory database called test --> <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url> <!-- JDBC driver name --> <driver>h2</driver> <!-- Credentials --> <security> <user-name>sa</user-name> <password>sa</password> </security> </datasource> <!-- Define the JDBC driver called 'h2' --> <drivers> <driver name="h2" module="com.h2database.h2"> <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> </driver> </drivers> </datasources> </subsystem> - infinispan に対する次のサブシステム定義を追加します。
<subsystem xmlns="urn:infinispan:server:core:6.0" default-cache-container="local"> <cache-container name="local" default-cache="default" statistics="true"> <local-cache name="default" start="EAGER" statistics="true"> <locking isolation="NONE" acquire-timeout="30000" concurrency-level="1000" striping="false"/> <transaction mode="NONE"/> </local-cache> <local-cache name="memcachedCache" start="EAGER" statistics="true"> <locking isolation="NONE" acquire-timeout="30000" concurrency-level="1000" striping="false"/> <transaction mode="NONE"/> </local-cache> <local-cache name="namedCache" start="EAGER" statistics="true"/> <!-- ADD a local cache called 'teams' --> <local-cache name="teams" start="EAGER" batching="false" statistics="true"> <!-- Disable transactions for this cache --> <transaction mode="NONE" /> <!-- Define the JdbcBinaryStores to point to the ExampleDS previously defined --> <string-keyed-jdbc-store datasource="java:jboss/datasources/ExampleDS" passivation="false" preload="false" purge="false"> <!-- Define the database dialect --> <property name="databaseType">H2</property> <!-- specifies information about database table/column names and data types --> <string-keyed-table prefix="JDG"> <id-column name="id" type="VARCHAR"/> <data-column name="datum" type="BINARY"/> <timestamp-column name="version" type="BIGINT"/> </string-keyed-table> </string-keyed-jdbc-store> </local-cache> <!-- End of local cache called 'teams' definition --> </cache-container> </subsystem>
注記
Hot Rod および REST エンドポイントはteamsという名前のキャッシュを使用し、memcached エンドポイントはデフォルトでmemcachedCacheを使用します。REST セキュリティーの無効化
デフォルトでは、standalone.xml設定ファイルはBASIC認証で REST エンドポイントを保護します。このクイックスタートは認証を実行できないため、security-domainおよびauth-methodパラメーターを削除して REST コネクターで REST 認証を無効にする必要があります。REST 認証が無効化された設定は次のようになります。<rest-connector virtual-server="default-host" cache-container="local" />セキュリティーに関する詳細は、 JBoss Data Grid 『Developer Guide』 のREST 認証の章を参照してください。サブモジュール設定ファイルの編集
各サブモジュール (hotrod-endpoint、rest-endpoint、およびmemcached-endpoint) には設定ファイルが含まれています ($JDG_QUICKSTART/src/main/resources/jdg.propertiesにあります)。設定ファイルのデフォルト値を編集し、指定の JBoss Data Grid インストールに必要な値を設定します。アプリケーションのビルド
次のコマンドを使用して、サンプルアプリケーションのディレクトリーでサンプルアプリケーションをビルドします。mvn clean package
これにより、すべての依存関係を 1 つの jar ファイルにバンドルして使いやすくする、Maven のシェードプラグインが使用されます。このファイルには{PROTOCOL}-endpoint-quickstart.jarという名前が付けられます。たとえば、REST の場合はrest-endpoint-quickstart.jarという名前になります。JBoss Data Grid の起動
以下のスクリプトを実行して、JBoss Data Grid を実行します。$JDG_HOME/bin/standalone.sh
アプリケーションの実行
以下のコマンドを実行し、サンプルアプリケーションのディレクトリーでサンプルアプリケーションを実行します。mvn exec:java

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.