CDM Library » History » Revision 86
« Previous |
Revision 86/120
(diff)
| Next »
Andreas Müller, 08/05/2008 11:56 AM
CDM Java Library¶
- Table of contents
- 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 serialised 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 are developing this library in collaboration with the CATE project initially, but we seeking development collaboration with other projects like Key2Nature and PESI as well.
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
Current layers¶
Planned layers¶
Reuse service layer for all clients (Eclipse editor, CDM Server, CATE webapplication) and create DTOs made of preloaded domain classes instead of seperate classes.
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¶
For data exchange purposes, we want to serialize/deserialize the domain objects of the cdmlib-model to/from XML format using the JAXB framework.
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:
- BerlinModel database
Planned:
TCS+DarwinCOre+SDD
TaxonX
For more information about data conversion see SampleDataConversion
Releases¶
Releases are currently in 2 flavours:
Versioning strategy¶
Starting with the frozen CommonDataModel v1 we release minor upgrades for every model change in the library. Inferior version numbers (3rd level) are for bug-fixes and library extensions, which do not change the core model classes. This guarantees that all bug-fix releases are still working on the same database structure.
For example: Svn:tags/cdmlib/rel_1.1.0 and rel_1.1.8 will work both on the same database structure as generated by hibernate. But for rel_1.2.0 you will have to update or better recreate your database, currently still losing all your data. In a later stage we will provide stable import/export formats to migrate your data to new versions.
Sourcecode via Subversion¶
The Maven project is available from our subversion server. For releases please see:
http://dev.e-taxonomy.eu/svn/tags/cdmlib/
Eclipse plugin¶
For the cdmlib-service module we host an Eclipse plugin update site which is available here:
http://wp5.e-taxonomy.eu/cdmlib/update/
CDM Library Usage¶
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 (adapt the right version number !!)
<dependency> <groupId>eu.etaxonomy</groupId> <artifactId>cdmlib-service</artifactId> <version>1.X</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" 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¶
- Hibernate works with most current RDBMS. See supported databases
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 Andreas Müller almost 16 years ago · 86 revisions