diff options
Diffstat (limited to 'sca-cpp/trunk/contrib/samples/RubyCalculator')
13 files changed, 694 insertions, 0 deletions
diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/Makefile.am b/sca-cpp/trunk/contrib/samples/RubyCalculator/Makefile.am new file mode 100644 index 0000000000..246ea1852f --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/Makefile.am @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +deploydir=$(prefix)/RubyCalculator/deploy +SUBDIRS = sample.calculator sample.calculator.client +EXTRA_DIST = *.composite README.html +deploy_DATA = *.composite diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/README b/sca-cpp/trunk/contrib/samples/RubyCalculator/README new file mode 100644 index 0000000000..670f561dc1 --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/README @@ -0,0 +1,20 @@ +Tuscany SCA for C++ Samples - Calculator Sample +=============================================== + +This is a very simple sample to show how an SCA composite can wire together +two components to implement a Calculator service and expose that service as +a Web Service. + +There are two sub projects in this workspace: + - sample.calculator + This contains the source code and SCDL artifacts for the SCA Calculator. + composite implementing the sample Calculator. + + - sample.calculator.client + A sample client which does a local call to the Calculator service. + +Additionally, there is the sample.calculator.app.composite file. This +describes the configuration of the SCA Calculator composite deployed to the +SCA runtime. + +See the README.html file for instructions to build and run this sample diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/README.html b/sca-cpp/trunk/contrib/samples/RubyCalculator/README.html new file mode 100644 index 0000000000..bb6fe7e0ea --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/README.html @@ -0,0 +1,187 @@ + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +<HTML> +<HEAD> + <META CONTENT="text/html; charset=iso-8859-1" HTTP-EQUIV="Content-Type"> + <META CONTENT="text/css" HTTP-EQUIV="Content-Style-Type"> + <STYLE MEDIA="all" TYPE="text/css"> +@import url("../../doc/css/maven-base.css"); +@import url("../../doc/css/maven-theme.css"); + </STYLE> + + <LINK HREF="../doc/css/maven-theme.css" MEDIA="print" REL="stylesheet" + TYPE="text/css"> + <TITLE>Tuscany SCA Native Samples - Ruby Calculator Sample</TITLE> +</HEAD> + +<BODY> +<DIV ID="bodyColumn"> + <DIV ID="contentBox"> + <DIV CLASS="section"> + <H1>Tuscany SCA Native Samples - Ruby Calculator Sample</H1> + + <P>This is a very simple sample to show how an SCA composite can wire + together two Ruby components to implement a Calculator service and invoke + the service via a local client. + </P> + <P>There are two sub projects in this workspace:</P> + <UL> + <LI>sample.calculator<BR/> + This contains the Ruby scripts and SCDL artifacts for the SCA Calculator + composite implementing the sample Calculator. + </LI> + <LI>sample.calculator.client<BR/> + A sample client which does a local call to the Calculator service. + </LI> + </UL> + <P>Additionally, there is the sample.calculator.app.composite file. This + describes the configuration of the SCA Calculator composite deployed to the SCA + runtime. + </P> + </DIV> + + <DIV CLASS="section"> + <H2>Contents</H2> + <OL> + <LI><A HREF="#linuxbld">Building the Ruby samples on Linux and Mac OS X</A></LI> + <LI><A HREF="#linuxrun">Running the Ruby Calculator sample on Linux and Mac OS X</A></LI> + <LI><A HREF="#winbld">Building the Ruby Calculator sample on Windows</A></LI> + <LI><A HREF="#winrun">Running the Ruby Calculator sample on Windows</A></LI> + <LI><A HREF="#help">Getting help</A></LI> + </OL> + </DIV> + + + <DIV CLASS="section"> + <A NAME="linuxbld"><H2>Building the Ruby samples on Linux and Mac OS X</H2></A> + <P>If using the binary distribution the samples are built and installed in + <tuscany_sca_install_dir>/samples - go directly to <A HREF="#linuxrun">Running the samples on Linux and Mac OS X</A>.</P> + <OL> + <LI>The following environment variables are required: + <UL> + <LI>TUSCANY_SCACPP=<path to installed Tuscany SCA></LI> + <LI>TUSCANY_SDOCPP=<path to installed Tuscany SDO></LI> + </UL></LI> + </LI> + <LI>As the Ruby 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: + <UL> + <LI>cd <tuscany_sca_install_dir>/samples</LI> + <LI>./configure --enable-ruby --enable-cpp=no --prefix=$TUSCANY_SCACPP/samples</LI> + <LI>make install</LI> + </UL> + NOTE: If you don't provide the --prefix configure option, it will by default install into + /usr/local/tuscany/sca/samples/RubyCalculator</LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="linuxrun"><H2>Running the Ruby Calculator sample on Linux and Mac OS X</H2></A> + <OL> + <LI>The Ruby Calculator sample requires the following extension: + <UL> + <LI><A HREF="../../doc/RubyExtension.html">Ruby Extension</A></LI> + </UL> + Please follow the documentation to ensure you have this extension built and installed + on your system + </LI> + + <LI>The following environment variables are required: + <UL> + <LI>TUSCANY_SCACPP=<path to installed Tuscany SCA></LI> + <LI>TUSCANY_SDOCPP=<path to installed Tuscany SDO></LI> + </UL> + </LI> + <LI>Run the sample with the following commands: + <UL> + <LI>cd <tuscany_sca_install_dir>/samples/RubyCalculator/deploy/sample.calculator.client</LI> + <LI>./runclient.sh</LI> + </UL> + </LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="winbld"><H2>Building the Ruby Calculator sample on Windows</H2></A> + <P>If using the binary distribution the samples are built and installed in + <tuscany_sca_install_dir>\samples - go directly to <A HREF="#winrun">Running the samples on Windows</A>.</P> + <OL> + <LI>The following environment variables are required: + <UL> + <LI>TUSCANY_SCACPP=<path to installed Tuscany SCA></LI> + <LI>TUSCANY_SDOCPP=<path to installed Tuscany SDO></LI> + </UL> + </LI> + <LI>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: + <UL> + <LI>cd <tuscany_sca_install_dir>\samples\RubyCalculator</LI> + <LI>deploy.bat</LI> + </UL> + </LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="winrun"><H2>Running the Ruby Calculator sample on Windows</H2></A> + <OL> + <LI>The Ruby Calculator sample requires the following extension: + <UL> + <LI><A HREF="../../doc/RubyExtension.html">Ruby Extension</A></LI> + </UL> + Please follow the documentation to ensure you have this extension built and installed + on your system + </LI> + <LI>The following environment variables are required: + <UL> + <LI>TUSCANY_SCACPP=<path to installed Tuscany SCA></LI> + <LI>TUSCANY_SDOCPP=<path to installed Tuscany SDO></LI> + </UL> + </LI> + <LI>Run the sample with the following commands: + <UL> + <LI>cd <tuscany_sca_install_dir>\samples\RubyCalculator\deploy\sample.calculator.client</LI> + <LI>runclient.bat</LI> + </UL> + </LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="help"><H2>Getting Help</H2></A> + + <P>The first place to look is at the Tuscany SCA FAQ at + <A HREF="http://cwiki.apache.org/confluence/display/TUSCANY/Tuscany+SCA+-+FAQ" + TARGET="_blank">http://cwiki.apache.org/confluence/display/TUSCANY/Tuscany+SCA+-+FAQ</A> </P> + + <P>Any problem with this release can be reported to the Tuscany + <A HREF="http://cwiki.apache.org/TUSCANY/mailing-lists.html" + TARGET="_blank">mailing lists</A> or create a JIRA issue at <A HREF="http://issues.apache.org/jira/browse/Tuscany" + TARGET="_blank">http://issues.apache.org/jira/browse/Tuscany</A>.</P> + + </DIV> + </DIV> +</DIV> +</BODY> + +</HTML> + diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.app.composite b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.app.composite new file mode 100644 index 0000000000..ada4d89a1c --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.app.composite @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + name="sample.calculator.app"> + + <component name="sample.calculator.CalculatorComponent"> + <implementation.composite name="sample.calculator" /> + </component> + +</composite> diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/CalculatorClient.rb b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/CalculatorClient.rb new file mode 100644 index 0000000000..253928df0c --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/CalculatorClient.rb @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# + +require("tuscany_sca_ruby") + +calculator = SCA::locateService("CalculatorComponent") + +x = calculator.div(5, 2) +print x, "\n" diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/Makefile.am b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/Makefile.am new file mode 100644 index 0000000000..38f61539d3 --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/Makefile.am @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +deploydir=$(prefix)/RubyCalculator/deploy +clientdir=$(deploydir)/sample.calculator.client + +client_DATA = *.rb +client_SCRIPTS = runclient.sh +EXTRA_DIST = runclient.sh *.rb diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/runclient.bat b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/runclient.bat new file mode 100644 index 0000000000..4a1079986a --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/runclient.bat @@ -0,0 +1,44 @@ +@echo off + +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. + +setlocal + +if "%TUSCANY_SCACPP%" == "" ( +echo "TUSCANY_SCACPP not set" +goto end +) +echo using SCA installed at %TUSCANY_SCACPP% + +if "%TUSCANY_SDOCPP%" == "" ( +echo "TUSCANY_SDOCPP not set" +goto end +) +echo using SDO installed at %TUSCANY_SDOCPP% + +set PATH=%TUSCANY_SCACPP%\extensions\ruby\bin;%TUSCANY_SCACPP%\bin;%TUSCANY_SDOCPP%\bin;%PATH% + +set TUSCANY_SCACPP_ROOT=%~d0%~p0\..\ +set TUSCANY_SCACPP_COMPONENT=sample.calculator.CalculatorComponent +set TUSCANY_SCACPP_BASE_URI=http://localhost:9090 + +cd %TUSCANY_SCACPP_ROOT%\sample.calculator.client +ruby -I%TUSCANY_SCACPP%\extensions\ruby\bin CalculatorClient.rb + +:end +endlocal diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/runclient.sh b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/runclient.sh new file mode 100755 index 0000000000..bc2d6c0904 --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator.client/runclient.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + +APFULLDIR=`pwd` + +if [ x$TUSCANY_SCACPP = x ]; then +echo "TUSCANY_SCACPP not set" +exit; +fi +echo "Using SCA installed at $TUSCANY_SCACPP" + +if [ x$TUSCANY_SDOCPP = x ]; then +echo "TUSCANY_SDOCPP not set" +exit; +fi +echo "Using SDO installed at $TUSCANY_SDOCPP" + +export LD_LIBRARY_PATH=$TUSCANY_SCACPP/extensions/ruby/lib:$TUSCANY_SCACPP/lib:$TUSCANY_SDOCPP/lib:$LD_LIBRARY_PATH + +export TUSCANY_SCACPP_ROOT=$APFULLDIR/../ +export TUSCANY_SCACPP_COMPONENT=sample.calculator.CalculatorComponent +export TUSCANY_SCACPP_BASE_URI=http://localhost:9090 + +cd $TUSCANY_SCACPP_ROOT/sample.calculator.client +ruby -I$TUSCANY_SCACPP/extensions/ruby/lib CalculatorClient.rb diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/Calculator.wsdl b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/Calculator.wsdl new file mode 100644 index 0000000000..331b996ba2 --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/Calculator.wsdl @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://sample/calculator" + targetNamespace="http://sample/calculator"> + <types> + <xs:schema targetNamespace="http://sample/calculator" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://sample/calculator" elementFormDefault="qualified"> + + <xs:element name="add"> + <xs:complexType> + <xs:sequence> + <xs:element name="param1" type="xs:float"/> + <xs:element name="param2" type="xs:float"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="sub"> + <xs:complexType> + <xs:sequence> + <xs:element name="param1" type="xs:float"/> + <xs:element name="param2" type="xs:float"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="mul"> + <xs:complexType> + <xs:sequence> + <xs:element name="param1" type="xs:float"/> + <xs:element name="param2" type="xs:float"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="div"> + <xs:complexType> + <xs:sequence> + <xs:element name="param1" type="xs:float"/> + <xs:element name="param2" type="xs:float"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="result"> + <xs:complexType> + <xs:sequence> + <xs:element name="data" type="xs:float"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + </xs:schema> + </types> + + <message name="addRequestMsg"> + <part name="body" element="tns:add" /> + </message> + <message name="subRequestMsg"> + <part name="body" element="tns:sub" /> + </message> + <message name="mulRequestMsg"> + <part name="body" element="tns:mul" /> + </message> + <message name="divRequestMsg"> + <part name="body" element="tns:div" /> + </message> + + <message name="calculatorResponseMsg"> + <part name="body" element="tns:result" /> + </message> + + <portType name="Calculator"> + <operation name="add"> + <input message="tns:addRequestMsg" /> + <output message="tns:calculatorResponseMsg" /> + </operation> + <operation name="sub"> + <input message="tns:subRequestMsg" /> + <output message="tns:calculatorResponseMsg" /> + </operation> + <operation name="mul"> + <input message="tns:mulRequestMsg" /> + <output message="tns:calculatorResponseMsg" /> + </operation> + <operation name="div"> + <input message="tns:divRequestMsg" /> + <output message="tns:calculatorResponseMsg" /> + </operation> + </portType> + + <binding name="CalculatorBinding" + type="tns:Calculator"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> + <operation name="add"> + <soap:operation soapAction="CalculatorService#add" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + <operation name="sub"> + <soap:operation soapAction="CalculatorService#sub" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + <operation name="mul"> + <soap:operation soapAction="CalculatorService#mul" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + <operation name="div"> + <soap:operation soapAction="CalculatorService#div" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + </binding> + + <service name="CalculatorService"> + <port name="CalculatorPort" + binding="tns:CalculatorBinding"> + <soap:address location="http://localhost:9090/axis2/services/sample.calculator.CalculatorComponent/CalculatorService" /> + </port> + </service> +</definitions> diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/CalculatorImpl.rb b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/CalculatorImpl.rb new file mode 100644 index 0000000000..36ed15ff9b --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/CalculatorImpl.rb @@ -0,0 +1,48 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# + +class CalculatorImpl + + attr_writer :divideService + + def initialize() + print "Ruby - CalculatorImpl.initialize\n" + end + + def div(arg1, arg2) + print "Ruby - CalculatorImpl.div\n" + @divideService.divide(arg1.to_f, arg2.to_f) + end + + def add(arg1, arg2) + print "Ruby - CalculatorImpl.add\n" + arg1.to_f + arg2.to_f + end + + def sub(arg1, arg2) + print "Ruby - CalculatorImpl.sub\n" + arg1.to_f - arg2.to_f + end + + def mul(arg1, arg2) + print "Ruby - CalculatorImpl.mul\n" + arg1.to_f * arg2.to_f + end + +end
\ No newline at end of file diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/DivideImpl.rb b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/DivideImpl.rb new file mode 100644 index 0000000000..c6615bfcfa --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/DivideImpl.rb @@ -0,0 +1,39 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# + +class DivideImpl + + attr_writer :round + + def initialize() + print "Ruby - DivideImpl.initialize\n" + end + + def divide(arg1, arg2) + print "Ruby - DivideImpl.divide ", arg1, " / ", arg2, "\n" + res = arg1.to_f / arg2.to_f + if @round then + res = res.round + print "DivideImpl.divide rounding\n" + end + print "DivideImpl.divide ", res, "\n" + res + end + +end
\ No newline at end of file diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/Makefile.am b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/Makefile.am new file mode 100644 index 0000000000..7de5b9fdd3 --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/Makefile.am @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +deploydir=$(prefix)/RubyCalculator/deploy +compositedir=$(deploydir)/sample.calculator + +composite_DATA = *.composite *.wsdl *.rb +EXTRA_DIST = *.composite *.wsdl *.rb diff --git a/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/sample.calculator.composite b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/sample.calculator.composite new file mode 100644 index 0000000000..d77ba538fe --- /dev/null +++ b/sca-cpp/trunk/contrib/samples/RubyCalculator/sample.calculator/sample.calculator.composite @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + name="sample.calculator"> + + <component name="CalculatorComponent"> + <implementation.ruby script="CalculatorImpl.rb" class="CalculatorImpl"/> + <reference name="divideService">DivideComponent</reference> + </component> + + <component name="DivideComponent"> + <implementation.ruby script="DivideImpl.rb" class="DivideImpl"/> + <property name="round">true</property> + </component> + +</composite>
\ No newline at end of file |