Experiences using Apache Cocoon - PowerPoint PPT Presentation

About This Presentation
Title:

Experiences using Apache Cocoon

Description:

Maximize code reuse, integrate with off-the-shelf components ... personname Fabian Pascal /personname role EDITOR /role /contributor /publication ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 21
Provided by: matthew385
Category:

less

Transcript and Presenter's Notes

Title: Experiences using Apache Cocoon


1
Experiences using Apache Cocoon Matthew
Mascord 21st January 2004
2
Slide 1
Structure
  • Context
  • Survey of Web Architectures
  • Apache Cocoon
  • Experiences

3
Slide 2
Context Publication Archive
  • Data-driven system, many output formats
  • Small code footprint gt modification easier, so
  • Maximize code reuse, integrate with off-the-shelf
    components
  • Favour declarative solutions over procedural
  • Use open standards
  • Separate concerns

4
Slide 3
Web Architectures Model 1
  • Collection of JSPs/ASPs/PHPs
  • Support classes (beans)
  • Simple but
  • business logic mixed with presentation
  • Lots of Java code intermixed with HTML
    (scriplets)
  • Difficult to maintain lacks SoC

5
Slide 4
Web Architectures Tag Libraries
  • Tag libraries bundle common operations
  • Coded in Java
  • JSTL standardises common tags
  • Expression Language to query Beans

6
Slide 5
Model 2 In Pictures
  • Based on Model-View-Controller (MVC)
  • Apache Struts as a very popular framework

Controller
View
Struts Controller
Action Class
JSP
HTTP Request
Model
HTTP Response
Form Bean
Result Bean
7
Slide 6
Model 2 - Assessed
  • Logic presentation separated but
  • can still hack the JSP
  • Struts APIs complex
  • JSP limited as view e.g. not pipelined
  • JSP compilation error reporting still a problem
  • JSP tags JSTL can help but tags written in Java
    hard to define tags in terms of other tags.

8
Slide 7
XSLT
  • Declarative (functional) language for
    transforming XML
  • Very powerful expression language XPath
  • Transforms XML to many formats TXT, HTML, XML,
    CSV, SVG, PDF (via XSL-FO), MS EXCEL etc etc
  • Model 2X proposed to integrate XSLT with Struts
    Model 2 architecture

9
Slide 8
Apache Cocoon
  • Web development framework built around Separation
    of Concerns (SoC) and component-based development
    (COP)
  • Lego -like approach to development minimal
    coding
  • XML publishing framework with XSLT and pipelined
    SAX processing
  • Data integration framework RDBMS, LDAP, XMLDB
    etc ? HTML, WML, PDF, RTF etc

10
Slide 9
Apache Cocoon - Concepts
  • Sitemap
  • Readers
  • Matchers Selectors
  • Generators
  • Transformers
  • Serializers
  • Actions
  • XSPs Logicsheets

11
Slide 10
Cocoon Pipeline Example
ltmappipelinegt ltmapmatch pattern"search"gt ltma
pact type"search"gt ltmapgenerate
type"serverpages" src"xsp/search.xsp"
/gt ltmaptransform src"xsl/search.xsl"/gt ltma
pserialize/gt lt/mapactgt lt/mapmatchgt lt/mappip
elinegt
12
Slide 11
Cocoon XML Example
ltpublicationgt lttitlegtFoundation for Future
Database Systemslt/titlegt ltcontributorgt ltpersonn
amegtC J Datelt/personnamegt ltrolegtAUTHORlt/rolegt lt
/contributorgt ltcontributorgt ltpersonnamegtHugh
Darwenlt/personnamegt ltrolegtAUTHORlt/rolegt lt/contr
ibutorgt ltcontributorgt ltpersonnamegtFabian
Pascallt/personnamegt ltrolegtEDITORlt/rolegt lt/contr
ibutorgt lt/publicationgt
13
Slide 12
Cocoon XSLT Example
ltxsltemplate match"publication"gt ltpgt Title
ltinput type"text" name"title"
value"title"/gt lt/pgt ltpgt Authors
ltxslfor-each select"contributorrole'AUTHOR'
"gt ltxslvalue-of select"personname"/gt ltxsl
if test"not(position()last())"gt ltxsltextgt,
lt/xsltextgt lt/xslifgt lt/xslfor-eachgt lt/pgt lt/xs
ltemplategt
14
Slide 13
Cocoon Example Result
Title Foundation for Future Database
Systems Authors C J Date, Hugh Darwen
15
Slide 14
Cocoon Decision to Use
  • Many frameworks need to make decision
  • Cocoon is mature popular
  • Well supported resources, newsgroups, Wiki
  • Open Source modular
  • Many output formats
  • Minimal coding
  • RDBMS -gt XML conversion

16
Slide 15
Cocoon Usage
  • Tomcat DBCP datasource exposed using JNDI
  • XSPs logicsheets for each page
  • ESQL translates RDBMS data to XML
  • Cocoon Actions call BL

17
Slide 16
Cocoon - Benefits
  • Sitemap pipelines very powerful MVC controller
  • Excellent for prototyping
  • Extremely customizable nearly all components
    are replaceable
  • Ties together disparate data sources
  • Delivers content to disparate devices

18
Slide 17
Cocoon - Drawbacks
  • XSP mixes syntax
  • Logicsheets difficult to debug. Like C STL.
  • ESQL not ideal
  • Tries to do everything (monolithic) gt
    integration challenges
  • Aim to use as presentation layer only
  • Have separate layer that generates XML

19
Slide 18
Conclusions
  • Lots of choice too much
  • XSLT simplifies presentation layer
  • Cocoon provides framework to do XSLT with minimal
    coding
  • Keep to the core features

20
Slide 19
References
  • http//java.sun.com/blueprints/patterns/MVC-detail
    ed.html
  • http//www.w3.org/TR/xslt
  • http//cocoon.apache.org/2.0/
  • http//www.javaworld.com/javaworld/jw-12-1999/jw-1
    2-ssj-jspmvc.html
  • http//www.javaworld.com/javaworld/jw-02-2002/jw-0
    201-strutsxslt.html
Write a Comment
User Comments (0)
About PowerShow.com