cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Boris Goldowsky <bgoldow...@cast.org>
Subject Sample Cocoon 2.2 + Database app
Date Fri, 06 Jun 2008 12:31:25 GMT
So I've been slowly figuring out how to integrate Cocoon 2.2, Hibernate,
and a database.  Many google- and mailing-list-archive searches later, I
have a working sample block that may be useful to others so I will make
it available here. 

Thanks are due to many members of this list for providing the hints I
needed, and to colleagues at CAST who know more about this than I.
I am by no means an expert on this, so I am not putting this forward as
a shining example of best practices.  But if any of the more experienced
folks on this list would like to take a look and give me any critiques,
I'd be very happy for that.

What the sample block does:
  - based on the Cocoon 2.2 archetype block, so you can run it
    standalone
  - connects to a database via Spring and Hibernate
  - The hibernate mapping file is used to generate corresponding Java 
    classes (via maven-hibernate-plugin)
  - The mapping file is also used to configure the database 
    (schema will be created or updated as necessary when the app
    is started)
  - Single hibernate session per request (via sitemap listener)
  - Database access done through service-class methods 
    which are automatically wrapped in database transactions

The impressive thing to me is that Cocoon lets all this be done with
actually a pretty small amount of code - about 20 files all told.

I put the source at http://udleditions.cast.org/misc/cewf-sample.zip
(if you're curious, the UDL Editions site is also a Cocoon app, of a
very different sort)

How to use it:

1. unzip

2. create an empty database (I use PostgreSQL, so that's what it's
   configured for.  If you use a different database, you'll need
   to adjust the dependencies and configurations)

3. put database name, username, password into
   src/main/resources/META-INF/cocoon/properties/db.properties

4. mvn jetty:run  [take short nap]

5. http://localhost:8888/cewf/

Comments, suggestions, improvements welcome.  This will be the basis of
a large project, so I'd like to get the basic structure solid at the
start.

Bng

-- 
Boris Goldowsky
Director of Technology
CAST, Inc. - http://www.cast.org/




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message