Tuscany SCA Native Samples - REST Calculator Sample
This is a very simple sample to show how an SCA composite can wire
together two Ruby components to implement a Calculator service and expose
that service as a REST Service running under Apache HTTPD.
The REST Calculator sample requires the following extensions:
Please follow the documentation to ensure you have these extensions built and installed
on your system
There are three sub projects in this workspace:
- sample.calculator
This contains the Ruby scripts and SCDL artifacts for the SCA Calculator
composite implementing the sample Calculator.
- sample.calculator.restclient
A sample client which does a local call to the Calculator service.
- httpserver
A minimal configuration for the Apache HTTP server used to host the
REST service as well as scripts to start and stop the server.
Additionally, there is the sample.calculator.app.composite file. This
describes the configuration of the SCA Calculator composite deployed to the SCA
runtime.
Building the REST Calculator sample on Linux and Mac OS X
If using the binary distribution the samples are built and installed in
<tuscany_sca_install_dir>/samples - go directly to Running the samples on Linux and Mac OS X.
- The following environment variables are required:
- TUSCANY_SCACPP=<path to installed Tuscany SCA>
- TUSCANY_SDOCPP=<path to installed Tuscany SDO>
- As the REST Calculator sample is based on Ruby scripts, a specific compilation step is not necessary -
only deployment is required. Deploy the Ruby samples only with the following command sequence:
- cd <tuscany_sca_install_dir>/samples
- ./configure --enable-ruby --enable-cpp=no --prefix=$TUSCANY_SCACPP/samples
- make install
NOTE: If you don't provide the --prefix configure option, it will by default install into
/usr/local/tuscany/sca/samples/RestCalculator
Running the REST Calculator sample on Linux and Mac OS X
- The REST Calculator sample requires the following extensions:
Please follow the documentation to ensure you have these extensions built and installed
on your system
- Start the HTTPD server:
- The following environment variables are required:
- TUSCANY_SCACPP=<path to installed Tuscany SCA>
- TUSCANY_SDOCPP=<path to installed Tuscany SDO>
- cd <tuscany_sca_install_dir>/samples/RestCalculator/deploy/httpserver
- ./startserver.sh
NOTE: Depending on your installation of Apache HTTPD you may need to log in as root before following
these steps. If so, you may also need to uncomment the User and Group directives in the
<tuscany_sca_install_dir>/samples/RestCalculator/deploy/httpserver/conf/httpd.conf file
and set these to the appropriate username and group that the server should run as
- Run the client:
- The following environment variables are required:
- TUSCANY_SCACPP=<path to installed Tuscany SCA>
- TUSCANY_SDOCPP=<path to installed Tuscany SDO>
- cd <tuscany_sca_install_dir>/samples/RestCalculator/deploy/sample.calculator.restclient
- ./runrestclient.sh
Building the REST Calculator sample on Windows
If using the binary distribution the samples are built and installed in
<tuscany_sca_install_dir>\samples - go directly to Running the samples on Windows.
- The following environment variables are required:
- TUSCANY_SCACPP=<path to installed Tuscany SCA>
- TUSCANY_SDOCPP=<path to installed Tuscany SDO>
- As this sample is based on Ruby scripts, a specific compilation step is not necessary -
only deployment is required. Deploy the sample with the following commands:
- cd <tuscany_sca_install_dir>\samples\RestCalculator
- deploy.bat
Running the REST Calculator sample on Windows
- The REST Calculator sample requires the following extensions:
Please follow the documentation to ensure you have these extensions built and installed
on your system
- Start the HTTPD server:
- The following environment variables are required:
- TUSCANY_SCACPP=<path to installed Tuscany SCA>
- TUSCANY_SDOCPP=<path to installed Tuscany SDO>
- HTTPD_HOME=<path to installed Apache HTTPD server>
- cd <tuscany_sca_install_dir>\samples\RestCalculator\deploy\httpserver
- startserver.bat
- Run the client:
- The following environment variables are required:
- TUSCANY_SCACPP=<path to installed Tuscany SCA>
- TUSCANY_SDOCPP=<path to installed Tuscany SDO>
- LIBCURL_HOME=<path to installed libcurl libraries>
- cd <tuscany_sca_install_dir>\samples\RestCalculator\deploy\sample.calculator.restclient
- runrestclient.bat