### Events Example

This example demonstrates the use of the Rio event framework to subscribe to and be notified of events. Both services in this example are implemented as ServiceBeans, client access to the example is done using either a CLI or through a Service UI. The use of customized proxies is also shown in this example, as well as the use of Watches. The Service UI can be viewed by using a service-UI compatible browser, such as the Rio Monitor. This document is organized as follows :

- Building the Example
- Example Source Files
- Running the Example

Building the Example
Building the example is straight forward, you must have Ant and the JDK. If these requirements are met :
$ cd <rio-home>/examples/events
$ ant

Example Source Files
Source code is located in <rio-home>/examples/calculator directory

File Name | Location | Description
Hello.java | /src/main/java/events | Interface for the Hello event service
HelloEvent.java | /src/main/java/events | The HelloEvent
HelloEventClient.java | /src/test/java/events/client | Provides a command line interface for running the example, includes an event consumer
HelloEventUI.java | /src/main/java/events/service/ui | Provides a JPanel UI to run the example as a Service UI
HelloImpl.java | /src/main/java/events/service | The Hello event service implementation
HelloEventConsumer.java | /src/main/java/events/service | A service with an event consumer and an example of using a StopWatch to measure how long it took to send the event
HelloProxy.java | /src/main/java/events/service | A smart proxy the Hello event service uses
events.xml | /src/main/conf | The opstring for the example
build.xml | . | The ant build file
readme.html | . | This file

Running the Example

How to run the example :

1. Start Rio services :
   $ cd <rio-home>/bin
   $ startall
2. Deploy the example using of the of following methods

- Using the Rio CLI
  $ cd <rio-home>/bin
  $ rio deploy ../examples/src/main/conf/resources/events.xml
- Using Ant deploy task
  $ cd <rio-home>/examples/events
  $ ant deploy

3. Run the client using ant
   $ cd <rio-home>/examples/events
   $ ant client
   Buildfile: build.xml
   client:
   [java] Discovering Hello Event service ...
   [java] Discovered Hello service
   [java] Invoking Hello service ...
   [java] Received HelloEvent seqno=0, message=[Hello vistor #1, your message was "Hello from dreedy"]
   BUILD SUCCESSFUL
   Total time: 1 second
   $
4. Undeploy the example using of the of following methods

- Using the Rio CLI
  $ cd <rio-home>/bin
  $ rio undeploy ../examples/events/src/main/conf/events.xml
- Using Ant undeploy task
  $ cd <rio-home>/examples/events
  $ ant deploy