Over a million developers have joined DZone.

Yet Another Petstore!

· Java Zone

Discover how AppDynamics steps in to upgrade your performance game and prevent your enterprise from these top 10 Java performance problems, brought to you in partnership with AppDynamics.

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 entire application with a certain technology). But let’s face it, the J2EE version was far too complex and was using plenty of (today outdated) design patterns. When I wrote my Java EE 5 book back in 2006 (sorry, it’s written in French), I decided to write a Petstore-like application in Java EE 5 but much simpler. But again, it’s out-dated today.

Later on I wrote a book about Java EE 6and felt there was a need to have an updated Petstore so we could discover new patterns and APIs. Unfortunately Sun/Oracle didn’t do it… so I’ve decided to do it myself (with some help from my friends Antoine Sabot-DurandBrice Leporini, Hervé Le Morvan). I’ve updated my YAPS Petstore to follow Java EE 6 and all its goodies (CDI, EJB Lite, REST interface, Bean Validation).

The goals of this sample is to :

  • use Java EE 6 and just Java EE 6 : no external framework or dependency (I even use java.util.logging API ;o)
  • make it simple : no complex business algorithm, but I use most of the Java EE 6 APIs, the point is to bring Java EE 6 technologies together to create an eCommerce website

If you want to use a different web interface (PrimeFaces, pure HTML, Android…), external frameworks, add some sexy alternative JVM language… feel free to fork the code and do so. But I won’t do it because I want this EE 6 Petstore to remain simple and to stick to Java EE 6.

The only external frameworks that I’ve used are Twitter Bootstrap (so my JSF pages don’t look too ugly) and Arquillian for integration testing. My goal is to be able to deploy this Yaps Petstore on different application servers. For now it’s mostly GlassFish, JBoss but some work is also happening on TomEE and I’ll try to port it later on Resin, Weblogic, Websphere…. and who knows, do some performance benchmark of the same application but on different servers.

My next task is to deploy this Yaps Petstore on CloudBees… stay tuned. In the meantime, give it a try and let me know what you think.

The Java Zone is brought to you in partnership with AppDynamics. AppDynamics helps you gain the fundamentals behind application performance, and implement best practices so you can proactively analyze and act on performance problems as they arise, and more specifically with your Java applications. Start a Free Trial.


Published at DZone with permission of Antonio Goncalves , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}