<code class="html"> <div style="font-size:300%; color: #600;">Outdated!</div>
Please see http://cybertaxonomy.eu/cdmlib/getting-started for up-to-date documentation.
CDM Library Developers Guide¶
Regarding the installation of the development tools please refer to DeveloperApplications.
Conventions regarding api method naming etc. are found in the CdmLibraryConventions.
- CDM Library Developers Guide
See also : DeveloperApplications#Maven
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>
To create a project site use mvn site:site. Due to the number of dependencies you will have to increase the available memory by setting the MAVEN_OPTS parameter to
SET MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=512m
See also: DeveloperFaq#Addingabundletoamavenrepository
For some unclear reasons we encountered problems using maven in combination with aspectj.
We did not yet resolve this problem but at least found a work-around:
run "mvn clean" (probably not really needed)
open eclipse IDE
make sure that cdmlib-model is converted to an AspcetJ project (see Eclipse setup for detailed information) - sometimes it helps if you first remove AspectJ and then convert it again.
run "mvn install"
This seems to work at least on our computers as eclipse better compiles aspectj then maven does.
So please first try the above if you encounter any compilation problems
If it still does not work please try to install the newest eclipse aspectj plugin (for installation instructions see below)
If it still does not work please let us know
To use the entire cdmlibrary with Eclipse, you need some plugins and to follow this installation guide:
install maven 2.0.x commandline tools locally (http://maven.apache.org/download.html). Follow the instruction to install maven on your local machine.
install subclipse 1.6.x in eclipse if not yet installed (Update Site: http://subclipse.tigris.org/update_1.6.x).
make sure Java JDK >= 1.6 is installed (JRE is not enough) and JAVA_HOME is set to JDK path
checkout cdmlib and create eclipse artifacts (using e.g. tortoiseSVN):
$ svn co http://dev.e-taxonomy.eu/svn/trunk/cdmlib/ .
make sure maven has run at least one time (to create the .m2 folder). If unsure how to do this, run
mvn installin the new checked out folder ../cdmlib/cmlib-commons
Set in Eclipse preferences (not project properties) M2_REPO java class variable (menue: java-buildPath-Classpath), pointing to your local repository.
- In OSX for example /Users/USERNAME/.m2/repository
- In WinXP for example C:\Documents and Settings\USERNAME.m2\repository
setup new eclipse workspace (where ever you want but using the cdmlib folder may be comfortable
run the following commands in your cdmlib folder
$ mvn install
to compile and install the cdmlib packages in your local repository.
$ mvn eclipse:eclipse
to let maven create project dependencies and Eclipse metafiles (.project s.o.)
create the java projects:
- In Eclipse open the Import Wizard: File->Import->General->Existing Projects into Workspace.
- Choose "Select root directory". Click "Browse" and navigate to your cdmlib folder (should open by default) and confirm the file dialog.
- The projects should now show in the Import Wizard window. Select the projects you want wo work on and hit OK.
Install AspectJ compiler http://www.eclipse.org/aspectj/downloads.php , make sure you add the /lib/aspectjrt.jar to your class path and /lib/ to your path
Install AspectJ Development Tools (AJDT) - Plugin (for eclipse) (Update-Site:http://download.eclipse.org/tools/ajdt/xx/dev/update) where xx depends on your eclipse installation: xx=35 for eclipse 3.5 and xx=36 for eclipse 3.6
Referesh cdmlib-model project within eclipse
Convert the cdmlib-model to AspectJ (right mouse click on project -> AspectJ Tools -> ...).
* It is also recommended to use the EclipseCodeTemplate
In case you run into trouble try one of the following
It wasn't clear to me (PC) from the above that at some point, the following must be executed in the "cdmlib" directory. I did this after all the above steps were completed, and the build was successful.
$ mvn install
$ mvn eclipse:eclipse
How to create a new cdmlib version¶
The following steps have to be followed when increasing the cdmlib version to make all applications running
update the cdmlib version number in parent.pom and all module poms (cdmlib-common.pom, cdmlib.model.pom, ...)
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:
<?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:
<?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>
- 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.
Aspect Oriented Programming¶
We use AspectJ to implement the change property crosscutting concern: