The following software prerequisites must be installed and in working order before building gridsam from source.
The following procedure will setup the required environment variables and software tools for building GridSAM
To access the SVN repository you will need to have a SourceForge account.
To gain write access, you need to be a member of the developer group. Please contact the GridSAM project administrator for access.
To check out gridsam, type the following command in the directory where you like gridsam to be checked out. The gridsam-core directory you have checked out will be referred as GRIDSAM_HOME
$> svn co https://gridsam.svn.sourceforge.net/svnroot/gridsam/trunk or (a particular development tag version) $> svn co https://gridsam.svn.sourceforge.net/svnroot/gridsam/tags/<BRANCH_NAME>
NOTE:
The source distribution of gridsam2 has the following directory structure
. |-- target ; maven output directory of a build | |-- classes ; java classes compiled from source | |-- dist ; contain different version of the binary distribution | | `-- gridsam-x.x ; | | `-- gridsam ; the directory containing the binary distribution | | ; (see next section) | |-- javagen ; temporary directory for dynamically generated classes | |-- javagen-nc ; temporary directory for dynamically generated sources | `-- surefire-reports ; containing junit test reports |-- dist | |-- client ; client binary distribution created by "build-client" | |-- server ; server binary distribution created by "build-server" |-- src ; source code | |-- doc ; root of the documentation directory |-- modules ; GridSAM sub-modules | |-- service ; service sub-module | |-- core ; core sub-module | |-- client ; client sub-module | |-- schema ; XML-to-Java sub-module | |-- broker-plugin ; simple, round-robin, GridSAM instances broker sub-module | |-- pom.xml ; Maven2 configuration file |-- build.xml ; the main build file `-- build.properties ; the build configuration file
|-- config ; configuration files |-- |-- ddl ; database SQL config scripts |-- docs ; this documentation | |-- javadoc ; the javadoc | |-- ... ; other documentation |-- build.xml ; server installation script `-- gridsam.war ; deployable service archive
|-- bin ; executable, shell scripts, etc.. |-- conf ; configuration file |-- data |-- |-- examples ; example JSDL files |-- docs ; documentation | |-- javadoc ; the javadoc | |-- ... ; other documentation `-- build.xml ; client installation script
The <GRIDSAM_HOME>/build.xml is the primary 'make' file used by Ant to build the module and execute any junit tests. The build.xml file defines ant build targets. Read the build.xml file for more information. Here are some of the useful targets:
$> ant -projecthelp Buildfile: build.xml Main targets: build-all build the server, client and documentation build-client build the client build-doc build the documentation build-server build the server test performs tests
$> cd <GRIDSAM_HOME> $> ant build-client
$> cd <GRIDSAM_HOME> $> ant test
NOTE
Developers are encouraged to use the org.apache.commons.logging API for fine-grained control of verbosity (e.g. severe, warning, debug), format (e.g. minimal, timestamped) and output (e.g. stdout, file, socket) of logging messages instead of the System.out.println() approach. It is the preferred practice to associate a org.apache.commons.logging.Log with each class you create.
package mypackage; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class MyClass { // the class logger. The name of the logger is the same as the fully-qualified // class name private static final Log sLog = LogFactory.getLog(MyClass.class); public void myMethod(){ sLog.debug("this is a debug message"); sLog.info("this is a informational message"); sLog.warn("this is a warning message"); sLog.error("this is a warning message"); try { // critical work here... } catch (SomeException e){ sLog.error("we have encountered an error", e); } } } Unit Testing JUnit is a regression testing framework. It is a powerful and simple tool to unit test a piece of functionality or a class against a set of requirement. Developers are encouraged to write JUnit TestCase for each class they have created, or at least for any well-defined piece of functionality. The gridsam build system will automatically execute all junit.framework. TestCase derived classes that has class name ending with *TestCase.java unless excluded in the build.xml file. A sample test case class looks like the following package mypackage; import junit.framework.TestCase; public class MyClassTestCase extends TestCase { public MyClassTestCase(String args){ super(args); } public void testMethodAWithNullParameter(){ MyClass c = new MyClass(); assertTrue(c.methodA(null)); } public void testMethodAWithStringParameter(){ MyClass c = new MyClass(); assertTrue(c.methodA("some string")); } }
Each method in the TestCase that starts with testXYZ() defines a test case. junit.framework.TestCase provides a collection of assertXYZ() method to assert truth of expected behaviour of the class you are testing. If any of the assert statement is failed, the test will fail. Test output can be found in the build/test/TEST-name-of-test-class.
NOTE
Developers are encouraged to adopt the Java coding convention to ensure consistency in the codebase. The following guidelines should be observed
Java packages in gridsam should start with org.icenigrid.gridsam.function. function is a self-contained functionality provided as part of gridsam, such as "webservice", "core", etc..
Dynamically generated classes should not be in the src/java directory. They should be created at build time. These classes are likely to be changed when the schema or WSDL changes. It is difficult to manage these classes if they are version-controlled.
Implementation classes that implements a well-defined interface should live in an impl package in the package of the API classes. The Factory/Builder pattern should be used to allow pluggable implementation. The core implementation of GridSAM uses Apache Hivemind to provider inversion of control styled dynamic composition of runtime objects.
Code should be documented using the Javadoc standard.
This section describes guideline for authoring and processing WSDL and XSD schemas.
XML Namespace URIs used in gridsam follows W3Cs naming convention.
http://www.icenigrid.org/<year>/<month>/<context>/<sub-context>
Example URIs
http://www.icenigrid.org/2004/11/service/gridsam
The DOM4j library is used throughout GridSAM for parsing and constructing XML document.