Git Product home page Git Product logo

petstoreee7's Introduction

Application - Petstore Java EE 7

  • 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 : A Petstore-like application using Java EE 7

Download the code from GitHub

Purpose of this application

Do you remember the good old Java Petstore ? It was a sample application created by Sun for its Java BluePrints program. The Java Petstore was designed to illustrate how J2EE (and then Java EE) could be used to develop an eCommerce web application. Yes, the point of the Petstore is to sell pets online. The Petstore had a huge momentum and we started to see plenty of Petstore-like applications flourish. The idea was to build an application with a certain technology. Let's face it, the J2EE version was far too complex using plenty of (today outdated) design patterns. When I wrote my Java EE 5 book back in 2006, I decided to write a Petstore-like application but much simpler. But again, it's out-dated today.

What you have here is another Petstore-like application but using Java EE 7 and all its goodies (CDI, EJB Lite, REST interface). It is based on the Petstore I developed for my Java EE 5 book (sorry, it's written in French). I've updated it based on my Java EE 6 book, and now I'm updating it again so it uses some new features of Java EE 7 described on my Java EE 7 book. 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

If you want to use a different web interface, external frameworks, add some sexy alternative JVM language… feel free to fork the code. But the goal of this EE 7 Petstore is to remain simple and to stick to Java EE 7.

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.

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.

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

Or if you prefer the managed mode :

mvn clean test -Parquillian-wildfly-managed

Execute the sample

Once deployed go to the following URL and start buying some pets: http://localhost:8080/applicationPetstore.

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/applicationPetstore/rs/catalog/categories
  • curl -X GET http://localhost:8080/applicationPetstore/rs/catalog/products
  • curl -X GET http://localhost:8080/applicationPetstore/rs/catalog/items

You can also get a JSON representation as follow :

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

Check the Swagger contract on :

Test this application on CloudBees

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.

Developpers

Some people who worked on this project :

Bugs & Workaround

Licensing

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

antonio goncalves

petstoreee7's People

Watchers

James Cloos avatar Antonio Casado avatar

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.