Creating Java XML API
How to create the Java XML API
Requirements
Python >= 2.4 (>= 2.4.2 recommended since 2.4.1 has bad memory leak).
If you have Python 2.4 then you also need to download ElementTree:
Element Tree download
Java >= 1.5 (but not tested with 1.6)
Check out code from repository (or update it)
To check out code you need to have CVS read access for SourceForge ccpn repository, or use anonymous CVS access (but that is not so good, since not always up-to-date and not reliable). If you want direct access contact ccpn-dev [at] mole.bio.cam.ac.uk.
Set environment variables (csh variant form show, bash uses 'export' instead):
setenv CVS_RSH ssh
setenv CVSROOT :ext:wb104@ccpn.cvs.sourceforge.net:/cvsroot/ccpn
(where you replace 'wb104' with your username)
Create directory where you want code to go. This is called CVSDIR below.
Check code out:
cd CVSDIR
cvs co .
Or, if you already have code checked out and want to update it, then do:
cd CVSDIR/ccpn
cvs update -d .
(the -d checks out any new directories, the default is that they are not).
Run Java generation scripts
Set Python path to point to your main CCPN Python directory:
setenv PYTHONPATH CVSDIR/ccpn/python
If you have Python 2.4 then you also need to have the top ElementTree directory on your path, e.g.
setenv PYTHONPATH CVSDIR/ccpn/python:/Users/wb104/elementtree-1.2.6-20050316
The above can be set in your .cshrc file.
Change into the script directory and run the scripts:
cd CVSDIR/ccpn/python/memops/scripts_v2
python makeJavaApi.py
python makeJavaXml.py
makeJavaApi.py will fail if some required handcode has not been added into the UML. If so email ccpn-dev [at] mole.bio.cam.ac.uk.
As of 6 December 2007 the default for Java is to create an API only for memops and ccp packages. You can edit makeJavaApi.py and makeJavaXml.py to turn on other packages, or to turn off, for example, ccp.
Create symbolic links
Create symbolic links in xmlApi directory to code in shared directory (which is written by hand).
cd CVSDIR/ccpn/java/xmlApi/memops
ln -s CVSDIR/ccpn/java/shared/memops/universal .
ln -s CVSDIR/ccpn/java/shared/memops/general .
ln -s CVSDIR/ccpn/java/shared/memops/format .
Note the last line above doesn't work straight off if you are using ant to compile the code. So ant likes to compile everything in every directory. But memops/format/sql contains old code so that should not be compiled. Either tell ant not to compile in that directory, or instead of the above linking for memops/format do instead:
cd CVSDIR/ccpn/java/xmlApi/memops
mkdir format
cd format
ln -s CVSDIR/ccpn/java/shared/memops/format/xml.
We need similar linking inside ccp:
cd CVSDIR/ccpn/java/xmlApi/ccp
ln -s CVSDIR/ccpn/java/shared/ccp/general .
Once you have run created the Java code once and then created the symbolic links, you do not need to do this step again.
(An alternative strategy is to have a script which copies stuff from both directories to a common directory.)
Compile Java code
The Java XML API ends up in CVSDIR/ccpn/java/xmlApi. Change into this directory and compile the code.
cd CVSDIR/ccpn/java/xmlApi
javac -J-Xms256m -J-Xmx256m memops/api/Implementation/MemopsRoot.java
javac -J-Xms256m -J-Xmx256m memops/xml/*.java ccp/xml/*/*.java
The first javac should compile all the API code. The second javac should compile all the XML code. (Sometimes Java figures out the dependencies and the second one is not needed.)
This step might well give Java compilation errors. If so email ccpn-dev [at] mole.bio.cam.ac.uk.