- Author : Antonio Goncalves
- Level : Intermediate
- Technologies : Java EE 7 (JPA 2.1, CDI 1.1, Bean Validation 1.1, EJB Lite 3.2, JSF 2.2, JAX-RS 2.0), Twitter Bootstrap (Bootstrap 3.x, JQuery 2.x, PrimeFaces 5.x)
- Application Servers : WildFly 8, WildFly 9
- Summary : An e-commerce web application using Java EE 7
This e-commerce web app allows you to buy CDs and Books.
The goals of this sample is to :
- use Java EE 7 and just Java EE 7 : no external framework or dependency (except web frameworks or logging APIs)
- make it simple : no complex business algorithm, the point is to bring Java EE 7 technologies together to create an eCommerce website
The only external framework used are Arquillian, Twitter Bootstrap and PrimeFaces. Arquillian is used for integration testing. Using Maven profile, you can test services, injection, persistence... against different application servers. Twitter Bootstrap and PrimeFaces bring a bit of beauty to the web interface.
To fill up the database, I've used some Amazon Web Services. You will find the raw XML data in the xml
directory with XSLT transformation (zipped so it's not too big).
Being Maven centric, you can compile and package it without tests using mvn clean compile -Dmaven.test.skip=true
, mvn clean package -Dmaven.test.skip=true
or mvn clean install -Dmaven.test.skip=true
. Once you have your war file, you can deploy it.
Launching tests under WildFly is straight forward. You only have to launch WidlFly and execute the tests using the Maven profile :
mvn clean test -Parquillian-wildfly-remote
Once deployed go to the following URL and start buying some books and cds: http://localhost:8080/applicationCDBookStore.
The admin REST interface allows you to create/update/remove items in the catalog, orders or customers. You can run the following curl commands :
curl -X GET http://localhost:8080/applicationCDBookStore/rs/catalog/categories
curl -X GET http://localhost:8080/applicationCDBookStore/rs/catalog/products
curl -X GET http://localhost:8080/applicationCDBookStore/rs/catalog/items
You can also get a JSON representation as follow :
curl -X GET -H "accept: application/json" http://localhost:8080/applicationCDBookStore/rs/catalog/items
When, like me, you have no web designer skills at all and your web pages look ugly, you use Twitter Bootstrap ;o)
I use Silk Icons which are in Creative Commons
Arquillian for the integration tests.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.