|
GettingStarted
This page provides documentation on using Cairngen.
Getting Started with CairngenGetting started with Cairngen is pretty simple. Begin by extracting the build directory to the root of your Flex project, or by creating a General Eclipse Project and modifying the Cairngen project.properties file to reflect your environment and project settings. If you are familiar with ANT, this will be very straight forward and you should be up and running in no time at all. Cairngen is completely configurable. Developers can modify the Cairngorm templates, properties files and build as needed to suite their particular needs. Code generation can be viewed in real time via the console. By default details of all generated code are written to a log file in your project’s root directory, this can be disabled if desired. Setting Up CairngenSetting up Cairngen is quick and easy, just follow these simple steps:
All Cairngorm template classes can be modified as needed. The template files are located in the build/templates/cairngorm/release directory. Generating a Cairngorm ProjectThe Cairngen build file contains a default target "main" which will create the typical Cairngorm project structure:
In addition the main target will also create your applications ModelLocator, FrontController and Services.mxml and generate them to the appropriate packages. The following example demonstrates the console output when generating a Cairngorm project: Buildfile: C:\workbench\ericfeminella\cairngen\build.xml
log:
delete-cairngorm-directories:
[echo] @Invoking Cairngen on [CairngenExample] --> Deleting Cairngorm directories
create-cairngorm-directories:
[echo] @Invoking Cairngen on [CairngenExample] --> Creating Cairngorm directories
[mkdir] Created dir: C:\workbench\CairngenTestProject\src\com\ericfeminella\cairngen\business
[mkdir] Created dir: C:\workbench\CairngenTestProject\src\com\ericfeminella\cairngen\commands
[mkdir] Created dir: C:\workbench\CairngenTestProject\src\com\ericfeminella\cairngen\control
[mkdir] Created dir: C:\workbench\CairngenTestProject\src\com\ericfeminella\cairngen\events
[mkdir] Created dir: C:\workbench\CairngenTestProject\src\com\ericfeminella\cairngen\model
[mkdir] Created dir: C:\workbench\CairngenTestProject\src\com\ericfeminella\cairngen\view
[mkdir] Created dir: C:\workbench\CairngenTestProject\src\com\ericfeminella\cairngen\vo
clean:
create-model-locator:
[echo] @Invoking Cairngen on [CairngenExample] --> Generating file(s): ModelLocator.as
[copy] Copying 1 file to C:\workbench\CairngenTestProject\src\com\ericfeminella\cairngen\model
create-front-controller:
[echo] @Invoking Cairngen on [CairngenExample] --> Generating file(s): CairngenExampleController.as
[copy] Copying 1 file to C:\workbench\CairngenTestProject\src\com\ericfeminella\cairngen\control
create-service-locator:
[echo] @Invoking Cairngen on [CairngenExample] --> Generating file(s): Services.mxml
[copy] Copying 1 file to C:\workbench\CairngenTestProject\src\com\ericfeminella\cairngen\business
create-cairngorm-project:
main:
BUILD SUCCESSFUL
Total time: 2 secondsGenerating Events, Commands and business DelegatesCairngen uses the term “Sequence” to describe the relationship between an Event, Command and Business Delegate (optional). The Cairngen build.xml file contains four targets for creating Sequences which are as follows:
When a "sequence" is generated the FrontController is modified with an additional 'addCommand' invocation which automates the process of mapping an Event to it’s associated Command. In order to facilitate generating addCommand(); invocations the "// todo: add commands" comment in the FrontController must be present. This comment is used as a token and is replaced with an addCommand when a "sequence" is generated. The following example demonstrates the console output when generating a "Sequence": Buildfile: C:\workbench\ericfeminella\cairngen\build.xml
log:
add-command-to-controller:
[echo] @Invoking Cairngen on [CairngenExample] --> Inserting addCommand in FrontController for LoginEvent and LoginCommand
add-command-to-controller-cleanup:
create-sequence-include-delegate:
[echo] @Invoking Cairngen on [CairngenExample] --> Generating file(s): LoginEvent.as, LoginCommand.as, LoginDelegate.as
[copy] Copying 1 file to C:\workbench\clients\CairngenTestProject\src\com\ericfeminella\cairngen\events
[copy] Copying 1 file to C:\workbench\clients\CairngenTestProject\src\com\ericfeminella\cairngen\commands
[copy] Copying 1 file to C:\workbench\clients\CairngenTestProject\src\com\ericfeminella\cairngen\business
BUILD SUCCESSFUL
Total time: 1 secondGenerating Value Objects (VOs)Cairngen provides targets for generating both single and multiple Value Objects. The two targets which generate ValueObjects are:
The following example demonstrates the console output when generating a Value Objects: Buildfile: C:\workbench\ericfeminella\cairngen\build.xml
create-value-object:
[echo] @Invoking Cairngen on [CairngenExample] --> Generating file(s): Login.as
[copy] Copying 1 file to C:\workbench\clients\CairngenTestProject\src\com\ericfeminella\cairngen\vo
BUILD SUCCESSFUL
Total time: 422 millisecondsCairngen Properties
|
Sign in to add a comment
cool :)
good work :)
which version of JDK and Ant are needed for this?
I use PureMVC instead.
Yes! Finally! Something that saves me from the prone error copy / paste! Thank you veryyyyy much! How can I donate something? Cairngorn is waaay better than PureMVC!