Examples
The examples are tested with CaesarJ compiler 0.8.5.
Simple examples
Here you can find source code of some examples. These examples are explained in detail in the
Programming Guide.
Pricing example
Demonstrates variation of pricing strategies and bindings.
[
download sources [
http://caesarj.org/downloads/examples/0.8.5/pricing.zip]]
Observer example
Implements observer design pattern using CaesarJ.
[
download sources [
http://caesarj.org/downloads/examples/0.8.5/observer.zip]]
Expressions example
Demonstrates expression problem. Caesar alternative to Visitor design pattern.
[
download sources [
http://caesarj.org/downloads/examples/0.8.5/expressions.zip]]
How to run examples?
- Unpack example in the Eclipse workspace directory.
- Use [File->Import->Existing project into workspace].
- Build the project and run the class with main() method.
Large Examples
Hierarchy display example
A large example, which demonstrates development and adaptation of a generic visualization component.
[
download sources [
http://caesarj.org/downloads/examples/0.8.5/hierarchies.zip]]
L2 Interpreter
L2 is a mini object-oriented language. The example demonstrates a modular and extensible implementation of the interpreter for the language in CaesarJ.
You will find several test programs of L2 and its sample extension in
/src/l2examples. To test the interpreter you can run the unit tests in
/src/test.
[
download sources [
http://caesarj.org/downloads/examples/0.8.5/l2-cj.zip]]
Dungeon Game
Dungeon is a middle size case study that demonstrates feature-oriented programming with CaesarJ.
Dungeon is a real-time game written in CaesarJ. The goal of the game is to find the princess in a labirinth of underground rooms. Some of the rooms contain monsters or entrapments. The player can collect various items: weapons, armor, potions and money. Weapons and armor can be configured in the inventory window.
To start the game run the "de.tud.st.dungeon.Run" class. The class shows a dialog which allows you to customize the game. Switch on the desired game features and press "START!!!".
Game controls:
- left mouse click on a location or a monster: move to this place or to attack the monster.
- right mouse click: enter and leave the inventory window
- middle mouse click on a merchant: start trading.
- 1 : normal battle mode
- 2 : parry battle mode
- 3 : agressive battle mode
To run the example you will have to extend the stack of JVM threads. This can be done by adding
"-Xss1M" argument in "Run...->Arguments->VM Arguments".
To run the example you also have to install [
https://java3d.dev.java.net/ Java 3D]]
[
download sources [
http://caesarj.org/downloads/examples/0.8.5/dungeon.zip]]
Remoting Examples
Remote Pricing
Pricing example with
StockBroker residing on remote process. The example demonstrates how we can deploy aspects on the threads of remote process.
[
download sources [
http://caesarj.org/downloads/examples/0.8.5/remotepricing.zip]]
To run the example:
- Unpack example in the Eclipse workspace directory.
- Use [File->Import->Existing project into workspace].
- Set CAESAR_HOME variable in Eclipse Ant settings to point to the CaesarJ plugin installation location.
- Run build.xml with default target. It will build all sources and prepare some of the classes for remoting.
- Refresh project
- Run class
stockinformationbroker.StockInfoServer to start server process.
- Run class
client.ClientTest to start client process.
Remote Hierarchies
Hierarchies example with client-server architecture. Data model resides on the server process, while the UI runs on the client side
[
download sources [
http://caesarj.org/downloads/examples/0.8.5/hierarchies-remote.zip]]
To run the example:
- Unpack example in the Eclipse workspace directory.
- Use [File->Import->Existing project into workspace].
- Set CAESAR_HOME variable in Eclipse Ant settings to point to the CaesarJ plugin installation location.
- Run build.xml with default target. It will build all sources and prepare some of the classes for remoting.
- Refresh project
- Run class
server.CompanyServer to start server process.
- Run class
gui.Application to start client processes.