The Web Graph Database


What follows is a pragmatic description of how to use InfoGrid to build your own Web application.

(1) In order to successfully create an Infogrid application, start by ensuring you have installed a reasonably new java jdk. It's possible to develop on either a Windows, Mac or Linux box. The Mac works best, although the jdk is always a bit behind and comes from Apple not Oracle. Windows users will not be able to rely on symbolic links, and Linux users be warned, InfoGrid has problems compiling against the OpenJDK, which comes bundled in many Linux distributions. Find out what your system's default JDK is, and if necessary replace it with Sun/Oracle?'s JDK. Different Linux distros have different ways of changing the default JDK.

(2) Install a copy of MySQL. Use the appropriate installer for your platform. It's also advisable to install a visual administration tool - on the Mac it's SequelPro. It would be nice if NetBeans? included such a feature, but oh well ...

(3) Optionally (and if you want to run all the tests) install a copy of Postgres.

(4) Download and install a copy of the latest NetBeans? IDE, use the customize option to install a copy of Tomcat version 7. You'll also need to grab a copy of Tomcat version 6 and install that alongside Tomcat 7.

(5) If you are running on Windows, download and install Cygwin - the open source UNIX shell. In the download options it's useful to install the binaries for: ssh, svn and a command line editor like vim.

(6) Create a workspace tree called ~svn/ and checkout the complete InfoGrid trunk into this directory. The easiest way is using the svn command from a shell. If you do not have a command line svn, use NetBeans? embedded svn client. The command line is far faster, use the following commend:

cd ~svn/;  svn checkout

You could of course use one of the stable tags, however the trunk is quite stable and the best version of the code, and will handle most of your library references for you, which the versions under /tags/ may not.

(7) Edit the file and set the variable "tomcat" to location of your Tomcat7 installation.

(8) Build the InfoGrid codebase and generate Javadocs from the command line like this (you should be in the /trunk/ directory):

 ig-tools/ -clean -build -doc -c ig-config/

Depending on your machine this could take well over 20 minutes to complete. You can additionally test the software by following the instructions here:

(9) Open NetBeans? and create a project group for InfoGrid. Follow the menu options: File=>Project Group=>New Group=>Folder of projects. Navigate to the directory into which you downloaded infogrid/trunk - then wait a few minutes until it is loaded. Linux users are likely to get a lot of "files are read-only" alerts if you didn't start NetBeans? from superuser!

(10) Create library references in NetBeans? for Infogrid. Navigate to: "Tools -> Libraries" select "New Library" then add:

ig-libary-jackson ... trunk/ig-vendors/libraries/ ig-libary-jee ... trunk/ig-vendors/libraries/ ig-libary-jstl ... trunk/ig-vendors/libraries/

... trunk/ig-vendors/libraries/

ig-libary-log4j ... trunk/ig-vendors/libraries/ ig-libary-mysql ... trunk/ig-vendors/libraries/ ig-library-tomcat6 ... trunk/ig-vendors/libraries/ ig-library-postgres ... trunk/ig-vendors/libraries/

(11) This is a good time to configure the the NetMeshWorld application to use MySQL and test it. Use NetBeans? to configure a connection to MySQL. Create a schema in MySQL called: netmeshworlddb. Use either NetBeans?, or mysql or a tool, ensure the user "test" with no password, has rights to create/read/write/update/delete in this schema. Then in NetBeans? configure ig-ui/testapps/ to use the database connection. Configure the applicaiton in the Properties setting to use Tomcat6. Try running the application on Tomcat.

(12) For your own application create a new directory branch alongside InfoGrid. In this example it's called example. Things will be greatly eased if you make sure the directory which contains both the InfoGrid codebase and your project folder are three levels above /trunk/, and that the location of your project is three levels below that. So, Infogrid's trunk should be in /svn/, and your project should be in /svn/ These details can be annoying, but the Ant build script depends on knowing the location of everything. If you encounter classpath errors as you try to compile (NetBeans? will tell you a certain file "does not exist"), changes can be made in /ig-tools/infogrid-ant-library.xml and /infogrid-ant-functions.xml

cd ~
mkdir svn/

(13) If you are NOT using Windows, create symbolic links from your tree to the similarly named InfoGrid modules. This will make it easier to update InfoGrid's codebase at a single location, rather than trying to keep track of numerous copies.

cd ~svn/

