Este contenido no está disponible en el idioma seleccionado.

16.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 Red Hat JBoss Data Grid.

Important

JBoss Data Grid does not support deploying applications, therefore this quickstart cannot be installed as a deployment.
Prerequisites

Prerequisites for this procedure are as follows:

  1. Obtain the most recent supported JBoss Data Grid Remote Client-Server Mode distribution files from Red Hat.
  2. Ensure that the JBoss Data Grid and JBoss Enterprise Application Platform Maven repositories are installed and configured. For details, see Chapter 3, Install and Use the Maven Repositories

Procedure 16.1. Build the Football Application

  1. Add Configurations

    Edit the standalone.xml file (located at $JDG_HOME/standalone/configuration/) to add definitions for the datasource and infinispan subsystems.
    1. Add the following subsystem definition for the datasource:
      <subsystem xmlns="urn:jboss:domain:datasources:4.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>
      Copy to Clipboard Toggle word wrap
    2. Add the following subsystem definition for infinispan:
      <subsystem xmlns="urn:infinispan:server:core:8.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>
      Copy to Clipboard Toggle word wrap

    Note

    The Hot Rod and REST endpoints use the cache named teams and memcached endpoint uses memcachedCache as a default.
  2. Disable REST Security

    As a default, the standalone.xml configuration file protects the REST endpoint with BASIC authentication. This quickstart cannot perform authentication, therefore the REST authentication must be disabled in the REST connector by removing the security-domain and auth-method parameters. The resulting configuration (with REST authentication disabled) is as follows:
    <rest-connector virtual-server="default-host"
                    cache-container="local" />
    Copy to Clipboard Toggle word wrap
    For more details about security, see the REST Authentication Chapter in JBoss Data Grid's Developer Guide.
  3. Edit the Submodule Configuration File

    Each submodule (specifically hotrod-endpoint, rest-endpoint and memcached-endpoint) contains a configuration file (located at $JDG_QUICKSTART/src/main/resources/jdg.properties). Modify the default values in the configuration file to set the values required for your specific JBoss Data Grid installation.
  4. Navigate to the Root Directory

    Open a command line and navigate to the root directory of this quickstart.
  5. Build the Application

    Use the following command to build the example application in its directory:
    mvn clean package
    Copy to Clipboard Toggle word wrap
    This step results in the use of Maven's shade plugin, which bundles all dependencies into a single jar file for ease of use. This file is named {PROTOCOL}-endpoint-quickstart.jar, for example rest-endpoint-quickstart.jar for the REST version.
  6. Start JBoss Data Grid

    Run the following script to run JBoss Data Grid:
    $JDG_HOME/bin/standalone.sh
    Copy to Clipboard Toggle word wrap
  7. Run the Application

    Run the example application in its directory with the following command:
    mvn exec:java
    Copy to Clipboard Toggle word wrap
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat