Coder Social home page Coder Social logo

hellowhuaairen / agoncal-application-cdbookstore Goto Github PK

View Code? Open in Web Editor NEW

This project forked from agoncal/agoncal-application-cdbookstore

0.0 1.0 0.0 1.3 MB

An e-commerce web app that sells CDs and Books

Java 52.48% GLSL 5.22% HTML 35.41% CSS 4.94% JavaScript 0.20% XSLT 1.76%

agoncal-application-cdbookstore's Introduction

Application - CD Book Store

  • 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, WildFly 10
  • Summary : An e-commerce web application using Java EE 7

Download the code from GitHub

Purpose of this application

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).

Architecture

The application is divided in several modules:

  • The CD-Boostore is the main web app that allows you to buy CDs and Books.
  • The Top Sells is a REST service that calculates the top sells. This REST service is invoked by CD-Boostore to display the top sells on the main page
  • Billing : is a Message Driven Bean that receives all the sells that have been done and creates invoices

Compile and package

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.

Starting JBoss/WildFly

The invoice is an MDB, so you need to start the full profile of JBoss :

  • ./standalone.sh -c standalone-full.xml

Then you need to create a Queue with the following command in jboss_cli.sh :

  • Create the queue : jms-queue add --queue-address=invoiceQueue --entries=jms/queue/invoiceQueue
  • Delete the queue : jms-queue remove --queue-address=invoiceQueue

Several WildFlies

If you want to execute each application on different WildFly instances, just do :

  • ./standalone.sh -c standalone-full.xml -Djboss.socket.binding.port-offset=2 (ports 8082 / 9992)
  • ./standalone.sh -c standalone-full.xml -Djboss.socket.binding.port-offset=3 (ports 8083 / 9993)
  • ./standalone.sh -c standalone-full.xml -Djboss.socket.binding.port-offset=5 (ports 8085 / 9995)

Test with Arquillian

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

Execute the sample

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
  • curl -X GET http://localhost:8085/applicationToprated/toprateditems

You can also get a JSON representation as follow :

  • curl -X GET -H "accept: application/json" http://localhost:8080/applicationCDBookStore/rs/catalog/items

Third Party Tools & Frameworks

Twitter Bootstrap

When, like me, you have no web designer skills at all and your web pages look ugly, you use Twitter Bootstrap ;o)

Silk Icons

I use Silk Icons which are in Creative Commons

Arquillian

Arquillian for the integration tests.

Bugs & Workaround

Licensing

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

antonio goncalves

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.