Chapter I. A Jspresso application from A to Z

Table of Contents

I.1. Setting-up the development environment
I.1.1. Installing the tools
I.1.2. Generating the skeleton project
I.1.3. Importing the project in Eclipse
I.2. The human resources (HR) sample application
I.2.1. The domain model
I.2.2. The application workspaces
I.2.3. The profiles
I.3. Layering the application
I.3.1. The domain model
I.3.2. The backend
I.3.3. The frontend
I.4. Describing the domain model
I.4.1. Using the "Sugar for Jspresso" DSL
I.4.2. Interfaces
I.4.3. Generating the domain model code
I.4.4. Adding life-cycle behaviour
I.4.5. Entities
I.4.6. Components
I.4.7. Unidirectional relationships
I.4.8. Entity inheritance
I.4.9. Bi-directional relationships
I.4.10. Component services
I.4.11. Computed properties
I.4.12. Property processors
I.4.13. Hibernate mapping
I.5. Describing the views
I.5.1. Component views
I.5.2. Composite views
I.5.3. Collection views
I.5.4. Tree views
I.5.5. Other types of views
I.6. Wiring the application
I.6.1. Configuring the backend layer
I.6.2. Configuring the frontend layer
I.7. Creating and registering application workspaces and modules
I.7.1. The master data management workspace
I.7.2. Improving the development lifecycle : setting-up test data on startup
I.7.3. Developing the remaining workspaces
I.7.4. Securing the application access : Authorization
I.8. Packaging and deploying
I.8.1. A quick overview of options
I.8.2. Packaging the application WAR archive
I.8.3. Deploying to the application server

This chapter will help you to understand the basics of the Jspresso application framework and how to work with it.

I.1. Setting-up the development environment

One of the interesting feature of Jspresso is its native integration with standard build tools. All the complex build process is completely handled in Maven. Jspresso also offers a Maven archetype to quickly setup your project and import it directly in Eclipse.

I.1.1. Installing the tools

Download, install and configure the following tools :

You must also increase the java heap space allocated to Maven :

  • on windows : set MAVEN_OPTS=-Xmx512m (or set it as a user env variable)

  • on linux : export MAVEN_OPTS=-Xmx512m (or set it as a user env variable)

I.1.2. Generating the skeleton project

This is a one-step operation using the Jspresso application Maven archetype. Move to your Eclipse workspace and perform :

  • mvn archetype:generate -DarchetypeCatalog=http://repository.jspresso.org/maven2/

And choose the “Jspresso Application Archetype”.

Then fill-in the questions with the following answers :

  • groupId” : org.jspresso.hrsample

  • artifactId” : hrsample

  • package” : org.jspresso.hrsample

  • version” : 1.0-SNAPSHOT

This will generate a complete project ready to be compiled and packaged under the hrsample/ directory. So move to the generated directory and type :

  • mvn package

The operation may take some time to finish since Maven will download all the needed plugins and dependencies in its local repository. Just wait for the “BUILD SUCCESSFUL” message and you should have a packaged hrsample-webapp.war in the hrsample/webapp/target/ directory.

I.1.3. Importing the project in Eclipse

Follow the installation steps described on the Jspresso site and then import the project skeleton you've generated using the M2Eclipse project import wizard.

The development environment is now set-up. We can begin the Human Resources sample application coding.