Install:

  1. intro
  2. configuration

Prerequisites:

  1. Apache Ant
  2. Servlet container
  3. DBMS

Tutorial:

  1. Create database
  2. Build TaskHeapDemo
  3. Run TaskHeapDemo
  4. Create your project
  5. Create your structs
  6. Create your nodes
  7. Create your config
  8. Create your UI
  9. Customize your display

More info:

  1. sandev.org
  2. sandservices.com
   

SANDev readme:

intro

Welcome to the SANDev readme. This file explains how to install and get started. For general info on Structs and Nodes Development (SAND), please see sandev.org. If you are reading this online, you can download the latest SANDev release from sourceforge and unzip to a convenient location on your hard drive. Alternatively you can pull down the latest via CVS. Once you have the source, define SAND_HOME to point to the sand directory (for example C:\sand, /dev/sand, or wherever you put it).


J2SE SDK

Install java as appropriate for your platform. After installing, define JAVA_HOME to be the location where it was placed. The build will look for JAVA_HOME/lib to find .jar files to compile with.

SAND is currently set up to work with java 1.5. If you compiling with 1.4, then the build will be unable to resolve some doclet classes that were introduced in 1.5. These are needed for symbol resolution when compiling the generators, but their content is not referenced so you can get past this by defining a few empty stub classes in SAND_HOME/apps/basics/build/generate/org/sandev/generator. To make the symbols resolve, create com.sun.javadoc class stubs for:

  • AnnotationDesc.java
  • AnnotationTypeDoc.java
  • ParameterizedType.java
  • TypeVariable.java
  • WildcardType.java

At the time of this writing, the core SAND source doesn't make use of any of the 1.5 features, so we can continue to support 1.4. If you are using 1.5 you may see a few "uses unchecked or unsafe operations" compiler messages from the earlier collections use.


Servlet container

The output of a SANDev build is a .war file which is deployed to the local servlet container. Apache Tomcat is pretty much assumed, although references to it are fairly minimal (primarily the platform build control targets) should you need to swap this out. In any case after installing a servlet container, set the TOMCAT_HOME environment variable to where the runtime can be found (for example C:\Program Files\Apache Software Foundation\Tomcat 5.0, /dev/apache-tomcat-6.0.13 or wherever you put it).


Extended Java support

SANDev requires a few things beyond basic java. One way to deal with this is to pull down J2EE, but that's frequently overkill. The recommended way is to add the extra .jars to tomcat lib to supplement the servlet support. Here's what you need to add:

  1. Support for Mail: Download javamail and the JavaBeans Activation Framework that it needs. Copy mail.jar and activation.jar into tomcat lib.
  2. Support for JMS: If you will be building a distributed system and using JMS messaging, then add the JMS support files from your JMS messaging service into tomcat lib. If you are not using JMS, then you can download the JMS API and copy the .jar files into tomcat lib to compile. JMS is not required at runtime unless you are using AuthorizedJMSMessager (located in SAND_HOME/platform/tools/src/org/sandev/tools/util).

The build looks in J2EE_HOME/lib for the .jar files it needs to compile with, so set the J2EE_HOME environment variable accordingly (for example C:\Program Files\Apache Software Foundation\Tomcat 5.0\server, /dev/apache-tomcat-6.0.13 or wherever this is installed).


Persistency and query support

SAND handles all persistency and query processing through a generalized Persister interface. The Persister implementation included in SANDev is based on JDBC, so you will need a JDBC database to run.

By default, the build is currently set up assuming you are using PostgreSQL, although HSQL and MySQL have been used in the past. Any database with a reasonably modern JDBC driver should work. Install the database according to your platform, and place the driver into the tomcat lib area so it will be found at runtime.

If you are using a database other than PostgreSQL, then you will need to change a couple of lines in the sandpersist declaration for the deployment you are building. So for example you might edit SAND_HOME/deploy/TaskHeapDemo/build/build.xml and change the lines that look like:

    structMapperClass="org.sandev.generator.PostgreSQLStructMapper"
and
    dataSource="direct:org.postgresql.Driver,jdbc:postgresql:taskheap,${LOCDB_USERPASS}"
to reflect the database you are using. For the dataSource, refer to your database documentation. For the structMapperClass, you can specify the name of an existing StructMapper implementation (for example MySQLStructMapper, DefaultSQLStructMapper) or write your own custom mapper to reflect how things structs should be translated into tables.

Depending on your database and JDBC driver, you may need to create the database named in the dataSource. Once the database is created, schema initialization and maintenance is handled automatically by the build.

If you are using the default build, set the LOCDB_USERPASS environment variable to be username/password for the database user.


Apache Ant

The SANDev build is based on extensions to Apache Ant, which you will need to download and install if you haven't already got it. To build, you will need both ant.jar and sandbuild.jar in your classpath, for example:

    CLASSPATH=c:\apache-ant-1.6.2\lib\ant.jar;c:\sand\platform\sandbuild\env\sandbuild.jar
or
    /Developer/Java/Ant/lib/ant.jar:/dev/sand/platform/sandbuild/env/sandbuild.jar

The release zip contains sandbuild.jar prebuilt. If you need to rebuild this, simply

    > cd $SAND_HOME/platform/sandbuild/build
    > ant clean
    > ant


Building the sample TaskHeap application

