diff options
Diffstat (limited to 'sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator')
7 files changed, 314 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/CalculatorImpl.componentType b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/CalculatorImpl.componentType new file mode 100644 index 0000000000..adbfd29266 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/CalculatorImpl.componentType @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * 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. +--> +<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"> + + <service name="CalculatorService"> + <interface.java class="calculator.CalculatorService" /> + </service> + + <reference name="divideService"> + <interface.java class="calculator.DivideService" /> + </reference> + +</componentType> +
\ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/CalculatorImpl.py b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/CalculatorImpl.py new file mode 100644 index 0000000000..86dbef9e4d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/CalculatorImpl.py @@ -0,0 +1,56 @@ +# 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. +# +# +# +# +# This Python code is a simple sample that provides a Python implementation of +# the Calculator sample +# + + +# The module-level add function +def add(val1, val2): + result = float(val1) + float(val2) + print "Python - CalculatorImpl.add " + str(val1) + " + " + str(val2) + " = " + str(result) + return result + +# The module-level sub function +def sub(val1, val2): + result = float(val1) - float(val2) + print "Python - CalculatorImpl.sub " + str(val1) + " - " + str(val2) + " = " + str(result) + return result + +# The module-level mul function +def mul(val1, val2): + result = float(val1) * float(val2) + print "Python - CalculatorImpl.mul " + str(val1) + " * " + str(val2) + " = " + str(result) + return result + +# The module-level div function +def div(val1, val2): + + + print "Python - CalculatorImpl.div calling divideService to determine " + str(val1) + " / " + str(val2) + + # Use the divideService reference + result = divideService.divide(val1, val2) + + print "Python - CalculatorImpl.div divideService returned " + str(result) + + return result + diff --git a/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/CalculatorImpl.rb b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/CalculatorImpl.rb new file mode 100644 index 0000000000..c198719b89 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/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-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/DivideImpl.componentType b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/DivideImpl.componentType new file mode 100644 index 0000000000..38704e597b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/DivideImpl.componentType @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="ASCII"?> +<!-- + * 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. +--> +<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:wsdli="http://www.w3.org/2006/01/wsdl-instance"> + + <service name="DivideService"> + <interface.java class="calculator.DivideService" /> + </service> + + <property name="round" type="xsd:boolean">false</property> + <property name="doRounding" type="xsd:boolean">false</property> + +</componentType> +
\ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/DivideImpl.py b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/DivideImpl.py new file mode 100644 index 0000000000..3921731de6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/DivideImpl.py @@ -0,0 +1,65 @@ +# 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. +# +# +# +# +# This Python code is a simple sample that provides a Python implementation of +# the Divide Service used in the Calculator sample +# +# Either use the divide function in the DivideClass class (using classes allows +# composite scoping to be used) +# e.g. in CalculatorComposite.composite use the line: +# <implementation.python module="DivideImpl" class="DivideClass"/> +# +# Or just use the module-level divide function +# e.g. in CalculatorComposite.composite use the line: +# <implementation.python module="DivideImpl" /> +# + + +class DivideClass: + "A class to handle dividing" + + def __init__(self): + print "Python - DivideImpl.DivideClass constructor" + + # The class-level divide function + def divide(self, val1, val2): + result = float(val1) / float(val2) + + print "Python - DivideImpl.DivideClass.divide " + str( val1 ) + " / " + str(val2) + " = " + str(result) + + # Use the doRounding property + if doRounding: + result = round(result) + print "Python - DivideImpl.DivideClass.divide is rounding the result to " + str(result) + + return result + +# The module-level divide function +def divide(val1, val2): + result = float(val1) / float(val2) + print "Python - DivideImpl.divide " + str(val1) + " / " + str(val2) + " = " + str(result) + + # Use the doRounding property + if doRounding: + result = round(result) + print "Python - DivideImpl.divide is rounding the result to " + str(result) + + return result + diff --git a/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/DivideImpl.rb b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/DivideImpl.rb new file mode 100644 index 0000000000..c6615bfcfa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/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-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/sample.calculator.composite b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/sample.calculator.composite new file mode 100644 index 0000000000..4006d3efe0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-integration/sca/extensions/script/itests/src/main/resources/calculator/sample.calculator.composite @@ -0,0 +1,45 @@ +<?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="RubyCalculatorComponent"> + <implementation.ruby script="calculator/CalculatorImpl.rb" class="CalculatorImpl"/> + <reference name="divideService">RubyDivideComponent</reference> + </component> + + <component name="RubyDivideComponent"> + <implementation.ruby script="calculator/DivideImpl.rb" class="DivideImpl"/> + <property name="round">true</property> + </component> + + <component name="PythonCalculatorComponent"> + <implementation.python module="calculator/CalculatorImpl.py" scope="composite"/> + <reference name="divideService">PythonDivideComponent</reference> + </component> + + <component name="PythonDivideComponent"> + <implementation.python module="calculator/DivideImpl.py" scope="composite"/> + <property name="doRounding">false</property> + </component> + + +</composite>
\ No newline at end of file |