The following software prerequisites must be installed and in working order before building gridrus from source.
The following procedure will setup the required environment variables and software tools for building gridrus
To access the CVS 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 lead developer for access.
To check out gridrus, type the following command in the directory where you like gridrus to be checked out. The gridrus-core directory you have checked out will be referred as GRIDRUS_HOME
$> setenv CVS_RSH ssh $> cvs -d:ext:<USER>@gridrus.cvs.sourceforge.net:/cvsroot/gridrus co gridrus/gridrus or (a particular development version) $> cvs -d:ext:<USER>@gridrus.cvs.sourceforge.net:/cvsroot/gridrus co -r <BRANCH_NAME> gridrus/gridrus
NOTE:
The source distribution of gridrus-core 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 | | `-- gridrus-x.x ; | | `-- gridrus ; 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 ; GridRUS sub-modules | |-- service ; service sub-module | |-- core ; core sub-module | `-- client ; client sub-module | |-- build.xml ; the main build file `-- build.properties ; the build configuration file
|-- docs ; this documentation | |-- javadoc ; the javadoc | |-- ... ; other documentation |-- build.xml ; server installation script `-- gridrus.war ; deployable service archive
|-- bin ; executable, shell scripts, etc.. |-- docs ; documentation | |-- javadoc ; the javadoc | |-- ... ; other documentation `-- build.xml ; client installation script
$> 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 <GRIDRUS_HOME> $> ant build-client
$> cd <GRIDRUS_HOME> $> ant test
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 gridrus 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
GridRUS uses Maven APT to generate documentation from presentation neutral XML sources.
To preview the document while authoring
$> cd ${GRIDRUS_HOME}/
$> mvn siteDevelopers are encouraged to adopt the Java coding convention to ensure consistency in the codebase. The following guidelines should be observed
Java packages in gridrus should start with org.icenigrid.gridrus.function. function is a self-contained functionality provided as part of gridrus, 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 GridRUS 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 gridrus follows W3Cs naming convention.
http://www.icenigrid.org/<year>/<month>/<context>/<sub-context>
Example URIs
http://www.icenigrid.org/2004/11/service/gridrus
The DOM4j library is used throughout GridRUS for parsing and constructing XML document.