Using the Examples

From ControlTier

Jump to: navigation, search

The Examples provide working models and processes that you can easily load into your ControlTier server and see working.

Each example is designed to be self-contained, and uses the source-based development method to organize and store the necesary model definitions and templates. The examples roughly correspond to the structure described in the How to use ControlTier.

Contents

Troubleshooting

If you have any problems running the examples, a solution might be found here:

Install ControlTier

Make sure you have met the prerequisites and installed ControlTier according to the Installing ControlTier instructions.

Create a New Project

Create a Project in Workbench called "demo". You can do this in two ways:

  • Navigate to the Workbench Admin page, and choose "Create Project". Enter the name "demo" and click Save. (After a new installation, you can also do this from the Home page.)

OR

  • On the command-line, execute the command ctl-depot -p demo -a create
Note: in all of the examples, the name of the Node used is assumed to be "localhost". If you have installed ControlTier using a different default Node name, you should follow the instructions in Troubleshooting the Examples#Using a different Node name before running each example.

Running an Example

Once ControlTier is installed, you can get started with any of these projects using this sequence of steps, just replace the word EXAMPLE with one of the existing example directories:

  1. ctl -p demo -m ProjectBuilder -c Register -- -xml $CTIER_ROOT/examples/EXAMPLE/projectbuilder.xml -install
    • This loads a ProjectBuilder object definition into the ControlTier Server for the example named EXAMPLE.
  2. ctl -p demo -t ProjectBuilder -o EXAMPLE -c Build
    • This builds the code for the example named EXAMPLE, and performs the necessary loading and deployment for the objects in the example.

Each example's object models are defined in the following way:

  • A templates directory holds two files:
    • defaults.xml
      • Modify this file to change the directory paths used in the example, and to customize things like Port numbers, and your Node name.
    • default-object.xml
      • This is a template which uses the defaults.xml file to generate the actual object model loaded by the ProjectBuilder.

When you run the Build command, the templates are used to generate a file called default-object.xml. This is the concrete model loaded into the server.

Subsequent directions are included in each example.

Further Customization

Feel free to modify the examples or copy them completely as a starting point for your own solutions.

Once you have modified the templates/default-object.xml file, re-run the Build command to load the changes into the server:

ctl -p demo -t ProjectBuilder -o EXAMPLE -c Build

(Replace Example with your object name.)

If you want to modify the example model, be aware of these caveats:

You should modify the file templates/default-object.xml and not the top-level file named default-object.xml.

When you run the Build command, the default-object.xml file will be regenerated from the template.

Duplicating the Examples

If you want to complety duplicate an example and use it as a starting point, you may want to modify the projectbuilder.xml file to specify a new name for your code project.

Edit the file and change this:

...
<deployment 
   type="ProjectBuilder"
   name="builder-simple" 
   description="ProjectBuilder for the builder-simple example"
   basedir="${env.CTIER_ROOT}/examples/builder-simple"
   installRoot="${env.CTIER_ROOT}/examples/builder-simple/target"      
   >
...
  1. Change the name=".." attribute to the new name for your code project.
  2. Change the basedir="..." and installRoot="..." directories, to point to the new project base and target dirs for your code project.

It is also useful if you do the same change in the templates/default-object.xml so that all of the Objects defined there will match the same name as your ProjectBuilder (and hence your entire code project). You can of course use any names you wish, but it is a good idea to rename them from the values used for the example.

Development