onsdag 27 juni 2012

Java EE6 - A complete WEB application example

A while ago I was thinking of a small application where I could upload example files and projects which others could download. It should be a simple application however it should be full application with authorization, logging and all the things which you need in a production system.

I am now done with a first version of application and I thought that the first project to share with the application would be the application it self. I will not go through the whole application but I will present you with a list of some features used and what you can expect from the application:

  • Possibilities to upload files.
  • List, edit, delete, and view uploaded files.
  • Download files using a REST api.
  • Statistics of downloaded files.
  • Form based login. 

The following techniques are used to build the application:

  • Build for running on Glassfish using standard Java EE6 techniques like JPA, EJB, and JSF.  
  • Maven as build tool.
  • PrimeFaces for UI and file upload.
  • Jersey REST API.
  • Arquillian for EJB tests using embedded Glassfish.

In the application you will also find examples of some common problems like:

  • How to configure you applications using @Singleton and @Startup
  • How to present version and build information using a property file and maven-replaces-plugin.
  • How to implement a @ViewScope which works with CDI beans.
  • How to setup form based login.
  • How to write custom validation annotations using @Constraint.
  • How to write custom converters.
  • How to write custom components using composite.
  • A simple JPA model for the application together with EJBs for accessing them.
  • Since the application is a complete application you will find out how I generally organize my Java EE6 applications with a back-end package and a front-end package.
  • Complete tests for the EJB using Arquillian and embedded Glassfish.

If you are new to Java EE6 you can have a look at http://loop81.blogspot.se/2012/05/java-ee6-getting-started-with-java-ee6.html to get some help to get started.

If you like to run the application you first need to setup a persistence unit named Loop81FilesPu or whatever you name it. Complete SQL scripts for the data base can be found under src/main/db/create.sql. Instructions for setting up users in Glassfish can be found in the web.xml or you can simple comment out the security parts from the web.xml.

The source code and Eclipse project can be downloaded here: http://files.loop81.com/rest/download/a0ed2cd7-0eb4-4482-a3c8-fe5a4497236b

Inga kommentarer:

Skicka en kommentar