Return-Path: Delivered-To: apmail-cocoon-docs-archive@www.apache.org Received: (qmail 98414 invoked from network); 16 Nov 2007 20:34:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Nov 2007 20:34:55 -0000 Received: (qmail 70252 invoked by uid 500); 16 Nov 2007 20:34:42 -0000 Delivered-To: apmail-cocoon-docs-archive@cocoon.apache.org Received: (qmail 70216 invoked by uid 500); 16 Nov 2007 20:34:42 -0000 Mailing-List: contact docs-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: docs@cocoon.apache.org List-Id: Delivered-To: mailing list docs@cocoon.apache.org Received: (qmail 70204 invoked by uid 99); 16 Nov 2007 20:34:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Nov 2007 12:34:42 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.67] (HELO cocoon.zones.apache.org) (140.211.11.67) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Nov 2007 20:34:32 +0000 Received: from cocoon.zones.apache.org (localhost [127.0.0.1]) by cocoon.zones.apache.org (8.13.7+Sun/8.13.7) with ESMTP id lAGKYPDB015276 for ; Fri, 16 Nov 2007 20:34:25 GMT Message-ID: <3832371.1195245265569.JavaMail.daisy@cocoon.zones.apache.org> Date: Fri, 16 Nov 2007 20:34:25 +0000 (GMT+00:00) From: daisy@cocoon.zones.apache.org To: docs@cocoon.apache.org Subject: [DAISY] Created: Usage Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org A new document has been created. http://cocoon.zones.apache.org/daisy/documentation/1424.html Document ID: 1424 Branch: main Language: default Name: Usage Document Type: Cocoon Document Created: 11/16/07 8:34:00 PM Creator (owner): Grzegorz Kossakowski State: publish Parts ===== Content ------- Mime type: text/xml Size: 3080 bytes Content:

Introduction

This document describes steps needed for making datasources defined as Spring beans to be working in Avalon components (like SQLTransformer).

This guide assumes that you use cocoon-databases-impl artifact with version at least 1.0.0-RC2.

Datasource declaration

Migration of datasources is not mandatory. You can leave Avalon-style declaration of datasources untouched and use such declared database connection in both Avalon and Spring components. Nevertheless, it's highly recommended to migrate to Spring declarations because they will be the only one actively supported in future versions of Cocoon Databases block.

Consider you have following datasource declaration in cocoon.xconf file:

 <datasources>
    <jdbc logger="core.datasources.personnel" name="personnel">
      <pool-controller max="10" min="5"/>
      <dburl>jdbc:hsqldb:hsql://localhost:3306/cocoondb</dburl>
      <user>sa</user>
      <password></password>
    </jdbc>
  </datasources>

Then the only thing you have to do is to create file named datasources.xml in META-INF/cocoon/spring folder of one of your blocks with following contents:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <bean name="javax.sql.DataSource/personnel" class="org.apache.cocoon.databases.bridge.spring.avalon.SpringToAvalonDataSourceWrapper">

        <property name="wrappedBean">
            <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
              <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
              <property name="url" value="jdbc:hsqldb:hsql://localhost:3306/cocoondb"/>
              <property name="username" value="sa"/>
              <property name="password" value=""/>
            </bean>
        </property>

    </bean>

</beans>

When it comes to configuring DataSource it's all you have to do. What's important datasource configured that way will be working just fine with old Avalon components.

Configuration of wrapped bean uses DriverManagerDataSource class that does not provide any support for connection pooling. You may want to consider integration of external libraries.
See javadocs comments of DriverManagerDataSource class for details.

When you don't plan to use your database connection in Avalon-based components you can resign from declaring wrapping bean and only declare wrapped bean on its own.

Collections =========== The document belongs to the following collections: cdocs-databases-bridge