Questo contenuto non è disponibile nella lingua selezionata.
10.2. Build the Football Application
The following procedure outlines the steps to build a football manager application as an example of REST, Hot Rod and memcached endpoints in JBoss Data Grid.
Note
JBoss Data Grid does not support deploying applications, therefore this quickstart cannot be installed as a deployment.
Procedure 10.1. Build the Football Application
Add Configurations
Edit thestandalone.xmlfile (located at$JDG_HOME/standalone/configuration/) to add definitions for the datasource and infinispan subsystems.- Add the following subsystem definition for the datasource:
<subsystem xmlns="urn:jboss:domain:datasources:1.0"> <datasources> <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true"> <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url> <driver>h2</driver> <security> <user-name>sa</user-name> <password>sa</password> </security> </datasource> <drivers> <driver name="h2" module="com.h2database.h2"> <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> </driver> </drivers> </datasources> </subsystem> - Add the following subsystem definition for infinispan:
<subsystem xmlns="urn:jboss:domain:infinispan:1.2" default-cache-container="local"> <cache-container name="local" default-cache="memcachedCache" listener-executor="infinispan-listener" start="EAGER"> <local-cache name="memcachedCache" start="EAGER" batching="false" indexing="NONE"> <locking isolation="REPEATABLE_READ" acquire-timeout="20000" concurrency-level="500" striping="false" /> <transaction mode="NONE" /> <string-keyed-jdbc-store datasource="java:jboss/datasources/ExampleDS" passivation="false" preload="false" purge="false"> <property name="databaseType">H2</property> <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> <local-cache name="teams" start="EAGER" batching="false" indexing="NONE"> <locking isolation="REPEATABLE_READ" acquire-timeout="20000" concurrency-level="500" striping="false" /> <transaction mode="NONE" /> <string-keyed-jdbc-store datasource="java:jboss/datasources/ExampleDS" passivation="false" preload="false" purge="false"> <property name="databaseType">H2</property> <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> </cache-container> </subsystem>
Note
The Hot Rod and REST endpoints use the cache namedteamsand memcached endpoint usesmemcachedCacheas a default.Edit the Submodule Configuration File
Each submodule (specificallyhotrod-endpoint,rest-endpointandmemcached-endpoint) contains a configuration file (located at$JDG_HOME/src/main/resources/jdg.properties). Edit the configuration to specify the values required for your JBoss Data Grid installation. The Hot Rod endpoint requires further configuration, as follows:Install the Maven Repository
For initial testing in a small team, the repository can be extracted to a directory on the local file system as follows:unzip jboss-datagrid-maven-repository-6.0.0.zipThis creates a Maven repository in a directory calledjboss-datagrid-maven-repository-6.0.0.For further information about the installation methods available to install the JBoss Data Grid Maven repository, refer to Chapter 4, Install and Use the Maven Repository.
Build the Application
Use the following command to build the example application in its directory:mvn packageThis step results in the use of Maven's shade plugin, which bundles all dependencies into a single jar file for ease of use.Start JBoss Data Grid
Run the following script to run JBoss Data Grid:$JDG_HOME/bin/standalone.shRun the Application
Run the example application in its directory.- For the Hot Rod endpoint, run the following command:
java -jar target/hotrod-endpoint-quickstart.jar - For the memcached endpoint, run the following command:
java -jar target/memcached-endpoint-quickstart.jar - For the REST endpoint, run the following command:
java -jar target/rest-endpoint-quickstart.jar