cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@cocoon.zones.apache.org
Subject [DAISY] Created: Usage
Date Sun, 25 Nov 2007 03:15:48 GMT
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:
<html>
<body>

<h1>Introduction</h1>

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

<p class="note">This guide assumes that you use cocoon-databases-impl artifact
with version at least <strong>1.0.0-RC2</strong>.</p>

<h1>Datasource declaration</h1>

<p class="note">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.</p>

<p>Consider you have following datasource declaration in <tt>cocoon.xconf</tt>
file:</p>

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

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

<pre>&lt;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"&gt;

    &lt;bean name="javax.sql.DataSource/personnel" class="org.apache.cocoon.databases.bridge.spring.avalon.SpringToAvalonDataSourceWrapper"&gt;

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

    &lt;/bean&gt;

&lt;/beans&gt;
</pre>

<p>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.</p>

<p class="warn">Configuration of wrapped bean uses DriverManagerDataSource class
that <strong>does not provide any support for connection pooling</strong>. You
may want to consider integration of external libraries.<br/>
See
<a href="http://www.springframework.org/docs/api/org/springframework/jdbc/datasource/DriverManagerDataSource.html">javadocs
comments</a> of DriverManagerDataSource class for details.</p>

<p class="note">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.</p>

</body>
</html>

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

Mime
View raw message