General notes
Instructions of how to run all sample applications can be found on the page Running sample applications.
Hello World example
This example presents two agents that take turns in writing a "Hello world" message to the log.
The used code is located in package: org.jage.examples.helloworld
.
The configuration file is located in: examples/helloworld/age.xml
. (You can see a description of it on the page Sample XML configuration.)
The Eclipse launch file is located in: config/helloworld.launch
.
Strategy usage
This example shows how to use strategies, as described on the WzorzecProjektowyStrategia page.
The used code is located in package: org.jage.examples.strategy
.
The configuration file is located in: examples/
strategy
/age.xml
.
The Eclipse launch file is located in: config/
strategy
.launch
.
Behavior
The example defines three agents of the same class. Each of them uses a completely different implementation of the echo strategy to perform its task. Three different strategies are actively used:
- The simple counting strategy, that keeps a count of all calls.
- The counting strategy that increases a counter by a specified value.
- The strategy that simply writes "ABC" to the output.
Simple strategy delegation
This example shows how an agent can obtain a strategy dynamically during runtime assuming it is visible in terms described in the page HierarchiaKontenerow. This pattern can be used as simple way to reconfigure agent behavior in the execution time.
The used code is located in package: org.jage.examples.delegation
.
The configuration file is located in: examples/delegation/age.xml
.
The Eclipse launch file is located in: config/delegation.launch
.
Behavior
During initialization a simple agent (class DelegationSimpleLeaf
) located in a leaf of the agent hierarchy obtains a name (as a string) of a strategy IEchoStrategy
from its parent (class DelegationSimpleAggregate
). After that it requests an implementation with this name from the instance provider. The strategy is located directly in the parent container. Then, when performing its actions, it executes this concrete implementation of the strategy.
Configuration examples
Configuration examples shows how to use some of mechanisms provided by jAgE for configuring the system.
Currently available examples:
- Usage of array
- Usage of collections
The used code is located in the package: org.jage.examples.configuration
.
Configuration files are located in examples/configuration/
directory.
Eclipse launch files are located in config/
directory and starts with configuration-
prefix.
Usage of array
The configuration file name: age-array.xml
.
The Eclipse launch file name: configuration-array.launch
.
Behavior
There is one agent configured with two sample arrays: object-array and long-array that contain respectively: three instances of ExampleClass
and three instances of longs. The agent obtains both of them during initialization and prints their content to the log.
Usage of collections
The configuration file name: age-collections.xml
.
The Eclipse launch file name: configuration-collections.launch
.
Behavior
There are two agents:
ListAgent
is configured with two sample lists: object-list and long-list. They contain respectively: three instances ofExampleClass
and three instances of longs.MapAgent
uses two maps: object-map and long-map. Both of maps map strings to instances ofExampleClass
or instances of longs.
Agents receive both of them by auto-wiring and again obtains them during initialization. Then they print their content to the log.
Multiworkplace
It consists of two examples: isolated and non-isolated. The former shows the behavior of agents in the isolated workplace (IsolatedSimpleWorkplace
class) and the latter - their behavior during identical actions in a connected (aware of the existence of other workplaces) workplace.
The used code is located in the package: org.jage.examples.multiworkplace
.
Configuration files are located in examples/multiworkplace/
directory.
Eclipse launch files are located in config/
directory and starts with multiworkplace-
prefix.
Distribution and communication examples
These examples shows AgE capabilities in the domain of distribution and remote (node-node) communication.
The used code is located in package: org.jage.examples.distribution
.
Configuration files are located in: examples/distribution/
.
These examples do not provide Eclipse launch files because they usually require starting of more than one JVM. You can start them using following commands:
mvn verify -Pexamples -DskipTests -Dage.node.conf=classpath:examples/distributed/age-minimal.xml
mvn verify -Pexamples-conf -DskipTests -Dage.node.conf=classpath:examples/distributed/age-minimal.xml -Dage.computation.conf=classpath:examples/distributed/age-distributed-computation.xml