Project

General

Profile

Actions

CDM Library » History » Revision 80

« Previous | Revision 80/120 (diff) | Next »
Markus Döring, 03/04/2008 04:22 PM


CDM Java Library

The CDM Library is meant to be a shared library for the between several applications which can be of any kind, i.e. J2EE having an application container, simple command line tools or swing desktop applications.

The library defines a persistent domain model, EDITs CommonDataModel, that can be serialsed and read in XML. Business logic shared between applications should be part of this library as much as possible, while application specific logic has to stay out. We hope to develop this library in collaboration with the CATE project initially.

Implementation

We use Wikipedia:Apache_Maven 2 for this project. The CDM library itself is devided into several maven subprojects, providing the following seperation of concerns:

  • MavenSite:cdmlib-commons

  • MavenSite:cdmlib-model

  • MavenSite:cdmlib-persistence

  • MavenSite:cdmlib-services

  • MavenSite:cdmlib-remote

  • MavenSite:cdmlib-io

Domain Model - cdmlib-model

Domain objects (also called business objects sometimes) are directly taken as POJOs from the CommonDataModel. The logic inherent to the domain objects are restricted to their own object graph, i.e. their own properties and related objects. But not unrelated objects available through DAOs only. Typical logic includes validation and calculations.

Property change support

We have implemented java.bean propertyChangeSupport methods for the entire cdm domain classes to send change events to registered listeners.

The TaxonomicEditor makes use of these through a data binding framework. See wiki:JavaResources#DataBinding for more.

XML binding

using JAXB

Persistence Layer - cdmlib-persistence

we use Hibernate for persistence. We run unit and integration tests for MySQL, Hypersonic, Postgres and MS SQL Server on a regular basis.

API - cdmlib-services

Work in progress. see "CdmLibrary#Servicelayer" or wiki:CdmAPI for now.

CDM Server - cdmlib-remote

That is the CdmServer community store.

Import/Export - cdmlib-io

Supported import formats:

Planned:

  • TCS+DarwinCOre+SDD

  • TaxonX

Using the CDM Library

Maven repository

To integrate the cdmlibray into your personal Maven project pelase add our Maven repository to your POM: http://wp5.e-taxonomy.eu/cdmlib/mavenrepo/

To use the cdm service package add the following dependency to you POM

     <dependency>
        <groupId>eu.etaxonomy</groupId>
        <artifactId>cdmlib-service</artifactId>
        <version>1.1-SNAPSHOT</version>
    </dependency>

Eclipse setup

To use the entire cdmlibrary with Eclipse, you need some plugins and to follow this installation guide:

*

  • install maven 2.0x commandline tools locally (http://maven.apache.org/download.html)

  • make sure Java JDK >= 1.5 is installed (JRE is not enough)

  • Set in Eclipse preferences (not project) M2_REPO java class variable, pointing to your local repository.

    • In OSX for example /Users/USERNAME/.m2/repository
    • In WinXP for example C:\Documents and Settings\USERNAME.m2\repository
    • checkout cdmlib and create eclipse artifacts:

$ svn co dev.e-taxonomy.eu/svn/trunk/cdmlib/

$ cd cdmlib

$ mvn eclipse:eclipse

  • setup new eclipse workspace

  • open/import relevant cdmlib eclipse projects into eclipse

  • Install AspectJ Development Tools (AJDT) - Plugin

(Update-Site:http://download.eclipse.org/tools/ajdt/33/update)

  • Convert the cdmlib-model to AspectJ (right mouse click on project -> AspectJ Tools -> ...)

Spring applications with cdmlib

In your own applicationContext.xml you can simply import the cdm service spring beans from the library. In addition it also needs a datasource bean and a hibernateProperties bean specific for that datasource. The CDM Library comes with an embedded hypersonic database that is super easy to use. All you need to do is to import that hsql specific spring configuration like this:

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<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.5.xsd">

    <import resource="classpath:/eu/etaxonomy/cdm/services.xml" />
    <import resource="classpath:/eu/etaxonomy/cdm/hsql-datasource.xml" />

</beans>

In case you want to define the datasource within your own applicationContext you can surely do so. For a typical mysql database it looks like this:

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<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.5.xsd">

    <import resource="classpath:/eu/etaxonomy/cdm/services.xml" />

    <bean id="dataSource"  lazy-init="true" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://192.168.2.10/cdm_build"/>
        <property name="username" value="cdm_user"/>
        <property name="password" value="why_do_i_need_this"/>
    </bean>

    <bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="properties">
            <props>
                <prop key="hibernate.hbm2ddl.auto">validate</prop>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
                <prop key="hibernate.show_sql">false</prop>
                <prop key="hibernate.format_sql">false</prop>
            </props>
        </property>
    </bean>    
</beans>

Background

Hibernate

Spring 2.0 Framework

We use the Spring 2.0 framework to develop the library and keep the coupling of components low.

Domain Models

Property Change

Useful Patterns

Aspect Oriented Programming

We use AspectJ to implement the change property crosscutting concern:

Updated by Markus Döring over 16 years ago · 80 revisions