OrangeApple
Java Code Geeks

We thought different, it's your turn now!
Jul 7 '12

Spring, Hibernate, Spring Data, Akka, Twitter Bootstrap, Apache Tiles, jQuery powered Maven Java Web Project Kickstarter Codebase

I am happy to upload my second project to GitHub to help people get started with Java Web App Development as quickly as possible. I am sharing this code with Apache License 2.0. Here is the URL for the same: 

https://github.com/ykameshrao/spring-hibernate-springdata-springmvc-maven-project-framework

The project consists of following parts:

1) Commons-Deps: Dependencies declared as a single pom file to easily manage the project dependencies. It is upto personal choice of users to still continue have it this way or go with their own chosen method to manage dependencies in maven pom.

2) Commons: A lot of common code snippets are provided as part of commons jar module to help send mails using gmail, java mail, utf8 encoding, JCS cache managers, session managers, random string, etc.

3) Framework: This part of the code base includes JPA and Spring Data Entities, JPA and Spring Data Repositories, Services which are built using Java Generics to help provide the CRUD actions on these Entities when users build their own domain specific entities, repositories and services extending the ones provided here. It also contains, API and Web App Controllers providing basic functionality again for people interested in building their own Spring MVC controllers using these. Also, contained here are validators, exceptions, AOP based exception handlers.

4) Your Own Web App Code: This part of the code provides a bootstrapped web project with API and Web UI using the best practices I picked across time to do things using the third party frameworks, libraries I have chosen here. The API parts is configured to accept and generate both XML and JSON request and response formats. Akka is also configured here to present the method in which it can be used to offload activities from your Spring MVC controllers (Servlets). Here it is programmed to offload the task of sending emails.

This is the wrapper framework laid out to start building Spring based Web apps with Hibernate ORM layer or Spring Data ORM powered NoSQL and Spring MVC in Java programming language. The purpose of this project is to get you started quickly in Java web app development over a widely used and tested Java web development infrastructure. 

This project provides sample hibernate entities, spring data entities, akka actors to offload mail sending like jobs, models, repositories, services and controllers classes. There are also many framework level classes to help handle exceptions and errors in the project you may start developing using this. The UI for the default simple web project bundled in this framework is built using Twiiter Bootstrap, Apache Tiles, jQuery, jQuery Validation, JSPs.


I can try my best to provide with as much detail as possible here, but the best way to understand all that is provided is by reading the code. Therefore, I also provided a sample web app project with functionality to register and login a user. All the code is presented in a package structure that can be renamed as per your own choice and requirements. Enjoy!


Configurations

config/props/mail.properties
mail.transport.protocol=smtps
mail.host=smtp.gmail.com
mail.user=
mail.pass=
mail.port=465
mail.starttls=true
mail.auth=true
mail.debug=true
mail.fromAddress=

config/props/database.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/yourwebprojectdb
jdbc.username=
jdbc.password=
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=600
hibernate.c3p0.max_statements=50

src/main/resources/tiles/templates.web.xml
<?xml version=”1.0” encoding=”UTF-8” ?>
<!DOCTYPE tiles-definitions PUBLIC
       ”-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN”
       ”http://tiles.apache.org/dtds/tiles-config_2_0.dtd”>
<tiles-definitions>
<definition name=”base” template=”/WEB-INF/views/layout/web.jsp”>
<put-attribute name=”title” value=”” />
<put-attribute name=”header” value=”/WEB-INF/views/common/header.web.jsp” />
        <put-attribute name=”message” value=”/WEB-INF/views/common/message.web.jsp” />
<put-attribute name=”content” value=”” />
<put-attribute name=”footer” value=”/WEB-INF/views/common/footer.web.jsp” />
</definition>
<definition name=”home” extends=”base”>
<put-attribute name=”title” value=”Your Web Project” />
<put-attribute name=”content” value=”/WEB-INF/views/web/home.web.jsp” />
</definition>
    <definition name=”userRegistration” extends=”base”>
    <put-attribute name=”title” value=”Register” />
    <put-attribute name=”content” value=”/WEB-INF/views/web/userRegistration.web.jsp” />
    </definition>
    <definition name=”dashboard” extends=”base”>
    <put-attribute name=”title” value=”Dashboard” />
    <put-attribute name=”content” value=”/WEB-INF/views/web/dashboard.web.jsp” />
    </definition>
    <definition name=”error” extends=”base”>
    <put-attribute name=”title” value=”Error” />
    <put-attribute name=”content” value=”/WEB-INF/views/web/error.web.jsp” />
    </definition>
</tiles-definitions>

Startup VM Options Required
-Dconf.path=”path-to-config-folder-on-target-machine-containing-property-files”

Refer: src/main/resources/config/spring/applicationContext-properties.xml
<util:properties id=”mdbProps” location=”file:#{systemProperties[‘conf.path’]}/config/props/mongodb.properties” />
    <util:properties id=”dbProps” location=”file:#{systemProperties[‘conf.path’]}/config/props/database.properties” />
    <util:properties id=”logProps” location=”file:#{systemProperties[‘conf.path’]}/config/props/log4j.properties” />
    <util:properties id=”amProps” location=”file:#{systemProperties[‘conf.path’]}/config/props/api.messages.properties” />
:
:


Screenshots

The frameworks strung together supporting multiple activities in this framework layer of code are -
Maven
Java 1.7
Spring 3.1.1
Hibernate 4+
Spring Data
MongoDB
Akka 1.3+
Apache Tiles 2+
Twitter Bootstrap 2+
Velocity for Mails
BootSwatch
jQuery

3 notes View comments Tags: spring hibernate akka spring-data twiiter-bootstrap apache-tiles jsp spring-mvc open-source programming

  1. prayagupd reblogged this from orangeappletemp
  2. bankedtrackrollerderby reblogged this from orangeappletemp
  3. orangeappletemp posted this
Blog comments powered by Disqus