ln -s ../../../
ln -s ../../../
ln -s ../../../
ln -s ../../../
ln -s ../../../
ln -s ../../../
ln -s ../../../
ln -s ../../../
ln -s ../../../
ln -s ../../../
ln -s ../../../

(14) Start your own workspace tree. Call it modules.

mkdir modules

(15) Make a copy of the InfoGrid NetMeshWorld application to bootstrap your efforts. Do this by exporting the NetMeshWorld test application from svn into your own local workspace. Note: You'll now be responsible for tracking changes in this project made in and applying them yourself to your own copy. Yes, you were just told to use symbolic links instead of making copies, but J2EE makes it necessary to copy NetMeshWorld since things like "tld" files are local to a specific Web application. Use a command like this:

svn export

(16) Rename and edit the exported file and edit the build.xml to the same project name to avoid a name clash and ensure NetBeans? knows its name. If you are using Windows, in build.xml, edit the tag -

<import file="../../../ig-tools/infogrid-ant-library.xml" 

And modify it to look like this:

<import file="C:/svn/" optional="true"/>

(17) Windows users should then edit the file ig-tools/infogrid-ant-library.xml and edit the property location for the property name "" Set this to its Windows fully pathed file name e.g. C:/svn/ This works around the issue with symbolic links. If you miss this step you will not be able to compile your own application against the IG tree.

(18) Create a MySQL schema and userid for your application.

(19) In your cloned copy of NetMeshWorld, edit the web.xml and context.xml files to change the resource url so that the app will write to the correct database in MySQL. Also, provide whatever username and password you have specified for MySQL. MySQL's defaults are "root" and "root". However, DO NOT change the resource name="jdbc/netmeshworlddb"

(20) Compile and run your stolen copy of NetMeshWorld. If everything is working, it will serve the UI to localhost:8080/[YourRenamedNetMeshWorld]

You should now have a reasonable basis for developing and testing your own application. The next step is creating a model.

(21) Create a NB java project in NetBeans? and name it something like org.example.model.SubjectArea. Create a new folder under this project, called "infogrid-models"

(22) In the build.xml, add the following lines (the first line is Windows-specific, the second line for Mac or Linux):

    <import file="C:/svn/" optional="true"/>
    <import file="../../../ig-tools/infogrid-ant-library.xml" optional="true"/> 
    <target name="-pre-compile" depends="-module-setup"/>

(23) Create a model.xml file in the infogrid-models folder. Create something very simple at first, and be sure the subjectarea ID is exactly the same as the name of this Java project. An example:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE model PUBLIC '-// Model//EN' ''>
    <subjectarea ID="org.example.model.SubjectArea">
        <username>A Subject Area</username>
        <userdescription>The Subject Area is for testing.</userdescription>

        <entitytype ID="org.example.model.SubjectArea/AnEntity">
            <username>A test entity</username>
            <userdescription>A test entity</userdescription>

            <propertytype ID="org.example.model.SubjectArea/AnEntity_Name">
                <username>The name</username>
                <userdescription>The name.</userdescription>

(24) Select "Clean and build". The build might fail, but it should create a folder called "build/module-generated." Open the project's properties in NB, and in "Sources" add this folder as a Source Package Folder. Build it again and hopefully it'll create a nice jar.

(25) Incrementally improve your model, adding the entities, property types and relationship types that suit your purposes. Be sure to run a clean compile after making edits, until you can accurately edit this file without creating errors. The compiler is quite good at finding errors, and will not tolerate non-unique identifiers which are easy to create in copying and pasting. You can make use of the numerous models that come included in InfoGrid. For example, to implement InfoGrid's protection domains to control data access, under the tag <subjectarea> you would add:


To have one of your entities subtype an entity from an InfoGrid model, add the following within the <entitytype> tags:


(26) Test your model by adding it to your version of the MeshWorld app. In the properties of your MeshWorld, select "Libraries" and add the org.example.model.SubjectArea project. Then return to the "Files" tab in NB and in your MeshWorld app navigate to the folder infogrid-moduleads. Edit the file module.adv, adding the line:

<requires name="org.example.model.SubjectArea"/>

(27) Run a clean build on your project. Then try running it. You should see your subject area appear in the dropdown menus, and you should be able to bless and relate objects with types in your model.

Last modified 7 years ago Last modified on 05/09/12 01:35:07