What is it?
CarMart is a simple web application that uses Infinispan Cache instead of a relational database.
Users can list cars, add new cars, or remove them from the CarMart. Information about each car is stored in a cache. The application also shows cache statistics like stores, hits, retrievals, and more.
The CarMart quickstart can work in two modes:
Library mode - In this mode, the application and the data grid are running in the same JVM. All libraries (JAR files) are bundled with the application and deployed to JBoss Enterprise Application Platform 6 or JBoss AS 7. The library usage mode only allows local access to a single node in a distributed cluster. This usage mode gives the application access to data grid functionality within a virtual machine in the container being used.
Client-server mode - In this mode, the Cache is stored in a managed, distributed and clusterable data grid server. Applications can remotely access the data grid server using Hot Rod, memcached or REST client APIs. This web application bundles only the HotRod client and communicates with a remote JBoss Data Grid (JDG) server. The JDG server is configured via the
standalone.xmlconfiguration file.
System requirements
All you need to build this project is Java 6.0 (Java SDK 1.6) or better, Maven 3.0 or better.
The application this project produces is designed to be run on JBoss Enterprise Application Platform 6 or JBoss AS 7.
Configure Maven
If you have not yet done so, you must Configure Maven before testing the quickstarts.
Start JBoss Enterprise Application Platform 6 or JBoss AS 7
- Open a command line and navigate to the root of the JBoss server directory.
-
The following shows the command line to start the server with the web profile:
For Linux: JBOSS_HOME/bin/standalone.sh For Windows: JBOSS_HOME\bin\standalone.bat
Build and Deploy the Application in Library Mode
NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See Build and Deploy the Quickstarts for complete instructions and additional options.
- Make sure you have started the JBoss Server as described above.
- Open a command line and navigate to the root directory of this quickstart.
-
Type this command to build and deploy the archive:
mvn clean package jboss-as:deploy This will deploy
target/jboss-as-carmart.warto the running instance of the server.
Access the application
The application will be running at the following URL: http://localhost:8080/jboss-as-carmart/
Undeploy the Archive
- Make sure you have started the JBoss Server as described above.
- Open a command line and navigate to the root directory of this quickstart.
-
When you are finished testing, type this command to undeploy the archive:
mvn jboss-as:undeploy
Debug the Application
If you want to debug the source code or look at the Javadocs of any library in the project, run either of the following commands to pull them into your local repository. The IDE should then detect them.
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
Build and Start the Application in Client-server Mode (using the HotRod client)
NOTE: The application must be deployed to JBoss Enterprise Application Platform 6 or JBoss AS 7. It can not be deployed to JDG since it does not support deployment of applications.
Obtain the JDG server distribution. See the following for more information: http://www.redhat.com/products/jbossenterprisemiddleware/data-grid/
-
Configure the remote datagrid in the
$JDG_HOME/standalone/configuration/standalone.xmlfile. Copy the following XML into the Infinispan subsystem before the ending tag. If you have an existingcarcacheelement, be sure to replace it with this one.<local-cache name="carcache" start="EAGER" batching="false" indexing="NONE"> <locking isolation="REPEATABLE_READ" striping="false" acquire-timeout="20000" concurrency-level="500"/> <eviction strategy="LIRS" max-entries="4"/> </local-cache> -
Start the JDG server using on localhost 100 on port offset:
$JDG_HOME/bin/standalone.sh -Djboss.socket.binding.port-offset=100 -
Start JBoss AS 7 into which you want to deploy your application
$JBOSS_HOME/bin/standalone.sh -
The application finds the JDG server using the values in the src/main/resources/META-INF/JDG.properties file. If you are not running the JDG server on the default host and port, you must modify this file to contain the correct values. If you need to change the JDG address:port information, edit src/main/resources/META-INF/JDG.properties file and specify address and port of the JDG server
datagrid.host=localhost datagrid.hotrod.port=11322 -
Build the application in the example's directory:
mvn clean package -Premote -
Deploy the application
mvn jboss-as:deploy -Premote The application will be running at the following URL: http://localhost:8080/jboss-as-carmart/
-
Undeploy the application
mvn jboss-as:undeploy -Premote
Share the Knowledge
Find this guide useful?
Feedback
Find a bug in the guide? Something missing? You can fix it by forking the repository, making the correction and sending a pull request. If you're just plain stuck, feel free to ask a question in the user discussion forum.
Recent Changelog
- Feb 12, 2013: Add quickstart source repository of record to the readme files Sande Gilda
- Jan 25, 2013: Pushed jdg quickstarts Rafael Benevides
- Oct 15, 2012: Slipping jdg from this release of jdf Rafael Benevides
- Aug 28, 2012: Put jdg quickstart in jdf format Rafael Benevides
- Mar 20, 2012: Make carmart work with tomcat7 Martin Gencur
- Mar 02, 2012: Change naming to jdg and com.jboss.datagrid, cleanup Martin Gencur
- Feb 20, 2012: Make carmart work with dr3, add home button to gui Martin Gencur
- Feb 15, 2012: Carmart quickstart - a simple web application Martin Gencur