Giter Club home page Giter Club logo

agoncal-application-petstore-ee6's Introduction

Application - Petstore Java EE 6

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 eCommernce 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 I decided to write a Petstore-like application but much simpler. But again, it's out-dated today.

So what you have here is another Petstore-like application but using Java EE 6 and all its goodies (CDI, EJB Lite, REST interface). The goals of this sample is to :

  • use Java EE 6 and just Java EE 6 : no external framework or dependency, we even use the java.util.logging API ;o)
  • make it simple : no complex business algorithm, the point is to bring Java EE 6 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 we won't do it. We want this EE 6 Petstore to remain simple and to stick to Java EE 6.

Component diagram

Compile and package

Being Maven centric, you can compile and package it with mvn clean compile, mvn clean package or mvn clean install. The package and install phase will automatically trigger the unit tests. Once you have your war file, you can deploy it.

Test in multiple containers

The application uses Arquillian for its integration test. Using Maven profile, you can test Services against different application servers

Test with Glassfish embedded

Launching tests under Glassfish is straight forward. You only have to lauch :

mvn clean install -Pglassfish-embedded

Galssfish will lauch during the build and tests will be executed in it.

Test with JBoss 7.0.2 managed

To launch tests under JBoss 7.0.2 you first should install JBoss 7.0.2 and set the environnment variable JBOSS_HOME to JBoss installation directory. Once this is done you'll launch the test with this command

mvn clean install -Pjbossas7-managed

During the build, Arquillian will launch JBoss and execute the tests in it.

Deploy the sample

This sample has been tested with GlassFish 3.1.2 in several modes :

  • GlassFish runtime : download GlassFish, install it, start GlassFish (typing asadmin start-domain) and once the application is packaged deploy it (using the admin console or the command line asadmin deploy target/applicationPetstore.war)
  • GlassFish embedded : use the GlassFish Maven Plugin by running mvn clean package embedded-glassfish:run (you might have to increase Perm Gen space with MAVEN_OPTS set to -XX:MaxPermSize=128m)

Execute the sample

Once deployed go to the following URL and start buying some pets: http://localhost:8080/applicationPetstore. You can use these login/passwd : marc/marc bill/bill jobs/jobs

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 reprensetation as follow :

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

agoncal-application-petstore-ee6's People

Contributors

agoncal avatar antoinesd avatar hlemorvan avatar

Watchers

 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.