### Bean Example

This is a simple example of a Hello World service using ServiceBean. The ServiceBean approach towards creating services is subtely different from the POJO approach (as outlined in the bean example).

This document is organized as follows :

- ServiceBean Overview
- Building the Example
- Example Source Files
- Running the Example

ServiceBean Overview
A ServiceBean is a simple component that provides the capability to develop, deploy and take direct advantage of Rio's capabilities surrounding Events, SLAs, Fault Detection Handling and Watches to create dynamic services. ServiceBean development follows an interface based programming model, such that a ServiceBean is defined with an interface, and it's backend-end support provided by a concrete implementation of that interface. Once instantiated, a ServiceBean is exported and communicated to using a proxy. A ServiceBean may optionally provide it's own proxy, our example uses the default mechanism.

ServiceBean development is meant to be easy. The approach is to allow the developer to focus on solving the domain issues, not be overly concerned with lower level infrastructure issues. However, overriding underlying service technology is possible, allowing custom behavior. A ServiceBean is activated and goes through various lifecycle steps as documented by the ServiceBean interface. Rio provides the necessary building blocks to make
dynamic service development easy.

This example provides a basic overview of ServiceBen development, using the classic Hello World 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/servicebean
$ ant

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

File Name | Location | Description
Hello.java | /src/main/java/servicebean | The interface for the bean
HelloClient.java | /src/test/java/servicebean/client | Provides a command line interface for running the example
HelloImpl.java | /src/main/java/servicebean/service | The bean implementation
servicebean.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 the Rio CLI
     $ cd <rio-home>/bin
     $ rio deploy ../examples/servicebean/src/main/conf/servicebean.xml
   - Using Ant deploy task
     $ cd <rio-home>/examples/servicebean
     $ ant deploy

3. Run the client using ant
   $ cd <rio-home>/examples/servicebean
   $ ant client
   Buildfile: build.xml
   client:
   [java] Discovering Hello service ...
   [java] Discovered Hello service
   [java] Invoking Hello service ...
   [java] Received: Hello vistor : 1 from Hello service
   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/servicebean/src/main/conf/servicebean.xml
   - Using Ant deploy task
   $ cd <rio-home>/examples/servicebean
   $ ant undeploy