Spring Template

This is a template Spring project that i think is usefull on create new web projects.

Have not done anything on this for a long time so it is kind of dead :-(

Using Spring, Spring Security and hibernate.
Using the database (derby) to save Spring Security users.
All configured with annotations.
All libs necessary to run Spring, Spring security and Hibernate with annotations.
In the gui you can list, add and remove users from Spring security database tables.
A example how to load environment specific variables in spring (See /web/WEB-INF/applicationContext-database.xml).
How to upload file to a spring controller.
Using some stuff from ClassCollection and SpringUtils.
Some usefull tag libs (SteelsquidSpringUtils).

Here you can download the code: Google Drive

Dependencies (All needed jar is under the lib directory)

Java 1.6
Apache Tomcat 6.0 (Servlet-api, Jsp-api) (http://tomcat.apache.org)
SteelsquidClassCollection 
SteelsquidSpringUtils 
Spring Framework 3.0.3 (http://www.springsource.org)
Spring Security 3.0.3 (http://static.springsource.org/spring-security/site/index.html)
Apache Derby 10.6.1.0 (http://db.apache.org/derby)
Apache log4j 1.2.16 (http://logging.apache.org/log4j/1.2)
Commons Collections 3.1 (http://commons.apache.org/collections)
Commons DBCB 1.3 (http://commons.apache.org/dbcp)
Commons Pool 1.5.5 (http://commons.apache.org/pool)
Commons Codec 1.4 (http://commons.apache.org/codec)
Commons Logging 1.1.1 (http://commons.apache.org/logging)
Commons FileUpload 1.2.2 (http://commons.apache.org/fileupload)
Commons IO 2.0 (http://commons.apache.org/io)
Hibernate 3.5.6 (http://www.hibernate.org)
Hibernate Validator 4.1.0 (http://www.hibernate.org)
Hibernate jpa 2.0 (http://www.hibernate.org)
JSTL 1.1.2 (http://tomcat.apache.org/taglibs/standard)
SLF4J 1.5.8 (http://www.slf4j.org)
CGLIB 2.2 (http://cglib.sourceforge.net)
Dom4j 1.6.1 (http://www.dom4j.org)
Antlr 2.7.6 (http://www.antlr2.org)
JTA 1.1 (http://www.oracle.com/technetwork/java/javaee/tech/jta-138684.html)
Javassist 3.9.0 (http://www.javassist.org)
Aopalliance 1.0 (http://www.antlr.org)
Validation-api 1.0.0 (???)

Usage

Deploy SteelsquidSpringTemplate.war in Apache Tomcat/Jetty and read documentation in code for explanation.
Point your browser to http://localhost:8080/SteelsquidSpringTemplate
You should see a login page.
You can login with User: admin and Password: admin

After that you can choose 'Users' to edit Spring security users.

Select 'Upload' to test the upload functionality.


Short description of classes

org.steelsquid.springtemplate.controller
All controller in the system, handles request from a client
org.steelsquid.springtemplate.controller.HomeController
This is the start page for SteelsquidSpringTemplate.
Maps to home.jsp.
This controller is connected to home.htm request.
org.steelsquid.springtemplate.controller.IndexController
This is the entry point of Steelsquid Spring Template.
Maps to index.jsp.
This controller is connected to index.htm request.
org.steelsquid.springtemplate.controller.UploadController
This is a file upload example for SteelsquidSpringTemplate.
Maps to upload.jsp.
This controller is connected to upload.htm and uploadFile.htm request
org.steelsquid.springtemplate.controller.UsersController
This controller list users from the database.
Maps to users.jsp.
This controller is connected to users.htm (and some others) request.
User with ROLE_ADMIN can search and edit users.
User with ROLE_USER can change there own information.
This controller list, add and delete users to Spring security.
org.steelsquid.springtemplate.dao
All database stuff.
org.steelsquid.springtemplate.dao.security
All security database stuff (Table User and authority).
org.steelsquid.springtemplate.dao.security.Authority
This is a authority for a user on the system.
Using hibernate to map the table authoritieslist.
org.steelsquid.springtemplate.dao.security.SecurityDao
This is the Dao object for the users and authorities tables.
Use this to list, add and delete users to Spring security.
org.steelsquid.springtemplate.dao.security.User
This is a user on the system.
using hibernate to map the table users and authorities.
org.steelsquid.springtemplate.interceptor.RequestInterceptor
Use this to execute stuff before and after requests.
See dispatcher-servlet.xml
org.steelsquid.springtemplate.interceptor.StartStopInterceptor
This will execute on start and stop of application.
Using it to run startupp stuff.
Se applicationContext-database.xml
Add roles and create a default user: admin
/web/META-INF/context.xml
This file can be used to define certain behaviours for your application,
JNDI resources and other settings.
/web/WEB-INF/jsp/home.jsp
This is the home page for Steelsquid Spring Template.
Using HomeController as controller.
This page is connected to home.htm request.
/web/WEB-INF/jsp/index.jsp
This is the start page for Steelsquid Spring Template.
Using IndexController as controller.
This page is connected to index.htm request
Using steelsquid:Workspace to generate a workspace for the application.
The workspace has a iframe with different pages.
/web/WEB-INF/jsp/upload.jsp
This is file upload example for Steelsquid Spring Template.
Using UploadController as controller.
This page is connected to upload.htm and uploadFile.htm request.
/web/WEB-INF/jsp/users.jsp
This page list users from the database.
Using UsersController as controller.
This page is connected to users.htm (and some others) request
User with ROLE_ADMIN can search and edit users.
User with ROLE_USER can change there own information only.
This page list, add and delete users to Spring security
/web/WEB-INF/jspf/head.jspf
This file create the html head content.
Contaions all Javascript and css that SteelsquidSpringTemplate needs.
A think it is usefull to have a jspf file as header on all pages...can add things globaly very easy.
This page executes onPageLoad() on start. Create method named onLoad() do execute stuff in page implementing this.
/web/WEB-INF/tld/steelsquidSpringUtils.tld
Some usefull tags, i use in my project.
/web/WEB-INF/applicationContext.xml
Application context definition (Configuration Files).
Loading different setting pending on environment varible.
/web/WEB-INF/applicationContext-database.xml
Application context definition (Configuration Files).
Configuring the database/hibernate in this file.
/web/WEB-INF/applicationContext-security.xml
Configuring spring security.
/web/WEB-INF/dispatcher-servlet.xml
Loading spring settings.
Configuring the spring request handling.
/web/WEB-INF/web.xml
The web.xml file provides configuration and deployment information for the Web components that comprise a Web application.
Examples of Web components are servlet parameters, servlet and JavaServer Pages (JSP) definitions, and Uniform Resource Locators (URL) mappings.
/web/login.jsp
This is the login page to Steelsquid Spring Template.
Using Spring security.
See applicationContext-security.xml
/web/redirect.jsp
This JSP is here to provide a redirect to the dispatcher servlet but should be the only JSP outside of WEB-INF.


ToDo

JSON and Spring example.

Revision history

2010-09-22  0.8   Initial release
2011-04-06  0.9   Change the workspace colors (Gray)
2011-06-15  1.0   Nothing new in the code but using Netbeans 7

Licensing

SteelsquidSpringTemplate GNU General Public License
SteelsquidSpringUtils GNU Lesser General Public License
SteelsquidClassCollection GNU Lesser General Public License
Spring Framework Apache License Version 2
Spring Security Apache License, Version 2.0
Apache Derby Apache License, Version 2.0
Apache Tomcat Apache License, Version 2.0
Apache log4j Apache License, Version 2.0
Commons Collections, dbcp, pool, codec, fileUpload, IO Apache License, Version 2.0
JSTL Apache License, Version 2.0
CGLIB Apache License, Version 2.0
Hibernate GNU Lesser General Public License
SLF4J MIT license
Dom4j BSD style license
Antlr Public domain
JTA License
Javassist Lesser General Public License v2.1 and Mozilla Public License 1.1
AopAlliance GNU Lesser General Public License
Validation-api Apache License, Version 2.0