Portlet development with the Spring Application Framework - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Portlet development with the Spring Application Framework

Description:

'Spring is a lightweight dependency injection. and ... (however, Spring 2.5 supports annotations which can reduce the XML bloat). JSR-286 not supported ... – PowerPoint PPT presentation

Number of Views:331
Avg rating:3.0/5.0
Slides: 20
Provided by: drlesly
Category:

less

Transcript and Presenter's Notes

Title: Portlet development with the Spring Application Framework


1
Portlet development with the Spring Application
Framework
  • Mike Jones
  • mike.a.jones_at_bristol.ac.uk

2
Outline ...
  • What is the Spring Framework?
  • Why use the Spring Portlet MVC?
  • Some technical details.
  • An example portlet (if theres time)
  • Further reading and useful links

2
3
What is the Spring Framework?
Spring is a lightweight dependency injection and
aspect-oriented container and framework.
Craig Walls, Spring in Action
  • Originated from code published in Rod Johnson
    Expert One-on-One J2EE Design and Development
    (2002)
  • Developed as a reaction to the complexity of J2EE
    and EJB.
  • Version 1.0 released in March 2004.
  • Current version is 2.5

4
Examples ...
  • VOCA - handles UK interbank payments. Replaced
    its COBOL system with Spring. Handles 2,500
    payments a second.
  • The French online tax system is based on Spring.
  • Alfresco, the open source enterprise content
    management system uses Spring.

4
5
Spring Modules
DAO
ORM
JEE
Web
AOP
Core
6
Dependency Injection
Constructor of the PersonServiceImpl class
public PersonServiceImpl(PersonDao personDao)
this.personDao personDao
In the Spring configuration file ...
ltbean idpersonService classorg.ilrt.pro
jectx.service.PersonServiceImplgt
ltconstructor-arg index0 refpersonDao
/gt lt/beangt
7
Why use the Spring Portlet MVC?
  • Can be used in any JSR-168 compliant portlet
    container.
  • It promotes best practices such as coding to
    interfaces and dependency injection.
  • Supports test-driven development through a mock
    testing framework.

7
8
Why use the Spring Portlet MVC?
  • It supports multiple view technologies, e.g. JSP,
    Velocity and FreeMarker.
  • It mirrors the Spring Web MVC framework. Easy to
    convert.
  • It supports the action phase and render phase of
    a portlet request - not hidden from the developer.

8
9
What is the MVC?
  • Model - a java.util.Map that holds domain
    objects.
  • View - displays the Model data.
  • Controller - handles the portlet request. It
    usually delegates to a service layer to perform
    business logic and obtain data. Prepares the
    Model.

9
10
DispatcherPortlet and the Portlet Request Life
Cycle
2. Consult handler mapping to discover controller
HandlerMapping
DispatcherPortlet
1. Request
3. Delegate
Controller
4. Return Model
5. Resolve the view
6. Render view
InternalResourceViewResolver
View template
11
Handler Mapping
12
The Controller Hierarchy
All classes implement the Controller interface.
13
An Example
public class ListGroupsController extends
AbstractController .... public ModelAndView
handleRenderRequestInternal(
RenderRequest request, RenderResponse response)
throws Exception
ListltGroupgt groups
addressBookService.findGroups()
ModelAndView mav new ModelAndView("listGroups")
mav.addObject("groups", groups)
return mav ...
14
An Example Portlet
  • A project team address book.
  • RDF/XML using the FOAF schema.
  • Data is queried through SPARQL.
  • Built via Maven 2.
  • Download fromlthttp//chillyinside.com/downloads/
    AddressBookPortlet.tar.gzgt

14
15
Further Reading
A free bonus chapter on building portlets can be
found on the publishers website lthttp//www.ma
nning.com/walls3/gt
16
Useful Links
  • Spring Portlet MVC Wikilthttp//opensource.atlassi
    an.com/confluence/spring/display/JSR168/Homegt
  • Spring Support Forumslthttp//forum.springframewor
    k.org/forumdisplay.php?f25gt
  • Spring Documentationlthttp//www.springframework.o
    rg/documentationgt

16
17
Closing Thoughts...the Pros
  • A framework that helps rather than hinders
    productivity.
  • It promotes good practice ... programming to
    interfaces, design patterns, TDD.
  • Good for portlets with complex needs.
  • It should be straight forward to convert a Spring
    MVC application to a Spring MVC Portlet.

17
18
Closing Thoughts...the Cons
  • Another framework to learn (although the learning
    curve is not steep).
  • Complete overkill for very simple portlets.
  • There can be lots of XML configuration (however,
    Spring 2.5 supports annotations which can reduce
    the XML bloat).
  • JSR-286 not supported ... should be supported in
    Spring 3.0.

18
19
?
Write a Comment
User Comments (0)
About PowerShow.com