Version 12, last updated by snajberk at Oct 03 05:32 2010 UTC
Tutorial examples
Here are a few tutorial examples of CoSi applications.
Message printer
First a really simple application:
- “server” component which exports a IMsgGen service with one method String getMsg()
- “client” component which imports this service and prints message on standard output
See example implementation in CoSi.
You can also check example implementation in Spring using RMI (Eclipse IDE projet files included).
You can also check example implementation in Osgi using equinox framework (Eclipse IDE projet files included).
Parking lot
Next a more complex thingy. The scenario is as follows: above motorway there is a board announcing how many places are free at our parking lot. Cars, buses and trucks enter and leave the lot via gate, being allowed entry only if there is space for the given type of vehicle on the parking lot – car takes 1 space, bus 2 spaces, truck 4 spaces. Parking lot announces the remaining capacity for the board to display.
The component model has these components, shown also on diagram below:
- “gate” which generates arrivals/departures (random), calling parking lot’s svc to register these arrivals/departures
- “parking lot” which announces via events how many places are free, setting the count according to the service methods called
- “board” above the motorway which tells how many places are free
- “pannel” which controls the whole system
- “configuration” library component providing also configuration parameters (“frequency” for gate, “capacity” for parking lot)
See images documenting the exercise taken from whiteboard and example implementation in CoSi – all in Czech, sorry.
You can also check example implementation in Spring (Eclipse IDE projet files included).
You can also check example implementation in Osgi using equinox framework and equinoq EventAdmin implementation (Eclipse IDE projet files included).