To build the sample app:

    > cd $SAND_HOME/deploy/TaskHeapDemo/build
    > ant

To access the sample app, follow the last link in the "Generated tools" section of the deployment doc page. If this link is broken or the build failed, verify the prerequisite software is installed and the main environment variables referenced in $SAND_HOME/apps/basics/build/mainbuild.xml are defined correctly.

The SANDev build process has the following stages:

  1. Load: The current project and any of the projects it requires are loaded and organized in dependency order.
  2. Code generation: The code generators are run according to their scope (local project, cross project, struct, node, or both).
  3. Standard build: Compile, .jar, .war, javadoc for each project.
  4. Deployment: .war repackaging and copying to local deployment.

For a development build (as opposed to a release build), the servlet container is bounced by default to avoid accumulating garbage.

The build process checks dependencies as best it can to make incremental development builds as fast as possible. So typing ant again will do an incremental build of whatever has changed. Use ant scrub to clear everything and rebuild from scratch.

If you want to play with the TaskHeap app, login as admin/whatever to start.


Create your project

A typical SAND project consists of an application and a deployment. So for a project called MyApp you might have:

  • sand/apps/MyApp
  • sand/deploy/MyAppMain
each with the following subdirectories and files:

The easiest way to set up a new SANDev project is to run the initproj script in the TaskHeapDemo deployment build directory: ant -f initproj.xml.


Create your structs

A struct is a plain java class declaration with a name ending in "Struct" which is placed into the structs source directory. So the source file would be something like:

    sand/apps/MyApp/src/org/MYDOMAIN/MyApp/structs/MyDataStruct.java
For some working struct declarations see:
TaskStruct.java or PlanComponentStruct.java

A struct contains only protected data member variables and meta tags. The base types for data members can be:

  • int, long, double, String, Date
  • a reference to a persistent struct (long with reference metatag)
  • another struct type (except persistent structs which may not aggregate)
  • arrays of any of the above
Types can be further refined in generated code using metadata tags. At the class level, a struct declares itself using

By convention the struct level tags are named StructTag*. Use the FieldTag* tags for member data variable declarations. See org.sandev.generator.tags for a complete list of metadata tag descriptions.

A struct may extend another struct.

By default, the AuthFilter will deny all access to messages not explicitely authorized. You will need to edit the AuthFilter implementation (in the UserLookup dir) for appropriate access to each new struct you define.


Create your nodes

A node is a plain java class declaration with a name ending in "NodeDecl" which is placed into its own source package. So the source file would be something like:

    sand/apps/MyApp/src/org/MYDOMAIN/MyApp/MyLogic/MyLogicNodeDecl.java
For some working node declarations see:
PlanCalculatorNodeDecl.java or TaskHeapUINodeDecl.java

A node may declare configuration parameters using the primitive types int, long, double, String, Date and the associated subset of struct metadata. A node declares all of its communication requirements and supported processing through:

tags. The tags are translated into supporting code in the generated NodeBase source file and used by the business logic in the hand coded Node file. For MyLogicNode, the source file structure is:
    public class MyLogicNodeDecl
    public class MyLogicNodeBase extends MyLogicNodeDecl //generated file
    public class MyLogicNode extends MyLogicNodeBase

The node declaration describes what messages are processed. Where messages are sent to and received from is set in the configuration.


Create your config

The bootstrap data for your application, the server(s) it runs on, and the nodes that make up the runtime architecture are declared using the Configuration Editor which is accessed via a link off the deployment project docsite page. The configuration is saved in the config.xml file in the env directory of the deployment. For an example see deploy/TaskHeapDemo/env/config.xml.

Until the graphical configuration editor is completed, we recommend placing a drawing of your configuration into the intro.html file for your deployment to serve as a reference. For details on the configuration structure, see the description of the struct in the basics project. Also see Messaging.html in the top level docs.


Create your UI

The screens that make up your application, the forms, custom tabs, custom action buttons, and generated output values are declared using the SandUI Editor which is accessed via a link off the deployment project docsite page. The UI definition is saved in the SandUI.xml file in the env directory of the deployment and becomes part of your deployment .war file. For an example see deploy/TaskHeapDemo/env/TaskHeapDemoSandUI.xml.

For details on the SandUI structure, see the description of the struct in the ui project. Also see UIGen.html in the top level docs.


Customize your display

With the SandUI and supporting code defined, the default templates provide enough functionality to enter development data, which completes the raw material for creating a custom UI display. To customize, edit the XSLT templates are stored in the webapp/templates subdirectory of the deployment. Rebuild to redeploy the changes.

During the early stages of UI development, it is sometimes helpful to retrieve the raw XHTML output from your application, save it to a file, and then work applying your template to that file directly rather than rebuilding and redeploying the app for each minor change. To retrieve the unconverted XHTML output from your app, specify the raw=true URL parameter. The base UIActionHandler also allows you to specify the screen, message class, uniqueID and action button name. Some examples:

    http://localhost:8080/THD_TaskHeapDemo/TaskHeap?scr=Main&class=Resource&id=1202 http://localhost:8080/THD_TaskHeapDemo/TaskHeap?scr=Main&class=Resource&id=1202&button=edit http://localhost:8080/THD_TaskHeapDemo/TaskHeap?scr=Main&class=Resource&id=1202&raw=true

See the templates in the TaskHeapDemo webapp directory for other useful techniques.