CdmLibraryDevelopersGuide » History » Revision 17
« Previous |
Revision 17/30
(diff)
| Next »
Niels Hoffmann, 06/14/2010 01:26 PM
CDM Library Developers Guide¶
NOTE
Regarding the installation of the development tools please refer to DeveloperApplications.
Conventions regarding api method naming etc. are found in the CdmLibraryConventions.
- Table of contents
- CDM Library Developers Guide
- Background
Maven repository¶
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
In order to install a file (e.g. a JAR) in you local repositry:
mvn install:install-file \ -DgroupId=<group-id> \ -DartifactId=<artifact-id> \ -Dversion=<version> \ -Dfile=<path-to-file> \ -Dpackaging=<packaging> (i.e. jar) \ -DgeneratePom=true
e.g. To install aspectjrt version 1.6.2 in your local repositry:
mvn install:install-file -DgroupId=aspectj -DartifactId=aspectjrt -Dversion=1.6.2 -Dfile=aspectjrt.jar -Dpackaging=jar -DgeneratePom=true
In order to deploy a jar to a remote repository deploy:deploy-file
should be used, since this plugin will also create the *.sha files with a hash.
Example: Prepare aspectjrt version 1.6.2 for a remote repository. With this command you in fact create the artifact in local temporary repository and then copy the resulting files to the remote repository:
mvn deploy:deploy-file -DgroupId=aspectj -DartifactId=aspectjrt -Dversion=1.6.2 -Dpackaging=jar -Dfile=aspectjrt.jar -Durl=file:///D:/tmp/repo
It is also possible to directy deploy to the remote repository via scp:
mvn deploy:deploy-file -DgroupId=aspectj -DartifactId=aspectjrt -Dversion=1.6.2 -Dpackaging=jar -Dfile=aspectjrt.jar -Durl=scp://you@192.168.1.17/var/www/wp5.e-taxonomy.eu/cdmlib/mavenrepo/org/aspectj/aspectjrt -DgeneratePom=true
Of course the repository must be configured in the ~/.m2/settings.xml file. The repository is accessed with SCP, authentication is done with public/private key. I could not jet get to work the delpoying via scp, though (Andreas K).
eg:
<servers> <server> <id>wp5.e-taxonomy.eu</id> <username>you</username> <passphrase>XXXXXXXXXXXX</passphrase> <filePermissions>775</filePermissions> <directoryPermissions>775</directoryPermissions> <privateKey>/Users/you/.ssh/id_rsa</privateKey> </server> </servers>
Also see: How do I install a file in my local repository along with a generic POM
Using maven¶
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 Project-clean
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
Eclipse setup¶
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.4.x in eclipse if not yet installed (Update Site: http://subclipse.tigris.org/update_1.4.x).
make sure Java JDK >= 1.5 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 install
in the new checked out folder ../cdmlib/cmlib-commonsSet 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=33 for eclipse 3.3 and xx=34 for eclipse 3.4
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
Install issues¶
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, ...)
update the
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 Niels Hoffmann about 14 years ago · 17 revisions