summaryrefslogtreecommitdiffstats
path: root/tags/native-sca-1.0.incubating-M3/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'tags/native-sca-1.0.incubating-M3/runtime')
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/Makefile.am18
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/Makefile.am18
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/deploy.bat72
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/Makefile.am79
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Exceptions.cpp305
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Exceptions.h346
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Operation.cpp578
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Operation.h251
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/SCARuntime.cpp619
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/SCARuntime.h295
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp50
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceProxy.h75
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp50
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceWrapper.h77
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/export.h41
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp46
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h79
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/InterfaceExtension.cpp47
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h78
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.cpp46
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.h81
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.cpp46
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.h81
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Binding.cpp49
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Binding.h83
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Component.cpp153
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Component.h183
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ComponentType.cpp294
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ComponentType.h186
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Composite.cpp258
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Composite.h215
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReference.cpp68
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReference.h93
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp62
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h108
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeService.cpp70
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeService.h83
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Contract.cpp49
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Contract.h85
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Interface.cpp49
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Interface.h90
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ModelLoader.cpp1820
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ModelLoader.h123
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Reference.cpp77
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Reference.h126
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp75
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceBinding.h100
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceType.cpp88
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceType.h138
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Service.cpp58
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Service.h101
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp51
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceBinding.h89
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceType.cpp62
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceType.h108
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLDefinition.cpp462
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLDefinition.h146
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLInterface.cpp107
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLInterface.h99
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLOperation.cpp63
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLOperation.h147
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Wire.cpp53
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Wire.h94
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp51
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h51
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/File.cpp243
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/File.h160
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp57
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/FileLogWriter.h58
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Library.cpp181
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Library.h103
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/LogWriter.cpp37
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/LogWriter.h53
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logger.cpp272
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logger.h136
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logging.h44
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Mutex.cpp109
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Mutex.h84
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Queue.cpp224
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Queue.h93
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/SDOUtils.cpp436
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/SDOUtils.h105
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Thread.cpp126
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Thread.h90
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/ThreadLocal.cpp120
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/ThreadLocal.h84
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Utils.cpp598
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Utils.h76
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/Makefile.am45
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/Makefile.am24
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/deploy.bat77
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/Makefile.am57
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp150
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h117
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp127
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h99
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h105
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/export.h42
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/sca.h31
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp72
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h57
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp101
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h74
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp71
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h74
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp192
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h117
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp198
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h160
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp208
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h119
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp128
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h89
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp83
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h77
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp85
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h148
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp63
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h117
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp61
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h96
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp54
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h81
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd49
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd43
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/AUTHORS0
-rwxr-xr-xtags/native-sca-1.0.incubating-M3/runtime/extensions/php/COPYING203
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/ChangeLog0
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/INSTALL2
-rwxr-xr-xtags/native-sca-1.0.incubating-M3/runtime/extensions/php/LICENSE177
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/Makefile.am24
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/NEWS0
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/NOTICE5
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/README276
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/VSExpress/tuscany_sca_php.vcproj273
-rwxr-xr-xtags/native-sca-1.0.incubating-M3/runtime/extensions/php/autogen.sh31
-rwxr-xr-xtags/native-sca-1.0.incubating-M3/runtime/extensions/php/build.sh55
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/configure.ac79
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/deploy.bat67
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/Makefile.am18
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/Makefile.am21
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/README32
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.app.composite28
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/Makefile.am24
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/calculator_client.py50
-rwxr-xr-xtags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/runclient.sh48
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Calculator.componentType31
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Calculator.php89
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Divide.componentType29
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Divide.php47
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Log.componentType25
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Log.php36
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Makefile.am23
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Multiply.php39
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/sample.calculator.composite44
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/Makefile.am59
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp71
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.h57
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp73
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h74
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPInterfaceExtension.cpp76
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPInterfaceExtension.h74
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp81
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h83
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp504
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h112
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/export.h41
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp85
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h95
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPInterface.cpp53
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPInterface.h77
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp61
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h92
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.cpp58
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.h81
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/php_sca.h132
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/sca.cpp517
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/sca.h49
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/php/xsd/sca-implementation-php.xsd39
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/Makefile.am24
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/deploy.bat66
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/deploymodule.bat61
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/Makefile.am66
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp76
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.h57
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.cpp86
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.h75
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.cpp123
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.h74
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.cpp81
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.h83
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp1096
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h142
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/export.h41
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.cpp131
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.h145
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.cpp53
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.h77
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.cpp61
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.h92
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.cpp58
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.h81
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp540
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py57
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/xsd/sca-implementation-python.xsd49
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/python/xsd/sca-interface-python.xsd62
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/Makefile.am6
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/deploy.bat45
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/Makefile.am1
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/deploy.bat66
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/Makefile.am25
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.cpp85
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.h76
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/exportinterface.h38
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/model/RESTInterface.cpp51
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/model/RESTInterface.h80
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/Makefile.am1
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/Makefile.am1
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/Makefile.am31
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.cpp89
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.h75
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp1222
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.h90
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/model/RESTServiceBinding.cpp59
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/model/RESTServiceBinding.h76
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/deploy.bat68
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/Makefile.am1
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/deploy.bat66
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/deploymod.bat63
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/Makefile.am1
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/Makefile.am44
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/ModREST.cpp1351
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.cpp86
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.h75
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTServiceProxy.cpp559
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTServiceProxy.h95
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/export.h38
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/model/RESTReferenceBinding.cpp66
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/model/RESTReferenceBinding.h90
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/xsd/sca-binding-rest.xsd34
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/xsd/sca-interface-rest.xsd38
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/Makefile.am24
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/deploy.bat66
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/Makefile.am34
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/deploy.bat59
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/src/Extension.cpp56
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/src/extconf.rb25
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/Makefile.am55
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/Ruby.h39
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp70
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.h50
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp72
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.h58
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.cpp74
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.h74
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp384
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h114
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp794
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.h94
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/export.h38
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.cpp171
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.h136
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.cpp60
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.h93
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.cpp54
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.h77
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/xsd/sca-implementation-ruby.xsd40
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/Makefile.am23
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/deploy.bat45
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/Makefile.am18
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/deploy.bat68
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/Makefile.am44
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp103
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/SCAServiceBindingExtension.h77
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/model/SCAServiceBinding.cpp59
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/model/SCAServiceBinding.h76
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/Makefile.am18
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/deploy.bat66
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/Makefile.am44
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp103
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/SCAReferenceBindingExtension.h77
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/model/SCAReferenceBinding.cpp66
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/model/SCAReferenceBinding.h85
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/xsd/sca-binding-sca.xsd37
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/Makefile.am23
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/deploy.bat45
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/Makefile.am18
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/Makefile.am18
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/Makefile.am56
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp803
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.h65
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp118
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.h78
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp131
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.h65
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/export.h38
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.cpp144
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.h137
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/deploy.bat68
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/Makefile.am18
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/Makefile.am18
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/Makefile.am96
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/axis2.xml181
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/deploy.bat39
-rwxr-xr-xtags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/deploy.sh47
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/module.xml25
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/services.xml25
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp177
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp149
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp543
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp77
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h46
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp119
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h76
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp572
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h95
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/export.h38
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp151
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h153
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/deploy.bat76
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/deploymodule.bat69
-rw-r--r--tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/xsd/sca-binding-webservice.xsd55
322 files changed, 38066 insertions, 0 deletions
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/Makefile.am
new file mode 100644
index 0000000000..8b13058152
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/Makefile.am
@@ -0,0 +1,18 @@
+# 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.
+
+SUBDIRS = core extensions
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/core/Makefile.am
new file mode 100644
index 0000000000..2b9491ec1c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/Makefile.am
@@ -0,0 +1,18 @@
+# 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.
+
+SUBDIRS = src
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/core/deploy.bat
new file mode 100644
index 0000000000..178ffb7b39
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/deploy.bat
@@ -0,0 +1,72 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set srcdir=%rootdir%\runtime\core\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %deploydir%\bin mkdir %deploydir%\bin
+if not exist %deploydir%\lib mkdir %deploydir%\lib
+if not exist %deploydir%\include mkdir %deploydir%\include
+if not exist %deploydir%\include\tuscany mkdir %deploydir%\include\tuscany
+if not exist %deploydir%\include\tuscany\sca mkdir %deploydir%\include\tuscany\sca
+if not exist %deploydir%\include\tuscany\sca\core mkdir %deploydir%\include\tuscany\sca\core
+if not exist %deploydir%\include\tuscany\sca\extension mkdir %deploydir%\include\tuscany\sca\extension
+if not exist %deploydir%\include\tuscany\sca\model mkdir %deploydir%\include\tuscany\sca\model
+if not exist %deploydir%\include\tuscany\sca\util mkdir %deploydir%\include\tuscany\sca\util
+if not exist %deploydir%\xsd mkdir %deploydir%\xsd
+
+del %deploydir%\bin\tuscany_sca.*
+del %deploydir%\lib\*.lib
+
+copy %srcdir%\tuscany\sca\*.h %deploydir%\include\tuscany\sca
+copy %srcdir%\tuscany\sca\core\*.h %deploydir%\include\tuscany\sca\core
+copy %srcdir%\tuscany\sca\extension\*.h %deploydir%\include\tuscany\sca\extension
+copy %srcdir%\tuscany\sca\model\*.h %deploydir%\include\tuscany\sca\model
+copy %srcdir%\tuscany\sca\util\*.h %deploydir%\include\tuscany\sca\util
+
+copy %rootdir%\xsd\*.* %deploydir%\xsd
+
+copy %inpath%\tuscany_sca.lib %deploydir%\lib
+copy %inpath%\tuscany_sca.dll %deploydir%\bin
+
+if exist %inpath%\tuscany_sca.pdb copy %inpath%\tuscany_sca.pdb %deploydir%\bin
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/core/src/Makefile.am
new file mode 100644
index 0000000000..afc25ae349
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/Makefile.am
@@ -0,0 +1,79 @@
+# 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.
+
+lib_LTLIBRARIES = libtuscany_sca.la
+
+nobase_include_HEADERS = \
+tuscany/sca/*.h \
+tuscany/sca/core/*.h \
+tuscany/sca/model/*.h \
+tuscany/sca/util/*.h \
+tuscany/sca/extension/*.h
+
+## To list the source files execute the following:
+## ls -1 tuscany/sca/util/*.cpp tuscany/sca/extension/*.cpp tuscany/sca/model/*.cpp tuscany/sca/core/*.cpp tuscany/sca/cpp/*.cpp tuscany/sca/ws/*.cpp | awk '{ print $1 " \\" }'
+## and copy/paste the output below
+libtuscany_sca_la_SOURCES = \
+tuscany/sca/core/Exceptions.cpp \
+tuscany/sca/core/Operation.cpp \
+tuscany/sca/core/SCARuntime.cpp \
+tuscany/sca/core/ServiceProxy.cpp \
+tuscany/sca/core/ServiceWrapper.cpp \
+tuscany/sca/extension/ImplementationExtension.cpp \
+tuscany/sca/extension/InterfaceExtension.cpp \
+tuscany/sca/extension/ReferenceBindingExtension.cpp \
+tuscany/sca/extension/ServiceBindingExtension.cpp \
+tuscany/sca/model/Binding.cpp \
+tuscany/sca/model/Component.cpp \
+tuscany/sca/model/ComponentType.cpp \
+tuscany/sca/model/Composite.cpp \
+tuscany/sca/model/CompositeReference.cpp \
+tuscany/sca/model/CompositeReferenceBinding.cpp \
+tuscany/sca/model/CompositeService.cpp \
+tuscany/sca/model/Contract.cpp \
+tuscany/sca/model/Interface.cpp \
+tuscany/sca/model/ModelLoader.cpp \
+tuscany/sca/model/ReferenceBinding.cpp \
+tuscany/sca/model/Reference.cpp \
+tuscany/sca/model/ReferenceType.cpp \
+tuscany/sca/model/ServiceBinding.cpp \
+tuscany/sca/model/Service.cpp \
+tuscany/sca/model/ServiceType.cpp \
+tuscany/sca/model/Wire.cpp \
+tuscany/sca/model/WSDLDefinition.cpp \
+tuscany/sca/model/WSDLInterface.cpp \
+tuscany/sca/model/WSDLOperation.cpp \
+tuscany/sca/util/DefaultLogWriter.cpp \
+tuscany/sca/util/File.cpp \
+tuscany/sca/util/FileLogWriter.cpp \
+tuscany/sca/util/Library.cpp \
+tuscany/sca/util/Logger.cpp \
+tuscany/sca/util/LogWriter.cpp \
+tuscany/sca/util/Mutex.cpp \
+tuscany/sca/util/Queue.cpp \
+tuscany/sca/util/SDOUtils.cpp \
+tuscany/sca/util/Thread.cpp \
+tuscany/sca/util/ThreadLocal.cpp \
+tuscany/sca/util/Utils.cpp
+
+libtuscany_sca_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -lpthread
+
+INCLUDES = -I$(top_builddir)/runtime/core/src \
+ -I${TUSCANY_SDOCPP}/include
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Exceptions.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Exceptions.cpp
new file mode 100644
index 0000000000..a75da50c22
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Exceptions.cpp
@@ -0,0 +1,305 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#else
+#include "tuscany_sca_config.h"
+#endif
+
+#include <sstream>
+#if defined(WIN32) || defined (_WINDOWS) || defined (IS_DARWIN)
+#else
+#include <execinfo.h>
+#endif
+
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ // ========================================================================
+ // Constructor
+ // ========================================================================
+ TuscanyRuntimeException :: TuscanyRuntimeException(const char* name,
+ severity_level sev,
+ const char* msg_text)
+ {
+ severity = sev;
+ location_set = 0;
+ class_name = new char[strlen(name) + 1];
+ strcpy(class_name,name);
+ message_text = new char[strlen(msg_text)+1];
+ strcpy(message_text,msg_text);
+
+#if defined(WIN32) || defined (_WINDOWS) || defined (IS_DARWIN)
+#else
+ void* array[25];
+ stacktrace_size = backtrace(array, 25);
+ stacktrace_symbols = backtrace_symbols(array, stacktrace_size);
+#endif
+
+ logwarning("%s raised: %s", class_name, message_text);
+
+ } // end TuscanyRuntimeException constuctor
+
+ // ========================================================================
+ // Constructor
+ // ========================================================================
+ TuscanyRuntimeException :: TuscanyRuntimeException(const TuscanyRuntimeException& c)
+ {
+ severity = c.getSeverity();
+ location_set = c.location_set;
+ class_name = new char[strlen(c.getEClassName()) + 1];
+ strcpy(class_name, c.getEClassName());
+ message_text = new char[strlen(c.getMessageText())+1];
+ strcpy(message_text,c.getMessageText());
+
+ for (int i=0; i < location_set; i++)
+ {
+ locations[i].file = new char[strlen(c.locations[i].file) + 1];
+ strcpy(locations[i].file,c.locations[i].file);
+ locations[i].line = c.locations[i].line;
+ locations[i].function = new char[strlen(c.locations[i].function) + 1];
+ strcpy(locations[i].function, c.locations[i].function);
+ }
+
+#if defined(WIN32) || defined (_WINDOWS) || defined (IS_DARWIN)
+#else
+ void* array[25];
+ stacktrace_size = backtrace(array, 25);
+ stacktrace_symbols = backtrace_symbols(array, stacktrace_size);
+#endif
+
+ logwarning("%s raised: %s", class_name, message_text);
+ }
+
+ // ========================================================================
+ // Constructor
+ // ========================================================================
+ TuscanyRuntimeException :: TuscanyRuntimeException(const SDORuntimeException& c)
+ {
+ class_name = new char[strlen(c.getEClassName()) + 1];
+ strcpy(class_name, c.getEClassName());
+ message_text = new char[strlen(c.getMessageText())+1];
+ strcpy(message_text,c.getMessageText());
+ switch (c.getSeverity())
+ {
+ case SDORuntimeException::Normal:
+ severity = Normal;
+ break;
+ case SDORuntimeException::Warning:
+ severity = Warning;
+ break;
+ case SDORuntimeException::Error:
+ severity = Error;
+ break;
+ default:
+ severity = Severe;
+ break;
+ }
+
+ const char* file = c.getFileName();
+ unsigned long line = c.getLineNumber();
+ const char* function = c.getFunctionName();
+ location_set = 0;
+ if (file)
+ {
+ setLocation(file, line, function);
+ }
+
+#if defined(WIN32) || defined (_WINDOWS) || defined (IS_DARWIN)
+#else
+ void* array[25];
+ stacktrace_size = backtrace(array, 25);
+ stacktrace_symbols = backtrace_symbols(array, stacktrace_size);
+#endif
+
+ logwarning("%s raised: %s", class_name, message_text);
+ }
+
+ // ========================================================================
+ // Destructor
+ // ========================================================================
+ TuscanyRuntimeException :: ~TuscanyRuntimeException()
+ {
+ if (class_name) delete class_name;
+ if (message_text) delete message_text;
+ for (int i=0;i<location_set;i++)
+ {
+ if (locations[i].file) delete locations[i].file;
+ if (locations[i].function) delete locations[i].function;
+ }
+
+#if defined(WIN32) || defined (_WINDOWS) || defined (IS_DARWIN)
+#else
+ free(stacktrace_symbols);
+#endif
+
+ } // end TuscanyRuntimeException destructor
+
+ // ========================================================================
+ // Return class name of this exception
+ // ========================================================================
+ const char* TuscanyRuntimeException :: getEClassName() const
+ {
+ return class_name;
+ } // end getClassName()
+
+ // ========================================================================
+ // Return severity
+ // ========================================================================
+ TuscanyRuntimeException::severity_level TuscanyRuntimeException :: getSeverity() const
+ {
+ return severity;
+ } // end getSeverity()
+
+ // ========================================================================
+ // Return message text associated with exception
+ // ========================================================================
+ const char* TuscanyRuntimeException :: getMessageText() const
+ {
+ return message_text;
+ } // end getMessageText()
+
+ // ========================================================================
+ // Return file name where exception was raised
+ // ========================================================================
+ const char* TuscanyRuntimeException :: getFileName() const
+ {
+ return locations[0].file;
+ } // end getFileName()
+
+ // ========================================================================
+ // Return line number where exception was raised
+ // ========================================================================
+ unsigned long TuscanyRuntimeException :: getLineNumber() const
+ {
+ return locations[0].line;
+ } // end getLineNumber()
+
+ // ========================================================================
+ // Return function name where exception was raised
+ // ========================================================================
+ const char* TuscanyRuntimeException :: getFunctionName() const
+ {
+ return locations[0].function;
+ } // end getFunctionName()
+
+
+ // ========================================================================
+ // set severity of exception
+ // ========================================================================
+ void TuscanyRuntimeException :: setSeverity(severity_level sev)
+ {
+ severity = sev;
+ } // end setSeverity(severity_level sev) const
+
+ // ========================================================================
+ // set message text associated with exception
+ // ========================================================================
+ void TuscanyRuntimeException :: setMessageText(const char* msg_text)
+ {
+ if (message_text != 0) delete message_text;
+ message_text = new char[strlen(msg_text) + 1];
+ strcpy(message_text,msg_text);
+ } // end setMessageText(const string &msg_text) const
+
+ // ========================================================================
+ // set location of most recent handling of the exception
+ // ========================================================================
+ void TuscanyRuntimeException :: setLocation(const char* file,
+ unsigned long line,
+ const char* function)
+ {
+ if (location_set < num_locations)
+ {
+ locations[location_set].file = new char[strlen(file) + 1];
+ strcpy(locations[location_set].file,file);
+ locations[location_set].line = line;
+ locations[location_set].function = new char[strlen(function) + 1];
+ strcpy(locations[location_set].function,function);
+
+ location_set++;
+ }
+ } // end setLocation()
+
+
+ // ========================================================================
+ // print self
+ // ========================================================================
+ ostream& TuscanyRuntimeException :: PrintSelf(ostream &os) const
+ {
+
+ os << "Exception" << endl;
+ os << " Class: " << class_name << endl;
+ os << " Description: " << message_text << endl;
+ if (location_set != 0)
+ {
+ os << " Origin:" << endl;
+ os << " File: " << locations[0].file << endl;
+ char lineNumber[100];
+ sprintf(lineNumber, "%lu",locations[0].line);
+ os << " Line: " << lineNumber << endl;
+ os << " Function: " << locations[0].function << endl;
+
+ if (location_set >1)
+ {
+ os << " Path:" << endl;
+ int i=1;
+ while (i < location_set)
+ {
+ os << " File: " << locations[i].file << endl;
+ os << " Line: " << locations[i].line << endl;
+ os << " Function: " << locations[i].function << endl;
+ i++;
+ }
+ }
+ }
+#if defined(WIN32) || defined (_WINDOWS) || defined (IS_DARWIN)
+#else
+ if (stacktrace_size != 0)
+ {
+ os << " Backtrace:" << endl;
+ for (int j = 0; j < stacktrace_size; j++)
+ {
+ os << " " << stacktrace_symbols[j] << endl;
+ }
+ }
+#endif
+ return os;
+ } // end ostream operator <<
+
+
+ // ========================================================================
+ // ostream operator <<
+ // ========================================================================
+ SCA_API ostream& operator<< (ostream &os, const TuscanyRuntimeException &except)
+ {
+ return except.PrintSelf(os);
+ } // end ostream operator <<
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Exceptions.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Exceptions.h
new file mode 100644
index 0000000000..3b5b048736
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Exceptions.h
@@ -0,0 +1,346 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_core_exceptions_h
+#define tuscany_sca_core_exceptions_h
+
+#include <ostream>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Top level exception to represent all the exceptions that may be
+ * thrown by an SCA runtime implementation.
+ */
+ class SCA_API TuscanyRuntimeException
+ {
+ public:
+ /**
+ * Represents the possible severity levels for an exception.
+ */
+ enum severity_level
+ {
+ Normal,
+ Warning,
+ Error,
+ Severe
+ };
+
+ /**
+ * Constructor.
+ * @param name Class name of the exception.
+ * @param sev Severity level.
+ * @param msg_text Detailed description of the exception.
+ */
+ TuscanyRuntimeException(
+ const char *name = "TuscanyRuntimeException",
+ severity_level sev = Severe,
+ const char* msg_text = "");
+
+ TuscanyRuntimeException(const TuscanyRuntimeException& c);
+ TuscanyRuntimeException(const SDORuntimeException& c);
+
+ // Destructor
+ virtual ~TuscanyRuntimeException();
+
+ /**
+ * Return class name of this exception.
+ */
+ const char* getEClassName() const;
+
+ /**
+ * Return severity.
+ */
+ severity_level getSeverity() const;
+
+ /**
+ * Return message text associated with exception.
+ */
+ const char* getMessageText() const;
+
+ /*
+ * Return file name where the exception was raised.
+ */
+ const char* getFileName() const;
+
+ /**
+ * Return line number where the exception was raised.
+ */
+ unsigned long getLineNumber() const;
+
+ /**
+ * Return function name where the exception was raised.
+ */
+ const char* getFunctionName() const;
+
+ /**
+ * Set the exception severity.
+ */
+ void setSeverity(severity_level sev);
+
+ /**
+ * Set the message text associated with exception.
+ */
+ void setMessageText(const char* msg_text);
+
+ /**
+ * Set the location where the exception was raised.
+ * @param file Name of the file.
+ * @param line Line number in the file.
+ * @param function Name of the function.
+ */
+ void setLocation(const char* file,
+ unsigned long line,
+ const char* function="");
+
+ /**
+ * Append exception details to ostream.
+ */
+ virtual std::ostream& PrintSelf(std::ostream &os) const;
+
+ /**
+ * Operator to send exceptions details to a stream.
+ */
+ SCA_API friend std::ostream& operator<< (std::ostream &os, const TuscanyRuntimeException &except);
+
+ protected:
+
+ private:
+ /**
+ * Class name of the exception.
+ */
+ char* class_name;
+
+ /**
+ * Severity level of the exception.
+ */
+ severity_level severity;
+
+ /**
+ * Description of the exception.
+ */
+ char* message_text; // Description of exception
+
+ /**
+ * Location where the exception was thrown or handled and thrown.
+ */
+ class location
+ {
+ public:
+ char* file; // File name (from __FILE__)
+ unsigned long line; // Line number (from __LINE__)
+ char* function; // Function name
+ };
+
+
+ enum {num_locations=5};
+ /**
+ * Array of locations where the exception has been handled and thrown.
+ */
+ location locations[num_locations];
+
+ /**
+ * The current location (index into TuscanyRuntimeException#location).
+ */
+ int location_set;
+
+ /**
+ * A snapshot of the stack when the exception was constructed
+ */
+#if defined(WIN32) || defined (_WINDOWS)
+#else
+ int stacktrace_size;
+ char** stacktrace_symbols;
+#endif
+
+ }; // End TuscanyRuntimeException class definition
+
+
+ /**
+ * Indicates a problem in the consistency of the SCA model provided to the
+ * Tuscany runtime.
+ */
+ class SCA_API SystemConfigurationException: public TuscanyRuntimeException
+ {
+ public:
+ SystemConfigurationException(const char* msg)
+ : TuscanyRuntimeException("SystemConfigurationException", Severe,
+ msg)
+ {
+ }
+
+ SystemConfigurationException(
+ const char *name,
+ severity_level sev,
+ const char* msg_text)
+ : TuscanyRuntimeException(name, sev, msg_text)
+ {
+ }
+
+ SystemConfigurationException(const SDORuntimeException& c)
+ : TuscanyRuntimeException(c)
+ {
+ }
+ private:
+ };
+
+ /**
+ * Indicates a problem while invoking a service.
+ */
+ class SCA_API ServiceInvocationException: public TuscanyRuntimeException
+ {
+ public:
+ ServiceInvocationException(const char* msg)
+ : TuscanyRuntimeException("ServiceInvocationException", Severe, msg)
+ {
+ }
+
+ ServiceInvocationException(
+ const char *name,
+ severity_level sev,
+ const char* msg_text)
+ : TuscanyRuntimeException(name, sev, msg_text)
+ {
+ }
+
+ ServiceInvocationException(const SDORuntimeException& c)
+ : TuscanyRuntimeException(c)
+ {
+ }
+
+ private:
+ };
+
+ /**
+ * Indicates a problem while working with service data.
+ */
+ class SCA_API ServiceDataException: public TuscanyRuntimeException
+ {
+ public:
+ ServiceDataException(const char* msg)
+ : TuscanyRuntimeException("ServiceDataException", Severe,
+ msg)
+ {
+ }
+
+ ServiceDataException(
+ const char *name,
+ severity_level sev,
+ const char* msg_text)
+ : TuscanyRuntimeException(name, sev, msg_text)
+ {
+ }
+
+ ServiceDataException(const SDORuntimeException& c)
+ : TuscanyRuntimeException(c)
+ {
+ }
+ private:
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+
+
+/**
+ * =========================================================================
+ * Macro - throwException
+ *
+ * adds the current file name, line number and function name to the exception.
+ * then throws the exception.
+ * The parameter 'function_name' should be the name of the function throwing
+ * this exception.
+ * The parameter 'type' is the class of exception to throw and must be a
+ * SDORuntimeException or a class derived from SDORuntimeException.
+ * The parameter 'parameter' is the construction parameter for the exception
+ * =========================================================================
+*/
+
+#if defined(WIN32) || defined (_WINDOWS)
+#define throwException(type, parameter) \
+{\
+ type __TuscanyThrownException__(parameter); \
+ __TuscanyThrownException__.setLocation(__FILE__,__LINE__,__FUNCTION__); \
+ throw __TuscanyThrownException__;\
+}
+#else
+#define throwException(type, parameter) \
+{\
+ type __TuscanyThrownException__(parameter); \
+ __TuscanyThrownException__.setLocation(__FILE__,__LINE__,__PRETTY_FUNCTION__); \
+ throw __TuscanyThrownException__;\
+}
+#endif
+
+/**
+ =========================================================================
+ * Macro - rethrowException
+ *
+ * adds the current file name, line number and function name to the exception.
+ * then re-throws the exception.
+ * The parameter 'function_name' should be the name of the function throwing
+ * this exception.
+ * =========================================================================
+*/
+#if defined(WIN32) || defined (_WINDOWS)
+#define rethrowException(exception) \
+{\
+ (exception).setLocation(__FILE__,__LINE__,__FUNCTION__); \
+ throw (exception);\
+}
+#else
+#define rethrowException(exception) \
+{\
+ (exception).setLocation(__FILE__,__LINE__,__PRETTY_FUNCTION__); \
+ throw (exception);\
+}
+#endif
+
+/**
+ * =========================================================================
+ * Macro - handleException
+ *
+ * adds the current file name, line number and function name to the exception.
+ * Writes an exception trace entry then continues.
+ * The parameter 'function_name' should be the name of the function handling
+ * this exception.
+ * =========================================================================
+*/
+#if defined(WIN32) || defined (_WINDOWS)
+#define handleException(__PRETTY_FUNCTION__, exception) \
+{\
+ (exception).setLocation(__FILE__,__LINE__,__FUNCTION__); \
+}
+#else
+#define handleException(__PRETTY_FUNCTION__, exception) \
+{\
+ (exception).setLocation(__FILE__,__LINE__,__PRETTY_FUNCTION__); \
+}
+#endif
+
+#endif // tuscany_sca_core_exceptions_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Operation.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Operation.cpp
new file mode 100644
index 0000000000..335ed5d369
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Operation.cpp
@@ -0,0 +1,578 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <stdarg.h>
+#include <sstream>
+
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace std;
+using namespace commonj::sdo;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ Operation::Operation(const char* operationName)
+ {
+ logentry();
+ if (operationName != 0)
+ {
+ name = operationName;
+ }
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ Operation::~Operation()
+ {
+ logentry();
+ clean();
+ }
+
+ // ==========
+ // Copy Constructor
+ // ==========
+ Operation::Operation(const Operation& op)
+ {
+ logentry();
+ copy(op);
+ }
+
+ // ==========
+ // operator=
+ // ==========
+ Operation& Operation::operator=(const Operation& op)
+ {
+ logentry();
+ if (&op != this)
+ {
+ copy(op);
+ }
+ return *this;
+ }
+
+ // ==========
+ // Clean
+ // ==========
+ void Operation::clean()
+ {
+ logentry();
+ for (unsigned int i = 0; i < getNParms(); i++)
+ {
+ const Parameter& parm = getParameter(i);
+ if (parm.getType() == DATAOBJECT)
+ {
+ delete (DataObjectPtr*)parm.getValue();
+ }
+ }
+
+ parameters.empty();
+
+ if (getReturnType() == DATAOBJECT)
+ {
+ delete (DataObjectPtr*)getReturnValue();
+ }
+ }
+
+ // ==========
+ // Copy
+ // ==========
+ void Operation::copy(const Operation& op)
+ {
+ logentry();
+ clean();
+ for (unsigned int i = 0; i < op.getNParms(); i++)
+ {
+ const Parameter& parm = op.getParameter(i);
+ if (parm.getType() == DATAOBJECT)
+ {
+ addParameter((const DataObject*)parm.getValue());
+ }
+ else
+ {
+ parameters.insert(parameters.end(), parm);
+ }
+ }
+
+ if (getReturnType() == DATAOBJECT)
+ {
+ setReturnValue((const DataObjectPtr*)op.getReturnValue());
+ }
+ else
+ {
+ returnValue = op.returnValue;
+ }
+ }
+
+ // ==============================================
+ // getParameter: return parameter at position pos
+ // ==============================================
+ void* Operation::getParameterValue(unsigned int pos) const
+ {
+ logentry();
+ if (pos < parameters.size())
+ {
+ return parameters[pos].getValue();
+ }
+
+ return 0;
+ }
+
+ // ==================================================
+ // getParameter: return parameter value based on name
+ // ==================================================
+ void* Operation::getParameterValue(const string& name) const
+ {
+ logentry();
+ try
+ {
+ return getParameter(name).getValue();
+ }
+ catch(ServiceInvocationException)
+ {}
+
+ return 0;
+ }
+
+ // ======================================================
+ // getParameter: return parameter based on index position
+ // ======================================================
+ const Operation::Parameter& Operation::getParameter(unsigned int pos) const
+ {
+ logentry();
+ if (pos < parameters.size())
+ {
+ return parameters[pos];
+ }
+
+ throwException(ServiceInvocationException, "Index out of range");
+ }
+
+ // ===============================================
+ // getParameter: return of parameter based on name
+ // ===============================================
+ const Operation::Parameter& Operation::getParameter(const string& name) const
+ {
+ logentry();
+ for(unsigned int pos=0; pos < parameters.size(); pos++)
+ {
+ if(parameters[pos].getName() == name)
+ {
+ return parameters[pos];
+ }
+ }
+
+ throwException(ServiceInvocationException, "Parameter name not found");
+ }
+
+
+ // ============================================================
+ // getParameterType: return type of parameter based on position
+ // ============================================================
+ Operation::ParameterType Operation::getParameterType(unsigned int pos) const
+ {
+ logentry();
+ if (pos < parameters.size())
+ {
+ return parameters[pos].getType();
+ }
+
+ return VOID_TYPE;
+ }
+
+ // ========================================================
+ // getParameterType: return type of parameter based on name
+ // ========================================================
+ Operation::ParameterType Operation::getParameterType(const string& name) const
+ {
+ logentry();
+ try
+ {
+ return getParameter(name).getType();
+ }
+ catch(ServiceInvocationException)
+ {}
+
+ return VOID_TYPE;
+ }
+
+ const string emptyString = string();
+
+ // ==============================================
+ // getParameterName: return name of parameter
+ // ==============================================
+ const string& Operation::getParameterName(unsigned int pos) const
+ {
+ logentry();
+ if (pos < parameters.size())
+ {
+ return parameters[pos].getName();
+ }
+
+ return emptyString;
+ }
+
+ // ===========================================
+ // addParameter: set parameter at position pos
+ // ===========================================
+ void Operation::addParameter(const void *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: void, value: %p", parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, VOID_TYPE));
+ }
+
+ void Operation::addParameter(const bool *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: bool, value: %d", (int)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, BOOL));
+ }
+
+ void Operation::addParameter(const short *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: short, value: %hd", (short)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, SHORT));
+ }
+
+ void Operation::addParameter(const int *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: int, value: %d", (int)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, INT));
+ }
+
+ void Operation::addParameter(const long *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: long, value: %ld", (long)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, LONG));
+ }
+
+ void Operation::addParameter(const unsigned short *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: unsigned short, value: %hu", (unsigned short)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, USHORT));
+ }
+
+ void Operation::addParameter(const unsigned int *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: unsigned int, value: %u", (unsigned int)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, UINT));
+ }
+
+ void Operation::addParameter(const unsigned long *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: unsigned long, value: %lu", (unsigned long)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, ULONG));
+ }
+
+ void Operation::addParameter(const float *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: float, value: %f", (float)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, FLOAT));
+ }
+
+ void Operation::addParameter(const double *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: double, value: %lf", (double)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, DOUBLE));
+ }
+
+ void Operation::addParameter(const long double *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: long double, value: %Lf", (long double)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, LONGDOUBLE));
+ }
+
+ void Operation::addParameter(const char* *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: char*, value: %s", (const char*)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, CHARS));
+ }
+
+ void Operation::addParameter(const char *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: char, value: %d", (int)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, CHAR));
+ }
+
+ void Operation::addParameter(const string *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, type: string, value: %s", (const char*)(*parm).c_str());
+ parameters.insert(parameters.end(), Parameter((void*)parm, STRING));
+ }
+
+ void Operation::addParameter(const DataObjectPtr *parm)
+ {
+ logentry();
+ ostringstream os;
+ os << *parm;
+ loginfo("Adding operation parameter, type: DataObject, value: %s", os.str().c_str());
+ parameters.insert(parameters.end(), Parameter((void*)new DataObjectPtr(*parm), DATAOBJECT));
+ }
+
+ // =======================================================
+ // addParameter: set parameter at position pos with a name
+ // =======================================================
+ void Operation::addParameter(const string& name, const void *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: void, value: %p", name.c_str(), parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, VOID_TYPE, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const bool *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: bool, value: %d", name.c_str(), (int)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, BOOL, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const short *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: short, value: %hd", name.c_str(), (short)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, SHORT, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const int *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: int, value: %d", name.c_str(), (int)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, INT, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const long *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: long, value: %ld", name.c_str(), (long)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, LONG, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const unsigned short *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: unsigned short, value: %hu", (unsigned short)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, USHORT, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const unsigned int *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: unsigned int, value: %u", name.c_str(), (unsigned int)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, UINT, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const unsigned long *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: unsigned long, value: %lu", name.c_str(), (unsigned long)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, ULONG, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const float *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: float, value: %f", name.c_str(), (float)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, FLOAT, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const double *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: double, value: %lf", name.c_str(), (double)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, DOUBLE, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const long double *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: long double, value: %Lf", name.c_str(), (long double)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, LONGDOUBLE, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const char* *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: char*, value: %s", name.c_str(), (const char*)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, CHARS, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const char *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: char, value: %d", name.c_str(), (int)*parm);
+ parameters.insert(parameters.end(), Parameter((void*)parm, CHAR, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const string *parm)
+ {
+ logentry();
+ loginfo("Adding operation parameter, name: %s, type: string, value: %s", name.c_str(), (const char*)(*parm).c_str());
+ parameters.insert(parameters.end(), Parameter((void*)parm, STRING, (string&) name));
+ }
+
+ void Operation::addParameter(const string& name, const DataObjectPtr *parm)
+ {
+ logentry();
+ ostringstream os;
+ os << *parm;
+ loginfo("Adding operation parameter, name: %s, type: DataObject, value: %s", name.c_str(), os.str().c_str());
+ parameters.insert(parameters.end(), Parameter((void*)new DataObjectPtr(*parm), DATAOBJECT, (string&) name));
+ }
+
+ Operation::Parameter::Parameter(void* val, Operation::ParameterType typ, const string& nam)
+ : value(val), type(typ), name(nam)
+ {
+ }
+
+ // ===========================================
+ // setReturnValue
+ // ===========================================
+ void Operation::setReturnValue(const void *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: void, value: %p", parm);
+ returnValue = Parameter((void*)parm, VOID_TYPE);
+ }
+
+ void Operation::setReturnValue(const bool *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: bool, value: %d", (bool)*parm);
+ returnValue = Parameter((void*)parm, BOOL);
+ }
+
+ void Operation::setReturnValue(const short *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: short, value: %h", (short)*parm);
+ returnValue = Parameter((void*)parm, SHORT);
+ }
+
+ void Operation::setReturnValue(const int *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: int, value: %d", (int)*parm);
+ returnValue = Parameter((void*)parm, INT);
+ }
+
+ void Operation::setReturnValue(const long *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: long, value: %l", (long)*parm);
+ returnValue = Parameter((void*)parm, LONG);
+ }
+
+ void Operation::setReturnValue(const unsigned short *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: unsigned short, value: %hu", (unsigned short)*parm);
+ returnValue = Parameter((void*)parm, USHORT);
+ }
+
+ void Operation::setReturnValue(const unsigned int *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: unsigned short, value: %u", (unsigned int)*parm);
+ returnValue = Parameter((void*)parm, UINT);
+ }
+
+ void Operation::setReturnValue(const unsigned long *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: unsigned long, value: %lu", (unsigned long)*parm);
+ returnValue = Parameter((void*)parm, ULONG);
+ }
+
+ void Operation::setReturnValue(const float *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: float, value: %f", (float)*parm);
+ returnValue = Parameter((void*)parm, FLOAT);
+ }
+
+ void Operation::setReturnValue(const double *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: double, value: %lf", (double)*parm);
+ returnValue = Parameter((void*)parm, DOUBLE);
+ }
+
+ void Operation::setReturnValue(const long double *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: long double, value: %Lf", (long double)*parm);
+ returnValue = Parameter((void*)parm, LONGDOUBLE);
+ }
+
+ void Operation::setReturnValue(const char *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: char, value: %d", (char)*parm);
+ returnValue = Parameter((void*)parm, CHAR);
+ }
+
+ void Operation::setReturnValue(const char* *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: char*, value: %s", (char*)*parm);
+ returnValue = Parameter((void*)parm, CHARS);
+ }
+
+ void Operation::setReturnValue(const string *parm)
+ {
+ logentry();
+ loginfo("Setting operation return value, type: string, value: %s", (*parm).c_str());
+ returnValue = Parameter((void*)parm, STRING);
+ }
+
+ void Operation::setReturnValue(const DataObjectPtr *parm)
+ {
+ logentry();
+ ostringstream os;
+ os << *parm;
+ loginfo("Setting operation return value, type: DataObject, value: %s", os.str().c_str());
+ returnValue = Parameter((void*)new DataObjectPtr(*parm), DATAOBJECT);
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Operation.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Operation.h
new file mode 100644
index 0000000000..89cf0b63b7
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/Operation.h
@@ -0,0 +1,251 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_core_operation_h
+#define tuscany_sca_core_operation_h
+
+#include <string>
+#include <vector>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Holds the details of a single invocation of a business method.
+ * This class is used to pass the parameters and operation name from the
+ * client to a service. It will also hold the return value on the
+ * return from the business method.
+ */
+ class Operation
+ {
+ public:
+ /**
+ * Create a new operation.
+ * @param operationName The method name of the business method to be invoked.
+ * @param numParameters The number of parameters to be passed.
+ */
+ SCA_API Operation(const char* operationName = 0);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~Operation();
+
+ /**
+ * Copy constructor.
+ */
+ SCA_API Operation(const Operation& op);
+
+ /**
+ * Assignment operator.
+ */
+ SCA_API Operation& operator=(const Operation& op);
+
+ /**
+ * Return the operation name.
+ * @return The name of the operation.
+ */
+ SCA_API const std::string& getName() const {return name;}
+
+
+ enum ParameterType
+ {
+ UNSET = 0,
+ VOID_TYPE,
+ BOOL,
+ SHORT,
+ INT,
+ LONG,
+ USHORT,
+ UINT,
+ ULONG,
+ FLOAT,
+ DOUBLE,
+ LONGDOUBLE,
+ CHARS,
+ CHAR,
+ STRING,
+ DATAOBJECT
+ };
+
+ class Parameter
+ {
+ public:
+ SCA_API Parameter(void* value = NULL, ParameterType type = VOID_TYPE, const std::string& name = "");
+ SCA_API void* getValue() const {return value;}
+ SCA_API ParameterType getType() const {return type;}
+ SCA_API const std::string& getName() const {return name;}
+ SCA_API bool hasName() const {return (name.length() > 0);}
+
+ private:
+ std::string name;
+ void* value;
+ ParameterType type;
+ };
+
+ /**
+ * Set a return value for the operation.
+ * @param retVal Pointer to the return value.
+ */
+ SCA_API void setReturnValue(const void *retVal);
+ SCA_API void setReturnValue(const bool *retVal);
+ SCA_API void setReturnValue(const short *retVal);
+ SCA_API void setReturnValue(const int *retVal);
+ SCA_API void setReturnValue(const long *retVal);
+ SCA_API void setReturnValue(const unsigned short *retVal);
+ SCA_API void setReturnValue(const unsigned int *retVal);
+ SCA_API void setReturnValue(const unsigned long *retVal);
+ SCA_API void setReturnValue(const float *retVal);
+ SCA_API void setReturnValue(const double *retVal);
+ SCA_API void setReturnValue(const long double *retVal);
+ SCA_API void setReturnValue(const char *retVal);
+ SCA_API void setReturnValue(const char* *retVal);
+ SCA_API void setReturnValue(const std::string *retVal);
+ SCA_API void setReturnValue(const commonj::sdo::DataObjectPtr *retVal);
+
+ /**
+ * Set a parameter on the operation.
+ * @param parm Pointer to the parameter to be passed.
+ */
+ SCA_API void addParameter(const void *parm);
+ SCA_API void addParameter(const bool *parm);
+ SCA_API void addParameter(const short *parm);
+ SCA_API void addParameter(const int *parm);
+ SCA_API void addParameter(const long *parm);
+ SCA_API void addParameter(const unsigned short *parm);
+ SCA_API void addParameter(const unsigned int *parm);
+ SCA_API void addParameter(const unsigned long *parm);
+ SCA_API void addParameter(const float *parm);
+ SCA_API void addParameter(const double *parm);
+ SCA_API void addParameter(const long double *parm);
+ SCA_API void addParameter(const char *parm);
+ SCA_API void addParameter(const char* *parm);
+ SCA_API void addParameter(const std::string *parm);
+ SCA_API void addParameter(const commonj::sdo::DataObjectPtr *parm);
+
+ /**
+ * Set a parameter on the operation.
+ * @param name The name of the parameter in the parameter list.
+ * @param parm Pointer to the parameter to be passed.
+ */
+ SCA_API void addParameter(const std::string& name, const void *parm);
+ SCA_API void addParameter(const std::string& name, const bool *parm);
+ SCA_API void addParameter(const std::string& name, const short *parm);
+ SCA_API void addParameter(const std::string& name, const int *parm);
+ SCA_API void addParameter(const std::string& name, const long *parm);
+ SCA_API void addParameter(const std::string& name, const unsigned short *parm);
+ SCA_API void addParameter(const std::string& name, const unsigned int *parm);
+ SCA_API void addParameter(const std::string& name, const unsigned long *parm);
+ SCA_API void addParameter(const std::string& name, const float *parm);
+ SCA_API void addParameter(const std::string& name, const double *parm);
+ SCA_API void addParameter(const std::string& name, const long double *parm);
+ SCA_API void addParameter(const std::string& name, const char *parm);
+ SCA_API void addParameter(const std::string& name, const char* *parm);
+ SCA_API void addParameter(const std::string& name, const std::string *parm);
+ SCA_API void addParameter(const std::string& name, const commonj::sdo::DataObjectPtr *parm);
+
+ SCA_API unsigned int getNParms() const {return parameters.size();}
+
+ /**
+ * Get a parameter from the operation.
+ * @param pos The position of the parameter in the parameter list.
+ * @return Pointer to the paramter at the given postion. Should be
+ * cast to the appropriate type.
+ */
+ SCA_API const Parameter& getParameter(unsigned int pos) const;
+
+ /**
+ * Get a parameter from the operation.
+ * @param name The name of the parameter in the parameter list.
+ * @return Pointer to the paramter with the given name. Should be
+ * cast to the appropriate type.
+ */
+ SCA_API const Parameter& getParameter(const std::string& name) const;
+
+ /**
+ * Get a parameter type from the operation.
+ * @param pos The position of the parameter in the parameter list.
+ * @return Type of the parameter at the given position.
+ */
+ SCA_API ParameterType getParameterType(unsigned int pos) const;
+
+ /**
+ * Get a parameter type from the operation.
+ * @param name The name of the parameter in the parameter list.
+ * @return Type of the parameter with the given name.
+ */
+ SCA_API ParameterType getParameterType(const std::string& name) const;
+
+ /**
+ * Get a parameter name from the operation.
+ * @param pos The position of the parameter in the parameter list.
+ * @return Name of the parameter at the given position.
+ */
+ SCA_API const std::string& getParameterName(unsigned int pos) const;
+
+ /**
+ * Get the parameter value from the operation.
+ * @param pos The position of the parameter in the parameter list.
+ * @return Pointer to the value of the parameter at the given postion. Should be
+ * cast to the appropriate type.
+ */
+ SCA_API void* getParameterValue(unsigned int pos) const;
+
+ /**
+ * Get the parameter value from the operation.
+ * @param name The name of the parameter in the parameter list.
+ * @return Pointer to the value of the parameter with the given name. Should be
+ * cast to the appropriate type.
+ */
+ SCA_API void* getParameterValue(const std::string& name) const;
+
+ SCA_API ParameterType getReturnType() const {return returnValue.getType();}
+ SCA_API void* getReturnValue() const {return returnValue.getValue();}
+
+ private:
+ /**
+ * Operation name (method name).
+ */
+ std::string name;
+
+ /**
+ * Array of parameters.
+ */
+ typedef std::vector<Parameter> PARAMETER_VECTOR;
+
+ PARAMETER_VECTOR parameters;
+
+ Parameter returnValue;
+
+ void clean();
+ void copy(const Operation& op);
+
+ };
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_operation_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/SCARuntime.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
new file mode 100644
index 0000000000..b518eff673
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
@@ -0,0 +1,619 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include "tuscany_sca_config.h"
+#endif
+
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/ModelLoader.h"
+#include "tuscany/sca/util/File.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Environment variable names
+ */
+ static const char* TUSCANY_SCACPP = "TUSCANY_SCACPP";
+ static const char* TUSCANY_SCACPP_SYSTEM_ROOT = "TUSCANY_SCACPP_SYSTEM_ROOT";
+ static const char* TUSCANY_SCACPP_DEFAULT_COMPONENT = "TUSCANY_SCACPP_DEFAULT_COMPONENT";
+
+ static const char* TUSCANY_SCACPP_ROOT = "TUSCANY_SCACPP_ROOT";
+ static const char* TUSCANY_SCACPP_COMPONENT = "TUSCANY_SCACPP_COMPONENT";
+ static const char* TUSCANY_SCACPP_PATH = "TUSCANY_SCACPP_PATH";
+ static const char* TUSCANY_SCACPP_BASE_URI = "TUSCANY_SCACPP_BASE_URI";
+
+ // Initialize statics
+ SCARuntime* SCARuntime::sharedRuntime = NULL;
+ Mutex SCARuntime::sharedRuntimeLock;
+ ThreadLocal SCARuntime::current;
+
+
+ // ===================================================================
+ // Constructor for the SCARuntime class. This will
+ // hold all the information about the current runtime.
+ // ===================================================================
+ SCARuntime::SCARuntime(const string& insRoot,
+ const string& sysRoot, const string& sysPath,
+ const string& base, const string& defName)
+ : system(0),
+ installRoot(insRoot), systemRoot(sysRoot), systemPath(sysPath),
+ defaultBaseURI(base), defaultComponentName(defName)
+ {
+ logentry();
+
+ if (installRoot == "")
+ {
+ // Get install dir from environment variable TUSCANY_SCACPP
+ const char* root = getenv(TUSCANY_SCACPP);
+ if (root != NULL)
+ {
+ installRoot = root;
+ }
+ else
+ {
+ string msg = TUSCANY_SCACPP;
+ msg += " environment variable not set";
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ }
+ loginfo("SCA runtime install root: %s", installRoot.c_str());
+
+ if (systemRoot == "")
+ {
+ // Get root from environment variable TUSCANY_SCACPP_ROOT
+ char* systemRootEnv = getenv(TUSCANY_SCACPP_ROOT);
+ if (systemRootEnv == 0)
+ {
+ // Get root from environment variable TUSCANY_SCACPP_SYSTEM_ROOT
+ systemRootEnv = getenv(TUSCANY_SCACPP_SYSTEM_ROOT);
+ }
+ if (systemRootEnv == 0)
+ {
+ string msg = TUSCANY_SCACPP_ROOT;
+ msg += " environment variable not set";
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ systemRoot = systemRootEnv;
+ }
+ else
+ {
+ loginfo("System root: %s", systemRoot.c_str());
+ }
+
+ if (systemPath == "")
+ {
+
+ // Get system path from environment variable TUSCANY_SCACPP_PATH
+ char* systemPathEnv = getenv(TUSCANY_SCACPP_PATH);
+ if (systemPathEnv != 0)
+ {
+ systemPath = systemPathEnv;
+ }
+ }
+ else
+ {
+ loginfo("System path: %s", systemPath.c_str());
+ }
+
+ if (defaultBaseURI == "")
+ {
+
+ // Get default base URI from environment variable TUSCANY_SCACPP_BASE_URI
+ char* baseURI = getenv(TUSCANY_SCACPP_BASE_URI);
+ if (baseURI != 0)
+ {
+ defaultBaseURI = baseURI;
+ }
+ }
+ else
+ {
+ loginfo("Default base URI: %s", defaultBaseURI.c_str());
+ }
+
+ if (defaultComponentName == "")
+ {
+ const char* defComp = getenv(TUSCANY_SCACPP_COMPONENT);
+ if (!defComp)
+ {
+ defComp = getenv(TUSCANY_SCACPP_DEFAULT_COMPONENT);
+ }
+ if (defComp)
+ {
+ defaultComponentName = defComp;
+ }
+ }
+ loginfo("Default component: %s", defaultComponentName.c_str());
+
+ SCARuntime* currentRuntime = (SCARuntime*)current.getValue();
+ current.setValue(this);
+ try
+ {
+
+ // Load the runtime extensions
+ loadExtensions();
+
+ // Load the system composite
+ loadSystem();
+ }
+ catch (...)
+ {
+ current.setValue(currentRuntime);
+ throw;
+ }
+ current.setValue(currentRuntime);
+
+ // Find the default component
+ if (defaultComponentName != "")
+ {
+ Component* comp = system->findComponent(defaultComponentName);
+ if (!comp)
+ {
+ string message = "Component \'" + defaultComponentName + "\' not found";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ defaultComponent.setValue(comp);
+ }
+
+ }
+
+ // ===================================================================
+ // Destructor for the SCARuntime class.
+ // ===================================================================
+ SCARuntime::~SCARuntime()
+ {
+ logentry();
+
+ if (system)
+ {
+ delete system;
+ }
+ }
+
+ // ==========================================================
+ // Returns the system configuration root
+ // ==========================================================
+ const string& SCARuntime::getSystemRoot()
+ {
+ return systemRoot;
+ }
+
+ // ==========================================================
+ // Returns the system path
+ // ==========================================================
+ const string& SCARuntime::getSystemPath()
+ {
+ return systemPath;
+ }
+
+ // ==========================================================
+ // Returns the default component name
+ // ==========================================================
+ const string& SCARuntime::getDefaultComponentName()
+ {
+ return defaultComponentName ;
+ }
+
+ // ==========================================================
+ // Returns the default base URI
+ // ==========================================================
+ const string& SCARuntime::getDefaultBaseURI()
+ {
+ return defaultBaseURI;
+ }
+
+ // ==========================================================
+ // Returns the install root
+ // ==========================================================
+ const string& SCARuntime::getInstallRoot()
+ {
+ return installRoot;
+ }
+
+ // =============================================================
+ // Get the runtime associated with the current thread.
+ // =============================================================
+ SCARuntime* SCARuntime::getCurrentRuntime()
+ {
+ logentry();
+
+ SCARuntime* runtime = (SCARuntime*)current.getValue();
+ if (runtime == NULL)
+ {
+ runtime = getSharedRuntime();
+ if (runtime != NULL)
+ {
+ setCurrentRuntime(runtime);
+ }
+ else
+ {
+ runtime = new SCARuntime();
+ setCurrentRuntime(runtime);
+ }
+ }
+ loginfo("Runtime: %p", runtime);
+ return runtime;
+ }
+
+ // =============================================================
+ // Set the runtime associated with the current thread.
+ // =============================================================
+ void SCARuntime::setCurrentRuntime(SCARuntime* runtime)
+ {
+ logentry();
+
+ loginfo("Runtime: %p", runtime);
+ current.setValue(runtime);
+ }
+
+ // =============================================================
+ // Get the runtime associated with the current process.
+ // =============================================================
+ SCARuntime* SCARuntime::getSharedRuntime()
+ {
+ logentry();
+
+ sharedRuntimeLock.lock();
+ SCARuntime* runtime = sharedRuntime;
+ sharedRuntimeLock.unlock();
+
+ return runtime;
+ }
+
+ // =============================================================
+ // Initialize the runtime associated with the current process.
+ // =============================================================
+ SCARuntime* SCARuntime::initializeSharedRuntime(const string& installRoot, const string& systemRoot,
+ const string& systemPath, const string& baseURI, const string& defaultComponentName)
+ {
+ logentry();
+
+ SCARuntime* runtime;
+
+ sharedRuntimeLock.lock();
+ try
+ {
+ if (sharedRuntime == NULL)
+ {
+ sharedRuntime = new SCARuntime(installRoot, systemRoot, systemPath, baseURI, defaultComponentName);
+ }
+ else
+ {
+ if (installRoot.size() != 0 && sharedRuntime->getInstallRoot() != installRoot)
+ {
+ string msg = "Cannot reconfigure runtime installation directory: " + string(installRoot);
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ if (systemRoot.size() != 0 && sharedRuntime->getSystemRoot() != systemRoot)
+ {
+ string msg = "Cannot reconfigure SCA system root: " + string(systemRoot);
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ if (systemPath.size() != 0 && sharedRuntime->getSystemPath() != systemPath)
+ {
+ string msg = "Cannot reconfigure SCA system path: " + string(systemPath);
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ if (baseURI.size() != 0 && sharedRuntime->getDefaultBaseURI() != baseURI)
+ {
+ string msg = "Cannot reconfigure SCA system URI: " + string(baseURI);
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ if (defaultComponentName.size() != 0 && sharedRuntime->getDefaultComponentName() != defaultComponentName)
+ {
+ string msg = "Cannot reconfigure main SCA component: " + string(baseURI);
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ }
+
+ runtime = sharedRuntime;
+ }
+ catch (...)
+ {
+ sharedRuntimeLock.unlock();
+ throw;
+ }
+ sharedRuntimeLock.unlock();
+
+ return runtime;
+ }
+
+ // ======================================
+ // Load the system composite
+ // ======================================
+ void SCARuntime::loadSystem()
+ {
+ logentry();
+
+ system = new Composite("tuscany/sca/system", "");
+ ModelLoader loader(this, system);
+ loader.load(systemRoot, systemPath);
+ }
+
+ // ======================================
+ // Load up extensions to the runtime
+ // ======================================
+ void SCARuntime::loadExtensions()
+ {
+ logentry();
+
+ string extensionsRoot = installRoot + "/extensions";
+
+#if defined(WIN32) || defined (_WINDOWS)
+ string libraryExtension = ".dll";
+#else
+#if defined(IS_DARWIN)
+ string libraryExtension = ".dylib";
+#else
+ string libraryExtension = ".so";
+#endif
+#endif
+ string pattern = "*" + libraryExtension;
+
+ // Get list of all directories named "module"
+ Files extensionModules(extensionsRoot, "module", true, true);
+ for (unsigned int emI=0; emI < extensionModules.size(); emI++)
+ {
+ string extensionRoot = extensionModules[emI].getDirectory().c_str();
+ extensionRoot += "/module";
+ loginfo("Loading extension module: %s", extensionRoot.c_str() );
+
+ Files files(extensionRoot, pattern, true);
+ for (unsigned int i=0; i < files.size(); i++)
+ {
+ try
+ {
+ string filename = files[i].getFileName();
+ Library lib = Library( files[i].getDirectory() + "/" + filename);
+
+ // Determine the name of the initialize method
+ // 1) strip the .dll/.so/.dylib suffix
+ // 2) for non-Windows strip any lib prefix
+ string initializeMethod;
+ #if defined(WIN32) || defined (_WINDOWS)
+ #else
+ if (filename.substr(0,3) == "lib")
+ {
+ initializeMethod = filename.substr(3, filename.size()-libraryExtension.size() - 3);
+ }
+ else
+ #endif
+ {
+ initializeMethod = filename.substr(0, filename.size()-libraryExtension.size());
+ }
+ initializeMethod += "_initialize";
+ TUSCANY_IMPLEMENTATION_EXTENSION_INITIALIZE extension =
+ (TUSCANY_IMPLEMENTATION_EXTENSION_INITIALIZE)lib.getSymbol(initializeMethod);
+ if (extension)
+ {
+ extension();
+ extensionsList.push_back(lib);
+ }
+ }
+ catch (TuscanyRuntimeException& ex)
+ {
+ logwarning("Failed to load extension library: %s: %s: %s",
+ files[i].getFileName().c_str(), ex.getEClassName(), ex.getMessageText());
+ }
+ }
+ }
+ }
+
+
+ // ======================================
+ // register an interfaceExtension
+ // ======================================
+ void SCARuntime::registerInterfaceExtension(InterfaceExtension* extension)
+ {
+ logentry();
+ if (extension)
+ {
+ loginfo("Registering interface: %s", extension->getExtensionTypeQName().c_str());
+ interfaceExtensions[extension->getExtensionTypeQName()] = extension;
+ }
+ }
+
+ // ======================================
+ // find an InterfaceExtension
+ // ======================================
+ InterfaceExtension* SCARuntime::getInterfaceExtension(const string& extensionTypeQName)
+ {
+ return interfaceExtensions[extensionTypeQName];
+ }
+
+ // ======================================
+ // register an implementationExtension
+ // ======================================
+ void SCARuntime::registerImplementationExtension(ImplementationExtension* extension)
+ {
+ logentry();
+ if (extension)
+ {
+ loginfo("Registering implementation: %s", extension->getExtensionTypeQName().c_str());
+ implementationExtensions[extension->getExtensionTypeQName()] = extension;
+ }
+ }
+
+ // ======================================
+ // find an implementationExtension
+ // ======================================
+ ImplementationExtension* SCARuntime::getImplementationExtension(const string& extensionTypeQName)
+ {
+ return implementationExtensions[extensionTypeQName];
+ }
+
+ // ======================================
+ // register a referenceBindingExtension
+ // ======================================
+ void SCARuntime::registerReferenceBindingExtension(ReferenceBindingExtension* extension)
+ {
+ logentry();
+ if (extension)
+ {
+ loginfo("Registering reference binding: %s", extension->getExtensionTypeQName().c_str());
+ referenceBindingExtensions[extension->getExtensionTypeQName()] = extension;
+ }
+ }
+
+ // ======================================
+ // find a referenceBindingExtension
+ // ======================================
+ ReferenceBindingExtension* SCARuntime::getReferenceBindingExtension(const string& extensionTypeQName)
+ {
+ return referenceBindingExtensions[extensionTypeQName];
+ }
+
+ // ======================================
+ // register a serviceBindingExtension
+ // ======================================
+ void SCARuntime::registerServiceBindingExtension(ServiceBindingExtension* extension)
+ {
+ logentry();
+ if (extension)
+ {
+ loginfo("Registering service binding: %s", extension->getExtensionTypeQName().c_str());
+ serviceBindingExtensions[extension->getExtensionTypeQName()] = extension;
+ }
+ }
+
+ // ======================================
+ // find a serviceBindingExtension
+ // ======================================
+ ServiceBindingExtension* SCARuntime::getServiceBindingExtension(const string& extensionTypeQName)
+ {
+ return serviceBindingExtensions[extensionTypeQName];
+ }
+
+
+ // ===================================
+ // Return the top of the runtime model
+ // ===================================
+ Composite* SCARuntime::getSystem()
+ {
+ logentry();
+
+ return system;
+ }
+
+
+ // ===================================================
+ // setCurrentComponent: push component for this thread
+ // ===================================================
+ void SCARuntime::setCurrentComponent(Component* component)
+ {
+ logentry();
+
+ COMPONENT_STACK* compStack = (COMPONENT_STACK*)componentStack.getValue();
+ if (compStack == NULL)
+ {
+ compStack = new COMPONENT_STACK();
+ componentStack.setValue(compStack);
+ }
+ compStack->push(component);
+ }
+
+ // ====================================================
+ // unsetCurrentComponent: pop component for this thread
+ // ====================================================
+ Component* SCARuntime::unsetCurrentComponent()
+ {
+ logentry();
+
+ COMPONENT_STACK* compStack = (COMPONENT_STACK*)componentStack.getValue();
+ if (compStack != NULL)
+ {
+ if (compStack->size() > 0)
+ {
+ Component* component = compStack->top();
+ compStack->pop();
+ return component;
+ }
+ }
+
+ return NULL;
+ }
+
+ // =============================================================
+ // getCurrentComponent: return current component for this thread
+ // =============================================================
+ Component* SCARuntime::getCurrentComponent()
+ {
+ logentry();
+
+ COMPONENT_STACK* compStack = (COMPONENT_STACK*)componentStack.getValue();
+ if (compStack != NULL)
+ {
+ if (compStack->size() > 0)
+ {
+ return compStack->top();
+ }
+ }
+
+ return NULL;
+ }
+
+ // ===========================================
+ // getDefaultComponent: return the default composite component
+ // ===========================================
+ Component* SCARuntime::getDefaultComponent()
+ {
+ logentry();
+
+ Component* comp = (Component*)defaultComponent.getValue();
+ if (comp == NULL && defaultComponentName != "")
+ {
+ comp = system->findComponent(defaultComponentName);
+ if (!comp)
+ {
+ string message = "Component \'" + defaultComponentName + "\' not found";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ defaultComponent.setValue(comp);
+ }
+ return comp;
+ }
+
+ // ===========================================
+ // Set the default composite component
+ // ===========================================
+ void SCARuntime::setDefaultComponent(Component* component)
+ {
+ logentry();
+
+ return defaultComponent.setValue(component);
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/SCARuntime.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/SCARuntime.h
new file mode 100644
index 0000000000..ff93bd5005
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/SCARuntime.h
@@ -0,0 +1,295 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_core_scaruntime_h
+#define tuscany_sca_core_scaruntime_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <pthread.h>
+#endif
+
+#include <stack>
+#include <string>
+#include <map>
+#include <list>
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/extension/InterfaceExtension.h"
+#include "tuscany/sca/extension/ImplementationExtension.h"
+#include "tuscany/sca/extension/ReferenceBindingExtension.h"
+#include "tuscany/sca/extension/ServiceBindingExtension.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/util/ThreadLocal.h"
+#include "tuscany/sca/util/Mutex.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ /**
+ * Represents an executing SCA runtime.
+ */
+ class SCARuntime {
+ public:
+
+ /**
+ * Constructor
+ */
+ SCA_API SCARuntime(const std::string& installRoot = "",
+ const std::string& systemRoot = "", const std::string& systemPath = "",
+ const std::string& baseURI = "", const std::string& defaultComponentName = "");
+
+ /**
+ * Destructor
+ */
+ SCA_API virtual ~SCARuntime();
+
+ /**
+ * Get the runtime associated with the current thread.
+ * @return The runtime associated with the current thread.
+ */
+ SCA_API static SCARuntime* getCurrentRuntime();
+
+ /**
+ * Get the runtime associated with the current thread.
+ * @return The runtime associated with the current thread.
+ */
+ SCA_API static void setCurrentRuntime(SCARuntime* runtime);
+
+ /**
+ * Get the runtime associated with the current process.
+ * @return The runtime associated with the current process.
+ */
+ SCA_API static SCARuntime* getSharedRuntime();
+
+ /**
+ * Initialize the runtime associated with the current process.
+ * @return The runtime associated with the current process.
+ */
+ SCA_API static SCARuntime* initializeSharedRuntime(const std::string& installRoot = "",
+ const std::string& systemRoot = "", const std::string& systemPath = "",
+ const std::string& baseURI = "", const std::string& defaultComponentName = "");
+
+ /**
+ * Returns the directory in which the Tuscany runtime has been installed.
+ */
+ SCA_API const std::string& getInstallRoot();
+
+ /**
+ * Returns the system root
+ */
+ SCA_API const std::string& getSystemRoot();
+
+ /**
+ * Returns the search path for composites.
+ */
+ SCA_API const std::string& getSystemPath();
+
+ /**
+ * Returns the default component name.
+ */
+ SCA_API const std::string& getDefaultComponentName();
+
+ /**
+ * Returns the default base URI for the system
+ */
+ SCA_API const std::string& getDefaultBaseURI();
+
+ /**
+ * Set the current component for the current thread.
+ * @param component The current component.
+ */
+ SCA_API void setCurrentComponent(tuscany::sca::model::Component* component);
+
+ /**
+ * Remove the current component from this thread, and return
+ * to the previous component (if there was one).
+ * @return The previous component.
+ */
+ SCA_API tuscany::sca::model::Component* unsetCurrentComponent();
+
+ /**
+ * Get a pointer to the configured SCA system which this
+ * SCA runtime represents.
+ * The rest of the SCA configuration can be navigated from
+ * the System.
+ * @return The configured SCA system.
+ */
+ SCA_API tuscany::sca::model::Composite* getSystem();
+
+ /**
+ * Return the current component for this thread.
+ * @return The current component for this thread.
+ */
+ SCA_API tuscany::sca::model::Component* getCurrentComponent();
+
+ /**
+ * Get the default component set for the current thread.
+ * @return The default composite.
+ */
+ SCA_API tuscany::sca::model::Component* getDefaultComponent();
+
+ /**
+ * Set the default component for the current thread.
+ * @return The default component.
+ */
+ SCA_API void setDefaultComponent(tuscany::sca::model::Component* component);
+
+ /**
+ * Register an implementation extension
+ */
+ SCA_API void registerImplementationExtension(ImplementationExtension* extension);
+
+ /**
+ * Returns the implementation extension associated with
+ * the specified qname
+ */
+ SCA_API ImplementationExtension* getImplementationExtension(const std::string& typeQname);
+
+ /**
+ * Register a reference binding extension
+ */
+ SCA_API void registerReferenceBindingExtension(ReferenceBindingExtension* extension);
+
+ /**
+ * Returns the reference binding extension associated with
+ * the specified qname
+ */
+ SCA_API ReferenceBindingExtension* getReferenceBindingExtension(const std::string& typeQname);
+
+ /**
+ * Register a service binding extension
+ */
+ SCA_API void registerServiceBindingExtension(ServiceBindingExtension* extension);
+
+ /**
+ * Returns the service binding extension associated with
+ * the specified qname
+ */
+ SCA_API ServiceBindingExtension* getServiceBindingExtension(const std::string& typeQname);
+
+ /**
+ * Register an interface extension
+ */
+ SCA_API void registerInterfaceExtension(InterfaceExtension* extension);
+
+ /**
+ * Returns the interface extension associated with
+ * the specified qname
+ */
+ SCA_API InterfaceExtension* getInterfaceExtension(const std::string& typeQname);
+
+ private:
+
+ /**
+ * The runtime associated with the current thread.
+ */
+ static tuscany::sca::util::ThreadLocal current;
+
+ /**
+ * The runtime shared by all threads of the current process.
+ */
+ static tuscany::sca::util::Mutex sharedRuntimeLock;
+ static SCARuntime* sharedRuntime;
+
+ /**
+ * Pointer to the top of the runtime model.
+ */
+ tuscany::sca::model::Composite* system;
+
+ /**
+ * The installed path of the Tuscany runtime.
+ */
+ std::string installRoot;
+
+ /**
+ * The path to the system configuration
+ */
+ std::string systemRoot;
+
+ /**
+ * The search path for composites.
+ */
+ std::string systemPath;
+
+ /**
+ * The default base URI.
+ */
+ std::string defaultBaseURI;
+
+ /**
+ * The default CompositeComponent name.
+ */
+ std::string defaultComponentName;
+
+ /**
+ * Load the SCA configuration from the scdl files (sca.composite,
+ * *.fragment, etc).
+ * This will create the runtime model from which the SCA runtime
+ * will operate.
+ */
+ void loadSystem();
+
+ /**
+ * Component stack for the current thread.
+ */
+ typedef std::stack<tuscany::sca::model::Component*> COMPONENT_STACK;
+ tuscany::sca::util::ThreadLocal componentStack;
+
+ /**
+ * The default component for the current thread.
+ */
+ tuscany::sca::util::ThreadLocal defaultComponent;
+
+ /**
+ * Runtime Extensions
+ */
+ typedef std::map<std::string, ImplementationExtension*> IMPLEMENTATION_EXTENSIONS_MAP;
+ IMPLEMENTATION_EXTENSIONS_MAP implementationExtensions;
+
+ typedef std::map<std::string, ReferenceBindingExtension*> REFERENCE_BINDING_EXTENSIONS_MAP;
+ REFERENCE_BINDING_EXTENSIONS_MAP referenceBindingExtensions;
+
+ typedef std::map<std::string, ServiceBindingExtension*> SERVICE_BINDING_EXTENSIONS_MAP;
+ SERVICE_BINDING_EXTENSIONS_MAP serviceBindingExtensions;
+
+ typedef std::map<std::string, InterfaceExtension*> INTERFACE_EXTENSIONS_MAP;
+ INTERFACE_EXTENSIONS_MAP interfaceExtensions;
+
+ void loadExtensions();
+
+ typedef std::list<tuscany::sca::util::Library> EXTENSIONS_LIST;
+ EXTENSIONS_LIST extensionsList;
+
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+
+typedef void (* TUSCANY_IMPLEMENTATION_EXTENSION_INITIALIZE) ();
+
+#endif // tuscany_sca_core_scaruntime_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp
new file mode 100644
index 0000000000..c54d7648e3
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ ServiceProxy::ServiceProxy(Reference* reference)
+ : reference(reference)
+ {
+ logentry();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ServiceProxy::~ServiceProxy()
+ {
+ logentry();
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceProxy.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceProxy.h
new file mode 100644
index 0000000000..f1a0309be1
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceProxy.h
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_core_serviceproxy_h
+#define tuscany_sca_core_serviceproxy_h
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ /**
+ * Holds a proxy for a given component and reference.
+ * The proxy which is held inside a ServiceProxy will be specific to the component
+ * and reference and will have been code generated and be contained in a dll
+ * created by a developer of an SCA application.
+ */
+ class SCA_API ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a reference. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The reference on the source component.
+ * @param target The wrapper of the service which is wired to this reference.
+ */
+ ServiceProxy(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ServiceProxy();
+
+ /**
+ * Returns the reference represented by this proxy.
+ * @return The Reference represented by this proxy.
+ */
+ tuscany::sca::model::Reference* getReference() const { return reference; };
+
+ private:
+
+ /**
+ * The reference represented by this proxy.
+ */
+ tuscany::sca::model::Reference* reference;
+
+ };
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_serviceproxy_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp
new file mode 100644
index 0000000000..17666a5bb7
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/util/Logging.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ // ===========
+ // Constructor
+ // ===========
+ ServiceWrapper::ServiceWrapper(Service* service)
+ : service(service)
+ {
+ logentry();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ServiceWrapper::~ServiceWrapper()
+ {
+ logentry();
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceWrapper.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceWrapper.h
new file mode 100644
index 0000000000..6a44c57675
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/core/ServiceWrapper.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_core_servicewrapper_h
+#define tuscany_sca_core_servicewrapper_h
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/Service.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ /**
+ * An abstract class that wraps a component implementation or an external
+ * service.
+ */
+ class SCA_API ServiceWrapper
+ {
+ public:
+ /**
+ * Constructor.
+ * @param target The service wrapper wraps the target of a wire.
+ */
+ ServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ServiceWrapper();
+
+ /**
+ * Get the service represented by this wrapper.
+ * @return The service represented by this wrapper.
+ */
+ tuscany::sca::model::Service* getService() const { return service; }
+
+ /**
+ * All business method calls on the target service are performed through
+ * this invoke method.
+ * @param operation The details of the method, paramaters and return value for the
+ * business method to be called on the target service.
+ */
+ virtual void invoke(Operation& operation) = 0;
+
+ private:
+ /**
+ * The target represented by this wrapper.
+ */
+ tuscany::sca::model::Service* service;
+
+ };
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_servicewrapper_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/export.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/export.h
new file mode 100644
index 0000000000..79b02fe4cf
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/export.h
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_export_h
+#define tuscany_sca_export_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef SCA_EXPORTS
+#define SCA_API __declspec(dllexport)
+#else
+#define SCA_API __declspec(dllimport)
+#endif
+
+#else
+#include <sys/time.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#define SCA_API
+#endif
+
+#endif // tuscany_sca_export_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp
new file mode 100644
index 0000000000..a20cf1f6da
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/extension/ImplementationExtension.h"
+#include "tuscany/sca/util/Logging.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ // ===================================================================
+ // Constructor for the ImplementationExtension class.
+ // ===================================================================
+ ImplementationExtension::ImplementationExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the ImplementationExtension class.
+ // ===================================================================
+ ImplementationExtension::~ImplementationExtension()
+ {
+ logentry();
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h
new file mode 100644
index 0000000000..524af2df77
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_implementationextension_h
+#define tuscany_sca_extension_implementationextension_h
+
+#include <string>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Composite.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ class SCA_API ImplementationExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ ImplementationExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~ImplementationExtension();
+
+ /**
+ * return the name of the extension (e.g. "cpp" "php")
+ */
+ virtual const std::string& getExtensionName() = 0;
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.cpp")
+ */
+ virtual const std::string& getExtensionTypeQName() = 0;
+
+ /**
+ * Get an implementation from a DataObject representing
+ * an SCDL implementation element
+ */
+ virtual tuscany::sca::model::ComponentType* getImplementation(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlImplementation) = 0;
+
+ };
+
+
+ } // End namespace sca
+} // End namespace tuscany
+
+
+#endif // tuscany_sca_extension_implementationextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/InterfaceExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/InterfaceExtension.cpp
new file mode 100644
index 0000000000..584945344b
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/InterfaceExtension.cpp
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/extension/InterfaceExtension.h"
+#include "tuscany/sca/util/Logging.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ // ===================================================================
+ // Constructor for the InterfaceExtension class.
+ // ===================================================================
+ InterfaceExtension::InterfaceExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the InterfaceExtension class.
+ // ===================================================================
+ InterfaceExtension::~InterfaceExtension()
+ {
+ logentry();
+ }
+
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h
new file mode 100644
index 0000000000..5329104c77
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_interfaceextension_h
+#define tuscany_sca_extension_interfaceextension_h
+
+#include <string>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/model/Composite.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ class SCA_API InterfaceExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ InterfaceExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~InterfaceExtension();
+
+ /**
+ * return the name of the extension (e.g. "cpp" "php")
+ */
+ virtual const std::string& getExtensionName() = 0;
+
+ /**
+ * return the QName of schema elemant for this interface extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp")
+ */
+ virtual const std::string& getExtensionTypeQName() = 0;
+
+ /**
+ * Get an interface from a DataObject representing an
+ * SCDL interface
+ */
+ virtual tuscany::sca::model::Interface* getInterface(
+ tuscany::sca::model::Composite *composite,
+ commonj::sdo::DataObjectPtr scdlInterface) = 0;
+
+ };
+
+
+ } // End namespace sca
+} // End namespace tuscany
+
+
+#endif // tuscany_sca_extension_interfaceextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.cpp
new file mode 100644
index 0000000000..a7f60dcbec
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/extension/ReferenceBindingExtension.h"
+#include "tuscany/sca/util/Logging.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ // ===================================================================
+ // Constructor for the ReferenceBindingExtension class.
+ // ===================================================================
+ ReferenceBindingExtension::ReferenceBindingExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the ReferenceBindingExtension class.
+ // ===================================================================
+ ReferenceBindingExtension::~ReferenceBindingExtension()
+ {
+ logentry();
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.h
new file mode 100644
index 0000000000..c3d1e97c9e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.h
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_referencebindingextension_h
+#define tuscany_sca_extension_referencebindingextension_h
+
+#include <string>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ class SCA_API ReferenceBindingExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ ReferenceBindingExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~ReferenceBindingExtension();
+
+ /**
+ * return the name of the extension (e.g. "cpp" "php")
+ */
+ virtual const std::string& getExtensionName() = 0;
+
+ /**
+ * return the QName of schema elemant for this binding extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#binding.ws")
+ */
+ virtual const std::string& getExtensionTypeQName() = 0;
+
+ /**
+ * Get a reference binding from a DataObject representing
+ * an SCDL binding element
+ */
+ virtual tuscany::sca::model::ReferenceBinding* getReferenceBinding(
+ tuscany::sca::model::Composite* composite,
+ tuscany::sca::model::Reference* reference,
+ commonj::sdo::DataObjectPtr scdlBinding) = 0;
+
+ };
+
+
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_referencebindingextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.cpp
new file mode 100644
index 0000000000..f5fe361d36
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/extension/ServiceBindingExtension.h"
+#include "tuscany/sca/util/Logging.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ // ===================================================================
+ // Constructor for the ServiceBindingExtension class.
+ // ===================================================================
+ ServiceBindingExtension::ServiceBindingExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the ServiceBindingExtension class.
+ // ===================================================================
+ ServiceBindingExtension::~ServiceBindingExtension()
+ {
+ logentry();
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.h
new file mode 100644
index 0000000000..d2f7e72ed0
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.h
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_servicebindingextension_h
+#define tuscany_sca_extension_servicebindingextension_h
+
+#include <string>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ class SCA_API ServiceBindingExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ ServiceBindingExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~ServiceBindingExtension();
+
+ /**
+ * return the name of the extension (e.g. "cpp" "php")
+ */
+ virtual const std::string& getExtensionName() = 0;
+
+ /**
+ * return the QName of schema elemant for this binding extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#binding.ws")
+ */
+ virtual const std::string& getExtensionTypeQName() = 0;
+
+ /**
+ * Get a reference binding from a DataObject representing
+ * an SCDL binding element
+ */
+ virtual tuscany::sca::model::ServiceBinding* getServiceBinding(
+ tuscany::sca::model::Composite* composite,
+ tuscany::sca::model::Service* service,
+ commonj::sdo::DataObjectPtr scdlBinding) = 0;
+
+ };
+
+
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_servicebindingextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Binding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Binding.cpp
new file mode 100644
index 0000000000..a654b9f0f7
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Binding.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/Binding.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ Binding::Binding(const string& uri) : uri(uri)
+ {
+ logentry();
+ }
+
+ // Destructor
+ Binding::~Binding()
+ {
+ logentry();
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Binding.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Binding.h
new file mode 100644
index 0000000000..66dc66e853
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Binding.h
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_binding_h
+#define tuscany_sca_model_binding_h
+
+#include <string>
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Represents a binding.
+ * Bindings are used by services and references. References use bindings
+ * to describe the access mechanism used to call an external service (which can
+ * be a service provided by another SCA composite). Services use bindings to describe
+ * the access mechanism that clients (which can be a client from another SCA composite)
+ * have to use to call the service.
+ * This interface will typically be extended by binding implementations to allow
+ * specification of binding/transport specific information.
+ */
+ class Binding
+ {
+
+ public:
+
+ /**
+ * Constructor to create a new binding.
+ * @param uri The binding URI.
+ */
+ SCA_API Binding(const std::string& uri);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~Binding();
+
+ /**
+ * Returns the binding type
+ * @return The binding type.
+ */
+ SCA_API virtual std::string getType() = 0;
+
+ /**
+ * Returns the binding URI.
+ * @return The binding URI.
+ */
+ SCA_API virtual const std::string& getURI() const { return uri; };
+
+ private:
+
+ /**
+ * The binding URI.
+ */
+ std::string uri;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_binding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Component.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Component.cpp
new file mode 100644
index 0000000000..11429193be
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Component.cpp
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <iostream>
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/ComponentType.h"
+
+using namespace std;
+using namespace commonj::sdo;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ // Constructor
+ Component::Component(Composite* composite, const std::string& componentName, ComponentType *componentType)
+ : name(componentName), composite(composite), type(componentType)
+ {
+ logentry();
+ loginfo("Component name: %s", name.c_str());
+
+ // Initialize the component from its component type
+ componentType->initializeComponent(this);
+
+ }
+
+ Component::~Component()
+ {
+ logentry();
+ }
+
+ void Component::addService(Service* service)
+ {
+ logentry();
+ services[service->getType()->getName()] = service;
+ }
+
+ Service* Component::findService(const string& serviceName)
+ {
+ logentry();
+
+ // If serviceName is empty then return the ONLY service
+ if (serviceName == ""
+ && services.size() == 1)
+ {
+ return services.begin()->second;
+ }
+ else
+ {
+ Service* service = services[serviceName];
+ if (service == NULL)
+ {
+ // A service with an empty name will match any service name
+ service = services[""];
+ }
+ return service;
+ }
+ }
+
+ void Component::addReference(Reference* reference)
+ {
+ logentry();
+ references[reference->getType()->getName()] = reference;
+ }
+
+ Reference* Component::findReference(const std::string& referenceName)
+ {
+ logentry();
+ return references[referenceName];
+ }
+
+ DataObjectPtr Component::getProperties()
+ {
+ logentry();
+
+ if (!properties)
+ {
+ properties = type->getPropertyDataFactory()->create("org/osoa/sca", "Properties");
+ }
+ return properties;
+ }
+
+ void Component::setProperty(const string& name, DataObjectPtr value)
+ {
+ logentry();
+
+ DataObjectPtr props = getProperties();
+
+ // Get the property's type
+ try
+ {
+ const Property& propProperty = props->getProperty(name);
+ const Type& propType = propProperty.getType();
+ if (propType.isDataType())
+ {
+ if (propProperty.isMany())
+ {
+ DataObjectList& dol = props->getList(propProperty);
+ dol.append(value->getCString(""));
+ }
+ else
+ {
+ props->setCString(propProperty, value->getCString(""));
+ }
+ }
+ else
+ {
+ // Create a new instance of the DO
+ // iterate over properties setting each one
+
+ // for now:
+ props->setDataObject(propProperty, value);
+ }
+ }
+ catch (SDORuntimeException& ex)
+ {
+ // Configuration error: property is not defined
+ throwException(SystemConfigurationException, ex);
+ }
+
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Component.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Component.h
new file mode 100644
index 0000000000..882d79a94c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Component.h
@@ -0,0 +1,183 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_component_h
+#define tuscany_sca_model_component_h
+
+#include <string>
+#include <map>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ class Composite;
+ class ComponentType;
+ class Reference;
+ class ReferenceType;
+ class Service;
+ class ServiceType;
+
+ /**
+ * A component is a configured instance of an implementation. Components provide
+ * and consume services. More than one component can use and configure the same
+ * implementation, where each component configures the implementation differently.
+ * For example each component may configure a reference of the same implementation
+ * to consume a different service.
+ */
+ class Component
+ {
+ public:
+
+ /**
+ * Constructor
+ * @param composite The composite containing the component.
+ * @param name The name of the component.
+ */
+ SCA_API Component(Composite *composite, const std::string& name, ComponentType *type);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~Component();
+
+ /**
+ * Returns the name of this component.
+ * @return the name of this component
+ */
+ SCA_API const std::string& getName() const { return name; }
+
+ /**
+ * Returns the composite containing this component.
+ * @return The composite containing this component.
+ */
+ SCA_API Composite* getComposite() const { return composite; }
+
+ /**
+ * Returns the type of this component.
+ * @return The type of this component.
+ */
+ SCA_API ComponentType* getType() const { return type; }
+
+ /**
+ * Add a new service to this component.
+ * @param service The service to add.
+ */
+ SCA_API void addService(Service* service);
+
+ /**
+ * Find an existing service on this component.
+ * @param serviceName The name of the service to find.
+ * If the serviceName is the zero length string then if there is
+ * only one service it will be returned.
+ * @return The found service, or 0 if not found.
+ */
+ SCA_API Service* findService(const std::string& serviceName);
+
+ /**
+ * Add a new reference to this component.
+ * @param reference The reference to add.
+ */
+ SCA_API void addReference(Reference* reference);
+
+ /**
+ * Find an existing reference on this component.
+ * @param referenceName The name of the reference to find.
+ * @return The found reference, or 0 if not found.
+ */
+ SCA_API Reference* findReference(const std::string& referenceName);
+
+ /**
+ * Returns all the services defined on this component.
+ * @return All the services defined on this component.
+ */
+ typedef std::map<std::string, Service*> SERVICE_MAP;
+ SCA_API const SERVICE_MAP& getServices() const { return services; };
+
+ /**
+ * Returns all the references defined on this component.
+ * @return All the references defined on this component.
+ */
+ typedef std::map<std::string, Reference*> REFERENCE_MAP;
+ SCA_API const REFERENCE_MAP& getReferences() const { return references; };
+
+ /**
+ * Set the value of a property defined on this component. The values
+ * will usually come from a component declaration in a composite file.
+ * @param name The name of the property.
+ * @param value The value of the property.
+ */
+ SCA_API void setProperty(const std::string& name, commonj::sdo::DataObjectPtr value);
+
+ /**
+ * Returns a data object from which all the properties of the component
+ * and their values can be accessed.
+ * @return A data object holding the property values.
+ */
+ SCA_API commonj::sdo::DataObjectPtr getProperties();
+
+ private:
+
+ /**
+ * Name of the component.
+ */
+ std::string name;
+
+ /**
+ * Composite containing the component.
+ */
+ Composite* composite;
+
+ /**
+ * Type of the component.
+ */
+ ComponentType* type;
+
+ /**
+ * Map of all the services defined on this component.
+ */
+ SERVICE_MAP services;
+
+ /**
+ * Map of all the references defined on this component.
+ */
+ REFERENCE_MAP references;
+
+ /**
+ * The properties and their values for this component.
+ */
+ commonj::sdo::DataObjectPtr properties;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_component_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ComponentType.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ComponentType.cpp
new file mode 100644
index 0000000000..306455840c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ComponentType.cpp
@@ -0,0 +1,294 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <iostream>
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Reference.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ // Constructor
+ ComponentType::ComponentType(Composite* composite, const string& name)
+ : composite(composite), name(name)
+ {
+ logentry();
+ }
+
+ // Destructor
+ ComponentType::~ComponentType()
+ {
+ logentry();
+ }
+
+ void ComponentType::addServiceType(ServiceType* serviceType)
+ {
+ logentry();
+ serviceTypes[serviceType->getName()] = serviceType;
+ }
+
+ ServiceType* ComponentType::findServiceType(const string& serviceName)
+ {
+ logentry();
+
+ // If serviceName is empty then return the ONLY service
+ if (serviceName == ""
+ && serviceTypes.size() == 1)
+ {
+ return serviceTypes.begin()->second;
+ }
+ else
+ {
+ return serviceTypes[serviceName];
+ }
+ }
+
+ void ComponentType::addReferenceType(ReferenceType* referenceType)
+ {
+ logentry();
+
+ referenceTypes[referenceType->getName()] = referenceType;
+ }
+
+ ReferenceType* ComponentType::findReferenceType(const string& referenceName)
+ {
+ logentry();
+
+ return referenceTypes[referenceName];
+ }
+
+ void ComponentType::addPropertyType(const string& name,
+ const string& type,
+ bool many,
+ DataObjectPtr* defaultValue)
+ {
+ logentry();
+
+ // Create a Type in the Properties dataFactory
+ DataFactoryPtr factory = getPropertyDataFactory();
+
+ string typeUri, typeName;
+ Utils::tokeniseQName(type, typeUri, typeName);
+
+ if (typeUri == "http://www.w3.org/2001/XMLSchema")
+ {
+ typeUri = Type::SDOTypeNamespaceURI;
+ if (typeName == "string")
+ {
+ typeName = "String";
+ }
+ else if (typeName == "anyType")
+ {
+ typeName = "DataObject";
+ }
+ else if (typeName == "int")
+ {
+ typeName = "Integer";
+ }
+ else if (typeName == "integer")
+ {
+ typeName = "Integer";
+ }
+ else if (typeName == "negativeInteger")
+ {
+ typeName = "Integer";
+ }
+ else if (typeName == "nonNegativeInteger")
+ {
+ typeName = "Integer";
+ }
+ else if (typeName == "positiveInteger")
+ {
+ typeName = "Integer";
+ }
+ else if (typeName == "nonPositiveInteger")
+ {
+ typeName = "Integer";
+ }
+ else if (typeName == "unsignedLong")
+ {
+ typeName = "Integer";
+ }
+ else if (typeName == "unsignedShort")
+ {
+ typeName = "Integer";
+ }
+ else if (typeName == "unsignedInt")
+ {
+ typeName = "Long";
+ }
+ else if (typeName == "long")
+ {
+ typeName = "Long";
+ }
+ else if (typeName == "double")
+ {
+ typeName = "Double";
+ }
+ else if (typeName == "short")
+ {
+ typeName = "Short";
+ }
+ else if (typeName == "unsignedByte")
+ {
+ typeName = "Short";
+ }
+ else if (typeName == "float")
+ {
+ typeName = "Float";
+ }
+ else if (typeName == "boolean")
+ {
+ typeName = "Boolean";
+ }
+ else if (typeName == "byte")
+ {
+ typeName = "Byte";
+ }
+ else if (typeName == "base64Binary")
+ {
+ typeName = "Bytes";
+ }
+ else if (typeName == "hexBinary")
+ {
+ typeName = "Bytes";
+ }
+ else if (typeName == "anyURI")
+ {
+ typeName = "URI";
+ }
+ else if (typeName == "QName")
+ {
+ typeName = "URI";
+ }
+ else
+ {
+ // Default unknown xs: types to string??
+ typeName = "String";
+ }
+ }
+ else
+ {
+ // It's not an XML type
+ }
+
+ factory->addPropertyToType(
+ "org/osoa/sca",
+ "Properties",
+ name.c_str(),
+ typeUri.c_str(),
+ typeName.c_str(),
+ many,
+ false,
+ true);
+
+ // Set the default for a dataType
+ if (defaultValue!=NULL)
+ {
+ try
+ {
+ const Type& propType = factory->getType(typeUri.c_str(), typeName.c_str());
+ if (propType.isDataType())
+ {
+ factory->setDefault("org/osoa/sca", "Properties",
+ name.c_str(),
+ (char*)(*defaultValue)->getCString(""));
+ }
+ }
+ catch (SDOTypeNotFoundException&)
+ {
+ }
+ }
+ }
+
+ const Property* ComponentType::findPropertyType(const string& propertyName)
+ {
+ logentry();
+ const Property* property = NULL;
+
+ DataFactoryPtr dataFactory = getPropertyDataFactory();
+ const Type& propertiesType = dataFactory->getType("org/osoa/sca", "Properties");
+
+ try
+ {
+ const Property& prop = propertiesType.getProperty(propertyName);
+ property = &prop;
+ }
+ catch(SDOPropertyNotFoundException)
+ {
+ loginfo("Property named %s not found, returning null", propertyName.c_str());
+ }
+ return property;
+ }
+
+ DataFactoryPtr ComponentType::getPropertyDataFactory()
+ {
+ logentry();
+
+ if (!propertyFactory)
+ {
+ propertyFactory = DataFactory::getDataFactory();
+ // Add the root type
+ propertyFactory->addType("org/osoa/sca", "Properties", false, false, false, false);
+ }
+ return propertyFactory;
+ }
+
+ void ComponentType::initializeComponent(Component* component)
+ {
+ logentry();
+
+ for (SERVICETYPE_MAP::iterator iter = serviceTypes.begin();
+ iter != serviceTypes.end();
+ iter++)
+ {
+ Service* service = new Service(component, iter->second);
+ component->addService(service);
+ }
+ for (REFERENCETYPE_MAP::iterator refiter = referenceTypes.begin();
+ refiter != referenceTypes.end();
+ refiter++)
+ {
+ Reference* reference = new Reference(component, refiter->second);
+ component->addReference(reference);
+ }
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ComponentType.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ComponentType.h
new file mode 100644
index 0000000000..86f17890e9
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ComponentType.h
@@ -0,0 +1,186 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_componenttype_h
+#define tuscany_sca_model_componenttype_h
+
+#include <string>
+#include <map>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/model/ReferenceType.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ class ServiceType;
+ class ReferenceType;
+ class Interface;
+ class Component;
+ class Composite;
+
+ /**
+ * Component type represents the configurable aspects of an implementation.
+ * A component type consists of services that are offered, references to other services
+ * that can be wired and properties that can be set. The settable properties and the settable
+ * references to services are configured by a component which uses the implementation.
+ * The component type can be thought of as the contract which is honoured by an implementation.
+ */
+ class ComponentType
+ {
+ public:
+
+ /**
+ * Constructor
+ */
+ SCA_API ComponentType(Composite* composite, const std::string& name);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~ComponentType();
+
+ /**
+ * Returns the name of the component type
+ */
+ SCA_API const std::string& getName() const { return name; };
+
+ /**
+ * Returns the composite containing this component type
+ */
+ SCA_API Composite* getComposite() const { return composite; };
+
+ /**
+ * Add a new service type to this component type.
+ * @param serviceType The service type to add.
+ */
+ SCA_API virtual void addServiceType(ServiceType* serviceType);
+
+ /**
+ * Find an existing service type on this component type.
+ * @param serviceName The name of the service type to find.
+ * If the serviceName is the zero length string then if there is
+ * only one service type it will be returned.
+ * @return The found service, or 0 if not found.
+ */
+ SCA_API virtual ServiceType* findServiceType(const std::string& serviceName);
+
+ /**
+ * Add a new reference type to this component type.
+ * @param referenceType The reference type to add.
+ */
+ SCA_API virtual void addReferenceType(ReferenceType* referenceType);
+
+ /**
+ * Find an existing reference type on this component type.
+ * @param referenceName The name of the reference type to find.
+ * @return The found reference type, or 0 if not found.
+ */
+ SCA_API virtual ReferenceType* findReferenceType(const std::string& referenceName);
+
+ /**
+ * Returns the service types defined on this component.
+ * @return The service types defined on this component.
+ */
+ typedef std::map<std::string, ServiceType*> SERVICETYPE_MAP;
+ SERVICETYPE_MAP getServiceTypes() const { return serviceTypes; };
+
+ /**
+ * Returns the reference types defined on this component.
+ * @return The reference types defined on this component.
+ */
+ typedef std::map<std::string, ReferenceType*> REFERENCETYPE_MAP;
+ REFERENCETYPE_MAP getReferenceTypes() const { return referenceTypes; };
+
+ /**
+ * Add a new property type to this component type. Property types are added
+ * one at a time. The property definitions usually come from a component type file.
+ * @param name The name of the property type.
+ * @param type The full name of the property data type (including uri and local name).
+ * @param many True if this is a many valued property.
+ * @param defaultValue The default value if the property does not have a
+ * value set.
+ */
+ SCA_API virtual void addPropertyType(const std::string& name,
+ const std::string& type,
+ bool many,
+ commonj::sdo::DataObjectPtr* defaultValue);
+
+ /**
+ * Find an existing property type on this component type.
+ * @param propertyName The name of the property type to find.
+ * @return The found property, or 0 if not found.
+ */
+ SCA_API virtual const commonj::sdo::Property* findPropertyType(const std::string& propertyName);
+
+ /**
+ * Return the SDO data factory which has the types of the properties defined
+ * in this component type.
+ * @return The data factory.
+ */
+ SCA_API virtual commonj::sdo::DataFactoryPtr getPropertyDataFactory();
+
+ /**
+ * Initialize a component of this type.
+ * @param component The component to initialize.
+ */
+ SCA_API virtual void initializeComponent(Component* component);
+
+ private:
+
+ /**
+ * The name of the component type
+ */
+ std::string name;
+
+ /**
+ * The composite containing this component type
+ */
+ Composite* composite;
+
+ /**
+ * Map of all the service types defined on this component.
+ */
+ SERVICETYPE_MAP serviceTypes;
+
+ /**
+ * Map of all the reference types defined on this component.
+ */
+ REFERENCETYPE_MAP referenceTypes;
+
+ /**
+ * SDO data factory which has all the types of the properties defined in
+ * this component type
+ */
+ commonj::sdo::DataFactoryPtr propertyFactory;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_componenttype_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Composite.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Composite.cpp
new file mode 100644
index 0000000000..7fcddd812a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Composite.cpp
@@ -0,0 +1,258 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/CompositeReference.h"
+#include "tuscany/sca/model/CompositeReferenceBinding.h"
+#include "tuscany/sca/model/CompositeService.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Wire.h"
+#include "tuscany/sca/model/WSDLDefinition.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+using namespace std;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ Composite::Composite(const string& name, const string& root)
+ : ComponentType(0, name), root(root)
+ {
+ logentry();
+ }
+
+ // Destructor
+ Composite::~Composite()
+ {
+ logentry();
+ }
+
+ void Composite::addComponent(Component* component)
+ {
+ logentry();
+ components[component->getName()] = component;
+ }
+
+ void Composite::addCompositeReference(CompositeReference* compositeReference)
+ {
+ logentry();
+ components[compositeReference->getName()] = compositeReference;
+
+ // Create a reference type describing the composite reference
+ ServiceType* serviceType = compositeReference->getType()->findServiceType("");
+ ReferenceType* referenceType = new ReferenceType(
+ this, compositeReference->getName(),
+ serviceType->getInterface(),
+ serviceType->getCallbackInterface(),
+ compositeReference->getMultiplicity());
+ addReferenceType(referenceType);
+ }
+
+ void Composite::addCompositeService(CompositeService* compositeService)
+ {
+ logentry();
+ components[compositeService->getName()] = compositeService;
+
+ // Create a service type describing the composite service
+ ReferenceType* referenceType = compositeService->getType()->findReferenceType("");
+ ServiceType* serviceType = new ServiceType(
+ this, compositeService->getName(),
+ referenceType->getInterface(),
+ referenceType->getCallbackInterface());
+ addServiceType(serviceType);
+ }
+
+ void Composite::initializeComponent(Component* component)
+ {
+ ComponentType::initializeComponent(component);
+
+ // Create bindings for all the services
+ const Component::SERVICE_MAP& services = component->getServices();
+ Component::SERVICE_MAP::const_iterator iter = services.begin();
+ for (unsigned int i=0; i< services.size(); i++)
+ {
+ Service *service = iter->second;
+ //CompositeServiceBinding* binding = new CompositeServiceBinding(service);
+ //service->setBinding(binding);
+ iter++;
+ }
+
+ // Create bindings for all the references
+ const Component::REFERENCE_MAP& references = component->getReferences();
+ Component::REFERENCE_MAP::const_iterator refiter = references.begin();
+ for (unsigned int ri=0; ri< references.size(); ri++)
+ {
+ Reference *reference = refiter->second;
+ CompositeReferenceBinding* binding = new CompositeReferenceBinding(reference);
+ reference->setBinding(binding);
+ refiter++;
+ }
+ }
+
+ Component* Composite::findComponent(const std::string& name)
+ {
+ logentry();
+ Component* component = components[name];
+ return component;
+ }
+
+ Service* Composite::findComponentService(const std::string& name)
+ {
+ logentry();
+
+ Service* service = 0;
+
+ string componentName;
+ string serviceName;
+ Utils::tokeniseUri(name, componentName, serviceName);
+
+ // Locate the component
+ Component* component = findComponent(componentName);
+ if (component)
+ {
+ // Locate the service
+ service = component->findService(serviceName);
+ }
+ return service;
+ }
+
+ void Composite::addWire(const std::string& source, const std::string& target)
+ {
+ logentry();
+ Wire* wire=new Wire(source, target);
+ wires.push_back(wire);
+ }
+
+ void Composite::addInclude(Composite* composite)
+ {
+ logentry();
+ includes.push_back(composite);
+
+ for (COMPONENT_MAP::iterator iter = composite->components.begin();
+ iter != composite->components.end();
+ iter++)
+ {
+ components[iter->first] = iter->second;
+ }
+ }
+
+ void Composite::resolveWires()
+ {
+ logentry();
+
+ for (WIRES::iterator iter = wires.begin();
+ iter != wires.end();
+ iter++)
+ {
+ Wire* wire = *iter;
+
+ // Find the source component and reference
+ Component* component = findComponent(wire->getSourceComponent());
+ Reference* reference;
+ if (component)
+ {
+ reference = component->findReference(wire->getSourceReference());
+ if (!reference)
+ {
+ logerror("Wire source reference %s not found", wire->getSourceReference().c_str());
+ }
+ }
+ else
+ {
+ reference = NULL;
+ logerror("Wire source %s not found", wire->getSourceComponent().c_str());
+ }
+
+ // Configure the reference binding with the wire target URI
+ if (reference)
+ {
+ reference->getBinding()->configure(wire->getTarget());
+ }
+ }
+ }
+
+ void Composite::addWSDLDefinition(commonj::sdo::DataObjectPtr wsdlModel)
+ {
+ logentry();
+ WSDLDefinition* wsdlDefinition = new WSDLDefinition(wsdlModel);
+
+ WSDLDefinition* existingDefinition = wsdlDefinitions[wsdlDefinition->getNamespace()];
+ if (existingDefinition == NULL)
+ {
+ wsdlDefinitions[wsdlDefinition->getNamespace()] = wsdlDefinition;
+ }
+ else{
+ existingDefinition->addWSDLModel(wsdlModel);
+ }
+ }
+
+ WSDLDefinition* Composite::findWSDLDefinition(const std::string& wsdlNamespace )
+ {
+ logentry();
+ return wsdlDefinitions[wsdlNamespace];
+
+ }
+
+ commonj::sdo::XSDHelperPtr Composite::getXSDHelper()
+ {
+ logentry();
+ if (xsdHelper == 0)
+ {
+ xsdHelper = commonj::sdo::HelperProvider::getXSDHelper();
+ }
+
+ return xsdHelper;
+ }
+
+ commonj::sdo::XMLHelperPtr Composite::getXMLHelper()
+ {
+ logentry();
+ if (xmlHelper == 0)
+ {
+ xmlHelper = commonj::sdo::HelperProvider::getXMLHelper(getXSDHelper()->getDataFactory());
+ }
+
+ return xmlHelper;
+ }
+
+ commonj::sdo::DataFactoryPtr Composite::getDataFactory()
+ {
+ logentry();
+ return getXSDHelper()->getDataFactory();
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Composite.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Composite.h
new file mode 100644
index 0000000000..5198e68f6d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Composite.h
@@ -0,0 +1,215 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_composite_h
+#define tuscany_sca_model_composite_h
+
+#include <string>
+#include <map>
+#include <vector>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/model/ComponentType.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+ class Component;
+ class ComponentType;
+ class CompositeReference;
+ class CompositeService;
+ class Service;
+ class WSDLDefinition;
+ class Wire;
+
+ /**
+ * Represents a composite.
+ * A composite is used to assemble SCA elements in logical groupings.
+ * It is the basic unit of composition within an SCA System. An SCA composite contains a
+ * set of components, services, references and the wires that interconnect them, plus a set
+ * of properties which can be used to configure components.
+ */
+ class Composite : public ComponentType
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param name the name of the composite.
+ * @param root the root of the composite in the file system.
+ */
+ SCA_API Composite(const std::string& name, const std::string& root);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~Composite();
+
+ /**
+ * Returns the root directory of the composite.
+ * @return The root of the composite in the file system.
+ */
+ SCA_API const std::string& getRoot() const { return root; }
+
+ /**
+ * Add a new component to the composite.
+ * @param component The component to add.
+ */
+ SCA_API void addComponent(Component* component);
+
+ /**
+ * Add a new composite reference to the composite.
+ * @param compositeReference The composite reference to add.
+ */
+ SCA_API void addCompositeReference(CompositeReference* compositeReference);
+
+ /**
+ * Add a new composite service to the composite.
+ * @param compositeService The composite service to add.
+ */
+ SCA_API void addCompositeService(CompositeService* compositeService);
+
+ /**
+ * Add/include a composite in this composite.
+ * @param composite The composite included in this composite.
+ */
+ SCA_API void addInclude(Composite* composite);
+
+ /**
+ * Add a wire to the model.
+ * @param source The source location. Either the source component and
+ * reference (optional), or an entry point.
+ * @param target The target location. Either the target component and
+ * service (optional), or an external service.
+ */
+ SCA_API void addWire(const std::string& source, const std::string& target);
+
+ /**
+ * Find a component by name.
+ * @param componentName The name of the component to be found.
+ * @return The component that was found, or 0 if not found.
+ */
+ SCA_API Component* findComponent(const std::string& componentName);
+
+ /**
+ * Find a component and service by name.
+ * @param componentServiceName A string of the form
+ * "componentName"/"serviceName" where the service name is optional
+ * if there is only one service on the component.
+ * @return The Service that was found, or 0 if not found.
+ */
+ SCA_API Service* findComponentService(const std::string& componentServiceName);
+
+ /**
+ * Add a WSDL definition to the composite.
+ * @param wsdlModel A data object holding all the information about
+ * the WSDL definition from a WSDL file.
+ */
+ SCA_API void addWSDLDefinition(commonj::sdo::DataObjectPtr wsdlModel);
+
+ /**
+ * Find a WSDL definition by target namespace.
+ * @param wsdlNamespace The namespace of the WSDL definitions to find.
+ */
+ SCA_API WSDLDefinition* findWSDLDefinition(const std::string& wsdlNamespace);
+
+ /**
+ * Initialize a component of this type.
+ * @param component The component to initialize.
+ */
+ virtual void initializeComponent(Component* component);
+
+ /**
+ * Return a cached SDO XSDHelper.
+ */
+ SCA_API commonj::sdo::XSDHelperPtr getXSDHelper(void);
+
+ /**
+ * Return a cached SDO XMLHelper.
+ */
+ SCA_API commonj::sdo::XMLHelperPtr getXMLHelper(void);
+
+ /**
+ * Return a data factory which has all the types defined in XSDs and
+ * WSDL files configured for this composite.
+ * @return The data factory for this composite.
+ */
+ SCA_API commonj::sdo::DataFactoryPtr getDataFactory(void);
+
+ /**
+ * Work through the list of wires and connect the source and target uris.
+ */
+ SCA_API void resolveWires();
+
+ private:
+
+ /**
+ * Directory of the root of the composite.
+ */
+ std::string root;
+
+ /**
+ * Cached XSDHelper.
+ */
+ commonj::sdo::XSDHelperPtr xsdHelper;
+
+ /**
+ * Cached XMLHelper.
+ */
+ commonj::sdo::XMLHelperPtr xmlHelper;
+
+ /**
+ * Map (by name) of all the components in this composite.
+ */
+ typedef std::map<std::string, Component*> COMPONENT_MAP;
+ COMPONENT_MAP components;
+
+ /**
+ * Vector of all the composites included in this composite.
+ */
+ typedef std::vector<Composite*> INCLUDES;
+ INCLUDES includes;
+
+ /**
+ * Vector of all the wires in this composite.
+ */
+ typedef std::vector<Wire*> WIRES;
+ WIRES wires;
+
+ /**
+ * Map by namespace of all the wsdl definitions in this composite.
+ */
+ typedef std::map<std::string, WSDLDefinition*> WSDL_MAP;
+ WSDL_MAP wsdlDefinitions;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_composite_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReference.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReference.cpp
new file mode 100644
index 0000000000..be0bf71a17
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReference.cpp
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/CompositeReference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Service.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ CompositeReference::CompositeReference(Composite* composite, const string& name,
+ Interface* intface, Interface* callbackInterface, bool conversational, ReferenceType::Multiplicity multiplicity) :
+ Component(composite, name, new ComponentType(composite, name))
+ {
+ logentry();
+ loginfo("Composite reference name: %s", name.c_str());
+
+ // Initialize the component type, service type and service
+ ComponentType* componentType = getType();
+ ServiceType* serviceType = new ServiceType(
+ componentType, "", intface, callbackInterface);
+ componentType->addServiceType(serviceType);
+
+ service = new Service(this, serviceType);
+ addService(service);
+ }
+
+ // Destructor
+ CompositeReference::~CompositeReference()
+ {
+ logentry();
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReference.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReference.h
new file mode 100644
index 0000000000..f5e2166e06
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReference.h
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_compositereferencetype_h
+#define tuscany_sca_model_compositereferencetype_h
+
+#include <string>
+
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ReferenceType.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+ class ComponentType;
+ class Composite;
+ class Interface;
+ class Service;
+
+ /**
+ * Represents a reference in a composite.
+ * Composite references represent dependencies that the composite has on services provided elsewhere,
+ * outside the composite.
+ */
+ class CompositeReference : public Component
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param name The name of the reference.
+ */
+ SCA_API CompositeReference(Composite* composite, const std::string& name,
+ Interface* intface, Interface* callbackInterface, bool conversational, ReferenceType::Multiplicity multiplicity);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~CompositeReference();
+
+ /**
+ * Returns the service exposed by this composite reference.
+ * @return The service exposed by this composite reference.
+ */
+ SCA_API Service* getService() const { return service; };
+
+ /**
+ * Returns the multiplicity of this composite reference
+ * @return The multiplicity of the composite reference
+ */
+ SCA_API ReferenceType::Multiplicity getMultiplicity() { return multiplicity; }
+
+ private:
+
+ /**
+ * The service exposed by this composite reference.
+ */
+ Service* service;
+
+ /**
+ * The multiplicity of this reference
+ */
+ ReferenceType::Multiplicity multiplicity;
+
+ };
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_compositereferencetype_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp
new file mode 100644
index 0000000000..7f24328cf5
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/CompositeReferenceBinding.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ // Constructor
+ CompositeReferenceBinding::CompositeReferenceBinding(Reference* reference)
+ : ReferenceBinding(reference, ""), uri("")
+ {
+ }
+
+ // Destructor
+ CompositeReferenceBinding::~CompositeReferenceBinding()
+ {
+ }
+
+ void CompositeReferenceBinding::configure(ServiceBinding *binding)
+ {
+ targetServiceBinding = binding;
+ }
+
+ ServiceProxy* CompositeReferenceBinding::getServiceProxy()
+ {
+ return serviceProxy;
+ }
+
+ void CompositeReferenceBinding::configure(const string& uri)
+ {
+ this->uri = uri;
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h
new file mode 100644
index 0000000000..b9daa534c2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_compositereferencebinding_h
+#define tuscany_sca_model_compositereferencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * A default composite reference binding
+ */
+ class CompositeReferenceBinding : public ReferenceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ */
+ SCA_API CompositeReferenceBinding(Reference* reference);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~CompositeReferenceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#CompositeServiceBinding"; };
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ SCA_API virtual void configure(ServiceBinding* serviceBinding);
+
+ /**
+ * Configure this binding from a URI.
+ */
+ SCA_API virtual void configure(const std::string& uri);
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ SCA_API virtual ServiceProxy* getServiceProxy();
+
+ /**
+ * Returns the target service binding.
+ */
+ ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; };
+
+ /**
+ * Returns the binding URI.
+ * @return The binding URI.
+ */
+ SCA_API virtual const std::string& getURI() const { return uri; };
+
+ private:
+
+ /**
+ * The proxy representing the reference to the client
+ * component.
+ */
+ ServiceProxy* serviceProxy;
+
+ /**
+ * The service binding of the target
+ */
+ ServiceBinding* targetServiceBinding;
+
+ /**
+ * The binding URI
+ */
+ std::string uri;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_compositereferencebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeService.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeService.cpp
new file mode 100644
index 0000000000..e06dc548c1
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeService.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/CompositeService.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/ServiceType.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ CompositeService::CompositeService(Composite* composite, const string& name,
+ Interface* intface, Interface* callbackInterface, bool conversational,
+ ReferenceType::Multiplicity multiplicity) :
+ Component(composite, name, new ComponentType(composite, name))
+ {
+ logentry();
+ loginfo("Composite service name: %s", name.c_str());
+
+ // Initialize the component type, reference type and reference
+ ComponentType* componentType = getType();
+ ReferenceType* referenceType = new ReferenceType(
+ componentType, "", intface, callbackInterface, multiplicity);
+ componentType->addReferenceType(referenceType);
+
+ reference = new Reference(this, referenceType);
+ addReference(reference);
+ }
+
+ // Destructor
+ CompositeService::~CompositeService()
+ {
+ logentry();
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeService.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeService.h
new file mode 100644
index 0000000000..8c626ccac3
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/CompositeService.h
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_compositeservicetype_h
+#define tuscany_sca_model_compositeservicetype_h
+
+#include <string>
+
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ReferenceType.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ class Composite;
+ class Component;
+ class Interface;
+ class Reference;
+
+ /**
+ * Represents a service in a composite.
+ * Composite services define the public services provided by the composite, which can be
+ * accessed from outside the composite.
+ */
+ class CompositeService : public Component
+ {
+
+ public:
+
+ /**
+ * Constructor.
+ * @param componentType The component type on which this service is defined.
+ * @param name The name of the service.
+ */
+ SCA_API CompositeService(Composite* composite, const std::string& name,
+ Interface* intface, Interface* callbackInterface, bool conversational, ReferenceType::Multiplicity multiplicity);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~CompositeService();
+
+ /**
+ * Returns the reference used by this composite service.
+ * @return The reference used by this composite service.
+ */
+ SCA_API Reference* getReference() const { return reference; };
+
+ private:
+
+ /**
+ * The reference used by this composite service.
+ */
+ Reference* reference;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_compositeservicetype_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Contract.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Contract.cpp
new file mode 100644
index 0000000000..99a1d04dc2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Contract.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/Contract.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ Contract::Contract(Interface *intface, Interface* callbackInterface) :
+ iface(intface), callbackInterface(callbackInterface)
+ {
+ logentry();
+ }
+
+ // Destructor
+ Contract::~Contract()
+ {
+ logentry();
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Contract.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Contract.h
new file mode 100644
index 0000000000..e1d526f842
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Contract.h
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_contract_h
+#define tuscany_sca_model_contract_h
+
+#include "tuscany/sca/model/Interface.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Interface contracts define one or more business functions. These business functions are
+ * provided by services and are used by references. Services are defined by the interface which
+ * they implement.
+ * This interface will typically be extended to support concrete interface type systems, such as
+ * CPP classes, Java interfaces, WSDL 1.1 portTypes and WSDL 2.0 interfaces.
+ */
+ class Contract
+ {
+ public:
+
+ /**
+ * Constructor.
+ */
+ SCA_API Contract(Interface* intface, Interface* callbackInterface);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~Contract();
+
+ /**
+ * Returns the interface for invocations from the requestor to the provider.
+ * @return The interface for invocations from the requestor to the provider.
+ */
+ SCA_API Interface* getInterface() const { return iface; }
+
+ /**
+ * Returns the interface for invocations from the provider back to the requestor.
+ * @return The interface for invocations from the provider back to the requestor.
+ */
+ SCA_API Interface* getCallbackInterface() const { return callbackInterface; }
+
+ private:
+
+ /**
+ * The interface for invocations from the requestor to the provider.
+ */
+ Interface* iface;
+
+ /**
+ * The interface for invocations from the provider back to the requestor.
+ */
+ Interface* callbackInterface;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_contract_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Interface.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Interface.cpp
new file mode 100644
index 0000000000..f8dd02a74a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Interface.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/Interface.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ Interface::Interface(bool remotable, bool conversational)
+ : remotable(remotable), conversational(conversational)
+ {
+ logentry();
+ }
+
+ Interface::~Interface()
+ {
+ logentry();
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Interface.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Interface.h
new file mode 100644
index 0000000000..5ac7736d43
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Interface.h
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_interface_h
+#define tuscany_sca_model_interface_h
+
+#include <string>
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ /**
+ * Information about an interface. Subtypes will hold information
+ * specific to a type of interface.
+ */
+ class Interface
+ {
+
+ public:
+
+ /**
+ * Constructor
+ */
+ SCA_API Interface(bool remotable, bool conversational);
+
+ /**
+ * Destructor
+ */
+ SCA_API virtual ~Interface();
+
+ /**
+ * Returns true if the interface is remotable.
+ * @return True if the interface is remotable.
+ */
+ SCA_API bool isRemotable() const { return remotable; };
+
+ /**
+ * Returns true if the interface is conversational.
+ * @return True if the interface is conversational.
+ */
+ SCA_API bool isConversational() const { return conversational; };
+
+ /**
+ * return the QName of schema type for this interface type
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#WSDLInterface")
+ */
+ SCA_API virtual const std::string& getInterfaceTypeQName() = 0;
+
+ private:
+
+ /**
+ * True if the interface is remotable
+ */
+ bool remotable;
+
+ /**
+ * True if the interface is conversational
+ */
+ bool conversational;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_interface_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ModelLoader.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
new file mode 100644
index 0000000000..d22427c4d4
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
@@ -0,0 +1,1820 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "commonj/sdo/TypeDefinitions.h"
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/ModelLoader.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/CompositeService.h"
+#include "tuscany/sca/model/CompositeReference.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/WSDLInterface.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/util/File.h"
+
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::util;
+
+
+#if defined(WIN32) || defined (_WINDOWS)
+#define PATH_SEPARATOR ";"
+#else
+#define PATH_SEPARATOR ":"
+#endif
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+ // ===========
+ // Constructor
+ // ===========
+ ModelLoader::ModelLoader(SCARuntime* runtime, Composite* system)
+ : system(system), runtime(runtime)
+ {
+ logentry();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ModelLoader::~ModelLoader()
+ {
+ logentry();
+ }
+
+ // =========================================================
+ // load: Load the runtime model from the deployed xml files
+ // This class has the responsibility for translating from
+ // the SCDL files to the SCA runtime's in memory model.
+ // =========================================================
+ void ModelLoader::load(const string& systemRoot, const string& systemPath)
+ {
+ logentry();
+ loginfo("System root: %s", systemRoot.c_str());
+ loginfo("System path: %s", systemPath.c_str());
+
+ // Load composite implementations
+ // Composite implementations can occur anywhere on the given search path
+ if (systemPath != "")
+ {
+ loadComposites(systemRoot + PATH_SEPARATOR + systemPath);
+ }
+ else
+ {
+ loadComposites(systemRoot);
+ }
+
+ // Load system composites
+ // Composites on the the system root path get included
+ // in the System composite
+ loadSystem(systemRoot);
+
+ // Resolve the wires in the system composite
+ system->resolveWires();
+ }
+
+ // ========================================================================
+ // loadSystem:
+ // Load all the composite files on the system root path
+ // Translate the composite information to composite model objects
+ // ========================================================================
+ void ModelLoader::loadSystem(const string& systemRoot)
+ {
+ logentry();
+
+ // Get all the composite files on the system root path
+ // These composites are included in the system composite
+ for (string path = systemRoot; path != ""; )
+ {
+ string dir;
+ Utils::tokeniseString(PATH_SEPARATOR, path, dir, path);
+ if (dir != "")
+ {
+ loginfo("System root directory: %s", dir.c_str());
+ Files files(dir, "*.composite", false);
+ for (unsigned int i=0; i < files.size(); i++)
+ {
+ string fileName = files[i].getDirectory() + "/" + files[i].getFileName();
+ Composite* composite = compositeFiles[fileName];
+ if (composite)
+ {
+ // Include the composite in the system composite
+ system->addInclude(composite);
+ }
+ else
+ {
+ // We already got an error or warning indicating why the file
+ // didn't turn into a composite
+ }
+ }
+ }
+ }
+ }
+
+ // =====================================================================
+ // loadComposites:
+ // Load all the composites from any directory under the composite search path
+ // Translate the composite information to composite model objects
+ // =====================================================================
+ void ModelLoader::loadComposites(const string& searchPath)
+ {
+ logentry();
+
+ // Get all the composite files on the composite search path
+ for (string path = searchPath; path != ""; )
+ {
+ string dir;
+ Utils::tokeniseString(PATH_SEPARATOR, path, dir, path);
+ if (dir != "")
+ {
+ loginfo("Composite path directory: %s", dir.c_str());
+ Files files(dir, "*.composite", true);
+ for (unsigned int i=0; i < files.size(); i++)
+ {
+ loadCompositeFile(files[i]);
+ }
+ }
+ }
+
+ // Complete the mapping of the composites
+ for (COMPOSITE_DATAOBJECTS::iterator iter = compositeDataObjects.begin();
+ iter != compositeDataObjects.end();
+ iter++)
+ {
+ mapCompositePass2(iter->first, iter->second);
+ }
+ }
+
+ // ====================================================================
+ // loadCompositeFile:
+ // This method is called for each .composite file found under the composite search
+ // path. The location of this composite file will indicate the root of a composite.
+ // ====================================================================
+ Composite* ModelLoader::loadCompositeFile(const File& file)
+ {
+ logentry();
+
+ loginfo("Composite file name: %s", file.getFileName().c_str());
+
+ Composite* composite = NULL;
+ try
+ {
+ string fileName = file.getDirectory() + "/" + file.getFileName();
+ if (compositeFiles[fileName] == NULL)
+ {
+ XMLDocumentPtr compositeFile = getXMLHelper()->loadFile(fileName.c_str());
+ if (compositeFile->getRootDataObject() == NULL)
+ {
+ logerror("Unable to load file: %s", fileName.c_str());
+ }
+ else
+ {
+ // Map the SCDL
+ composite = mapCompositePass1(file, compositeFile->getRootDataObject());
+
+ // Load the xsd types and wsdl files in the composite
+ loadTypeMetadata(file.getDirectory(), composite);
+ }
+ }
+
+ } catch (SDORuntimeException& ex)
+ {
+ logerror("Unable to load composite: %s", ex.getMessageText());
+ }
+ return composite;
+ }
+
+ // ===========
+ // mapCompositePass1
+ // ===========
+ Composite* ModelLoader::mapCompositePass1(const File& file, DataObjectPtr root)
+ {
+ logentry();
+
+ const string& compositeRootDir = file.getDirectory();
+ const string compositeName = root->getCString("name");
+ loginfo("Composite: %s, root directory: %s", compositeName.c_str(), compositeRootDir.c_str());
+
+ Composite* composite = new Composite(compositeName, compositeRootDir);
+ compositeModels[compositeName] = composite;
+ compositeDataObjects[compositeName] = root;
+ compositeFiles[file.getDirectory() + "/" + file.getFileName()] = composite;
+
+ // ------------
+ // Composite services
+ // ------------
+ DataObjectList& compositeServiceList = root->getList("service");
+ for (unsigned int i = 0; i < compositeServiceList.size(); i++)
+ {
+ addCompositeService(composite, compositeServiceList[i]);
+ }
+
+ // -----------------
+ // Composite references
+ // -----------------
+ DataObjectList& compositeReferenceList = root->getList("reference");
+ for (unsigned int cri = 0; cri < compositeReferenceList.size(); cri++)
+ {
+ addCompositeReference(composite, compositeReferenceList[cri]);
+ }
+
+ // -----
+ // Wires
+ // -----
+ DataObjectList& wireList = root->getList("wire");
+ for (unsigned int l = 0; l < wireList.size(); l++)
+ {
+ string source = wireList[l]->getCString("source");
+ string target = wireList[l]->getCString("target");
+ composite->addWire(source, target);
+ }
+
+ return composite;
+ }
+
+ // ===========
+ // mapCompositePass2
+ // ===========
+ Composite* ModelLoader::mapCompositePass2(const string& compositeName, DataObjectPtr root)
+ {
+ logentry();
+ loginfo("Composite: %s", compositeName.c_str());
+
+ Composite* composite = compositeModels[compositeName];
+
+ // ----------------------------
+ // Add components to the composite
+ // ----------------------------
+ DataObjectList& componentList = root->getList("component");
+ unsigned int i;
+ for (i=0; i < componentList.size(); i++)
+ {
+ addComponent(composite, componentList[i]);
+ }
+
+ // Resolve all the wires inside the composite
+ composite->resolveWires();
+
+ return composite;
+ }
+
+ // =================================
+ // addComponent:
+ // =================================
+ void ModelLoader::addComponent(Composite* composite, DataObjectPtr componentDO)
+ {
+ logentry();
+
+ // -------------------
+ // Get the component implementation
+ // -------------------
+ DataObjectPtr impl = componentDO->getDataObject("implementation");
+ if (!impl)
+ {
+ string message = "No implementation for component: ";
+ message = message + componentDO->getCString("name");
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+ // Create the component type
+ ComponentType* componentType;
+ string componentTypeName;
+ string componentTypePath;
+
+ string implTypeQname = impl->getType().getURI();
+ implTypeQname += "#";
+ implTypeQname += impl->getType().getName();
+
+ if (implTypeQname == "http://www.osoa.org/xmlns/sca/1.0#SCAImplementation")
+ {
+ // Handle a composite implementation
+ Composite* composite = compositeModels[impl->getCString("name")];
+ if (!composite)
+ {
+ string message = "Composite not found: ";
+ message = message + impl->getCString("name");
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ componentType = composite;
+ }
+ else
+ {
+
+ // Locate extension that handles this implementation type
+ ImplementationExtension* implExtension = runtime->getImplementationExtension(implTypeQname);
+ if (implExtension)
+ {
+ componentType = implExtension->getImplementation(composite, impl);
+
+ // -----------------------
+ // Load the .componentType
+ // -----------------------
+ string typeFileName = composite->getRoot() + "/" + componentType->getName() + ".componentType";
+
+ // Check that the component type file exists
+ //TODO We need a better and portable way to do this
+ string dirName;
+ string fileName;
+ Utils::rTokeniseString("/", typeFileName, dirName, fileName);
+ Files files(dirName, fileName, false);
+ if (files.size() !=0)
+ {
+ try
+ {
+ XMLDocumentPtr componentTypeFile = getXMLHelper()->loadFile(typeFileName.c_str());
+ if (!componentTypeFile || componentTypeFile->getRootDataObject() == 0)
+ {
+ // Component type files are optional
+ logerror("Unable to load file: %s", typeFileName.c_str());
+ }
+ else
+ {
+ //Utils::printDO(componentTypeFile->getRootDataObject());
+ //commonj::sdo::SDOUtils::printDataObject(componentTypeFile->getRootDataObject());
+ addServiceTypes(composite, componentType, componentTypeFile->getRootDataObject());
+ addReferenceTypes(composite, componentType, componentTypeFile->getRootDataObject());
+ addPropertyTypes(componentType, componentTypeFile->getRootDataObject());
+ }
+ } catch (SDORuntimeException& ex)
+ {
+ logerror("Unable to load file:%s", typeFileName.c_str());
+ throwException(SystemConfigurationException, ex);
+ }
+ }
+ }
+ else
+ {
+ logerror("Unsupported implementation type: %s", implTypeQname.c_str());
+
+ string message = "Implementation type not supported: ";
+ message = message + implTypeQname;
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ }
+
+ // First check that references and properties exist, some component types
+ // will create all used references & properties automatically
+ DataObjectList& refs = componentDO->getList("reference");
+ for (unsigned int i=0; i<refs.size(); i++)
+ {
+ string refName = refs[i]->getCString("name");
+ if (!componentType->findReferenceType(refName))
+ {
+ // Configuration error: reference is not defined
+ string message = "Undefined reference: " + refName;
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ }
+
+ DataObjectList& props = componentDO->getList("property");
+ for (unsigned int pi=0; pi<props.size(); pi++)
+ {
+ string propName = props[pi]->getCString("name");
+ if (!componentType->findPropertyType(propName))
+ {
+ // Configuration error: property is not defined
+ string message = "Undefined property: " + propName;
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ }
+
+
+ // Create the component
+ Component* component = new Component(composite, componentDO->getCString("name"), componentType);
+ composite->addComponent(component);
+
+ // ----------
+ // Properties
+ // ----------
+ for (unsigned int pi=0; pi<props.size(); pi++)
+ {
+ string propName = props[pi]->getCString("name");
+ DataObjectPtr propValue = props[pi]->getDataObject("value");
+
+ component->setProperty(propName, propValue);
+ }
+
+ // ----------
+ // References
+ // ----------
+ for (unsigned int ri=0; ri<refs.size(); ri++)
+ {
+ // ----------------------------------------------------------
+ // Add the reference to the composite wires to be resolved later
+ // ----------------------------------------------------------
+ string refName = refs[ri]->getCString("name");
+ if (!component->findReference(refName))
+ {
+ // Configuration error: reference is not defined
+ string message = "Undefined reference: " + refName;
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+ string src = component->getName() + "/" + refName;
+
+ // Get the reference value
+ string refValue = refs[ri]->getCString("value");
+
+ composite->addWire(src, refValue);
+ }
+ }
+
+ // =====================================================================
+ // addServiceTypes: add the services to the component type
+ // =====================================================================
+ void ModelLoader::addServiceTypes(Composite* composite, ComponentType* componentType, DataObjectPtr componentTypeDO)
+ {
+ logentry();
+
+ DataObjectList& serviceTypes = componentTypeDO->getList("service");
+ for (unsigned int i=0; i<serviceTypes.size(); i++)
+ {
+ Interface* iface = getInterface(composite, serviceTypes[i]);
+ ServiceType* serviceType = new ServiceType(
+ componentType, serviceTypes[i]->getCString("name"), iface, NULL);
+ componentType->addServiceType(serviceType);
+ }
+ }
+
+ // ===================================================
+ // addReferenceTypes: add the references to the component type
+ // ===================================================
+ void ModelLoader::addReferenceTypes(Composite* composite, ComponentType* componentType, DataObjectPtr componentTypeDO)
+ {
+ logentry();
+
+ DataObjectList& refs = componentTypeDO->getList("reference");
+ for (unsigned int i=0; i<refs.size(); i++)
+ {
+ ReferenceType::Multiplicity multiplicity;
+ if (refs[i]->isSet("multiplicity"))
+ {
+ string s = refs[i]->getCString("multiplicity");
+ multiplicity = ReferenceType::getMultiplicityFromString(s);
+ }
+ else
+ {
+ multiplicity = ReferenceType::ONE_ONE;
+ }
+
+ Interface* iface = getInterface(composite, refs[i]);
+
+ ReferenceType* referenceType = new ReferenceType(
+ componentType, refs[i]->getCString("name"), iface, NULL, multiplicity);
+ componentType->addReferenceType(referenceType);
+
+ }
+ }
+
+
+ // ==============
+ // getInterface
+ // ==============
+ Interface* ModelLoader::getInterface(Composite* composite, DataObjectPtr obj)
+ {
+ logentry();
+
+ // -----------------
+ // get the interface
+ // -----------------
+ DataObjectPtr iface = obj->getDataObject("interface");
+ if (!iface)
+ {
+ string message = "No interface for: ";
+ message = message + obj->getCString("name");
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+ string typeQname = iface->getType().getURI();
+ typeQname += "#";
+ typeQname += iface->getType().getName();
+
+ if (typeQname == WSDLInterface::typeQName)
+ {
+ // Load a WSDL interface
+ string qname = iface->getCString("interface");
+
+ return new WSDLInterface(qname, true, false);
+ }
+ else
+ {
+ // Locate extension that handles this interface type
+ InterfaceExtension* ifaceExtension = runtime->getInterfaceExtension(typeQname);
+ if (ifaceExtension)
+ {
+ return ifaceExtension->getInterface(composite, iface);
+ }
+ else
+ {
+ // log this for now.
+ logerror("Unsupported interface type: %s", typeQname.c_str());
+ return 0;
+ }
+ }
+
+ }
+
+ // ==============================================
+ // addProperties: add properties to the component type
+ // ==============================================
+ void ModelLoader::addPropertyTypes(ComponentType* componentType, DataObjectPtr componentTypeDO)
+ {
+ logentry();
+
+ DataObjectList& props = componentTypeDO->getList("property");
+ for (unsigned int i=0; i<props.size(); i++)
+ {
+ //cout << "Property " << props[i];
+
+ string name = props[i]->getCString("name");
+ string type = props[i]->getCString("type");
+ bool many=false;
+ if (props[i]->isSet("many"))
+ {
+ many = props[i]->getBoolean("many");
+ }
+
+ //TODO need to add support for complex properties, need the SDO
+ // folks to help understand how to do this...
+ DataObjectPtr defaultValue = props[i]->getDataObject("value");
+
+ componentType->addPropertyType(name, type, many, &defaultValue);
+ }
+ }
+
+ // ===============================================
+ // addCompositeService: add an CompositeService to the composite
+ // ===============================================
+ void ModelLoader::addCompositeService(Composite* composite, DataObjectPtr compositeServiceDO)
+ {
+ logentry();
+
+ string compositeServiceName = compositeServiceDO->getCString("name");
+
+ Interface* iface;
+ if (compositeServiceDO->getDataObject("interface"))
+ {
+ iface = getInterface(composite, compositeServiceDO);
+ }
+ else
+ {
+ iface = NULL;
+ }
+
+ ReferenceType::Multiplicity multiplicity;
+ if (compositeServiceDO->isSet("multiplicity"))
+ {
+ string s = compositeServiceDO->getCString("multiplicity");
+ multiplicity = ReferenceType::getMultiplicityFromString(s);
+ }
+ else
+ {
+ multiplicity = ReferenceType::ONE_ONE;
+ }
+
+ CompositeService* compositeService = new CompositeService(
+ composite, compositeServiceName, iface, NULL, false, multiplicity);
+
+ composite->addCompositeService(compositeService);
+
+ DataObjectList& refs = compositeServiceDO->getList("reference");
+ for (unsigned int i=0; i<refs.size(); i++)
+ {
+ // ----------------------------------------------------------
+ // Add the reference to the composite wires to be resolved later
+ // ----------------------------------------------------------
+ string targ = refs.getCString(i);
+ composite->addWire(compositeServiceName, targ);
+ }
+
+ // Get binding, it will be the first and only binding
+ DataObjectList& bindings = compositeServiceDO->getList("binding");
+ if (bindings.size()==0)
+ {
+ string message = "No binding for compositeService: ";
+ message = message + compositeServiceDO->getCString("name");
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ DataObjectPtr binding = bindings[0];
+
+ // Determine the binding type
+ string bindingType = binding->getType().getName();
+ string bindingTypeQname = binding->getType().getURI();
+ bindingTypeQname += "#";
+ bindingTypeQname += binding->getType().getName();
+
+ // Locate the extension that handles this binding type
+ ReferenceBindingExtension* bindingExtension = runtime->getReferenceBindingExtension(bindingTypeQname);
+ if (bindingExtension)
+ {
+ Reference* reference = compositeService->getReference();
+ ReferenceBinding* referenceBinding = bindingExtension->getReferenceBinding(composite, reference, binding);
+ reference->setBinding(referenceBinding);
+ }
+ else
+ {
+ logerror("Unsupported binding type: %s", bindingTypeQname.c_str());
+
+ string message = "Binding type not supported: ";
+ message = message + bindingTypeQname;
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ }
+
+
+ // =========================================================
+ // addCompositeReference: add a CompositeReference to the composite
+ // =========================================================
+ void ModelLoader::addCompositeReference(Composite* composite, DataObjectPtr compositeReferenceDO)
+ {
+ logentry();
+
+ string compositeReferenceName = compositeReferenceDO->getCString("name");
+
+ Interface* iface;
+ if (compositeReferenceDO->getDataObject("interface"))
+ {
+ iface = getInterface(composite, compositeReferenceDO);
+ }
+ else
+ {
+ iface = NULL;
+ }
+
+ CompositeReference* compositeReference = new CompositeReference(
+ composite, compositeReferenceName, iface, NULL, false, ReferenceType::ONE_ONE);
+
+ composite->addCompositeReference(compositeReference);
+
+ // Get binding, it will be the first and only binding
+ DataObjectList& bindings = compositeReferenceDO->getList("binding");
+ if (bindings.size()==0)
+ {
+ string message = "No binding for compositeReference: ";
+ message = message + compositeReferenceDO->getCString("name");
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ DataObjectPtr binding = bindings[0];
+
+ // Determine the binding type
+ string bindingType = binding->getType().getName();
+ string bindingTypeQname = binding->getType().getURI();
+ bindingTypeQname += "#";
+ bindingTypeQname += binding->getType().getName();
+
+ // Locate the extension that handles this binding type
+ ServiceBindingExtension* bindingExtension = runtime->getServiceBindingExtension(bindingTypeQname);
+ if (bindingExtension)
+ {
+ Service *service = compositeReference->getService();
+ ServiceBinding* serviceBinding = bindingExtension->getServiceBinding(composite, service, binding);
+ service->setBinding(serviceBinding);
+ }
+ else
+ {
+ logerror("Unsupported binding type: %s", bindingTypeQname.c_str());
+
+ string message = "Binding type not supported: ";
+ message = message + bindingTypeQname;
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ }
+
+
+ ///
+ /// Use the Tuscany.config file in the composite root directory to
+ /// determine which xsds and wsdls to load into a dataFactory.
+ ///
+ void ModelLoader::loadTypeMetadata(const string &compositeRootDir, Composite* composite)
+ {
+ logentry();
+
+ // Load the "Tuscany.config" file, if it exists
+ Files files(compositeRootDir, "Tuscany.config", false);
+ if (files.size() !=0)
+ {
+ for (unsigned int i=0; i < files.size(); i++)
+ {
+ string filename = compositeRootDir + "/" + files[i].getFileName();
+ XMLDocumentPtr compositeConfigFile = getXMLHelper()->loadFile(filename.c_str());
+ if (compositeConfigFile->getRootDataObject() == 0)
+ {
+ logerror("Unable to load file: %s", filename.c_str());
+ }
+ else
+ {
+ loginfo("Composite config for: %s, root directory: %s", composite->getName().c_str(), compositeRootDir.c_str());
+
+ if(compositeConfigFile->getRootDataObject()->isSet("xsd"))
+ {
+ DataObjectList& xsds = compositeConfigFile->getRootDataObject()->getList("xsd/file");
+
+ for (unsigned int i=0; i<xsds.size(); i++)
+ {
+ if(xsds[i]->isSet("name"))
+ {
+ // Load a xsd file -> set the types in the compositeComponents data factory file
+ string xsdName = compositeRootDir + "/" +xsds[i]->getCString("name");
+ loadXMLSchema(composite, xsdName.c_str());
+ }
+ }
+ }
+
+
+ if( compositeConfigFile->getRootDataObject()->isSet("wsdl"))
+ {
+ DataObjectList& wsdls = compositeConfigFile->getRootDataObject()->getList("wsdl/file");
+ for (unsigned int j=0; j<wsdls.size(); j++)
+ {
+ if(wsdls[i]->isSet("name"))
+ {
+ string wsdlName = compositeRootDir + "/" +wsdls[j]->getCString("name");
+ // Load a wsdl file -> get the types, then the contents of the wsdl
+ loadXMLSchema(composite, wsdlName.c_str());
+
+ // Load the contents of the wsdl files
+ loadWSDLDefinition(composite, wsdlName.c_str());
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ // The default scheme is to have no Tuscany.config file, then we simply load all
+ // WSDLs and XSDs that we find under the composite root
+
+ Files xsdFiles(compositeRootDir, "*.xsd", true);
+ for (unsigned int i=0; i < xsdFiles.size(); i++)
+ {
+ // Load a xsd file -> set the types in the compositeComponents data factory file
+ string xsdName = xsdFiles[i].getDirectory() + "/" + xsdFiles[i].getFileName();
+ loadXMLSchema(composite, xsdName.c_str());
+
+ }
+
+ Files wsdlFiles(compositeRootDir, "*.wsdl", true);
+ for (unsigned int wi=0; wi < wsdlFiles.size(); wi++)
+ {
+ // Load a wsdl file -> get the types, then the contents of the wsdl
+ string wsdlName = wsdlFiles[wi].getDirectory() + "/" + wsdlFiles[wi].getFileName();
+ loadXMLSchema(composite, wsdlName.c_str());
+
+ // Load the contents of the wsdl files
+ loadWSDLDefinition(composite, wsdlName.c_str());
+ }
+ }
+ }
+
+
+ ///
+ /// Use the types from an xsd or wsdl file
+ ///
+ void ModelLoader::loadXMLSchema(Composite* composite, const char *fileName)
+ {
+ logentry();
+ loginfo("Loading XML schema %s", fileName);
+ // Load a xsd file -> set the types in the data factory associated with
+ // the composite
+ try {
+ composite->getXSDHelper()->defineFile(fileName);
+ //Utils::printTypes(composite->getXSDHelper()->getDataFactory());
+
+ } catch (SDORuntimeException& ex)
+ {
+ logerror("Unable to load schema: %s", fileName);
+ throwException(SystemConfigurationException, ex);
+ }
+ }
+
+ ///
+ /// Load the web services definition from a wsdl
+ ///
+ void ModelLoader::loadWSDLDefinition(Composite* composite, const char *fileName)
+ {
+ logentry();
+
+ try {
+ // Load the wsdl file
+ XMLDocumentPtr doc = getXMLHelper()->loadFile(fileName);
+
+ if (doc!=0 && doc->getRootDataObject()!=0)
+ {
+ //Utils::printDO(doc->getRootDataObject());
+
+ // Add the root WSDL object to the composite
+ composite->addWSDLDefinition(doc->getRootDataObject());
+
+ }
+ else
+ {
+ logerror("Unable to load or parse WSDL: %s", fileName);
+ }
+
+ } catch (SDORuntimeException& ex)
+ {
+ logerror("Unable to load or parse WSDL: %s", fileName);
+ throwException(SystemConfigurationException, ex);
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Methods used to load the model into memory
+ //////////////////////////////////////////////////////////////////////////////
+
+ ///
+ /// Get an XSDHelper that has the appropriate XSDs already loaded
+ ///
+ const XSDHelperPtr ModelLoader::getXSDHelper()
+ {
+ logentry();
+
+ if (myXSDHelper == 0)
+ {
+
+ // Create an xsd helper
+ myXSDHelper = HelperProvider::getXSDHelper();
+
+ try {
+
+ // Load the Assembly model schema
+ string root = runtime->getInstallRoot();
+ string filename = root + "/xsd/sca.xsd";
+
+ myXSDHelper->defineFile(filename.c_str());
+
+ // Tuscany specific xsd for config files
+ filename = root + "/xsd/tuscany.xsd";
+ myXSDHelper->defineFile(filename.c_str());
+
+ initializeWSDLModel(myXSDHelper);
+
+ // Load any schema from the extensions directory
+ string extensionsRoot = root + "/extensions";
+
+ Files files(extensionsRoot, "*.xsd", true);
+ for (unsigned int i=0; i < files.size(); i++)
+ {
+ string extensionSchema = files[i].getDirectory() + "/" + files[i].getFileName();
+ myXSDHelper->defineFile(extensionSchema.c_str());
+ }
+
+
+ } catch (SDORuntimeException& ex)
+ {
+ throwException(SystemConfigurationException, ex);
+ }
+ }
+
+ return myXSDHelper;
+ }
+
+
+ ///
+ /// Get an XMLHelper to load files
+ ///
+ const XMLHelperPtr ModelLoader::getXMLHelper()
+ {
+ logentry();
+
+ if (myXMLHelper == 0) {
+
+ // Create an xml helper
+ myXMLHelper = HelperProvider::getXMLHelper(getXSDHelper()->getDataFactory());
+
+ }
+
+ return myXMLHelper;
+ }
+
+ void ModelLoader::initializeWSDLModel(XSDHelperPtr xsdHelper)
+ {
+ logentry();
+
+ DataFactoryPtr dataFactory = xsdHelper->getDataFactory();
+
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBinding",
+ false, true, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationFault",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationMessage",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDocumentation",
+ true, true, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDocumented",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement",
+ false, false, true);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented",
+ false, true, true);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented",
+ false, true, true);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tFault",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tImport",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tMessage",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tOperation",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tParam",
+ false, false, false);
+
+
+ TypeDefinition tpart;
+ tpart.setUri("http://schemas.xmlsoap.org/wsdl/");
+ tpart.setName("tPart");
+ tpart.setParentType("http://schemas.xmlsoap.org/wsdl/",
+ "tExtensibleAttributesDocumented", false);
+ PropertyDefinition propdef;
+ propdef.setName("name");
+ propdef.setLocalName("name");
+ propdef.setType("commonj.sdo", "String");
+ propdef.setIsContainment(true);
+ tpart.addPropertyDefinition(propdef);
+ propdef.setName("element");
+ propdef.setLocalName("element");
+ propdef.setIsQName(true);
+ tpart.addPropertyDefinition(propdef);
+ propdef.setName("type");
+ propdef.setLocalName("type");
+ tpart.addPropertyDefinition(propdef);
+ TypeDefinitions typedefs;
+ typedefs.addTypeDefinition(tpart);
+ xsdHelper->defineTypes(typedefs);
+
+ //Utils::printTypes(dataFactory);
+ /*dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPart",
+ false, false, false);*/
+
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPort",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPortType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tService",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/", "tTypes",
+ false, false, false);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "definitions",
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "import",
+ "http://schemas.xmlsoap.org/wsdl/", "tImport",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "types",
+ "http://schemas.xmlsoap.org/wsdl/", "tTypes",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "message",
+ "http://schemas.xmlsoap.org/wsdl/", "tMessage",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "portType",
+ "http://schemas.xmlsoap.org/wsdl/", "tPortType",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "binding",
+ "http://schemas.xmlsoap.org/wsdl/", "tBinding",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "service",
+ "http://schemas.xmlsoap.org/wsdl/", "tService",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "input",
+ "http://schemas.xmlsoap.org/wsdl/", "tParam",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "output",
+ "http://schemas.xmlsoap.org/wsdl/", "tParam",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "fault",
+ "http://schemas.xmlsoap.org/wsdl/", "tFault",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "output",
+ "http://schemas.xmlsoap.org/wsdl/", "tParam",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "input",
+ "http://schemas.xmlsoap.org/wsdl/", "tParam",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "fault",
+ "http://schemas.xmlsoap.org/wsdl/", "tFault",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "arrayType",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "RootType",
+ "required",
+ "commonj.sdo", "Boolean",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBinding",
+ "operation",
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBinding",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBinding",
+ "type",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation",
+ "input",
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationMessage",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation",
+ "output",
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationMessage",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation",
+ "fault",
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationFault",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationFault",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationFault",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationMessage",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationMessage",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ "import",
+ "http://schemas.xmlsoap.org/wsdl/", "tImport",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ "types",
+ "http://schemas.xmlsoap.org/wsdl/", "tTypes",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ "message",
+ "http://schemas.xmlsoap.org/wsdl/", "tMessage",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ "portType",
+ "http://schemas.xmlsoap.org/wsdl/", "tPortType",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ "binding",
+ "http://schemas.xmlsoap.org/wsdl/", "tBinding",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ "service",
+ "http://schemas.xmlsoap.org/wsdl/", "tService",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ "targetNamespace",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDefinitions",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tDocumented",
+ "documentation",
+ "http://schemas.xmlsoap.org/wsdl/", "tDocumentation",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement",
+ "required",
+ "commonj.sdo", "Boolean",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented",
+ "http://schemas.xmlsoap.org/wsdl/", "tDocumented");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented",
+ "http://schemas.xmlsoap.org/wsdl/", "tDocumented");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tFault",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tFault",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tFault",
+ "message",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tImport",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tImport",
+ "namespace",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tImport",
+ "location",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tMessage",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tMessage",
+ "part",
+ "http://schemas.xmlsoap.org/wsdl/", "tPart",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tMessage",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tOperation",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tOperation",
+ "input",
+ "http://schemas.xmlsoap.org/wsdl/", "tParam",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tOperation",
+ "output",
+ "http://schemas.xmlsoap.org/wsdl/", "tParam",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tOperation",
+ "fault",
+ "http://schemas.xmlsoap.org/wsdl/", "tFault",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tOperation",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tOperation",
+ "parameterOrder",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tParam",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tParam",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tParam",
+ "message",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPart",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented");
+ /*dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPart",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPart",
+ "element",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPart",
+ "type",
+ "commonj.sdo", "URI",
+ false, false, true);*/
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPort",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPort",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPort",
+ "binding",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPortType",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPortType",
+ "operation",
+ "http://schemas.xmlsoap.org/wsdl/", "tOperation",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tPortType",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tService",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tService",
+ "port",
+ "http://schemas.xmlsoap.org/wsdl/", "tPort",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/", "tService",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/", "tTypes",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented");
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tAddress",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBinding",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBody",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFault",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes",
+ false, false, true);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tOperation",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tStyleChoice",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice",
+ false, false, false);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "binding",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBinding",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "operation",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tOperation",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "body",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBody",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "encodingStyle",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "use",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "namespace",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "fault",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFault",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "header",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "message",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "part",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "use",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "encodingStyle",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "namespace",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "headerfault",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "RootType",
+ "address",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tAddress",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tAddress",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tAddress",
+ "location",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBinding",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBinding",
+ "transport",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBinding",
+ "style",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tStyleChoice",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBody",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBody",
+ "parts",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBody",
+ "encodingStyle",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBody",
+ "use",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBody",
+ "namespace",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFault",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFault",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tBody");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes",
+ "required",
+ "commonj.sdo", "Boolean",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes",
+ "parts",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes",
+ "encodingStyle",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes",
+ "use",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes",
+ "namespace",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader",
+ "headerfault",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault",
+ true, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader",
+ "message",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader",
+ "part",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader",
+ "use",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader",
+ "encodingStyle",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader",
+ "namespace",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault",
+ "message",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault",
+ "part",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault",
+ "use",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault",
+ "encodingStyle",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault",
+ "namespace",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tOperation",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tOperation",
+ "soapAction",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tOperation",
+ "style",
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tStyleChoice",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "tStyleChoice",
+ "commonj.sdo", "String");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice",
+ "commonj.sdo", "String");
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "RootType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "addressType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "bindingType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "operationType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "urlEncoded",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "urlReplacement",
+ false, false, false);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "RootType",
+ "address",
+ "http://schemas.xmlsoap.org/wsdl/http/", "addressType",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "RootType",
+ "binding",
+ "http://schemas.xmlsoap.org/wsdl/http/", "bindingType",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "RootType",
+ "operation",
+ "http://schemas.xmlsoap.org/wsdl/http/", "operationType",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "RootType",
+ "urlEncoded",
+ "http://schemas.xmlsoap.org/wsdl/http/", "urlEncoded",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "RootType",
+ "urlReplacement",
+ "http://schemas.xmlsoap.org/wsdl/http/", "urlReplacement",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "addressType",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "addressType",
+ "location",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "bindingType",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "bindingType",
+ "verb",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "operationType",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/http/", "operationType",
+ "location",
+ "commonj.sdo", "URI",
+ false, false, true);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "RootType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "contentType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "multipartRelatedType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "tMimeXml",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "tPart",
+ false, true, false);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "RootType",
+ "content",
+ "http://schemas.xmlsoap.org/wsdl/mime/", "contentType",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "RootType",
+ "multipartRelated",
+ "http://schemas.xmlsoap.org/wsdl/mime/", "multipartRelatedType",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "RootType",
+ "mimeXml",
+ "http://schemas.xmlsoap.org/wsdl/mime/", "tMimeXml",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "contentType",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "contentType",
+ "type",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "contentType",
+ "part",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "multipartRelatedType",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "multipartRelatedType",
+ "part",
+ "http://schemas.xmlsoap.org/wsdl/mime/", "tPart",
+ true, false, true);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "tMimeXml",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "tMimeXml",
+ "part",
+ "commonj.sdo", "String",
+ false, false, true);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/wsdl/mime/", "tPart",
+ "name",
+ "commonj.sdo", "String",
+ false, false, true);
+
+
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "RootType",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tAddress",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tBinding",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tBody",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs",
+ false, true, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tFault",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tFaultRes",
+ false, false, true);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tHeader",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tHeaderFault",
+ false, true, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tOperation",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tParts",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tStyleChoice",
+ false, false, false);
+ dataFactory->addType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "useChoice",
+ false, false, false);
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tAddress",
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tBinding",
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tBody",
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs",
+ "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tFault",
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tFaultRes");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tFaultRes",
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tBody");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tHeader",
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tOperation",
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "tStyleChoice",
+ "commonj.sdo", "String");
+ dataFactory->setBaseType(
+ "http://schemas.xmlsoap.org/wsdl/soap12/", "useChoice",
+ "commonj.sdo", "String");
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ModelLoader.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ModelLoader.h
new file mode 100644
index 0000000000..68893e7ba3
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ModelLoader.h
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_modelloader_h
+#define tuscany_sca_model_modelloader_h
+
+#include <map>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/util/File.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ /**
+ * Provides methods to load the runtime model from the SCDL file.
+ */
+ class ModelLoader {
+
+ public:
+ /**
+ * Constructor.
+ * @param system The SCA system to load.
+ */
+ ModelLoader(tuscany::sca::SCARuntime* runtime, Composite* system);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ModelLoader();
+
+ /**
+ * Load the model from the configuration information.
+ * @param systemRoot The location of the system configuration
+ * @param systemPath The search path for composites
+ */
+ void load(const std::string& systemRoot, const std::string& systemPath);
+
+ private:
+ void loadSystem(const std::string& systemRoot);
+
+ void loadComposites(const std::string& searchPath);
+ Composite* loadCompositeFile(const tuscany::sca::util::File& file);
+ Composite* mapCompositePass1(const tuscany::sca::util::File& file, commonj::sdo::DataObjectPtr rootDO);
+ Composite* mapCompositePass2(const std::string& compositeName, commonj::sdo::DataObjectPtr rootDO);
+
+ void addComponent(Composite* composite, commonj::sdo::DataObjectPtr componentDO);
+ void addCompositeService(Composite* composite, commonj::sdo::DataObjectPtr compositeServiceDO);
+ void addCompositeReference(Composite* composite, commonj::sdo::DataObjectPtr referenceServiceDO);
+
+ void addServiceTypes(Composite* composite, ComponentType* componentType, commonj::sdo::DataObjectPtr componentTypeDO);
+ void addReferenceTypes(Composite* composite, ComponentType* componentType, commonj::sdo::DataObjectPtr componentTypeDO);
+ void addPropertyTypes(ComponentType* componentType, commonj::sdo::DataObjectPtr componentTypeDO);
+
+ void loadTypeMetadata(const std::string &compositeRootDir, Composite* composite);
+
+ void loadXMLSchema(Composite* composite, const char *fileName);
+ void loadWSDLDefinition(Composite* composite, const char *fileName);
+ void initializeWSDLModel(commonj::sdo::XSDHelperPtr xsdHelper);
+
+ Interface* getInterface(Composite* composite, commonj::sdo::DataObjectPtr obj);
+
+ SCARuntime* runtime;
+
+ commonj::sdo::XMLHelperPtr myXMLHelper; // Used to load scdl files
+ commonj::sdo::XSDHelperPtr myXSDHelper; // Used to load xsds
+
+ const commonj::sdo::XSDHelperPtr getXSDHelper(void);
+ const commonj::sdo::XMLHelperPtr getXMLHelper(void);
+
+ /**
+ * The composite describing the composition of the system
+ */
+ Composite* system;
+
+ /**
+ * Maps of all the composites installed on the system.
+ */
+ typedef std::map<std::string, Composite*> COMPOSITE_MODELS;
+ COMPOSITE_MODELS compositeModels;
+
+ typedef std::map<std::string, commonj::sdo::DataObjectPtr> COMPOSITE_DATAOBJECTS;
+ COMPOSITE_DATAOBJECTS compositeDataObjects;
+
+ typedef std::map<std::string, Composite*> COMPOSITE_FILES;
+ COMPOSITE_FILES compositeFiles;
+
+ };
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_modelloader_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Reference.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Reference.cpp
new file mode 100644
index 0000000000..8820379c4e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Reference.cpp
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ // Constructor
+ Reference::Reference(Component* component, ReferenceType* referenceType)
+ : component(component), type(referenceType), binding(0)
+ {
+ logentry();
+ }
+
+ // Destructor
+ Reference::~Reference()
+ {
+ logentry();
+ }
+
+ void Reference::setBinding(ReferenceBinding* binding)
+ {
+ this->binding = binding;
+ }
+
+ ReferenceBinding* Reference::getBinding() const
+ {
+ return binding;
+ }
+
+ void Reference::addTarget(Service* target)
+ {
+ logentry();
+
+ if (type->getMultiplicity() == ReferenceType::ONE_ONE || type->getMultiplicity() == ReferenceType::ZERO_ONE)
+ {
+ if (targets.size() > 0)
+ {
+ string message = "Duplicate wire for reference: " + type->getName();
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ }
+
+ targets.push_back(target);
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Reference.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Reference.h
new file mode 100644
index 0000000000..33413b488f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Reference.h
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_reference_h
+#define tuscany_sca_model_reference_h
+
+#include <vector>
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ class Component;
+ class ReferenceType;
+ class ReferenceBinding;
+ class Service;
+
+ /**
+ * An addressable instance of a reference type associated with a particular component.
+ * Each reference represents a configured version of a logical
+ * reference type defined in the component type. If the logical reference
+ * has a multiplicity greater than 1 (0..n or 1..n) then the configured
+ * reference many have multiple targets.
+ */
+ class Reference
+ {
+ public:
+ /**
+ * Constructor.
+ * @param component The component on which the reference is defined.
+ * @param referenceType The reference type defining the characteristics of the reference.
+ */
+ SCA_API Reference(Component* component, ReferenceType* referenceType);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~Reference();
+
+ /**
+ * Returns the component on which this reference is defined.
+ * @return The component on which this reference is defined.
+ */
+ SCA_API Component* getComponent() const { return component; }
+
+ /**
+ * Returns the reference type defining the characteristics of the reference.
+ * @return The reference type defining the characteristics of the reference.
+ */
+ SCA_API ReferenceType* getType() const { return type; }
+
+ /**
+ * Returns the binding supported by the reference.
+ * @return The binding supported by the reference.
+ */
+ SCA_API ReferenceBinding* getBinding() const;
+
+ /**
+ * Sets the binding supported by the reference.
+ * @param binding The binding supported by the reference.
+ */
+ SCA_API void setBinding(ReferenceBinding* binding);
+
+ /**
+ * Add a target for this reference. There may be more than
+ * one if the multiplicity is 0..n or 1..n.
+ * @param target The target of the reference.
+ */
+ SCA_API void addTarget(Service* target);
+
+ typedef std::vector<Service*> TARGETS;
+
+ /**
+ * Get a vector of all the targets from this reference.
+ * @return The targets of this reference.
+ */
+ SCA_API const TARGETS& getTargets() const { return targets; }
+
+ private:
+
+ /**
+ * The component on which this reference is defined.
+ */
+ Component* component;
+
+ /**
+ * The reference type defining the characteristics of the reference.
+ */
+ ReferenceType* type;
+
+ /**
+ * The binding supported by this reference
+ */
+ ReferenceBinding* binding;
+
+ /**
+ * Vector of all the targets wired from this reference.
+ */
+ TARGETS targets;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_reference_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
new file mode 100644
index 0000000000..1f74dfbbb3
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/ReferenceBinding.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ ReferenceBinding::ReferenceBinding(Reference *reference, const string& uri) :
+ Binding(uri), reference(reference)
+ {
+ logentry();
+ }
+
+ // Destructor
+ ReferenceBinding::~ReferenceBinding()
+ {
+ logentry();
+ }
+
+ void ReferenceBinding::configure(const string& uri)
+ {
+ logentry();
+
+ // Find the target service
+ Component* component = reference->getComponent();
+ Composite* composite = component->getComposite();
+ Service* service;
+ service = composite->findComponentService(uri);
+ if (!service)
+ {
+ logerror("Wire target %s not found", uri.c_str());
+ }
+ else
+ {
+ // Configure this binding from the target service binding
+ configure(service->getBinding());
+ }
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceBinding.h
new file mode 100644
index 0000000000..4563f0a736
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceBinding.h
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_referencebinding_h
+#define tuscany_sca_model_referencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/Binding.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ class ServiceProxy;
+
+
+ namespace model
+ {
+ class Reference;
+ class ServiceBinding;
+
+ /**
+ * Represents a reference binding.
+ * Bindings are used by services and references. References use bindings
+ * to describe the access mechanism used to call an external service (which can
+ * be a service provided by another SCA composite). Services use bindings to describe
+ * the access mechanism that clients (which can be a client from another SCA composite)
+ * have to use to call the service.
+ * This interface will typically be extended by binding implementations to allow
+ * specification of binding/transport specific information.
+ */
+ class ReferenceBinding : public Binding
+ {
+ public:
+
+ /**
+ * Constructor to create a new binding.
+ */
+ SCA_API ReferenceBinding(Reference* reference, const std::string& uri);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~ReferenceBinding();
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ SCA_API virtual ServiceProxy* getServiceProxy() = 0;
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ SCA_API virtual void configure(ServiceBinding* serviceBinding) = 0;
+
+ /**
+ * Configure this binding from a URI.
+ */
+ SCA_API virtual void configure(const std::string& uri);
+
+ /**
+ * Returns the reference.
+ * @return The reference.
+ */
+ SCA_API Reference* getReference() const { return reference; };
+
+ private:
+
+ /**
+ * The reference configured with the binding.
+ */
+ Reference* reference;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_referencebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceType.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceType.cpp
new file mode 100644
index 0000000000..732a14cace
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceType.cpp
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/model/ReferenceType.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+
+ // Constructor
+ ReferenceType::ReferenceType(ComponentType* componentType, const string& name,
+ Interface* intface, Interface* callbackInterface, Multiplicity multiplicity)
+ : Contract(intface, callbackInterface),
+ componentType(componentType), name(name), multiplicity(multiplicity)
+ {
+ logentry();
+ }
+
+ ReferenceType::~ReferenceType()
+ {
+ logentry();
+ }
+
+ ReferenceType::Multiplicity ReferenceType::getMultiplicityFromString(const string& multip)
+ {
+ logentry();
+
+ if (multip == "0..1")
+ {
+ return ReferenceType::ZERO_ONE;
+ }
+ else if (multip == "1..1")
+ {
+ return ReferenceType::ONE_ONE;
+ }
+ else if (multip == "0..n")
+ {
+ return ReferenceType::ZERO_MANY;
+ }
+ else if (multip == "1..n")
+ {
+ return ReferenceType::ONE_MANY;
+ }
+ else
+ {
+ return ReferenceType::UNKNOWN;
+ }
+ }
+
+ void ReferenceType::setBinding(Binding* binding)
+ {
+ this->binding = binding;
+ }
+
+ Binding* ReferenceType::getBinding() const
+ {
+ return binding;
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceType.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceType.h
new file mode 100644
index 0000000000..87d38ab330
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ReferenceType.h
@@ -0,0 +1,138 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_referencetype_h
+#define tuscany_sca_model_referencetype_h
+
+#include <string>
+
+#include "tuscany/sca/model/Contract.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ class ComponentType;
+ class Interface;
+ class Binding;
+
+ /**
+ * Represents an SCA reference. SCA references within an implementation represent
+ * links to services that the implementation uses that must be provided by other components
+ * in the SCA system.
+ */
+ class ReferenceType : public Contract
+ {
+ public:
+
+ /**
+ * Multiplicity (how many wires can be connected to this
+ * reference)
+ */
+ enum Multiplicity
+ {
+ ZERO_ONE = 1,
+ ONE_ONE = 2,
+ ZERO_MANY = 3,
+ ONE_MANY = 4,
+ UNKNOWN = 0,
+ };
+
+ /**
+ * Constructor.
+ * @param name The name of the reference.
+ */
+ SCA_API ReferenceType(ComponentType* componentType, const std::string& name,
+ Interface* intface, Interface* callbackInterface, Multiplicity multiplicity);
+
+ /**
+ * Destructor.
+ */;
+ SCA_API virtual ~ReferenceType();
+
+ /**
+ * Returns the component type on which this reference is defined.
+ * @return The component type on which this reference is defined.
+ */
+ SCA_API ComponentType* getComponentType() const { return componentType; }
+
+ /**
+ * Returns the name of the reference.
+ * @return The name of the reference.
+ */
+ SCA_API const std::string& getName() const { return name; }
+
+ /**
+ * Returns the multiplicity allowed for wires connected to this reference.
+ * @return The multiplicity allowed for wires connected to this reference
+ */
+ SCA_API Multiplicity getMultiplicity() const { return multiplicity; }
+
+ /**
+ * Returns the binding supported by the reference.
+ * @return The binding supported by the reference.
+ */
+ SCA_API Binding* getBinding() const;
+
+ /**
+ * Sets the binding supported by the reference.
+ * @param binding The binding supported by the reference.
+ */
+ SCA_API void setBinding(Binding* binding);
+
+ /**
+ * Get the multiplicity corresponding to the given
+ * string.
+ */
+ static Multiplicity getMultiplicityFromString(const std::string& multip);
+
+ private:
+
+ /**
+ * The component type on which this reference is defined.
+ */
+ ComponentType *componentType;
+
+ /**
+ * The name of the reference type.
+ */
+ std::string name;
+
+ /**
+ * The multiplicity allowed for wires connected to this reference.
+ */
+ Multiplicity multiplicity;
+
+ /**
+ * The binding supported by this reference type.
+ */
+ Binding* binding;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_referencetype_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Service.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Service.cpp
new file mode 100644
index 0000000000..4df1d1efc6
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Service.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/model/Service.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ // Constructor
+ Service::Service(Component* component, ServiceType* serviceType)
+ : component(component), type(serviceType), binding(0)
+ {
+ logentry();
+ }
+
+ // Destructor
+ Service::~Service()
+ {
+ logentry();
+ }
+
+ void Service::setBinding(ServiceBinding* binding)
+ {
+ this->binding = binding;
+ }
+
+ ServiceBinding* Service::getBinding() const
+ {
+ return binding;
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Service.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Service.h
new file mode 100644
index 0000000000..a1f2c5d672
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Service.h
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_service_h
+#define tuscany_sca_model_service_h
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ class Component;
+ class ServiceType;
+ class ServiceBinding;
+
+ /**
+ * An addressable instance of a service type associated with a particular component.
+ */
+ class Service
+ {
+ public:
+ /**
+ * Constructor.
+ * @param component The component on which the service is defined.
+ * @param serviceType The service type defining the characteristics of the service.
+ */
+ SCA_API Service(Component* component, ServiceType* serviceType);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~Service();
+
+ /**
+ * Returns the component on which this service is defined.
+ * @return The component on which this service is defined.
+ */
+ SCA_API Component* getComponent() const { return component; }
+
+ /**
+ * Returns the service type defining the characteristics of the service.
+ * @return The service type defining the characteristics of the service.
+ */
+ SCA_API ServiceType* getType() const { return type; }
+
+ /**
+ * Returns the binding supported by the service.
+ * @return The binding supported by the service.
+ */
+ SCA_API ServiceBinding* getBinding() const;
+
+ /**
+ * Sets the binding supported by the service.
+ * @param binding The binding supported by the service.
+ */
+ SCA_API void setBinding(ServiceBinding* binding);
+
+ private:
+
+ /**
+ * The component on which this service is defined.
+ */
+ Component* component;
+
+ /**
+ * The service type defining the characteristics of the service.
+ */
+ ServiceType* type;
+
+ /**
+ * The binding supported by this service
+ */
+ ServiceBinding* binding;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_service_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp
new file mode 100644
index 0000000000..ddc5e6a711
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+
+using namespace std;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ ServiceBinding::ServiceBinding(Service* service, const string& uri) :
+ Binding(uri), service(service)
+ {
+ logentry();
+ }
+
+ // Destructor
+ ServiceBinding::~ServiceBinding()
+ {
+ logentry();
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceBinding.h
new file mode 100644
index 0000000000..4e68f492a3
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceBinding.h
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_servicebinding_h
+#define tuscany_sca_model_servicebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/Binding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ class ServiceWrapper;
+
+ namespace model
+ {
+ class Service;
+
+ /**
+ * Represents a service binding.
+ * Bindings are used by services and references. References use bindings
+ * to describe the access mechanism used to call an external service (which can
+ * be a service provided by another SCA composite). Services use bindings to describe
+ * the access mechanism that clients (which can be a client from another SCA composite)
+ * have to use to call the service.
+ * This interface will typically be extended by binding implementations to allow
+ * specification of binding/transport specific information.
+ */
+ class ServiceBinding : public Binding
+ {
+ public:
+
+ /**
+ * Constructor to create a new binding.
+ */
+ SCA_API ServiceBinding(Service* service, const std::string& uri);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~ServiceBinding();
+
+ /**
+ * Create a service wrapper handling the interaction
+ * with the service configured with this binding.
+ */
+ SCA_API virtual ServiceWrapper* getServiceWrapper() = 0;
+
+ /**
+ * Returns the service
+ * @return The service.
+ */
+ SCA_API Service* getService() const { return service; };
+
+ private:
+
+ /**
+ * The service configured with the binding.
+ */
+ Service* service;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_servicebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceType.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceType.cpp
new file mode 100644
index 0000000000..819a832443
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceType.cpp
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/ServiceType.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+
+ // Constructor
+ ServiceType::ServiceType(ComponentType* componentType, const string& name,
+ Interface* intface, Interface* callbackInterface)
+ : Contract(intface, callbackInterface),
+ componentType(componentType), name(name)
+ {
+ logentry();
+ }
+
+ // Destructor
+ ServiceType::~ServiceType()
+ {
+ logentry();
+ }
+
+ void ServiceType::setBinding(Binding* binding)
+ {
+ this->binding = binding;
+ }
+
+ Binding* ServiceType::getBinding() const
+ {
+ return binding;
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceType.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceType.h
new file mode 100644
index 0000000000..08a76e3b3f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/ServiceType.h
@@ -0,0 +1,108 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_servicetype_h
+#define tuscany_sca_model_servicetype_h
+
+#include <string>
+
+#include "tuscany/sca/model/Contract.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ class ComponentType;
+ class Binding;
+ class Interface;
+
+ /**
+ * Represents a service type. Services are used to publish services provided by
+ * implementations, so that they are addressable by other components.
+ */
+ class ServiceType : public Contract
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param componentType The component type on which this service is defined.
+ * @param name The name of the service.
+ */
+ SCA_API ServiceType(ComponentType* componentType, const std::string& name,
+ Interface* intface, Interface* callbackInterface);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~ServiceType();
+
+ /**
+ * Returns the component type on which this service is defined.
+ * @return The component type on which this service is defined.
+ */
+ SCA_API ComponentType* getComponentType() const { return componentType; }
+
+ /**
+ * Returns the name of the service type.
+ * @return The name of the service type
+ */
+ SCA_API const std::string& getName() const { return name; }
+
+ /**
+ * Returns the binding supported by this service type.
+ * @return The binding supported by this service type
+ */
+ SCA_API Binding* getBinding() const;
+
+ /**
+ * Sets the binding supported by this service type.
+ * @param binding the binding supported by this service type
+ */
+ SCA_API void setBinding(Binding* binding);
+
+ private:
+
+ /**
+ * The component type on which this service is defined.
+ */
+ ComponentType* componentType;
+
+ /**
+ * The name of the service type.
+ */
+ std::string name;
+
+ /**
+ * The binding supported by this service
+ */
+ Binding* binding;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_servicetype_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLDefinition.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLDefinition.cpp
new file mode 100644
index 0000000000..5a98db3cdd
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLDefinition.cpp
@@ -0,0 +1,462 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/model/WSDLDefinition.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/Exceptions.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ // Constructor
+ WSDLDefinition::WSDLDefinition(DataObjectPtr wsdlModel)
+ {
+ logentry();
+
+ wsdlModels.insert(wsdlModels.end(), wsdlModel);
+ }
+
+ WSDLDefinition::~WSDLDefinition()
+ {
+ logentry();
+ }
+
+ ///
+ /// The namespace of the service and other definitions defined in this wsdl definition
+ string WSDLDefinition::getNamespace()
+ {
+ logentry();
+ return wsdlModels[0]->getCString("targetNamespace");
+ }
+
+ void WSDLDefinition::addWSDLModel(DataObjectPtr wsdlModel)
+ {
+ logentry();
+ wsdlModels.insert(wsdlModels.end(), wsdlModel);
+ }
+
+ ///
+ /// Find the operation defined in this wsdl
+ ///
+ const WSDLOperation& WSDLDefinition::findOperation(const string& serviceName,
+ const string& portName,
+ const string& operationName)
+ {
+ logentry();
+
+ string message;
+
+ string operationKey = serviceName+"#"+portName+"#"+operationName;
+ OPERATION_MAP::iterator iter = operationMap.find(operationKey);
+ if (iter != operationMap.end())
+ {
+ return iter->second;
+ }
+
+ // Find the service
+ DataObjectPtr service = findService(serviceName);
+ if (!service)
+ {
+ // Service not found
+ message = "Unable to find service ";
+ message = message + serviceName;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ else
+ {
+
+
+ // Found the service
+ DataObjectList& portList = service->getList("port");
+ for (unsigned int j=0; j<portList.size();j++)
+ {
+ string portListName(portList[j]->getCString("name"));
+ if (portListName.compare(portName) == 0)
+ {
+ // found port
+ // Add address at this point
+ string targetAddress(portList[j]->getCString("address/location"));
+
+ // find operation by traversing the binding, portType then operation
+ string wsBindingName(portList[j]->getCString("binding"));
+
+ DataObjectPtr wsBinding = findBinding(wsBindingName);
+ if (!wsBinding)
+ {
+ message = "Unable to find binding ";
+ message = message + wsBindingName;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+
+ string soapAction = "";
+ bool documentStyle = true;
+ bool wrappedStyle = true;
+ bool useEncoded = false;
+ WSDLOperation::soapVersion soapVer = WSDLOperation::SOAP11;
+
+ // Find the binding operation
+ DataObjectList& bindingOperationList = wsBinding->getList("operation");
+ for (unsigned int i=0; i<bindingOperationList.size(); i++)
+ {
+ string name(bindingOperationList[i]->getCString("name"));
+
+ if (name.compare(operationName) == 0)
+ {
+ DataObjectPtr op = bindingOperationList[i]->getDataObject("operation");
+ string opType = op->getType().getURI();
+ if (opType == "http://schemas.xmlsoap.org/wsdl/soap12/")
+ {
+ soapVer = WSDLOperation::SOAP12;
+ }
+
+ // Get the soapAction
+ soapAction = bindingOperationList[i]->getCString("operation/soapAction");
+
+ // Get the style
+ string style = bindingOperationList[i]->getCString("operation/style");
+ if (style == "")
+ {
+ style = wsBinding->getCString("binding/style");
+ }
+ if (style != "document")
+ {
+ documentStyle = false;
+ wrappedStyle = false;
+ }
+
+ // get the use
+ string use = bindingOperationList[i]->getCString("input/body/use");
+ if (use == "encoded")
+ {
+ useEncoded = true;
+ }
+ }
+ }
+
+
+ // TODO - get the style from the binding or operation????
+
+ // Found the binding, get the portType
+ string wsPortTypeName(wsBinding->getCString("type"));
+ DataObjectPtr wsPortType = findPortType(wsPortTypeName);
+ if (!wsPortType)
+ {
+ message = "Unable to find PortType ";
+ message = message + wsPortTypeName;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+ //Utils::printDO(wsPortType);
+
+ // Found the portType, find the operation
+ DataObjectList& operationList = wsPortType->getList("operation");
+ for (unsigned int k=0; k< operationList.size(); k++)
+ {
+ string opName(operationList[k]->getCString("name"));
+ if( opName.compare(operationName) == 0)
+ {
+ // Found the operation
+
+ // Find the type of the request message
+ string inputMessageType = string(operationList[k]->getCString("input/message"));
+
+ DataObjectPtr wsMessageIn = findMessage(inputMessageType);
+ if (!wsMessageIn)
+ {
+ message = "Unable to find message ";
+ message = message + inputMessageType;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+ string requestType(wsMessageIn->getList("part")[0]->getCString("element"));
+
+ // Find the type of the response message
+ string outputMessageType = string(operationList[k]->getCString("output/message"));
+
+ DataObjectPtr wsMessageOut = findMessage(outputMessageType);
+ if (!wsMessageOut)
+ {
+ message = "Unable to find message ";
+ message = message + outputMessageType;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+ string responseType(wsMessageOut->getList("part")[0]->getCString("element"));
+
+ WSDLOperation& wsdlOp = operationMap[operationKey];
+ wsdlOp.setOperationName(operationName);
+ wsdlOp.setSoapAction(soapAction);
+ wsdlOp.setEndpoint(targetAddress);
+ wsdlOp.setSoapVersion(soapVer);
+ wsdlOp.setDocumentStyle(documentStyle);
+ wsdlOp.setWrappedStyle(wrappedStyle);
+ wsdlOp.setEncoded(useEncoded);
+ wsdlOp.setInputType(requestType);
+ wsdlOp.setOutputType(responseType);
+ return wsdlOp;
+ }
+
+ }
+
+ message = "Unable to find Operation ";
+ message = message + operationName;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ }
+ // cannot find the port
+ message = "Unable to find port ";
+ message = message + portName;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+ }
+
+ ///
+ /// Find the operation defined in this wsdl
+ ///
+ const WSDLOperation& WSDLDefinition::findOperation(const string& portTypeName,
+ const string& operationName)
+ {
+ logentry();
+
+ string operationKey = portTypeName+"#"+operationName;
+ OPERATION_MAP::iterator iter = operationMap.find(operationKey);
+ if (iter != operationMap.end())
+ {
+ return iter->second;
+ }
+
+ string soapAction = getNamespace() + "#" + operationName;
+ bool documentStyle = true;
+ bool wrappedStyle = true;
+ bool useEncoded = false;
+ WSDLOperation::soapVersion soapVer = WSDLOperation::SOAP11;
+
+ // Get the portType
+ DataObjectPtr wsPortType = findPortType(portTypeName);
+ if (!wsPortType)
+ {
+ string message = "Unable to find PortType ";
+ message = message + portTypeName;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+ // Found the portType, find the operation
+ DataObjectList& operationList = wsPortType->getList("operation");
+ for (unsigned int k=0; k< operationList.size(); k++)
+ {
+ string opName(operationList[k]->getCString("name"));
+ if( opName.compare(operationName) == 0)
+ {
+ // Found the operation
+
+ // Find the type of the request message
+ string inputMessageType = string(operationList[k]->getCString("input/message"));
+
+ DataObjectPtr wsMessageIn = findMessage(inputMessageType);
+ if (!wsMessageIn)
+ {
+ string message = "Unable to find message ";
+ message = message + inputMessageType;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+ string requestType(wsMessageIn->getList("part")[0]->getCString("element"));
+
+ // Find the type of the response message
+ string outputMessageType = string(operationList[k]->getCString("output/message"));
+
+ DataObjectPtr wsMessageOut = findMessage(outputMessageType);
+ if (!wsMessageOut)
+ {
+ string message = "Unable to find message ";
+ message = message + outputMessageType;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+
+ string responseType(wsMessageOut->getList("part")[0]->getCString("element"));
+
+ WSDLOperation& wsdlOp = operationMap[operationKey];
+ wsdlOp.setOperationName(operationName);
+ wsdlOp.setSoapAction(soapAction);
+ wsdlOp.setEndpoint("");
+ wsdlOp.setSoapVersion(soapVer);
+ wsdlOp.setDocumentStyle(documentStyle);
+ wsdlOp.setWrappedStyle(wrappedStyle);
+ wsdlOp.setEncoded(useEncoded);
+ wsdlOp.setInputType(requestType);
+ wsdlOp.setOutputType(responseType);
+ return wsdlOp;
+ }
+ }
+
+ string message = "Unable to find Operation ";
+ message = message + operationName;
+ message = message + " in the WSDL definition";
+ throwException(SystemConfigurationException, message.c_str());
+
+ }
+
+ ///
+ /// Find a service
+ ///
+ DataObjectPtr WSDLDefinition::findService(const string& serviceName)
+ {
+ logentry();
+
+ DataObjectPtr service = 0;
+
+ // Find the binding
+ for (unsigned int m = 0; m < wsdlModels.size(); m++)
+ {
+ DataObjectList& serviceList = wsdlModels[m]->getList("service");
+ for (unsigned int i=0; i<serviceList.size(); i++)
+ {
+ string name(serviceList[i]->getCString("name"));
+
+ if (name.compare(serviceName) == 0)
+ {
+ return serviceList[i];
+ }
+ }
+ }
+
+ return service;
+ }
+
+
+ ///
+ /// Find a named binding
+ ///
+ DataObjectPtr WSDLDefinition::findBinding(const string& bindingName)
+ {
+ logentry();
+
+ DataObjectPtr binding = 0;
+ string uri;
+ string name;
+
+ Utils::rTokeniseString(":", bindingName, uri, name);
+
+ // Find the binding
+ for (unsigned int m = 0; m < wsdlModels.size(); m++)
+ {
+ DataObjectList& bindingList = wsdlModels[m]->getList("binding");
+ for (unsigned int i=0; i<bindingList.size(); i++)
+ {
+ string nameBinding(bindingList[i]->getCString("name"));
+
+ if (nameBinding.compare(name) == 0)
+ {
+ return bindingList[i];
+ }
+ }
+ }
+
+ return binding;
+ }
+
+ ///
+ /// Find a named portType
+ ///
+ DataObjectPtr WSDLDefinition::findPortType(const string& portTypeName)
+ {
+ logentry();
+
+ DataObjectPtr portType = 0;
+ string uri;
+ string name;
+
+ Utils::rTokeniseString(":", portTypeName, uri, name);
+
+ // Find the binding
+ for (unsigned int m = 0; m < wsdlModels.size(); m++)
+ {
+ DataObjectList& portTypeList = wsdlModels[m]->getList("portType");
+ for (unsigned int i=0; i<portTypeList.size(); i++)
+ {
+ string namePortType(portTypeList[i]->getCString("name"));
+
+ if (namePortType.compare(name) == 0)
+ {
+ return portTypeList[i];
+ }
+ }
+ }
+
+ return portType;
+ }
+
+ ///
+ /// Find a named message
+ ///
+ DataObjectPtr WSDLDefinition::findMessage(const string& messageName)
+ {
+ logentry();
+
+ DataObjectPtr message = 0;
+ string uri;
+ string name;
+
+ Utils::rTokeniseString(":", messageName, uri, name);
+
+ // Find the binding
+ for (unsigned int m = 0; m < wsdlModels.size(); m++)
+ {
+ DataObjectList& messageList = wsdlModels[m]->getList("message");
+ for (unsigned int i=0; i<messageList.size(); i++)
+ {
+ string nameMessage(messageList[i]->getCString("name"));
+
+ if (nameMessage.compare(name) == 0)
+ {
+ return messageList[i];
+ }
+ }
+ }
+
+ return message;
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLDefinition.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLDefinition.h
new file mode 100644
index 0000000000..9be553205a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLDefinition.h
@@ -0,0 +1,146 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_wsdldefinition_h
+#define tuscany_sca_model_wsdldefinition_h
+
+#include <string>
+#include <map>
+#include <vector>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ class WSDLOperation;
+
+ /**
+ * Holds information about a WSDL definition loaded into the runtime.
+ */
+ class WSDLDefinition
+ {
+ public:
+ /**
+ * Constructor.
+ * @param wsdlModel The data object representing the WSDL document
+ * defining a web service.
+ */
+ SCA_API WSDLDefinition(commonj::sdo::DataObjectPtr wsdlModel);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~WSDLDefinition();
+
+ /**
+ * Returns the target namespace of the WSDL definitions.
+ * @return The target namespace.
+ */
+ SCA_API std::string getNamespace(void);
+
+ /**
+ * Add a WSDL model.
+ */
+ SCA_API void addWSDLModel(commonj::sdo::DataObjectPtr wsdlModel);
+
+ /**
+ * Find an operation in the WSDL definitions.
+ * @param serviceName The name of the service on which this
+ * operation is defined.
+ * @param portName The name of the port in the service to
+ * use.
+ * @param operationName The name of the operation to find.
+ * @return The operation if found. Exception thrown if not found.
+ */
+ SCA_API const WSDLOperation& findOperation(const std::string& serviceName,
+ const std::string& portName,
+ const std::string& operationName);
+
+ /**
+ * Find an operation in the WSDL definitions.
+ * @param portTypeName The name of the portType on which this
+ * operation is defined.
+ * @param operationName The name of the operation to find.
+ * @return The operation if found. Exception thrown if not found.
+ */
+ SCA_API const WSDLOperation& findOperation(const std::string& portTypeName,
+ const std::string& operationName);
+
+ private:
+
+ /**
+ * Find a service in the wsdl definition.
+ * @param serviceName The name of the service.
+ * @return A data object describing the service if found, otherwise
+ * a 0 if not found.
+ */
+ commonj::sdo::DataObjectPtr findService(const std::string& serviceName);
+
+ /**
+ * Find a binding in the wsdl definition.
+ * @param bindingName The name of the binding to find.
+ * @return A data object describing the binding if found, otherwise
+ * a 0 if not found.
+ */
+ commonj::sdo::DataObjectPtr findBinding(const std::string& bindingName);
+
+ /**
+ * Find a portType in the wsdl definition.
+ * @param portTypeName The name of the portType.
+ * @return A data object describing the portType if found, otherwise
+ * a 0 if not found.
+ */
+ commonj::sdo::DataObjectPtr findPortType(const std::string& portTypeName);
+
+ /**
+ * Find a message in the wsdl definition.
+ * @param messageName The name of the message.
+ * @return A data object describing the message if found, otherwise
+ * a 0 if not found.
+ */
+ commonj::sdo::DataObjectPtr findMessage(const std::string& messageName);
+
+
+ /**
+ * The data object representation of the WSDL document.
+ */
+ typedef std::vector<commonj::sdo::DataObjectPtr> MODEL_VECTOR;
+ MODEL_VECTOR wsdlModels;
+
+ typedef std::map<std::string, WSDLOperation> OPERATION_MAP;
+ OPERATION_MAP operationMap;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_wsdldefinition_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLInterface.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLInterface.cpp
new file mode 100644
index 0000000000..5fa45a9967
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLInterface.cpp
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/WSDLInterface.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ const string WSDLInterface::typeQName("http://www.osoa.org/xmlns/sca/1.0#WSDLPortType");
+
+ // Constructor
+ WSDLInterface::WSDLInterface(
+ const string& qname, bool remotable, bool conversational)
+ : Interface(remotable, conversational)
+ {
+ logentry();
+ parse(qname);
+ }
+
+ void WSDLInterface::parse(const string& qname)
+ {
+ logentry();
+
+ // PortType is of the form: <wsdl-namepace-uri>#wsdl.interface(<portType-name>)
+ string::size_type hash = qname.find("#");
+ if (hash != string::npos)
+ {
+ // Found a hash
+
+ // Namepace is the part before the #
+ namespaceURI = qname.substr(0, hash);
+
+ if ( (hash+1) < qname.length())
+ {
+ // Check the next part is wsdl.interface(
+ int ending = hash+16;
+ string check = qname.substr(hash+1, 15);
+ if (check.compare("wsdl.interface(") == 0)
+ {
+ // Find the matching )
+ int endBracket = qname.find(")",ending);
+ if (endBracket-1 > ending+1)
+ {
+ name = qname.substr(ending, endBracket-ending);
+ }
+ else
+ {
+ // Nothing between the ()
+ name = "";
+ }
+ }
+ else
+ {
+ // not the correct characters after the #, ignore the rest
+ name = "";
+ }
+
+ }
+ else
+ {
+ // Nothing after the hash
+ name = "";
+ }
+ }
+ else
+ {
+ // No hash at all
+ namespaceURI = qname;
+ name = "";
+ }
+ }
+
+
+ WSDLInterface::~WSDLInterface()
+ {
+ logentry();
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLInterface.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLInterface.h
new file mode 100644
index 0000000000..b071dd221e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLInterface.h
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_wsdlinterface_h
+#define tuscany_sca_model_wsdlinterface_h
+
+#include <string>
+
+#include "tuscany/sca/model/Interface.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Holds information about an interface described using a WSDL
+ * port type.
+ */
+ class WSDLInterface : public Interface
+ {
+
+ public:
+ /**
+ * Constuctor.
+ * @param interfaceName Name of the WSDL interface.
+ */
+ WSDLInterface(const std::string& qname, bool remotable, bool conversational);
+
+ /**
+ * Destructor.
+ */
+ virtual ~WSDLInterface();
+
+ /**
+ * Returns the WSDL namespace
+ */
+ std::string getNamespaceURI() const { return namespaceURI; }
+
+ /**
+ * Returns the interface name
+ */
+ std::string getName() const { return name; }
+
+ /**
+ * return the QName of the schema type for this interface type
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp")
+ */
+ virtual const std::string& getInterfaceTypeQName() { return typeQName; };
+
+ /**
+ * The QName of the schema type for this interface type.
+ */
+ SCA_API static const std::string typeQName;
+
+ private:
+
+ /**
+ * Parse the WSDL qname
+ */
+ void parse(const std::string& qname);
+
+ /**
+ * WSDL namespace.
+ */
+ std::string namespaceURI;
+
+ /**
+ * Name of the WSDL interface.
+ */
+ std::string name;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_wsdlinterface_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLOperation.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLOperation.cpp
new file mode 100644
index 0000000000..12a0b61fd2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLOperation.cpp
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/model/WSDLOperation.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+
+ // Constructor
+ WSDLOperation::WSDLOperation()
+ {
+ logentry();
+ }
+
+ WSDLOperation::~WSDLOperation()
+ {
+ logentry();
+ }
+
+
+ void WSDLOperation::setInputType(const string& inputType)
+ {
+ logentry();
+ Utils::tokeniseQName(inputType, inputTypeUri, inputTypeName);
+ }
+
+ void WSDLOperation::setOutputType(const string& outputType)
+ {
+ logentry();
+ Utils::tokeniseQName(outputType, outputTypeUri, outputTypeName);
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLOperation.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLOperation.h
new file mode 100644
index 0000000000..874da80450
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/WSDLOperation.h
@@ -0,0 +1,147 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_wsdloperation_h
+#define tuscany_sca_model_wsdloperation_h
+
+#include <string>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ /**
+ * Represents a single.,bound WSDL defined operation.
+ * This class includes information from the soapBinding
+ * in addition to the WSDL definition of the operation.
+ */
+ class WSDLOperation
+ {
+ public:
+ /**
+ * Constructor.
+ * @param operation The name of the operation.
+ * @param soapAction The soapAction associated with this operation
+ * in the SOAP binding of the operation.
+ * @param endpoint The endpoint address of the operation.
+ * @param responseName The name of the response message.
+ */
+ SCA_API WSDLOperation();
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~WSDLOperation();
+
+ /**
+ * Return the name of the operation for use when serializing an
+ * outgoing message.
+ * @return The name of the element in the request message.
+ */
+ SCA_API const std::string& getOperationName() const {return operationName;}
+ SCA_API void setOperationName(const std::string& opName) {operationName = opName;}
+
+ /**
+ * The soap action string for this operation.
+ * @return The soap action.
+ */
+ SCA_API const std::string& getSoapAction() const {return soapAction;}
+ SCA_API void setSoapAction(const std::string& soapAct) {soapAction = soapAct;}
+
+ /**
+ * Return the endpoint address for the target web service.
+ * @return The endpoint address.
+ */
+ SCA_API const std::string& getEndpoint() const {return endpoint;}
+ SCA_API void setEndpoint(const std::string& ep) {endpoint = ep;}
+
+ enum soapVersion
+ {
+ SOAP11,
+ SOAP12
+ };
+
+ SCA_API void setSoapVersion(soapVersion ver) {soapVer = ver;}
+ SCA_API soapVersion getSoapVersion() const {return soapVer;}
+
+ SCA_API void setDocumentStyle(bool docStyle) {documentStyle = docStyle;}
+ SCA_API bool isDocumentStyle() const {return documentStyle;}
+
+ SCA_API void setWrappedStyle(bool wrapStyle) {wrappedStyle = wrapStyle;}
+ SCA_API bool isWrappedStyle() const {return wrappedStyle;}
+
+ SCA_API void setEncoded(bool enc) {encoded = enc;}
+ SCA_API bool isEncoded() const {return encoded;}
+
+
+ SCA_API void setInputType(const std::string& inputType);
+ SCA_API const std::string& getInputTypeUri() const {return inputTypeUri;}
+ SCA_API const std::string& getInputTypeName() const {return inputTypeName;}
+ SCA_API void setOutputType(const std::string& outputType);
+ SCA_API const std::string& getOutputTypeUri() const {return outputTypeUri;}
+ SCA_API const std::string& getOutputTypeName() const {return outputTypeName;}
+
+ private:
+ /**
+ * The name of the operation for use when serializing an
+ * outgoing message.
+ */
+ std::string operationName;
+
+ /**
+ * The soap action string for this operation.
+ */
+ std::string soapAction;
+
+ /**
+ * The endpoint address of the target web service.
+ */
+ std::string endpoint;
+
+ bool documentStyle;
+ bool wrappedStyle;
+ bool encoded;
+ soapVersion soapVer;
+
+ std::string inputTypeUri;
+ std::string inputTypeName;
+
+ std::string outputTypeUri;
+ std::string outputTypeName;
+
+ commonj::sdo::DataObjectPtr inputMessage;
+ commonj::sdo::DataObjectPtr outputMessage;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_wsdloperation_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Wire.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Wire.cpp
new file mode 100644
index 0000000000..03f475af09
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Wire.cpp
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/Wire.h"
+
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ // Constructor
+ Wire::Wire(const std::string& source, const std::string& targ)
+ {
+ logentry();
+
+ Utils::tokeniseUri(source, sourceComponent, sourceReference);
+ target = targ;
+ }
+
+ Wire::~Wire()
+ {
+ logentry();
+ }
+
+ } // End namespace model
+
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Wire.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Wire.h
new file mode 100644
index 0000000000..ab136e9109
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/model/Wire.h
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_wire_h
+#define tuscany_sca_model_wire_h
+
+#include <string>
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Information about a wire in the model.
+ */
+ class Wire
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param source The source of the wire. Either the component and
+ * reference name (optional) or an entry point.
+ * @param target The target of the wire. Either a component and service
+ * service name (optional) or an external sevice.
+ */
+ SCA_API Wire(const std::string& source, const std::string& target);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~Wire();
+
+ /**
+ * Get the component name defined by the source of the wire.
+ * @return The component name which is the source of the wire.
+ */
+ SCA_API const std::string& getSourceComponent() const { return sourceComponent; }
+
+ /**
+ * Get the reference name defined by the source of the wire.
+ * @return The reference name which is the source of the wire.
+ */
+ SCA_API const std::string& getSourceReference() const { return sourceReference; }
+
+ /**
+ * Get the target uri defined by the target of the wire.
+ * @return The target uri which is the source of the wire.
+ */
+ SCA_API const std::string& getTarget() { return target; }
+
+ private:
+ /**
+ * The source component of the wire.
+ */
+ std::string sourceComponent;
+
+ /**
+ * The source reference of the wire.
+ */
+ std::string sourceReference;
+
+ /**
+ * The target uri of the wire.
+ */
+ std::string target;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_wire_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp
new file mode 100644
index 0000000000..48cc0aa1e6
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <iostream>
+
+#include "tuscany/sca/util/DefaultLogWriter.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ DefaultLogWriter::~DefaultLogWriter()
+ {
+ }
+
+ void DefaultLogWriter::log(int level, const char* tid, const char* msg)
+ {
+ cout << tid << " ";
+ for (int i=0; i < level; i++)
+ {
+ cout << " ";
+ }
+ cout << msg <<endl;
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h
new file mode 100644
index 0000000000..80e07d696c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_defaultlogwriter_h
+#define tuscany_sca_util_defaultlogwriter_h
+
+#include "tuscany/sca/util/LogWriter.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * Log writer to write out to standard out.
+ */
+ class DefaultLogWriter : public LogWriter
+ {
+ public:
+ virtual ~DefaultLogWriter();
+
+ /**
+ * Will write to the console.
+ * See LogWriter#log.
+ */
+ virtual void log(int level, const char* tid, const char* msg);
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_defaultlogwriter_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/File.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/File.cpp
new file mode 100644
index 0000000000..507c1b38ea
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/File.cpp
@@ -0,0 +1,243 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#endif
+
+#include <iostream>
+#include <string>
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <unistd.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#endif
+
+#include "tuscany/sca/util/File.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ File::File(const string& dir, const string& file, bool isDirectory)
+ : directory(dir), fileName(file), isDir(isDirectory)
+ {
+ }
+ File::~File()
+ {
+ }
+
+
+ Files::Files(const string& rootDir, const string& pattern, bool subdirectories, bool directories)
+ : rootDirectory(rootDir)
+ {
+ findFiles(rootDirectory, pattern, subdirectories, directories);
+ }
+
+ Files::~Files()
+ {
+ }
+
+ unsigned int Files::size()
+ {
+ return files.size();
+ }
+
+ const File& Files::operator[] (unsigned int index)
+ {
+ if (size() <= index)
+ {
+ throwException(SystemConfigurationException, "Index of of bounds");
+ }
+
+ FILES::iterator iter = files.begin();
+ for (unsigned int i=0; i<index; i++)
+ {
+ iter++;
+ }
+
+ return *iter;
+ }
+
+
+ void Files::findFiles(const string& rootDir, const string& pattern, bool subdirectories, bool directories)
+ {
+
+#if defined(WIN32) || defined (_WINDOWS)
+ char currentDir[ _MAX_FNAME];
+
+ GetCurrentDirectory(_MAX_FNAME, currentDir);
+
+ // Set current directory, from which to search.
+ if (!SetCurrentDirectory(rootDir.c_str()))
+ {
+ loginfo("Unable to set current directory to: %s", rootDir.c_str());
+ return;
+ }
+ char fullDirname[ _MAX_FNAME];
+ GetCurrentDirectory(_MAX_FNAME, fullDirname);
+
+ // First, look for all files in this directory that meet the pattern
+ char search[ _MAX_FNAME];
+ strcpy(search, pattern.c_str());
+
+ // Find the first file in the directory
+ WIN32_FIND_DATA data;
+ HANDLE searchHandle = FindFirstFile(search, &data);
+
+ int more = TRUE;
+ if (searchHandle != INVALID_HANDLE_VALUE)
+ {
+ // Found some matching files, so call the function with the details of each one
+ while (more)
+ {
+ // Skip over directories
+ if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
+ {
+ if (!directories)
+ {
+ // Add the file to our list
+ files.push_back(File(fullDirname, data.cFileName));
+ }
+ }
+ else if (directories)
+ {
+ files.push_back(File(fullDirname, data.cFileName, true));
+ }
+
+ more = FindNextFile(searchHandle, &data);
+ }
+ }
+
+
+ if (!subdirectories)
+ return;
+
+ // Now recurse down all the directories
+ // Find the first file in the directory
+ searchHandle = FindFirstFile( "*.*", &data);
+ more = TRUE;
+
+ if (searchHandle != INVALID_HANDLE_VALUE)
+ {
+ // Found some files in the directory.
+ while (more)
+ {
+ // If directory
+ if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ // Skip over '.' and '..'
+ if ((strcmp(data.cFileName, ".")) && (strcmp("..", data.cFileName)))
+ {
+ // Recurse
+ findFiles(data.cFileName, pattern, subdirectories, directories);
+ }
+ }
+
+ more = FindNextFile(searchHandle, &data);
+ }
+ }
+ SetCurrentDirectory(currentDir);
+#else
+ // Linux
+ //char fullDirname[MAX_PATH];
+ //getcwd(fullDirname, MAX_PATH);
+
+ DIR* root = opendir(rootDir.c_str());
+ if (!root)
+ {
+ logwarning("Unable to open directory: %s", rootDir.c_str());
+ return;
+ }
+
+ bool exactMatch = true;
+ string token1, token2;
+ if (pattern.find('*') != string::npos)
+ {
+ exactMatch = false;
+ Utils::tokeniseString("*", pattern, token1, token2);
+ }
+
+ struct dirent *entry=0;
+ while ((entry = readdir(root)))
+ {
+ string entryName = rootDir + "/" + entry->d_name;
+ struct stat statbuf;
+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
+ continue;
+ if (stat(entryName.c_str(), &statbuf) != 0)
+ {
+ logwarning("Unable to stat entry: %s", entryName.c_str());
+ }
+ else
+ {
+ string filename = entry->d_name;
+
+ if ((exactMatch && filename == pattern) ||
+ (!exactMatch &&
+ ((filename.find(token1) == 0)
+ && (filename.length() >= token2.length())
+ && (filename.rfind(token2) == (filename.length() - token2.length())) )))
+ {
+ if (S_ISDIR(statbuf.st_mode))
+ {
+ if (directories)
+ {
+ files.push_back(File(rootDir, filename, true));
+ }
+ }
+ else if (S_ISREG(statbuf.st_mode))
+ {
+ if (!directories)
+ {
+ // Add the file to our list
+ files.push_back(File(rootDir, filename));
+ }
+ }
+ } // end - matching filename
+
+ // recurse if necessary
+ if (subdirectories && S_ISDIR(statbuf.st_mode))
+ {
+ findFiles(entryName, pattern, subdirectories, directories);
+ }
+ }
+ }
+
+ closedir(root);
+#endif
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/File.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/File.h
new file mode 100644
index 0000000000..944a192cf6
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/File.h
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_file_h
+#define tuscany_sca_util_file_h
+
+#include <string>
+#include <vector>
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * File access methods. Provides platform independent
+ * access to files.
+ */
+ class File
+ {
+ public:
+ /**
+ * Constructor.
+ * @param directory Name of the directory in which this file is located.
+ * Either / or \ can be used interchangeably for separating directory elements.
+ * @param fileName Name of the file in the dirctory.
+ */
+ File(const std::string& directory, const std::string& fileName, bool isDirectory = false);
+
+ /**
+ * Destructor.
+ */
+ virtual ~File();
+
+ /**
+ * Return the directory in which this file is located.
+ * @return Name of the parent directory.
+ */
+ const std::string& getDirectory() const {return directory;}
+
+ /**
+ * Return the name of the file.
+ * @return Name of the file/directory.
+ */
+ const std::string& getFileName() const {return fileName;}
+
+ /**
+ * Return if this is a directory
+ * @return true if a directory
+ */
+ bool isDirectory() const {return isDir;}
+
+ /**
+ * Return if this is a file
+ * @return true if a file
+ */
+ bool isFile() const {return !isDir;}
+
+ private:
+ /**
+ * Name of the parent directory.
+ */
+ std::string directory;
+
+ /**
+ * Name of the file/directory
+ */
+ std::string fileName;
+
+ /**
+ * Is this a directory
+ */
+ bool isDir;
+ };
+
+ /**
+ * Collection of File to provide platform independent access
+ * to files and directories.
+ */
+ class Files
+ {
+ public:
+ /**
+ * Constructor which will search a given directory with a pattern and return a
+ * new instance of this collection class.
+ * @param rootDirectory The directory in which to search.
+ * @param pattern A pattern for matching file names. Can include * and ?.
+ * @param subdirectories Whether subdirectories should be searched too.
+ * @param directories Whether to directories or files.
+ */
+ Files(const std::string& rootDirectory,
+ const std::string& pattern,
+ bool subdirectories = false,
+ bool directories = false);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Files();
+
+ /**
+ * Return the number of files found.
+ * @return The number of files found.
+ */
+ unsigned int size();
+
+ /**
+ * Return a File at this position in the collection.
+ * @param index The index into the collection.
+ * @return The File at this index in the collection.
+ */
+ const File& operator[] (unsigned int index);
+
+ private:
+ /**
+ * Search the given directory and pattern for matching files.
+ * @param rootDirectory The directory in which to search.
+ * @param pattern A pattern for matching file names. Can include * and ?.
+ * @param subdirectories Whether subdirectories should be searched too.
+ * @param directories Whether to directories or files.
+ */
+ void findFiles(const std::string& rootDirectory, const std::string& pattern,
+ bool subdirectories, bool directories);
+
+ /**
+ * The top level directory to search.
+ */
+ std::string rootDirectory;
+
+ typedef std::vector<File> FILES;
+
+ /**
+ * Vector of File.
+ */
+ FILES files;
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_file_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp
new file mode 100644
index 0000000000..56eb3146dd
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <iostream>
+
+#include "tuscany/sca/util/FileLogWriter.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ FileLogWriter::FileLogWriter(const char* logfile)
+ {
+ logFile.open(logfile, ios_base::app);
+ }
+
+ FileLogWriter::~FileLogWriter()
+ {
+ logFile.close();
+ }
+
+ void FileLogWriter::log(int level, const char*tid, const char* msg)
+ {
+ logFile << tid << " ";
+ for (int i=0; i < level; i++)
+ {
+ logFile << " ";
+ }
+ logFile << msg <<endl;
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/FileLogWriter.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/FileLogWriter.h
new file mode 100644
index 0000000000..5925fdca85
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/FileLogWriter.h
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_filelogwriter_h
+#define tuscany_sca_util_filelogwriter_h
+
+#include <iostream>
+#include <fstream>
+
+#include "tuscany/sca/util/LogWriter.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * Log writer to write out to standard out.
+ */
+ class FileLogWriter : public LogWriter
+ {
+ public:
+ FileLogWriter(const char* logfile);
+
+ virtual ~FileLogWriter();
+
+ /**
+ * Will write to the console.
+ * See LogWriter#log.
+ */
+ virtual void log(int level, const char* tid, const char* msg);
+ private:
+ std::ofstream logFile;
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_defaultlogwriter_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Library.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Library.cpp
new file mode 100644
index 0000000000..366fcdf1f3
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Library.cpp
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#else
+#include "tuscany_sca_config.h"
+#endif
+
+#include <sstream>
+
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ Library::Library()
+ : hDLL(NULL)
+ {
+ }
+
+ Library::Library(const string& libraryName)
+ : name(libraryName), hDLL(NULL)
+ {
+ logentry();
+ load();
+ }
+
+ Library::Library(const Library& lib)
+ : name(lib.name), hDLL(NULL)
+ {
+ logentry();
+ if (lib.hDLL)
+ {
+ load();
+ }
+ }
+
+ Library& Library::operator=(const Library& lib)
+ {
+ logentry();
+ if (&lib != this)
+ {
+ unload();
+ name = lib.name;
+ load();
+ }
+ return *this;
+ }
+
+ Library::~Library()
+ {
+ logentry();
+ unload();
+ }
+
+
+ void Library::load()
+ {
+ logentry();
+ loginfo("Library: %s", name.c_str());
+
+ string msg;
+#if defined(WIN32) || defined (_WINDOWS)
+ int l = name.length();
+ string dllName;
+ if (l>=4 && name.substr(l-4, 4)==".dll")
+ {
+ dllName = name;
+ }
+ else
+ {
+ dllName = name+".dll";
+ }
+ SetErrorMode(SEM_FAILCRITICALERRORS);
+ hDLL = LoadLibrary(dllName.c_str());
+ if (hDLL == NULL)
+ {
+ ostringstream msgs;
+ msgs << "Unable to load library: " + dllName << ", error: ";
+ Utils::printLastError(msgs);
+ msg = msgs.str();
+ }
+#else
+ int l = name.length();
+ string libName;
+#ifdef IS_DARWIN
+ string suffix = ".dylib";
+#else
+ string suffix = ".so";
+#endif
+ unsigned int suffixLength = suffix.length();
+ if (l>=suffixLength && name.substr(l-suffixLength, suffixLength)==suffix)
+ {
+ libName = name;
+ }
+ else
+ {
+ int s = name.rfind("/");
+ if (s == name.length())
+ {
+ libName = name + suffix;
+ }
+ else
+ {
+ s++;
+ libName = name.substr(0, s) + "lib" + name.substr(s, name.length()-s) + suffix;
+ }
+ }
+ hDLL = dlopen(libName.c_str(), RTLD_NOW);
+ if (hDLL == NULL)
+ {
+ msg = "Unable to load library: " + libName + ": " + dlerror();
+ }
+#endif
+ if (hDLL == NULL)
+ {
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ }
+
+ void Library::unload()
+ {
+ logentry();
+ loginfo("Library: %s", name.c_str());
+
+ if (hDLL != NULL)
+ {
+#if defined(WIN32) || defined (_WINDOWS)
+ FreeLibrary(hDLL);
+#else
+ dlclose(hDLL);
+#endif
+ hDLL = NULL;
+ }
+ }
+
+ void* Library::getSymbol(const string& symbol)
+ {
+ logentry();
+ loginfo("Symbol: %s", symbol.c_str());
+ if (!hDLL)
+ {
+ return 0;
+ }
+#if defined(WIN32) || defined (_WINDOWS)
+ return GetProcAddress(hDLL, symbol.c_str());
+#else
+ return dlsym(hDLL, symbol.c_str());
+#endif
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Library.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Library.h
new file mode 100644
index 0000000000..6b0a17d2b7
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Library.h
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_library_h
+#define tuscany_sca_util_library_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <unistd.h>
+#include <dlfcn.h>
+#endif
+
+#include <string>
+
+#include "tuscany/sca/export.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * Information about shared libraries and methods to
+ * access these shared libraries.
+ */
+ class SCA_API Library
+ {
+ public:
+ Library();
+
+ /**
+ * Constructor. Will load the library.
+ * @param libraryName Fully qualified name of the library.
+ */
+ Library(const std::string& libraryName);
+
+ /**
+ * Destructor. Will unload the library.
+ */
+ virtual ~Library();
+
+ Library(const Library& lib);
+ Library& operator=(const Library& lib);
+
+ /**
+ * Find an externalized symbol in the library.
+ * @param symbol The name of the symbol to be found.
+ * @return The pointer to the symbol if found, otherwise 0.
+ */
+ void* getSymbol(const std::string& symbol);
+ private:
+ /**
+ * Name of the library.
+ */
+ std::string name;
+
+ /**
+ * Handle to the loaded library.
+ */
+#if defined(WIN32) || defined (_WINDOWS)
+ HINSTANCE hDLL;
+#else
+ void* hDLL;
+#endif
+
+ /**
+ * Load the library.
+ */
+ void load();
+
+ /**
+ * Unload the library, if successfully loaded.
+ */
+ void unload();
+
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_util_library_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/LogWriter.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/LogWriter.cpp
new file mode 100644
index 0000000000..e551d04eda
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/LogWriter.cpp
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/LogWriter.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ LogWriter::~LogWriter()
+ {
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/LogWriter.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/LogWriter.h
new file mode 100644
index 0000000000..5a6a5c38f7
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/LogWriter.h
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_logwriter_h
+#define tuscany_sca_util_logwriter_h
+
+#include "tuscany/sca/export.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * Abstract class for extending logging to other destinations.
+ */
+ class SCA_API LogWriter
+ {
+ public:
+ virtual ~LogWriter();
+
+ /**
+ * Log a message.
+ * @param level The level of logging for this message.
+ * @param tid The current thread id.
+ * @param msg The message to log.
+ */
+ virtual void log(int level, const char* tid, const char* msg) = 0;
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_logwriter_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logger.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logger.cpp
new file mode 100644
index 0000000000..9d55c5fb43
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logger.cpp
@@ -0,0 +1,272 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <iostream>
+#include <stdarg.h>
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#include <process.h>
+#else
+#include <unistd.h>
+#include <pthread.h>
+#endif
+
+#include "tuscany/sca/util/Logger.h"
+#include "tuscany/sca/util/DefaultLogWriter.h"
+#include "tuscany/sca/util/FileLogWriter.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ LogWriter* Logger::logWriter = getLogWriter();
+
+ LogWriter* Logger::getLogWriter()
+ {
+ if (logWriter == 0)
+ {
+ setLogWriter(0);
+
+ }
+ return logWriter;
+ }
+
+ void Logger::setLogWriter(LogWriter* writer)
+ {
+ if (logWriter != writer
+ && logWriter != 0)
+ {
+ delete logWriter;
+ }
+
+ if (writer == 0)
+ {
+ char* loggingVar = 0;
+ loggingVar = getenv("TUSCANY_SCACPP_LOG");
+ if (loggingVar == 0)
+ logWriter = new DefaultLogWriter;
+ else
+ logWriter = new FileLogWriter(loggingVar);
+ }
+ else
+ {
+ logWriter = writer;
+ }
+ }
+
+ int Logger::loggingLevel = setLogging();
+
+ int Logger::setLogging()
+ {
+ char* loggingVar = 0;
+ loggingVar = getenv("TUSCANY_SCACPP_LOGGING");
+ if (loggingVar == 0)
+ return 0;
+ else
+ return atoi(loggingVar);
+ }
+
+ void Logger::setLogging(int level)
+ {
+ loggingLevel = level;
+ }
+
+ void Logger::log(int level, const char* msg)
+ {
+ if (level <= loggingLevel)
+ {
+ char tid[21];
+ formatThreadID(tid);
+ logWriter->log(level, tid, msg);
+ }
+ }
+
+ void Logger::formatThreadID(char* tid)
+ {
+#if defined(WIN32) || defined (_WINDOWS)
+ sprintf(tid, "%lu:%lu", (unsigned long)_getpid(), (unsigned long)GetCurrentThreadId());
+#else
+ sprintf(tid, "%lu:%lu", (unsigned long)getpid(), (unsigned long)pthread_self());
+#endif
+ }
+
+ void Logger::logArgs(int level, const char* msg, ...)
+ {
+ if (level <= loggingLevel)
+ {
+ va_list variableArguments;
+ va_start(variableArguments, msg);
+ char tid[21];
+ formatThreadID(tid);
+ char messageBuffer[256];
+ int size = vsnprintf(messageBuffer, 255, msg, variableArguments);
+#if defined(WIN32) || defined (_WINDOWS)
+ if (size == -1)
+ {
+ size = _vscprintf(msg, variableArguments);
+ char* bigMessageBuffer = new char[size+1];
+ vsnprintf(bigMessageBuffer, size, msg, variableArguments);
+ bigMessageBuffer[size] = '\0';
+ logWriter->log(level, tid, bigMessageBuffer);
+ delete bigMessageBuffer;
+ }
+#else
+ if (size > 255)
+ {
+ char* bigMessageBuffer = new char[size+1];
+ vsnprintf(bigMessageBuffer, size, msg, variableArguments);
+ bigMessageBuffer[size] = '\0';
+ logWriter->log(level, tid, bigMessageBuffer);
+ delete bigMessageBuffer;
+ }
+#endif
+ else
+ {
+ messageBuffer[255] = '\0';
+ logWriter->log(level, tid, messageBuffer);
+ }
+ va_end(variableArguments);
+ }
+ }
+
+ void Logger::logArgs0(const char* msg, ...)
+ {
+ if (0 <= loggingLevel)
+ {
+ va_list variableArguments;
+ va_start(variableArguments, msg);
+ char tid[21];
+ formatThreadID(tid);
+ char messageBuffer[256];
+ int size = vsnprintf(messageBuffer, 255, msg, variableArguments);
+#if defined(WIN32) || defined (_WINDOWS)
+ if (size == -1)
+ {
+ size = _vscprintf(msg, variableArguments);
+ char* bigMessageBuffer = new char[size+1];
+ vsnprintf(bigMessageBuffer, size, msg, variableArguments);
+ bigMessageBuffer[size] = '\0';
+ logWriter->log(0, tid, bigMessageBuffer);
+ delete bigMessageBuffer;
+ }
+#else
+ if (size > 255)
+ {
+ char* bigMessageBuffer = new char[size+1];
+ vsnprintf(bigMessageBuffer, size, msg, variableArguments);
+ bigMessageBuffer[size] = '\0';
+ logWriter->log(0, tid, bigMessageBuffer);
+ delete bigMessageBuffer;
+ }
+#endif
+ else
+ {
+ messageBuffer[255] = '\0';
+ logWriter->log(0, tid, messageBuffer);
+ }
+ va_end(variableArguments);
+ }
+ }
+ void Logger::logArgs1(const char* msg, ...)
+ {
+ if (1 <= loggingLevel)
+ {
+ va_list variableArguments;
+ va_start(variableArguments, msg);
+ char tid[21];
+ formatThreadID(tid);
+ char messageBuffer[256];
+ int size = vsnprintf(messageBuffer, 255, msg, variableArguments);
+#if defined(WIN32) || defined (_WINDOWS)
+ if (size == -1)
+ {
+ size = _vscprintf(msg, variableArguments);
+ char* bigMessageBuffer = new char[size+1];
+ vsnprintf(bigMessageBuffer, size, msg, variableArguments);
+ bigMessageBuffer[size] = '\0';
+ logWriter->log(1, tid, bigMessageBuffer);
+ delete bigMessageBuffer;
+ }
+#else
+ if (size > 255)
+ {
+ char* bigMessageBuffer = new char[size+1];
+ vsnprintf(bigMessageBuffer, size, msg, variableArguments);
+ bigMessageBuffer[size] = '\0';
+ logWriter->log(1, tid, bigMessageBuffer);
+ delete bigMessageBuffer;
+ }
+#endif
+ else
+ {
+ messageBuffer[255] = '\0';
+ logWriter->log(1, tid, messageBuffer);
+ }
+ va_end(variableArguments);
+ }
+ }
+ void Logger::logArgs2(const char* msg, ...)
+ {
+ if (2 <= loggingLevel)
+ {
+ va_list variableArguments;
+ va_start(variableArguments, msg);
+ char tid[21];
+ formatThreadID(tid);
+ char messageBuffer[256];
+ int size = vsnprintf(messageBuffer, 255, msg, variableArguments);
+#if defined(WIN32) || defined (_WINDOWS)
+ if (size == -1)
+ {
+ size = _vscprintf(msg, variableArguments);
+ char* bigMessageBuffer = new char[size+1];
+ vsnprintf(bigMessageBuffer, size, msg, variableArguments);
+ bigMessageBuffer[size] = '\0';
+ logWriter->log(2, tid, bigMessageBuffer);
+ delete bigMessageBuffer;
+ }
+#else
+ if (size > 255)
+ {
+ char* bigMessageBuffer = new char[size+1];
+ vsnprintf(bigMessageBuffer, size, msg, variableArguments);
+ bigMessageBuffer[size] = '\0';
+ logWriter->log(2, tid, bigMessageBuffer);
+ delete bigMessageBuffer;
+ }
+#endif
+ else
+ {
+ messageBuffer[255] = '\0';
+ logWriter->log(2, tid, messageBuffer);
+ }
+ va_end(variableArguments);
+ }
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logger.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logger.h
new file mode 100644
index 0000000000..eccf3cf02f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logger.h
@@ -0,0 +1,136 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_logger_h
+#define tuscany_sca_util_logger_h
+
+#include "tuscany/sca/export.h"
+#include "tuscany/sca/util/LogWriter.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * Provide a logging interface.
+ */
+ class Logger {
+
+ public:
+ /**
+ * Set the log writer to use.
+ * @param writer The writer to use for all subsequent logging.
+ */
+ SCA_API static void setLogWriter(LogWriter* writer);
+
+ /**
+ * Set or reset the logging level. Any message with a higher logging
+ * level than this value will be filtered (i.e. not shown).
+ * @param level The level of logging to use for all subsequent logging.
+ */
+ SCA_API static void setLogging(int level);
+
+ /**
+ * Log a message.
+ * @param level The log level of this message.
+ * @param msg The message to be logged.
+ */
+ SCA_API static void log(int level, const char* msg);
+
+ /**
+ * Log a message with variable arguments.
+ * @param level The log level of this message.
+ * @param msg The message to be logged. Must include template
+ * characters as described in printf.
+ * @param ... Variable arguments.
+ */
+ SCA_API static void logArgs(int level, const char* msg, ...);
+ SCA_API static void logArgs0(const char* msg, ...);
+ SCA_API static void logArgs1(const char* msg, ...);
+ SCA_API static void logArgs2(const char* msg, ...);
+
+ /**
+ * The currently set logging level
+ */
+ SCA_API static int loggingLevel;
+
+ private:
+ /**
+ * The current log writer.
+ */
+ static LogWriter* logWriter;
+
+ /**
+ * Get the current log writer.
+ * @return The current log writer.
+ */
+ static LogWriter* getLogWriter();
+
+ /**
+ * Retrieves the logging level set as an environment variable.
+ */
+ static int setLogging();
+
+ /**
+ * Print the current thread id into the given char buffer.
+ */
+ static void formatThreadID(char* tid);
+
+ /**
+ * Message buffer
+ */
+ static char messageBuffer[4096];
+
+ };
+
+ class LogEntry
+ {
+ public:
+
+ LogEntry(const char* func)
+ : funcName(func)
+ {
+ if (Logger::loggingLevel >= 2)
+ {
+ Logger::logArgs(2, ">> %s", funcName);
+ }
+ }
+
+ ~LogEntry()
+ {
+ if (Logger::loggingLevel >= 2)
+ {
+ Logger::logArgs(2, "<< %s", funcName);
+ }
+ }
+
+ private:
+ const char *funcName;
+
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_util_logger_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logging.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logging.h
new file mode 100644
index 0000000000..bf1419faa8
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Logging.h
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_logging_h
+#define tuscany_sca_util_logging_h
+
+#include "tuscany/sca/util/Logger.h"
+
+#if defined(WIN32) || defined (_WINDOWS)
+#define logentry() \
+const tuscany::sca::util::LogEntry __LOGENTRY__(__FUNCTION__)
+#else
+#define logentry() \
+const tuscany::sca::util::LogEntry __LOGENTRY__(__PRETTY_FUNCTION__)
+#endif
+
+#define loginfo \
+if (tuscany::sca::util::Logger::loggingLevel >= 2) tuscany::sca::util::Logger::logArgs2
+
+#define logwarning \
+if (tuscany::sca::util::Logger::loggingLevel >= 1) tuscany::sca::util::Logger::logArgs1
+
+#define logerror \
+if (tuscany::sca::util::Logger::loggingLevel >= 0) tuscany::sca::util::Logger::logArgs0
+
+#endif // tuscany_sca_util_logging_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Mutex.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Mutex.cpp
new file mode 100644
index 0000000000..8a9494d7de
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Mutex.cpp
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#else
+#include "tuscany_sca_config.h"
+#endif
+
+#include <errno.h>
+
+#include <sstream>
+
+#include "tuscany/sca/util/Mutex.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+
+using namespace std;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ Mutex::Mutex()
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ InitializeCriticalSection(&section);
+#else
+ int rc = pthread_mutex_init(&mutex, NULL);
+ if (rc)
+ {
+ ostringstream msg;
+ msg << "Failed to create mutex, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ Mutex::~Mutex()
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ DeleteCriticalSection(&section);
+#else
+ int rc = pthread_mutex_destroy(&mutex);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to destroy mutex, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ void Mutex::lock()
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ EnterCriticalSection(&section);
+#else
+ int rc = pthread_mutex_lock(&mutex);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to lock mutex, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ void Mutex::unlock()
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ LeaveCriticalSection(&section);
+#else
+ int rc = pthread_mutex_unlock(&mutex);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to unlock mutex, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Mutex.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Mutex.h
new file mode 100644
index 0000000000..d509ba6d73
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Mutex.h
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_mutex_h
+#define tuscany_sca_util_mutex_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <pthread.h>
+#endif
+
+#include "tuscany/sca/export.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * Information about shared libraries and methods to
+ * access these shared libraries.
+ */
+ class SCA_API Mutex
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ Mutex();
+
+ /**
+ * Destructor.
+ */
+ virtual ~Mutex();
+
+ /**
+ * Lock the mutex.
+ */
+ void lock();
+
+ /**
+ * Unlock the mutex.
+ */
+ void unlock();
+
+ private:
+
+ /**
+ * Handle to the mutex.
+ */
+#if defined(WIN32) || defined (_WINDOWS)
+ CRITICAL_SECTION section;
+#else
+ pthread_mutex_t mutex;
+#endif
+
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_util_mutex_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Queue.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Queue.cpp
new file mode 100644
index 0000000000..099e3cece8
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Queue.cpp
@@ -0,0 +1,224 @@
+/*
+ * 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.
+ */
+
+/* $Rev: 491752 $ $Date: 2007-01-01 22:22:23 -0800 (Mon, 01 Jan 2007) $ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#pragma warning(disable: 4251)
+#else
+#include "tuscany_sca_config.h"
+#endif
+
+#include <errno.h>
+
+#include <sstream>
+
+#include "tuscany/sca/util/Queue.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+
+using namespace std;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ Queue::Queue()
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ InitializeCriticalSection(&section);
+ hevent = CreateEvent (NULL, TRUE, FALSE, NULL);
+#else
+ int rc = pthread_mutex_init(&mutex, NULL);
+ if (rc)
+ {
+ ostringstream msg;
+ msg << "Failed to create mutex, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+
+ rc = pthread_cond_init(&cond, NULL);
+ if (rc)
+ {
+ ostringstream msg;
+ msg << "Failed to create condition variable, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ Queue::~Queue()
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ DeleteCriticalSection(&section);
+ CloseHandle(hevent);
+#else
+ int rc = pthread_mutex_destroy(&mutex);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to destroy mutex, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+
+ rc = pthread_cond_destroy(&cond);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to destroy condition variable, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ void Queue::enqueue(void* element)
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ EnterCriticalSection(&section);
+
+ try
+ {
+ queue.push(element);
+
+ if (queue.size() == 1)
+ {
+ SetEvent(hevent);
+ }
+ }
+ catch (...)
+ {
+ LeaveCriticalSection(&section);
+ throw;
+ }
+ LeaveCriticalSection(&section);
+#else
+ int rc = pthread_mutex_lock(&mutex);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to lock mutex, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+ try
+ {
+ queue.push(element);
+
+ if (queue.size() == 1)
+ {
+ rc = pthread_cond_signal(&cond);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to broadcast condition variable, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+ }
+
+ }
+ catch(...)
+ {
+ pthread_mutex_unlock(&mutex);
+ throw;
+ }
+ rc = pthread_mutex_unlock(&mutex);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to unlock mutex, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ void* Queue::dequeue()
+ {
+ logentry();
+
+ void* element = NULL;
+
+#if defined(WIN32) || defined (_WINDOWS)
+
+ EnterCriticalSection(&section);
+ try
+ {
+ while (queue.size() == 0) {
+ LeaveCriticalSection(&section);
+ WaitForSingleObject(hevent, INFINITE);
+ EnterCriticalSection(&section);
+ }
+
+ element = queue.front();
+ queue.pop();
+
+ if (queue.size() == 0)
+ {
+ ResetEvent(hevent);
+ }
+ }
+ catch(...)
+ {
+ LeaveCriticalSection(&section);
+ throw;
+ }
+ LeaveCriticalSection(&section);
+
+#else
+ int rc = pthread_mutex_lock(&mutex);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to lock mutex, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+ try
+ {
+ while (queue.size() == 0) {
+ rc = pthread_cond_wait(&cond, &mutex);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to wait for condition variable, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+ }
+
+ element = queue.front();
+ queue.pop();
+ }
+ catch(...)
+ {
+ pthread_mutex_unlock(&mutex);
+ throw;
+ }
+ rc = pthread_mutex_unlock(&mutex);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to unlock mutex, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+
+#endif
+
+ return element;
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Queue.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Queue.h
new file mode 100644
index 0000000000..e2ff104631
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Queue.h
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+/* $Rev: 492011 $ $Date: 2007-01-02 18:15:11 -0800 (Tue, 02 Jan 2007) $ */
+
+#ifndef tuscany_sca_util_queue_h
+#define tuscany_sca_util_queue_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <pthread.h>
+#endif
+
+#include <queue>
+
+#include "tuscany/sca/export.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * A thread safe FIFO queue.
+ */
+ class SCA_API Queue
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ Queue();
+
+ /**
+ * Destructor.
+ */
+ virtual ~Queue();
+
+ /**
+ * Dequeue an element
+ */
+ void* dequeue();
+
+ /**
+ * Enqueue an element
+ */
+ void enqueue(void* element);
+
+ private:
+
+ /**
+ * The STL queue used to hold elements.
+ */
+ std::queue<void*> queue;
+
+ /**
+ * Handles to the mutex and condition variable
+ * used to synchronize access to the queue.
+ */
+#if defined(WIN32) || defined (_WINDOWS)
+ CRITICAL_SECTION section;
+ HANDLE hevent;
+#else
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+#endif
+
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_util_queue_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/SDOUtils.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/SDOUtils.cpp
new file mode 100644
index 0000000000..f2ccda9d69
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/SDOUtils.cpp
@@ -0,0 +1,436 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#endif
+
+#include "tuscany/sca/util/SDOUtils.h"
+
+using namespace std;
+using namespace commonj::sdo;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+
+ /**
+ * Constructor
+ */
+ SDOVisitor::SDOVisitor()
+ {
+ }
+
+ /**
+ * Destructor
+ */
+ SDOVisitor::~SDOVisitor()
+ {
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, bool boolData)
+ {
+ return SDOVisitor::RESULT_NOT_SUPPORTED;
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, char byteData)
+ {
+ return SDOVisitor::RESULT_NOT_SUPPORTED;
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, const char* bytesData)
+ {
+ return SDOVisitor::RESULT_NOT_SUPPORTED;
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, wchar_t charData)
+ {
+ return SDOVisitor::RESULT_NOT_SUPPORTED;
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, const SDODate& dateData)
+ {
+ return SDOVisitor::RESULT_NOT_SUPPORTED;
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, long double doubleData)
+ {
+ return SDOVisitor::RESULT_NOT_SUPPORTED;
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, float floatData)
+ {
+ return SDOVisitor::RESULT_NOT_SUPPORTED;
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, long intData)
+ {
+ return SDOVisitor::RESULT_NOT_SUPPORTED;
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, short shortData)
+ {
+ return SDOVisitor::RESULT_NOT_SUPPORTED;
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, const string& stringData)
+ {
+ return SDOVisitor::RESULT_CONTINUE;
+ }
+
+ SDOVisitor::RESULT SDOVisitor::visit(DataObjectPtr parent, const Property& property, DataObjectPtr dataObjectData)
+ {
+ return SDOVisitor::RESULT_CONTINUE;
+ }
+
+ SDOVisitor::RESULT SDOUtils::accept(DataObjectPtr dataObject, SDOVisitor& visitor, SDOVisitor::DEPTH depth)
+ {
+ SDOVisitor::RESULT result = SDOVisitor::RESULT_CONTINUE;
+
+ const Type& type = dataObject->getType();
+ if (type.isSequencedType())
+ {
+ Sequence* sequence = dataObject->getSequence();
+ int size = sequence->size();
+ for (int i = 0; i < size; i++)
+ {
+ if (sequence->isText(i))
+ {
+ const string text(sequence->getCStringValue(i));
+ result = visitor.visit(dataObject, *(Property*)NULL, (const string&)text);
+ }
+ else
+ {
+ const Property& seqProperty = sequence->getProperty(i);
+ const Type& seqType = seqProperty.getType();
+ if (seqType.isDataObjectType())
+ {
+ DataObjectPtr dob;
+ if (seqProperty.isMany())
+ {
+ int index = sequence->getListIndex(i);
+ dob = dataObject->getList(seqProperty)[index];
+ }
+ else
+ {
+ dob = dataObject->getDataObject(seqProperty);
+ }
+
+ if (dob)
+ {
+ result = visitor.visit(dataObject, seqProperty, (DataObjectPtr)dob);
+ }
+ }
+ else
+ {
+ Type::Types t = seqProperty.getTypeEnum();
+ switch (t)
+ {
+ case Type::BooleanType:
+ {
+ result = visitor.visit(dataObject, seqProperty, (bool)sequence->getBooleanValue(i));
+ }
+ break;
+ case Type::ByteType:
+ {
+ result = visitor.visit(dataObject, seqProperty, (char)sequence->getByteValue(i));
+ }
+ break;
+ case Type::CharacterType:
+ {
+ result = visitor.visit(dataObject, seqProperty, (wchar_t)sequence->getCharacterValue(i));
+ }
+ break;
+ case Type::IntegerType:
+ {
+ result = visitor.visit(dataObject, seqProperty, (long)sequence->getIntegerValue(i));
+ }
+ break;
+ case Type::ShortType:
+ {
+ result = visitor.visit(dataObject, seqProperty, (short)sequence->getShortValue(i));
+ }
+ break;
+ case Type::DoubleType:
+ {
+ result = visitor.visit(dataObject, seqProperty, (long double)sequence->getDoubleValue(i));
+ }
+ break;
+ case Type::FloatType:
+ {
+ result = visitor.visit(dataObject, seqProperty, (float)sequence->getFloatValue(i));
+ }
+ break;
+ case Type::LongType:
+ {
+ result = visitor.visit(dataObject, seqProperty, (long)sequence->getLongValue(i));
+ }
+ break;
+ case Type::DateType:
+ {
+ const SDODate date = sequence->getDateValue(i);
+ result = visitor.visit(dataObject, seqProperty, (const time_t)date.getTime());
+ }
+ break;
+ case Type::BigDecimalType:
+ case Type::BigIntegerType:
+ case Type::UriType:
+ case Type::StringType:
+ {
+ ;
+ const string stringData(sequence->getCStringValue(i));
+ result = visitor.visit(dataObject, seqProperty, (const string&)stringData);
+ }
+ break;
+ case Type::BytesType:
+ {
+ unsigned int len = sequence->getLength(i);
+ char* byteData = new char[len];
+ sequence->getBytesValue(i, byteData, len);
+ result = visitor.visit(dataObject, seqProperty, byteData);
+ delete byteData;
+ }
+ break;
+ default:
+ result = SDOVisitor::RESULT_NOT_SUPPORTED;
+ break;
+ }
+ if (result == SDOVisitor::RESULT_NOT_SUPPORTED)
+ {
+ ;
+ const string stringData(sequence->getCStringValue(i));
+ result = visitor.visit(dataObject, seqProperty, (const string&)stringData);
+ }
+ }
+ }
+ if (result == SDOVisitor::RESULT_STOP)
+ return result;
+ }
+ }
+ else
+ {
+ PropertyList pl = dataObject->getInstanceProperties();
+ for (unsigned int i = 0; i < pl.size(); i++)
+ {
+ if (dataObject->isSet(pl[i]))
+ {
+ if (pl[i].getType().isDataObjectType())
+ {
+ if (pl[i].isMany())
+ {
+ DataObjectList& doList = dataObject->getList(pl[i]);
+ for (unsigned int li = 0; li < doList.size(); li++)
+ {
+ DataObjectPtr dob = doList[li];
+ result = visitor.visit(dataObject, pl[i], (DataObjectPtr)dob);
+ if (result == SDOVisitor::RESULT_STOP)
+ return result;
+ }
+ }
+ else
+ {
+ DataObjectPtr dob = dataObject->getDataObject(pl[i]);
+ result = visitor.visit(dataObject, pl[i], (DataObjectPtr)dob);
+ }
+ }
+ else
+ {
+ if (pl[i].isMany())
+ {
+ Type::Types t = pl[i].getTypeEnum();
+ DataObjectList& doList = dataObject->getList(pl[i]);
+ for (unsigned int li = 0; li < doList.size(); li++)
+ {
+ switch (t)
+ {
+ case Type::BooleanType:
+ {
+ result = visitor.visit(dataObject, pl[i], (bool)doList.getBoolean(li));
+ }
+ break;
+ case Type::ByteType:
+ {
+ result = visitor.visit(dataObject, pl[i], (char)doList.getByte(li));
+ }
+ break;
+ case Type::CharacterType:
+ {
+ result = visitor.visit(dataObject, pl[i], (wchar_t)doList.getCharacter(li));
+ }
+ break;
+ case Type::IntegerType:
+ {
+ result = visitor.visit(dataObject, pl[i], (long)doList.getInteger(li));
+ }
+ break;
+ case Type::ShortType:
+ {
+ result = visitor.visit(dataObject, pl[i], (short)doList.getShort(li));
+ }
+ break;
+ case Type::DoubleType:
+ {
+ result = visitor.visit(dataObject, pl[i], (long double)doList.getDouble(li));
+ }
+ break;
+ case Type::FloatType:
+ {
+ result = visitor.visit(dataObject, pl[i], (float)doList.getFloat(li));
+ }
+ break;
+ case Type::LongType:
+ {
+ result = visitor.visit(dataObject, pl[i], (long)doList.getLong(li));
+ }
+ break;
+ case Type::DateType:
+ {
+ const SDODate date = doList.getDate(li);
+ result = visitor.visit(dataObject, pl[i], (const time_t)date.getTime());
+ }
+ break;
+ case Type::BigDecimalType:
+ case Type::BigIntegerType:
+ case Type::UriType:
+ case Type::StringType:
+ {
+ const string stringData(doList.getCString(li));
+ result = visitor.visit(dataObject, pl[i], (const string&)stringData);
+ }
+ break;
+ case Type::BytesType:
+ {
+ unsigned int len = doList.getLength(li);
+ char* byteData = new char[len];
+ doList.getBytes(li, byteData, len);
+ result = visitor.visit(dataObject, pl[i], byteData);
+ delete byteData;
+ }
+ break;
+ default:
+ result = SDOVisitor::RESULT_NOT_SUPPORTED;
+ break;
+ }
+ if (result == SDOVisitor::RESULT_NOT_SUPPORTED)
+ {
+ const string stringData(doList.getCString(li));
+ result = visitor.visit(dataObject, pl[i], (const string&)stringData);
+ }
+ if (result == SDOVisitor::RESULT_STOP)
+ return result;
+ }
+ }
+ else
+ {
+ Type::Types t = pl[i].getTypeEnum();
+ switch (t)
+ {
+ case Type::BooleanType:
+ {
+ result = visitor.visit(dataObject, pl[i], (bool)dataObject->getBoolean(pl[i]));
+ }
+ break;
+ case Type::ByteType:
+ {
+ result = visitor.visit(dataObject, pl[i], (char)dataObject->getByte(pl[i]));
+ }
+ break;
+ case Type::CharacterType:
+ {
+ result = visitor.visit(dataObject, pl[i], (wchar_t)dataObject->getCharacter(pl[i]));
+ }
+ break;
+ case Type::IntegerType:
+ {
+ result = visitor.visit(dataObject, pl[i], (long)dataObject->getInteger(pl[i]));
+ }
+ break;
+ case Type::ShortType:
+ {
+ result = visitor.visit(dataObject, pl[i], (short)dataObject->getShort(pl[i]));
+ }
+ break;
+ case Type::DoubleType:
+ {
+ result = visitor.visit(dataObject, pl[i], (long double)dataObject->getDouble(pl[i]));
+ }
+ break;
+ case Type::FloatType:
+ {
+ result = visitor.visit(dataObject, pl[i], (float)dataObject->getFloat(pl[i]));
+ }
+ break;
+ case Type::LongType:
+ {
+ result = visitor.visit(dataObject, pl[i], (long)dataObject->getLong(pl[i]));
+ }
+ break;
+ case Type::DateType:
+ {
+ const SDODate date = dataObject->getDate(pl[i]);
+ result = visitor.visit(dataObject, pl[i], (const time_t)date.getTime());
+ }
+ break;
+ case Type::BigDecimalType:
+ case Type::BigIntegerType:
+ case Type::UriType:
+ case Type::StringType:
+ {
+ const string stringData(dataObject->getCString(pl[i]));
+ result = visitor.visit(dataObject, pl[i], (const string&)stringData);
+ }
+ break;
+ case Type::BytesType:
+ {
+ unsigned int len = dataObject->getLength(pl[i]);
+ char* byteData = new char[len];
+ dataObject->getBytes(pl[i], byteData, len);
+ result = visitor.visit(dataObject, pl[i], byteData);
+ delete byteData;
+ }
+ break;
+ default:
+ result = SDOVisitor::RESULT_NOT_SUPPORTED;
+ break;
+ }
+ if (result == SDOVisitor::RESULT_NOT_SUPPORTED)
+ {
+ const string stringData(dataObject->getCString(pl[i]));
+ result = visitor.visit(dataObject, pl[i], (const string&)stringData);
+ }
+ }
+ }
+ }
+ if (result == SDOVisitor::RESULT_STOP)
+ return result;
+ }
+ }
+
+ return SDOVisitor::RESULT_CONTINUE;
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/SDOUtils.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/SDOUtils.h
new file mode 100644
index 0000000000..8b5b3b8130
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/SDOUtils.h
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_sdovisitor_h
+#define tuscany_sca_util_sdovisitor_h
+
+#include <string>
+#include <vector>
+#include <time.h>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * An SDO visitor interface
+ */
+ class SCA_API SDOVisitor
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ SDOVisitor();
+
+ /**
+ * Destructor.
+ */
+ virtual ~SDOVisitor();
+
+ /**
+ * Visit depth
+ */
+ enum DEPTH
+ {
+ DEPTH_ZERO = 0,
+ DEPTH_ONE,
+ DEPTH_INFINITE
+ };
+
+ /**
+ * Visit status
+ */
+ enum RESULT
+ {
+ RESULT_CONTINUE = 0,
+ RESULT_STOP,
+ RESULT_NOT_SUPPORTED
+ };
+
+ /**
+ * Visit an SDO.
+ */
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, bool boolData);
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, char byteData);
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, const char* bytesData);
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, wchar_t charData);
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, const commonj::sdo::SDODate& dateData);
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, long double doubleData);
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, float floatData);
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, long intData);
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, short shortData);
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, const std::string& stringData);
+ virtual RESULT visit(commonj::sdo::DataObjectPtr parent, const commonj::sdo::Property& property, commonj::sdo::DataObjectPtr dataObjectData);
+ };
+
+ /**
+ * SDO utilities.
+ */
+ class SCA_API SDOUtils
+ {
+ public:
+
+ static SDOVisitor::RESULT accept(commonj::sdo::DataObjectPtr dataObject, SDOVisitor& visitor, SDOVisitor::DEPTH depth);
+
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_sdovisitor_file_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Thread.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Thread.cpp
new file mode 100644
index 0000000000..d70ce28190
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Thread.cpp
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+
+/* $Rev: 491752 $ $Date: 2007-01-01 22:22:23 -0800 (Mon, 01 Jan 2007) $ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#include <process.h>
+#else
+#include "tuscany_sca_config.h"
+#endif
+
+#include <errno.h>
+
+#include <sstream>
+
+#include "tuscany/sca/util/Thread.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+
+using namespace std;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+
+#if defined(WIN32) || defined (_WINDOWS)
+ unsigned int __stdcall runThread(void *args)
+ {
+ Thread* thread = (Thread*)args;
+ thread->run();
+ return 0;
+ }
+#else
+ void* runThread(void* args)
+ {
+ Thread* thread = (Thread*)args;
+ thread->run();
+ return NULL;
+ }
+#endif
+
+ Thread::Thread()
+#if defined(WIN32) || defined (_WINDOWS)
+ : hthread(0)
+#else
+#endif
+ {
+ logentry();
+ }
+
+ Thread::~Thread()
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ if (hthread != 0)
+ {
+ CloseHandle(hthread);
+ }
+#else
+#endif
+ }
+
+ void Thread::start()
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ hthread = (HANDLE)_beginthreadex(NULL, 0, runThread, this, 0, NULL);
+ if (hthread == 0)
+ {
+ ostringstream msg;
+ msg << "Failed to create thread, errno: " << __doserrno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#else
+ int rc =pthread_create(&thread, NULL, runThread, this);
+ if (rc)
+ {
+ ostringstream msg;
+ msg << "Failed to create thread, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ void Thread::join()
+ {
+ logentry();
+
+#if defined(WIN32) || defined (_WINDOWS)
+ WaitForSingleObject(hthread, INFINITE);
+#else
+ int rc =pthread_join(thread, NULL);
+ if (rc)
+ {
+ ostringstream msg;
+ msg << "Failed to join thread, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Thread.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Thread.h
new file mode 100644
index 0000000000..2ca9142994
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Thread.h
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+/* $Rev: 492011 $ $Date: 2007-01-02 18:15:11 -0800 (Tue, 02 Jan 2007) $ */
+
+#ifndef tuscany_sca_util_thread_h
+#define tuscany_sca_util_thread_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <pthread.h>
+#endif
+
+#include <queue>
+
+#include "tuscany/sca/export.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * A portable wrapper for native threads.
+ */
+ class SCA_API Thread
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ Thread();
+
+ /**
+ * Destructor.
+ */
+ virtual ~Thread();
+
+ /**
+ * The method that will be run in the thread.
+ */
+ virtual void run() = 0;
+
+ /**
+ * Start the thread.
+ */
+ void start();
+
+ /**
+ * Join the thread.
+ */
+ void join();
+
+ private:
+
+ /**
+ * Native thread handle.
+ */
+#if defined(WIN32) || defined (_WINDOWS)
+ HANDLE hthread;
+#else
+ pthread_t thread;
+#endif
+
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_util_thread_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/ThreadLocal.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/ThreadLocal.cpp
new file mode 100644
index 0000000000..33aa1f7605
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/ThreadLocal.cpp
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#else
+#include "tuscany_sca_config.h"
+#endif
+
+#include <errno.h>
+
+#include <sstream>
+
+#include "tuscany/sca/util/ThreadLocal.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+
+using namespace std;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ ThreadLocal::ThreadLocal()
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ index = TlsAlloc();
+ if (index == TLS_OUT_OF_INDEXES)
+ {
+ ostringstream msg;
+ msg << "Failed to create thread local index, error: " << GetLastError();
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#else
+ int rc = pthread_key_create(&key, NULL);
+ if (rc)
+ {
+ ostringstream msg;
+ msg << "Failed to create thread local key, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ ThreadLocal::~ThreadLocal()
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ if (!TlsFree(index))
+ {
+ ostringstream msg;
+ msg << "Failed to destroy thread local index, error: " << GetLastError();
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#else
+ int rc = pthread_key_delete(key);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to destroy thread local key, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ void ThreadLocal::setValue(void* value)
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ if (!TlsSetValue(index, value))
+ {
+ ostringstream msg;
+ msg << "Failed to set thread local value, error: " << GetLastError();
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#else
+ int rc = pthread_setspecific(key, value);
+ if (rc) {
+ ostringstream msg;
+ msg << "Failed to set thread local value, errno: " << errno;
+ throwException(TuscanyRuntimeException, msg.str().c_str());
+ }
+#endif
+ }
+
+ void* ThreadLocal::getValue() const
+ {
+ logentry();
+#if defined(WIN32) || defined (_WINDOWS)
+ return TlsGetValue(index);
+#else
+ return pthread_getspecific(key);
+#endif
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/ThreadLocal.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/ThreadLocal.h
new file mode 100644
index 0000000000..556055f183
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/ThreadLocal.h
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_threadlocal_h
+#define tuscany_sca_util_threadlocal_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <pthread.h>
+#endif
+
+#include "tuscany/sca/export.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * Information about shared libraries and methods to
+ * access these shared libraries.
+ */
+ class SCA_API ThreadLocal
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ ThreadLocal();
+
+ /**
+ * Destructor.
+ */
+ virtual ~ThreadLocal();
+
+ /**
+ * Set the ThreadLocal value.
+ */
+ void setValue(void *value);
+
+ /**
+ * Get the ThreadLocal value.
+ */
+ void* getValue() const;
+
+ private:
+
+ /**
+ * Handle to the thread local key.
+ */
+#if defined(WIN32) || defined (_WINDOWS)
+ DWORD index;
+#else
+ pthread_key_t key;
+#endif
+
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_util_threadlocal_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Utils.cpp b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Utils.cpp
new file mode 100644
index 0000000000..98a929392d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Utils.cpp
@@ -0,0 +1,598 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#endif
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <errno.h>
+#endif
+
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace commonj::sdo;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ void Utils::tokeniseUri(const string& uri, string& token1, string& token2)
+ {
+ tokeniseString("/", uri, token1, token2);
+ }
+
+ void Utils::tokeniseQName(const string& qname, string& uri, string& name)
+ {
+ tokeniseString("#", qname, uri, name);
+ if (name == "")
+ {
+ name = uri;
+ uri = "";
+ }
+ }
+
+ void Utils::tokeniseString(
+ const string& separator,
+ const string& str,
+ string& token1,
+ string& token2)
+ {
+ string::size_type sep = str.find(separator);
+ if (sep != string::npos)
+ {
+ int l = separator.length();
+ token1 = str.substr(0, sep);
+ if ( (sep+l) < str.length())
+ {
+ token2 = str.substr(sep+l);
+ }
+ else
+ {
+ token2 = "";
+ }
+ }
+ else
+ {
+ token1 = str;
+ token2 = "";
+ }
+ }
+
+ void Utils::rTokeniseString(
+ const string& separator,
+ const string& str,
+ string& token1,
+ string& token2)
+ {
+ string::size_type sep = str.rfind(separator);
+ if (sep != string::npos)
+ {
+ int l = separator.length();
+ token1 = str.substr(0, sep);
+ if ( (sep+l) < str.length())
+ {
+ token2 = str.substr(sep+l);
+ }
+ else
+ {
+ token2 = "";
+ }
+ }
+ else
+ {
+ token1 = "";
+ token2 = str;
+ }
+ }
+
+ void Utils::breakpoint() {
+ // dummy method used to set breakpoints
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Print a DatObject tree
+ //////////////////////////////////////////////////////////////////////////
+ void Utils::tabs(int inc)
+ {
+ for (int ind=0; ind <inc; ind++)
+ {
+ cout << " ";
+ }
+ }
+
+ const bool Utils::compareProperties(DataObjectPtr dataObject1, const Property& prop1, DataObjectPtr dataObject2, const Property& prop2, string& diff)
+ {
+ if(strcmp(prop1.getName(),prop2.getName()) != 0)
+ {
+ diff.append("Differing names for Properties:\n");
+ diff.append(prop1.getName());
+ diff.append("\n");
+ diff.append(prop2.getName());
+ return false;
+ }
+
+ const Type& propertyType1 = prop1.getType();
+ const Type& propertyType2 = prop2.getType();
+
+ if(strcmp(propertyType1.getName(), propertyType2.getName()) != 0 ||
+ strcmp(propertyType1.getURI(),propertyType2.getURI()) != 0 )
+ {
+ diff.append("Differing types for Properties:\n");
+ diff.append(propertyType1.getName());
+ diff.append("#");
+ diff.append(propertyType1.getURI());
+ diff.append("\n");
+ diff.append(propertyType2.getName());
+ diff.append("#");
+ diff.append(propertyType2.getURI());
+ return false;
+ }
+ if (dataObject1->isSet(prop1) != dataObject2->isSet(prop2))
+ {
+ diff.append("Property ");
+ diff.append(prop1.getName());
+ diff.append(" is set on one DataObject but not the other");
+ return false;
+ }
+
+ if (dataObject1->isSet(prop1))
+ {
+
+ if (prop1.isMany() != prop2.isMany())
+ {
+ diff.append("Property ");
+ diff.append(prop1.getName());
+ diff.append(" is many on one DataObject but not the other");
+ return false;
+ }
+ if (propertyType1.isDataType() != propertyType2.isDataType())
+ {
+ diff.append("Property ");
+ diff.append(prop1.getName());
+ diff.append(" is dataType on one DataObject but not the other");
+ return false;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // For a many-valued property get the list of values
+ //////////////////////////////////////////////////////////////////////
+ if (prop1.isMany())
+ {
+ DataObjectList& dol1 = dataObject1->getList(prop1);
+ DataObjectList& dol2 = dataObject2->getList(prop2);
+ if (dol1.size() != dol2.size())
+ {
+ diff.append("Property ");
+ diff.append(prop1.getName());
+ diff.append(" is many but has differing number of elements");
+ return false;
+ }
+
+ for (unsigned int j = 0; j <dol1.size(); j++)
+ {
+
+ if (propertyType1.isDataType())
+ {
+ if( strcmp(dol1.getCString(j), dol2.getCString(j)) != 0)
+ {
+ diff.append("Differing value for Property ");
+ diff.append(prop1.getName());
+ diff.append("[");
+ diff += ((int)j);
+ diff.append("]:\n");
+ diff.append(dol1.getCString(j));
+ diff.append("\n");
+ diff.append(dol2.getCString(j));
+ return false;
+ }
+ }
+ else
+ {
+ if(!compareDataObjects(dol1[j], dol2[j], diff))
+ {
+ return false;
+ }
+ }
+ }
+ } // end IsMany
+
+
+ //////////////////////////////////////////////////////////////////////
+ // For a primitive data type compare the values
+ //////////////////////////////////////////////////////////////////////
+ else if (propertyType1.isDataType())
+ {
+ if( strcmp(dataObject1->getCString(prop1), dataObject2->getCString(prop2)) != 0)
+ {
+ diff.append("Differing value for Property ");
+ diff.append(prop1.getName());
+ diff.append(":\n");
+ diff.append(dataObject1->getCString(prop1));
+ diff.append("\n");
+ diff.append(dataObject2->getCString(prop2));
+ return false;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // For a dataobject compare the DOs
+ //////////////////////////////////////////////////////////////////////
+ else
+ {
+ if(!compareDataObjects(dataObject1->getDataObject(prop1), dataObject2->getDataObject(prop2), diff))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ const bool Utils::compareDataObjects(DataObjectPtr dataObject1, DataObjectPtr dataObject2, string& diff)
+ {
+ if (!dataObject1 || !dataObject2)
+ {
+ diff.append("Cannot compare null DataObjects");
+ return false;
+ }
+
+ const Type& dataObject1Type = dataObject1->getType();
+ const Type& dataObject2Type = dataObject2->getType();
+
+ if( strcmp(dataObject1Type.getURI(), dataObject2Type.getURI()) != 0 ||
+ strcmp(dataObject1Type.getName(), dataObject2Type.getName()) != 0 )
+ {
+ diff.append("DataObject Types differ:\n");
+ diff.append(dataObject1Type.getURI());
+ diff.append("#");
+ diff.append(dataObject1Type.getName());
+ diff.append("\n");
+ diff.append(dataObject2Type.getURI());
+ diff.append("#");
+ diff.append(dataObject2Type.getName());
+ return false;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Iterate over all the properties
+ //////////////////////////////////////////////////////////////////////////
+ PropertyList pl1 = dataObject1->getInstanceProperties();
+ PropertyList pl2 = dataObject2->getInstanceProperties();
+ if (pl1.size() != pl2.size())
+ {
+ diff.append("Differing number of properties");
+ return false;
+ }
+
+ if (pl1.size() != 0)
+ {
+ for (unsigned int i = 0; i < pl1.size(); i++)
+ {
+ if(!compareProperties(dataObject1, pl1[i], dataObject2, pl2[i], diff))
+ {
+ return false;
+ }
+ }
+ }
+ else
+ {
+ if(dataObject1->getType().isOpenType() != dataObject2->getType().isOpenType() &&
+ dataObject1->getType().isDataObjectType() != dataObject2->getType().isDataObjectType())
+ {
+ diff.append("DataObject is open & DO type on one but not the other");
+ return false;
+ }
+
+ // Compare elements under an open DataObject
+ if(dataObject1->getType().isOpenType() && dataObject1->getType().isDataObjectType())
+ {
+ SequencePtr sequence1 = dataObject1->getSequence();
+ SequencePtr sequence2 = dataObject2->getSequence();
+
+ if (sequence1 != NULL && sequence2 != NULL)
+ {
+ if (sequence1->size() != sequence1->size())
+ {
+ diff.append("Open DataObjects have differing number of elements");
+ return false;
+ }
+
+ for (unsigned int i = 0; i < sequence1->size(); i++)
+ {
+ if (sequence1->isText(i) != sequence2->isText(i))
+ {
+ diff.append("Open DataObjects have differing element types at position ");
+ diff += ((int) i);
+ return false;
+ }
+ if (sequence1->isText(i))
+ {
+ if( strcmp(sequence1->getCStringValue(i), sequence2->getCStringValue(i)) != 0)
+ {
+ diff.append("Differing value for element at position ");
+ diff += ((int) i);
+ diff.append(":\n");
+ diff.append(sequence1->getCStringValue(i));
+ diff.append("\n");
+ diff.append(sequence2->getCStringValue(i));
+ return false;
+ }
+ }
+ else
+ {
+ const Property& p1 = sequence1->getProperty(i);
+ const Property& p2 = sequence2->getProperty(i);
+
+ if(!compareProperties(dataObject1, p1, dataObject2, p2, diff))
+ {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ void Utils::printDO(DataObjectPtr dataObject, int increment)
+ {
+ int inc=increment;
+ if (!dataObject)
+ return;
+ const Type& dataObjectType = dataObject->getType();
+ tabs(inc);
+ cout << "DataObject type: " << dataObjectType.getURI()<< "#" << dataObjectType.getName() << endl;
+ inc++;
+
+ //////////////////////////////////////////////////////////////////////////
+ // Iterate over all the properties
+ //////////////////////////////////////////////////////////////////////////
+ PropertyList pl = dataObject->getInstanceProperties();
+ if (pl.size() != 0)
+ {
+ for (unsigned int i = 0; i < pl.size(); i++)
+ {
+ tabs(inc);
+ cout << "Property: " << pl[i].getName() << endl;
+
+ const Type& propertyType = pl[i].getType();
+
+ tabs(inc);
+ cout << "Property Type: " << propertyType.getURI()<< "#" << propertyType.getName() << endl;
+
+ if (dataObject->isSet(pl[i]))
+ {
+
+ //////////////////////////////////////////////////////////////////////
+ // For a many-valued property get the list of values
+ //////////////////////////////////////////////////////////////////////
+ if (pl[i].isMany())
+ {
+ inc++;
+ DataObjectList& dol = dataObject->getList(pl[i]);
+ for (unsigned int j = 0; j <dol.size(); j++)
+ {
+ tabs(inc);
+ cout << "Value " << j <<endl;
+ inc++;
+
+ if (propertyType.isDataType())
+ {
+ tabs(inc);
+ cout<< "Property Value: " << dol.getCString(j) <<endl ;
+ }
+ else
+ printDO(dol[j], inc);
+ inc--;
+ }
+ inc--;
+ } // end IsMany
+
+
+ //////////////////////////////////////////////////////////////////////
+ // For a primitive data type print the value
+ //////////////////////////////////////////////////////////////////////
+ else if (propertyType.isDataType())
+ {
+ tabs(inc);
+ cout<< "Property Value: " << dataObject->getCString(pl[i]) <<endl ;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // For a dataobject print the do
+ //////////////////////////////////////////////////////////////////////
+ else
+ {
+ inc++;
+ printDO(dataObject->getDataObject(pl[i]), inc);
+ inc--;
+ }
+ }
+ else
+ {
+ tabs(inc);
+ cout<< "Property Value: not set" <<endl ;
+ }
+
+ }
+ }
+ else
+ {
+ // Print elements under an open DataObject
+ if(dataObject->getType().isOpenType() && dataObject->getType().isDataObjectType())
+ {
+ SequencePtr sequence = dataObject->getSequence();
+ if (sequence != NULL)
+ {
+ for (unsigned int i = 0; i < sequence->size(); i++)
+ {
+ if (sequence->isText(i))
+ {
+ tabs(inc);
+ cout<< "Text Value: " << sequence->getCStringValue(i) <<endl ;
+ }
+ else {
+ const Property& p = sequence->getProperty(i);
+
+ tabs(inc);
+ cout << "Property: " << p.getName() << endl;
+
+ const Type& propertyType = p.getType();
+
+ tabs(inc);
+ cout << "Property Type: " << propertyType.getURI()<< "#" << propertyType.getName() << endl;
+
+ if (dataObject->isSet(p))
+ {
+
+ //////////////////////////////////////////////////////////////////////
+ // For a many-valued property get the list of values
+ //////////////////////////////////////////////////////////////////////
+ if (p.isMany())
+ {
+ inc++;
+ DataObjectList& dol = dataObject->getList(p);
+ for (unsigned int j = 0; j <dol.size(); j++)
+ {
+ tabs(inc);
+ cout << "Value " << j <<endl;
+ inc++;
+
+ if (propertyType.isDataType())
+ {
+ tabs(inc);
+ cout<< "Property Value: " << dol.getCString(j) <<endl ;
+ }
+ else
+ printDO(dol[j], inc);
+ inc--;
+ }
+ inc--;
+ } // end IsMany
+
+
+ //////////////////////////////////////////////////////////////////////
+ // For a primitive data type print the value
+ //////////////////////////////////////////////////////////////////////
+ else if (propertyType.isDataType())
+ {
+ tabs(inc);
+ cout<< "Property Value: " << dataObject->getCString(p) <<endl ;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // For a dataobject print the do
+ //////////////////////////////////////////////////////////////////////
+ else
+ {
+ inc++;
+ printDO(dataObject->getDataObject(p), inc);
+ inc--;
+ }
+ }
+ else
+ {
+ tabs(inc);
+ cout<< "Property Value: not set" <<endl ;
+ }
+ }
+ }
+ }
+ }
+ }
+ inc--;
+ }
+
+ void Utils::printTypes(DataFactoryPtr df)
+ {
+ //////////////////////////////////////////////////////////////////////////
+ // Retrieve the DataFactory from the mediator
+ // get the list of Types in the DataFactory and list them
+ //////////////////////////////////////////////////////////////////////////
+ TypeList tl = df->getTypes();
+ for (unsigned int i = 0; i < tl.size(); i++)
+ {
+ cout << "Type: " << tl[i].getURI()<< "#" << tl[i].getName() << endl;
+ PropertyList pl = tl[i].getProperties();
+ for (unsigned int j = 0; j < pl.size(); j++)
+ {
+ cout << "\tProperty: " << pl[j].getName()
+ << " type: " <<pl[j].getType().getURI()<<"#"<<pl[j].getType().getName()<< endl;
+
+ }
+ }
+
+ }
+
+ void Utils::printType(const Type& type, int increment)
+ {
+ int inc = increment;
+ tabs(inc);
+ cout << "Type: " << type.getURI()<< "#" << type.getName() << endl;
+ inc++;
+ PropertyList pl = type.getProperties();
+ for (unsigned int j = 0; j < pl.size(); j++)
+ {
+ tabs(inc);
+ cout << "\tProperty: " << pl[j].getName()
+ << " type: " <<pl[j].getType().getURI()<<"#"<<pl[j].getType().getName()<< endl;
+ inc++;
+ printType(pl[j].getType(), inc);
+ inc--;
+ }
+ }
+
+ void Utils::printLastError(ostream& os)
+ {
+#if defined(WIN32) || defined (_WINDOWS)
+ DWORD err = GetLastError();
+ LPTSTR buf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ err,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &buf,
+ 0, NULL );
+
+ os << (const char *)buf;
+ LocalFree(buf);
+#else
+ char buf[256];
+ strerror_r(errno, buf, 255);
+ os << buf;
+#endif
+ }
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Utils.h b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Utils.h
new file mode 100644
index 0000000000..bbe1aa812a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/core/src/tuscany/sca/util/Utils.h
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_utils_h
+#define tuscany_sca_util_utils_h
+
+#include <string>
+#include <ostream>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/export.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace util
+ {
+ /**
+ * Utility methods to parse strings and provide debugging information.
+ */
+ class SCA_API Utils {
+
+ public:
+ static void tokeniseUri(const std::string& uri, std::string& token1, std::string& token2);
+ static void tokeniseQName(const std::string& sdoname, std::string& uri, std::string& name);
+ static void tokeniseString(
+ const std::string& separator,
+ const std::string& str,
+ std::string& token1,
+ std::string& token2);
+
+ static void rTokeniseString(
+ const std::string& separator,
+ const std::string& str,
+ std::string& token1,
+ std::string& token2);
+
+ static void breakpoint();
+
+ static void printLastError(std::ostream& os);
+
+ static void printDO(commonj::sdo::DataObjectPtr dataObject, int increment=0);
+ static void printTypes(commonj::sdo::DataFactoryPtr df);
+ static void printType(const commonj::sdo::Type& type, int increment=0);
+
+ static const bool compareDataObjects(commonj::sdo::DataObjectPtr dataObject1, commonj::sdo::DataObjectPtr dataObject2, std::string& diff);
+ static const bool compareProperties(commonj::sdo::DataObjectPtr dataObject1, const commonj::sdo::Property& prop1, commonj::sdo::DataObjectPtr dataObject2, const commonj::sdo::Property& prop2, std::string& diff);
+
+ private:
+ static void tabs(int increment=0);
+ };
+
+ } // End namespace util
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_utils_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/Makefile.am
new file mode 100644
index 0000000000..1cc28fe80e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/Makefile.am
@@ -0,0 +1,45 @@
+# 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.
+
+if WANT_ALL
+ CPP_EXTENSION = cpp
+ PYTHON_EXTENSION = python
+ RUBY_EXTENSION = ruby
+ WSBINDING_EXTENSION = ws
+ SCABINDING_EXTENSION = sca
+ RESTBINDING_EXTENSION = rest
+endif
+if WANT_CPP
+ CPP_EXTENSION = cpp
+endif
+if WANT_PYTHON
+ PYTHON_EXTENSION = python
+endif
+if WANT_RUBY
+ RUBY_EXTENSION = ruby
+endif
+
+if WANT_WSBINDING
+ WSBINDING_EXTENSION = ws
+endif
+if WANT_SCABINDING
+ SCABINDING_EXTENSION = sca
+endif
+if WANT_RESTBINDING
+ RESTBINDING_EXTENSION = rest
+endif
+SUBDIRS = ${CPP_EXTENSION} ${WSBINDING_EXTENSION} ${SCABINDING_EXTENSION} ${RESTBINDING_EXTENSION} ${PYTHON_EXTENSION} ${RUBY_EXTENSION}
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/Makefile.am
new file mode 100644
index 0000000000..7fac33118a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/Makefile.am
@@ -0,0 +1,24 @@
+# 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.
+
+SUBDIRS = src
+
+datadir=$(prefix)/extensions/cpp
+
+nobase_data_DATA = xsd/*.xsd
+
+EXTRA_DIST = xsd \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/deploy.bat
new file mode 100644
index 0000000000..644cbfc4a3
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/deploy.bat
@@ -0,0 +1,77 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set cppextdir=%extdir%\cpp
+set srcdir=%rootdir%\runtime\extensions\cpp\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %cppextdir% mkdir %cppextdir%
+if not exist %cppextdir%\module mkdir %cppextdir%\module
+if not exist %cppextdir%\bin mkdir %cppextdir%\bin
+if not exist %cppextdir%\lib mkdir %cppextdir%\lib
+if not exist %cppextdir%\include mkdir %cppextdir%\include
+if not exist %cppextdir%\include\osoa mkdir %cppextdir%\include\osoa
+if not exist %cppextdir%\include\osoa\sca mkdir %cppextdir%\include\osoa\sca
+if not exist %cppextdir%\include\tuscany mkdir %cppextdir%\include\tuscany
+if not exist %cppextdir%\include\tuscany\sca mkdir %cppextdir%\include\tuscany\sca
+if not exist %cppextdir%\include\tuscany\sca\cpp mkdir %cppextdir%\include\tuscany\sca\cpp
+if not exist %cppextdir%\include\tuscany\sca\cpp\model mkdir %cppextdir%\include\tuscany\sca\cpp\model
+if not exist %cppextdir%\xsd mkdir %cppextdir%\xsd
+
+del %cppextdir%\bin\tuscany_sca_cpp.*
+del %cppextdir%\lib\*.lib
+
+copy %srcdir%\osoa\sca\*.h %cppextdir%\include\osoa\sca
+copy %srcdir%\tuscany\sca\cpp\*.h %cppextdir%\include\tuscany\sca\cpp
+copy %srcdir%\tuscany\sca\cpp\model\*.h %cppextdir%\include\tuscany\sca\cpp\model
+
+copy %srcdir%\..\xsd\*.* %cppextdir%\xsd
+
+copy %inpath%\tuscany_sca_cpp.lib %cppextdir%\lib
+copy %inpath%\tuscany_sca_cpp.dll %cppextdir%\bin
+copy %inpath%\tuscany_sca_cpp.dll %cppextdir%\module
+
+if exist %inpath%\tuscany_sca_cpp.pdb copy %inpath%\tuscany_sca_cpp.pdb %cppextdir%\bin
+if exist %inpath%\tuscany_sca_cpp.pdb copy %inpath%\tuscany_sca_cpp.pdb %cppextdir%\module
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/Makefile.am
new file mode 100644
index 0000000000..bb28aed8b9
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/Makefile.am
@@ -0,0 +1,57 @@
+# 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.
+
+libdir=$(prefix)/extensions/cpp/lib
+
+lib_LTLIBRARIES = libtuscany_sca_cpp.la
+includedir=$(prefix)/extensions/cpp/include
+nobase_include_HEADERS = \
+osoa/sca/*.h \
+tuscany/sca/cpp/*.h \
+tuscany/sca/cpp/model/*.h
+
+libtuscany_sca_cpp_la_SOURCES = \
+osoa/sca/ComponentContext.cpp \
+osoa/sca/CompositeContext.cpp \
+tuscany/sca/cpp/ComponentContextImpl.cpp \
+tuscany/sca/cpp/CompositeContextImpl.cpp \
+tuscany/sca/cpp/CPPExtension.cpp \
+tuscany/sca/cpp/CPPImplementationExtension.cpp \
+tuscany/sca/cpp/CPPInterfaceExtension.cpp \
+tuscany/sca/cpp/CPPServiceProxy.cpp \
+tuscany/sca/cpp/CPPServiceWrapper.cpp \
+tuscany/sca/cpp/TuscanyRuntime.cpp \
+tuscany/sca/cpp/model/CPPImplementation.cpp \
+tuscany/sca/cpp/model/CPPInterface.cpp \
+tuscany/sca/cpp/model/CPPReferenceBinding.cpp \
+tuscany/sca/cpp/model/CPPServiceBinding.cpp
+
+libtuscany_sca_cpp_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca
+
+INCLUDES = -Imodel -I$(top_builddir)/runtime/core/src \
+ -I${TUSCANY_SDOCPP}/include
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+moduledir=$(prefix)/extensions/cpp/module
+extension = libtuscany_sca_cpp$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension)
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp
new file mode 100644
index 0000000000..d686c4c09f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp
@@ -0,0 +1,150 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/ComponentContext.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/ComponentContextImpl.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace commonj::sdo;
+using namespace tuscany::sca;
+using namespace tuscany::sca::cpp;
+using namespace tuscany::sca::model;
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ // =======================================================
+ // getCurrent: create a context from the current component
+ // =======================================================
+ ComponentContext ComponentContext::getCurrent()
+ {
+ logentry();
+ try
+ {
+ Component* component = tuscany::sca::SCARuntime::getCurrentRuntime()->getCurrentComponent();
+ if (!component)
+ {
+ throwException(ComponentContextException, "No current component");
+ }
+ ComponentContext* cci = new ComponentContextImpl(component);
+ return ComponentContext(cci);
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ // ===========
+ // Constructor
+ // ===========
+ ComponentContext::ComponentContext(ComponentContext* implementation)
+ : impl(implementation)
+ {
+ logentry();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ComponentContext::~ComponentContext()
+ {
+ logentry();
+ delete impl;
+ }
+
+ // ===================================
+ // Copy constructor: create a new impl
+ // ===================================
+ ComponentContext::ComponentContext(const ComponentContext& ctx)
+ {
+ logentry();
+ Component* component = ((ComponentContextImpl*)impl)->getComponent();
+ impl = new ComponentContextImpl(component);
+ }
+
+ // =============================
+ // operator= : create a new impl
+ // =============================
+ ComponentContext& ComponentContext::operator=(const ComponentContext& ctx)
+ {
+ logentry();
+ if (this != &ctx)
+ {
+ Component* component = ((ComponentContextImpl*)impl)->getComponent();
+ impl = new ComponentContextImpl(component);
+ }
+ return *this;
+ }
+
+ // ==========
+ // getService
+ // ==========
+ void* ComponentContext::getService(const std::string& referenceName)
+ {
+ logentry();
+ void* service = impl->getService(referenceName);
+ return service;
+ }
+
+ // ===========
+ // getServices
+ // ===========
+ std::list<void*> ComponentContext::getServices(const std::string& referenceName)
+ {
+ logentry();
+ return impl->getServices(referenceName);
+ }
+
+ // ============
+ // getProperties
+ // =============
+ DataObjectPtr ComponentContext::getProperties()
+ {
+ logentry();
+ DataObjectPtr properties = impl->getProperties();
+ return properties;
+ }
+
+ // ============
+ // getDataFactory
+ // =============
+ DataFactoryPtr ComponentContext::getDataFactory()
+ {
+ logentry();
+ DataFactoryPtr dataFactory = impl->getDataFactory();
+ return dataFactory;
+ }
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h
new file mode 100644
index 0000000000..2c305c5161
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef osoa_sca_componentcontext_h
+#define osoa_sca_componentcontext_h
+
+#include <string>
+#include <list>
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/export.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ /**
+ * An SCA component implementation uses the ComponentContext class to
+ * retrieve information about the configured SCA component.
+ */
+ class SCA_CPP_API ComponentContext
+ {
+
+ public:
+ /**
+ * Return a new ComponentContext for the current Component.
+ */
+ static ComponentContext getCurrent();
+
+ /**
+ * Resolve a reference name into a single configured service.
+ * If the component's reference is wired to more than one service
+ * then theis method will return an exception.
+ * @param referenceName The reference to be resolved. This must match
+ * the name of a reference configured in the component type file for
+ * this component.
+ */
+ virtual void* getService(const std::string& referenceName);
+
+ /**
+ * Resolve a reference name into a list of configured services.
+ * @param referenceName The reference to be resolved. This must match
+ * the name of a reference configured in the component type file for
+ * this component.
+ */
+ virtual std::list<void*> getServices(const std::string& referenceName);
+
+ /**
+ * Get the configured properties for the component.
+ * @return A data object representing all the properties that
+ * are configured for this component.
+ */
+ virtual commonj::sdo::DataObjectPtr getProperties();
+
+ /**
+ * Get an SDO data factory which will allow the component to
+ * create data objects for all the types configured for this
+ * component.
+ * @return A data factory to be used by the component to create
+ * new data objects.
+ */
+ virtual commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Destructor
+ */
+ virtual ~ComponentContext();
+
+ /**
+ * Constructor
+ */
+ ComponentContext(const ComponentContext&);
+
+ /**
+ * Copy operator
+ */
+ ComponentContext& operator=(const ComponentContext&);
+
+ /**
+ * Constructor to create an interface class from the contained
+ * implementation.
+ * @param implementation the actual implementation class
+ */
+ ComponentContext(ComponentContext* implementation);
+
+ private:
+
+ /**
+ * Pointer to the class which provides the actual implementation.
+ */
+ ComponentContext* impl;
+
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_componentcontext_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp
new file mode 100644
index 0000000000..d3f06e1b12
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/CompositeContext.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/CompositeContextImpl.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace commonj::sdo;
+using namespace tuscany::sca;
+using namespace tuscany::sca::cpp;
+
+
+namespace osoa
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ CompositeContext::CompositeContext(CompositeContext* implementation)
+ : impl(implementation)
+ {
+ logentry();
+ }
+
+ // ===================================
+ // Copy constructor: create a new impl
+ // ===================================
+ CompositeContext::CompositeContext(const CompositeContext& ctx)
+ {
+ logentry();
+ impl = new CompositeContextImpl(
+ tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent());
+ }
+
+ // =============================
+ // operator= : create a new impl
+ // =============================
+ CompositeContext& CompositeContext::operator=(const CompositeContext& ctx)
+ {
+ logentry();
+ if (this != &ctx)
+ {
+ impl = new CompositeContextImpl(
+ tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent());
+ }
+ return *this;
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ CompositeContext::~CompositeContext()
+ {
+ logentry();
+ delete impl;
+ }
+
+ // ====================================================
+ // getCurrent: create a context from the current composite
+ // ====================================================
+ CompositeContext CompositeContext::getCurrent()
+ {
+ logentry();
+ try
+ {
+ CompositeContext* cci = new CompositeContextImpl(
+ tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent());
+
+ return CompositeContext(cci);
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ // =============
+ // locateService
+ // =============
+ void* CompositeContext::locateService(const std::string& serviceName)
+ {
+ logentry();
+ void* sp = impl->locateService(serviceName);
+ return sp;
+ }
+
+ // =============
+ // getDataFactory
+ // =============
+ DataFactoryPtr CompositeContext::getDataFactory()
+ {
+ logentry();
+ DataFactoryPtr df = impl->getDataFactory();
+ return df;
+ }
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h
new file mode 100644
index 0000000000..a047f82e46
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef osoa_sca_compositecontext_h
+#define osoa_sca_compositecontext_h
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/export.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+ /**
+ * An SCA component implementation, or a non-SCA client, uses the
+ * CompositeContext class to retrieve information about the configured
+ * SCA composite.
+ */
+ class SCA_CPP_API CompositeContext
+ {
+
+ public:
+ /**
+ * Return a new CompositeContext for the current Component.
+ */
+ static CompositeContext getCurrent();
+
+ /**
+ * Resolve a service name into a single component service.
+ * @param serviceName The name of the service in the form
+ * "component name"/"service name". The service name is
+ * optional in the component has one service.
+ * @return A pointer to an object which can be cast to the
+ * business interface of the target service.
+ */
+ virtual void* locateService(const std::string& serviceName);
+
+ /**
+ * Get an SDO data factory which will allow the component to
+ * create data objects for all the types configured for this
+ * component.
+ * @return A data factory to be used by the component to create
+ * new data objects.
+ */
+ virtual commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Destructor.
+ */
+ virtual ~CompositeContext();
+
+ /**
+ * Constructor
+ */
+ CompositeContext(const CompositeContext&);
+
+ /**
+ * Copy operator
+ */
+ CompositeContext& operator=(const CompositeContext&);
+
+ /**
+ * Constructor to create an interface class from the contained
+ * implementation.
+ * @param implementation The actual implementation class.
+ */
+ CompositeContext(CompositeContext* implementation);
+
+ private:
+
+ /**
+ * Pointer to the class which provides the actual implementation.
+ */
+ CompositeContext* impl;
+
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_compositecontext_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h
new file mode 100644
index 0000000000..6d64a32dd6
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef osoa_sca_serviceruntimeexception_h
+#define osoa_sca_serviceruntimeexception_h
+
+#include "osoa/sca/export.h"
+
+#include "tuscany/sca/core/Exceptions.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+ /**
+ * Top level exception to represent all the exceptions that may be
+ * thrown by an SCA runtime implementation.
+ */
+ class SCA_CPP_API ServiceRuntimeException : public tuscany::sca::TuscanyRuntimeException
+ {
+ public:
+ ServiceRuntimeException(
+ const char *name="ServiceRuntimeException",
+ severity_level sev=Severe,
+ const char* msg_text="")
+ : tuscany::sca::TuscanyRuntimeException(name, sev, msg_text)
+ {
+ }
+
+ ServiceRuntimeException(const tuscany::sca::TuscanyRuntimeException& e)
+ : tuscany::sca::TuscanyRuntimeException(e)
+ {
+ }
+ }; // End ServiceRuntimeException class definition
+
+ /**
+ * A remotable service is currently unavailable. It is possible that a retry
+ * may resolve this exception.
+ */
+ class SCA_CPP_API ServiceUnavailableException: public ServiceRuntimeException
+ {
+ public:
+ ServiceUnavailableException(const char* serviceName)
+ : ServiceRuntimeException("ServiceUnavailableException", Warning,
+ serviceName)
+ {
+ }
+ private:
+ }; // End ServiceUnavailableException class definition
+
+
+ /**
+ * The target of a wire cannot be found, or the reference has not been
+ * configured.
+ */
+ class SCA_CPP_API ServiceNotFoundException: public ServiceRuntimeException
+ {
+ public:
+ ServiceNotFoundException(const char* msg)
+ : ServiceRuntimeException("ServiceNotFoundException", Error,
+ msg)
+ {
+ }
+ private:
+ }; // End ServiceNotFoundException class definition
+
+
+ /**
+ * There is no current component (for example, if a non-SCA component
+ * tries to get the current ComponentContext).
+ */
+ class SCA_CPP_API ComponentContextException: public ServiceRuntimeException
+ {
+ public:
+ ComponentContextException(const char* msg)
+ : ServiceRuntimeException("ComponentContextException", Error,
+ msg)
+ {
+ }
+ private:
+ }; // End ComponentContextException class definition
+
+
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_serviceruntimeexception_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/export.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/export.h
new file mode 100644
index 0000000000..8a69913be4
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/export.h
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef osoa_sca_export_h
+#define osoa_sca_export_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef TUSCANY_SCA_CPP_EXPORTS
+#define SCA_CPP_API __declspec(dllexport)
+#else
+#define SCA_CPP_API __declspec(dllimport)
+#endif
+
+#else
+#include <sys/time.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#define SCA_CPP_API
+#endif
+
+#endif // osoa_sca_export_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/sca.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/sca.h
new file mode 100644
index 0000000000..6cce9453d7
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/osoa/sca/sca.h
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef osoa_sca_sca_h
+#define osoa_sca_sca_h
+
+#include "osoa/sca/export.h"
+#include "osoa/sca/CompositeContext.h"
+#include "osoa/sca/ComponentContext.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#endif // osoa_sca_sca_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp
new file mode 100644
index 0000000000..74a30fb772
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/cpp/CPPExtension.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/cpp/CPPImplementationExtension.h"
+#include "tuscany/sca/cpp/CPPInterfaceExtension.h"
+
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_cpp_initialize()
+ {
+ tuscany::sca::cpp::CPPExtension::initialize();
+ }
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ // ===================================================================
+ // Constructor for the CPPExtension class.
+ // ===================================================================
+ CPPExtension::CPPExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the CPPExtension class.
+ // ===================================================================
+ CPPExtension::~CPPExtension()
+ {
+ logentry();
+ }
+
+ void CPPExtension::initialize()
+ {
+ logentry();
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ runtime->registerImplementationExtension(new CPPImplementationExtension());
+ runtime->registerInterfaceExtension(new CPPInterfaceExtension());
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h
new file mode 100644
index 0000000000..d6c872629d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_cppextension_h
+#define tuscany_sca_cpp_cppextension_h
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ class CPPExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ CPPExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~CPPExtension();
+
+ static void initialize();
+
+ private:
+
+ };
+
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp
new file mode 100644
index 0000000000..b5312ab243
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp
@@ -0,0 +1,101 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/cpp/CPPImplementationExtension.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::util;
+using namespace tuscany::sca::model;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ // ===================================================================
+ // Constructor for the CPPImplementationExtension class.
+ // ===================================================================
+ CPPImplementationExtension::CPPImplementationExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the CPPImplementationExtension class.
+ // ===================================================================
+ CPPImplementationExtension::~CPPImplementationExtension()
+ {
+ logentry();
+ }
+
+ const string CPPImplementationExtension::extensionName("cpp");
+ const string CPPImplementationExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPImplementation");
+
+ // ===================================================================
+ // loadModelElement - load the info from implementation.cpp
+ // ===================================================================
+ ComponentType* CPPImplementationExtension::getImplementation(Composite *composite, DataObjectPtr scdlImplementation)
+ {
+ logentry();
+ string library = scdlImplementation->getCString("library");
+ string header = scdlImplementation->getCString("header");
+ string className = scdlImplementation->getCString("class");
+ string scopeName = scdlImplementation->getCString("scope");
+
+ CPPImplementation::Scope scope;
+ if (scopeName == "composite")
+ {
+ scope = CPPImplementation::COMPOSITE;
+ }
+ else
+ {
+ scope = CPPImplementation::STATELESS;
+ }
+
+ string headerPath;
+ string headerStub;
+
+ // Separate any path element
+ Utils::rTokeniseString("/", header, headerPath, headerStub);
+ if (headerPath != "")
+ {
+ headerPath += "/";
+ }
+
+ // Determine the header stub name
+ string tmp;
+ Utils::rTokeniseString(".h", headerStub, headerStub, tmp);
+
+ CPPImplementation* cppImpl = new CPPImplementation(
+ composite, library, header, headerPath, headerStub, className, scope);
+
+ return cppImpl;
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h
new file mode 100644
index 0000000000..8eb7b88691
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_cppimplementationextension_h
+#define tuscany_sca_cpp_cppimplementationextension_h
+
+#include "tuscany/sca/extension/ImplementationExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ class CPPImplementationExtension : public ImplementationExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ CPPImplementationExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~CPPImplementationExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema type for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.cpp")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ComponentType* getImplementation(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlImplementation);
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppimplementationextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp
new file mode 100644
index 0000000000..7bb84a7673
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/cpp/CPPInterfaceExtension.h"
+#include "tuscany/sca/cpp/model/CPPInterface.h"
+#include "tuscany/sca/util/Logging.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ // ===================================================================
+ // Constructor for the CPPInterfaceExtension class.
+ // ===================================================================
+ CPPInterfaceExtension::CPPInterfaceExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the CPPInterfaceExtension class.
+ // ===================================================================
+ CPPInterfaceExtension::~CPPInterfaceExtension()
+ {
+ logentry();
+ }
+
+ const string CPPInterfaceExtension::extensionName("cpp");
+ const string CPPInterfaceExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPInterface");
+
+ // ===================================================================
+ // loadModelElement - load the info from interface.cpp
+ // ===================================================================
+ tuscany::sca::model::Interface* CPPInterfaceExtension::getInterface(Composite* composite, DataObjectPtr scdlInterface)
+ {
+ logentry();
+
+ string header = scdlInterface->getCString("header");
+ string className = scdlInterface->getCString("class");
+ bool remotable = scdlInterface->getBoolean("remotable");
+
+ return new CPPInterface(header, className, remotable, false);
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h
new file mode 100644
index 0000000000..04ac9f6970
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_cppinterfaceextension_h
+#define tuscany_sca_cpp_cppinterfaceextension_h
+
+#include "tuscany/sca/extension/InterfaceExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ class CPPInterfaceExtension : public InterfaceExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ CPPInterfaceExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~CPPInterfaceExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema type for this interface extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::Interface* getInterface(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlInterface);
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppinterfaceextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp
new file mode 100644
index 0000000000..cc45ea9fb8
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp
@@ -0,0 +1,192 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/cpp/model/CPPReferenceBinding.h"
+
+using namespace std;
+using namespace osoa::sca;
+using namespace tuscany::sca::model;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ CPPServiceProxy::CPPServiceProxy(Reference* reference)
+ : ServiceProxy(reference)
+ {
+ logentry();
+
+ // ----------------------
+ // Get the component
+ // ----------------------
+ Component* component = reference->getComponent();
+ string name = reference->getType()->getName();
+
+ // Get the service wrapper
+ CPPReferenceBinding* referenceBinding = (CPPReferenceBinding*)reference->getBinding();
+
+ ServiceWrapper* serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
+
+ createProxy(component, name, serviceWrapper);
+ }
+
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ CPPServiceProxy::CPPServiceProxy(Service* service)
+ : ServiceProxy(0)
+ {
+ logentry();
+
+ // ----------------------
+ // Get the component
+ // ----------------------
+ Component* component = service->getComponent();
+ string name = service->getType()->getName();
+
+ // Get the service wrapper
+ ServiceWrapper* serviceWrapper = service->getBinding()->getServiceWrapper();
+
+ createProxy(component, name, serviceWrapper);
+ }
+
+ void CPPServiceProxy::createProxy(Component* component, const string& name, ServiceWrapper* serviceWrapper)
+ {
+ logentry();
+
+ ComponentType* componentType = component->getType();
+ if (!componentType)
+ {
+ string msg = "Component " + component->getName() + " has no implementation defined";
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+
+ // If we got here we have a CPP implementation
+ CPPImplementation* impl = (CPPImplementation *)componentType;
+
+ // ----------------------------------------------------
+ // Get implementation dll name and service factory name
+ // ----------------------------------------------------
+ string library = impl->getLibrary();
+ string headerStub = impl->getHeaderStub();
+
+ string fullLibraryName = component->getComposite()->getRoot() + "/" + library;
+ string proxyFactoryName = headerStub + "_" + name + "_Proxy_Factory";
+ string proxyDestructorName = headerStub + "_" + name + "_Proxy_Destructor";
+ typedef void* (* PROXYFACTORY) (ServiceWrapper*);
+
+ // ------------
+ // Load the dll
+ // ------------
+ proxyLibrary = Library(fullLibraryName);
+
+ // -------------------------
+ // Locate the factory method
+ // -------------------------
+ PROXYFACTORY proxyFactory = (PROXYFACTORY)proxyLibrary.getSymbol(proxyFactoryName);
+ if (!proxyFactory)
+ {
+ logerror("Unable to locate %s in library %s",
+ proxyFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Unable to locate " + proxyFactoryName + " in library " + fullLibraryName;
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+
+ // -----------------------------------
+ // Now create an instance of the proxy
+ // -----------------------------------
+ void* proxy = proxyFactory(serviceWrapper);
+ if (!proxy)
+ {
+ logerror("Factory method %s in library %s returned null",
+ proxyFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Factory method " + proxyFactoryName + " in library " + fullLibraryName + " returned null";
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+ else
+ {
+ proxies.push_back(proxy);
+ }
+
+ // -------------------------
+ // Get the destructor method
+ // -------------------------
+ destructor = (PROXYDESTRUCTOR)proxyLibrary.getSymbol(proxyDestructorName);
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ CPPServiceProxy::~CPPServiceProxy()
+ {
+ logentry();
+
+ // Delete the proxies
+ if (destructor != NULL && proxies.size() != 0)
+ {
+ destructor(*proxies.begin());
+ }
+ }
+
+ CPPServiceProxy::PROXIES CPPServiceProxy::getProxies()
+ {
+ return proxies;
+ }
+
+ void* CPPServiceProxy::getProxy()
+ {
+ logentry();
+
+ if (proxies.size() != 0)
+ {
+ return *proxies.begin();
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h
new file mode 100644
index 0000000000..8406e9bc44
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_cpp_cppserviceproxy_h
+#define tuscany_sca_cpp_cppserviceproxy_h
+
+#include "osoa/sca/export.h"
+
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ /**
+ * Holds a proxy for a given component and reference.
+ * The proxy which is held inside a ServiceProxy will be specific to the component
+ * and reference and will have been code generated and be contained in a dll
+ * created by a developer of an SCA application.
+ */
+ class CPPServiceProxy : public ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a reference. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The reference on the source component.
+ * @param target The wrapper of the service which is wired to this reference.
+ */
+ CPPServiceProxy(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Create a new service proxy for a service. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The service on the target component.
+ * @param target The wrapper of the target service.
+ */
+ CPPServiceProxy(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPServiceProxy();
+
+ /**
+ * Return an instance of the proxy created for this particular component and reference.
+ * @return The proxy.
+ */
+ virtual void* getProxy();
+
+ /**
+ * Return the proxies created for this particular component and reference.
+ * @return The proxies.
+ */
+ typedef std::list<void*> PROXIES;
+ virtual PROXIES getProxies();
+
+ private:
+
+ /**
+ * Create the proxy
+ */
+ void createProxy(tuscany::sca::model::Component* component,
+ const std::string& name,
+ ServiceWrapper* serviceWrapper);
+
+ /**
+ * Holds the instances of the code generated proxies.
+ */
+ PROXIES proxies;
+
+ /**
+ * A function pointer to the destructor of the proxy.
+ */
+ typedef void (* PROXYDESTRUCTOR) (void*);
+ PROXYDESTRUCTOR destructor;
+
+ /**
+ * The library which contains the code for the proxy.
+ */
+ tuscany::sca::util::Library proxyLibrary;
+
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppserviceproxy_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp
new file mode 100644
index 0000000000..fbf8281178
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp
@@ -0,0 +1,198 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/cpp/CPPServiceWrapper.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/model/Interface.h"
+
+using namespace std;
+using namespace osoa::sca;
+using namespace tuscany::sca::model;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ===================
+ // Static data members
+ // ===================
+ void* CPPServiceWrapper::staticImpl = 0;
+
+ // ===========
+ // Constructor
+ // ===========
+ CPPServiceWrapper::CPPServiceWrapper(Service* service)
+ : ServiceWrapper(service)
+ {
+ logentry();
+
+ component = service->getComponent();
+ interf = service->getType()->getInterface();
+ implementation = (CPPImplementation*)component->getType();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ CPPServiceWrapper::~CPPServiceWrapper()
+ {
+ logentry();
+ }
+
+
+ // ======================================================================
+ // getImplementation: get an implementation for this scope
+ // ======================================================================
+ void* CPPServiceWrapper::getImplementation()
+ {
+ logentry();
+ if (implementation->getScope() == CPPImplementation::COMPOSITE)
+ {
+ if (!staticImpl)
+ {
+ staticImpl = newImplementation();
+ }
+ return staticImpl;
+ }
+ else // (scope == CPPInterface::STATELESS)
+ {
+ return newImplementation();
+ }
+ }
+
+ // ======================================================================
+ // releaseImplementation: release the implementation for this scope
+ // ======================================================================
+ void CPPServiceWrapper::releaseImplementation()
+ {
+ logentry();
+ if (implementation->getScope() == CPPImplementation::STATELESS)
+ {
+ deleteImplementation();
+ }
+ }
+
+ // ======================================================================
+ // invoke: wrapper call to service with setting the component context
+ // ======================================================================
+ void CPPServiceWrapper::invoke(Operation& operation)
+ {
+ logentry();
+
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ runtime->setCurrentComponent(component);
+
+ try
+ {
+ invokeService(operation);
+ }
+ catch (...)
+ {
+ runtime->unsetCurrentComponent();
+ throw;
+ }
+ runtime->unsetCurrentComponent();
+ }
+
+ void CPPServiceWrapper::setLibrary(Library* lib)
+ {
+ wrapperLibrary = lib;
+ }
+
+ // ======================================================================
+ // getServiceWrapper: create a wrapper for the target ComponentService
+ // ======================================================================
+ CPPServiceWrapper* CPPServiceWrapper::getServiceWrapper(Service* service)
+ {
+ logentry();
+
+ CPPServiceWrapper* serviceWrapper = 0;
+
+ // -----------------------------------------------
+ // Get the implementation for the target component
+ // -----------------------------------------------
+ Component* component = service->getComponent();
+ CPPImplementation* impl = (CPPImplementation*)component->getType();
+ if (!impl)
+ {
+ string msg = "Component " + component->getName() + " has no implementation defined";
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+
+ // ----------------------------------------------------
+ // Get implementation dll name and wrapper factory name
+ // ----------------------------------------------------
+ string libraryName = impl->getLibrary();
+ string wrapperFactoryName = impl->getHeaderStub()
+ + "_" + service->getType()->getName() + "_Wrapper_Factory";
+
+ // ------------
+ // Load the dll
+ // ------------
+ string fullLibraryName = component->getComposite()->getRoot() + "/" + libraryName;
+ typedef CPPServiceWrapper* (* WRAPPERFACTORY) (Service*);
+ Library* wrapperLib = new Library(fullLibraryName);
+
+ // -------------------------
+ // Locate the factory method
+ // -------------------------
+ WRAPPERFACTORY wrapperFactory = (WRAPPERFACTORY)wrapperLib->getSymbol(wrapperFactoryName);
+ if (!wrapperFactory)
+ {
+ logerror("Unable to locate %s in library %s",
+ wrapperFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Unable to locate " + wrapperFactoryName + " in library " + fullLibraryName;
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+
+ // -------------------------------------
+ // Now create an instance of the wrapper
+ // -------------------------------------
+ serviceWrapper = wrapperFactory(service);
+ if (!serviceWrapper)
+ {
+ logerror("Factory method %s in library %s returned null",
+ wrapperFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Factory method " + wrapperFactoryName + " in library " + fullLibraryName + " returned null";
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+ serviceWrapper->setLibrary(wrapperLib);
+
+ return serviceWrapper;
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h
new file mode 100644
index 0000000000..e8111b6423
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h
@@ -0,0 +1,160 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_cppservicewrapper_h
+#define tuscany_sca_cpp_cppservicewrapper_h
+
+#include "osoa/sca/export.h"
+
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/util/Library.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ /**
+ * Wraps the service on a component implementation.
+ * This abstract class is extended by generated code which provides
+ * the implementation of some of the methods.
+ * An instance of this class wraps the actual component implementation which
+ * has been written by a developer of an SCA application.
+ */
+ class SCA_CPP_API CPPServiceWrapper : public ServiceWrapper
+ {
+ public:
+ /**
+ * Factory method to create a new CPPServiceWrapper for a given target
+ * service. This method will provide all the loading of dlls required to
+ * create the target component.
+ * @param target The service on the component for which this wrapper is to be
+ * created.
+ * @return A wrapper that references the given target.
+ */
+ static CPPServiceWrapper* getServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Constructor.
+ * @param target The component service to which this wrapper refers.
+ */
+ CPPServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPServiceWrapper();
+
+ /**
+ * All business method calls to the target component go through the invoke method.
+ * @param operation The details of the method, paramaters and return value for the
+ * business method to be called on the target component.
+ */
+ virtual void invoke(Operation& operation);
+
+ /**
+ * Return the loaded shared library for the target component.
+ */
+ tuscany::sca::util::Library* getLibrary() const { return wrapperLibrary; }
+
+ protected:
+
+ /**
+ * Delegated method to invoke the correct method on the target component.
+ * Implemented by the subtype.
+ */
+ virtual void invokeService(Operation& operation) = 0;
+
+ /**
+ * Delegated method to create a new component implementation.
+ * Implemented by the subtype.
+ * @return A pointer to an instance of the component implementation class.
+ */
+ virtual void* newImplementation() = 0;
+
+ /**
+ * Delegated method to delete the current instance of the component
+ * implementation.
+ * Implemented by the subtype.
+ */
+ virtual void deleteImplementation() = 0;
+
+ /**
+ * Return the current instance of the component implementation.
+ * @return A pointer to an instance of the component implementation class.
+ */
+ virtual void* getImplementation();
+
+ /**
+ * Indicates that the current instance of the component implementation
+ * has been finished with.
+ * Will call CPPServiceWrapper#deleteImplementation if the
+ * implementation is stateless (so that a new instance is returned
+ * for each call).
+ */
+ virtual void releaseImplementation();
+
+ private:
+ /**
+ * Holds an implementation instance if the scope is set to composite.
+ */
+ static void* staticImpl;
+
+ /**
+ * The component to which this wrapper refers.
+ */
+ tuscany::sca::model::Component* component;
+
+ /**
+ * A pointer to the interface which the service exposes.
+ */
+ tuscany::sca::model::Interface* interf;
+
+ /**
+ * The component implementation
+ */
+ CPPImplementation* implementation;
+
+ /**
+ * Pointer to the loaded library which contains the component
+ * implementation.
+ */
+ tuscany::sca::util::Library* wrapperLibrary;
+
+ /**
+ * Set the loaded library which contains the component
+ * implementation.
+ * @param lib The library.
+ */
+ void setLibrary(tuscany::sca::util::Library* lib);
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppservicewrapper_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp
new file mode 100644
index 0000000000..3de0cb968c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp
@@ -0,0 +1,208 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/ComponentContextImpl.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ReferenceBinding.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+
+using namespace std;
+using namespace osoa::sca;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ===========
+ // Constructor
+ // ===========
+ ComponentContextImpl::ComponentContextImpl(Component* comp)
+ : ComponentContext(0), component(comp)
+ {
+ logentry();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ComponentContextImpl::~ComponentContextImpl()
+ {
+ logentry();
+ }
+
+
+ // ==========================================================================
+ // getServices: return a list of Proxies for services wired to this reference
+ // ==========================================================================
+ std::list<void*> ComponentContextImpl::getServices(const std::string& referenceName)
+ {
+ logentry();
+ try
+ {
+ // --------------------------------------------------------------
+ // locate reference in the current component and determine target
+ // --------------------------------------------------------------
+ Reference* reference = component->findReference(referenceName);
+ if (!reference)
+ {
+ string message = "Reference not defined: ";
+ message = message + referenceName;
+ throwException(ServiceNotFoundException, message.c_str());
+ }
+
+ // Get a service proxy from the binding configured on the reference
+ CPPServiceProxy* serviceProxy = (CPPServiceProxy*)reference->getBinding()->getServiceProxy();
+ if (serviceProxy == NULL)
+ {
+ string message = "Reference ";
+ message = message + referenceName + " not wired";
+ throwException(ServiceNotFoundException, message.c_str());
+ }
+
+ return serviceProxy->getProxies();
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+
+ } // End getServices()
+
+
+ // ===================================================================
+ // getService: return a Proxy for the services wired to this reference
+ // ===================================================================
+ void* ComponentContextImpl::getService(const std::string& referenceName)
+ {
+ logentry();
+ try
+ {
+ // --------------------------------------------------------------
+ // locate reference in the current component and determine target
+ // --------------------------------------------------------------
+ Reference* reference = component->findReference(referenceName);
+ if (!reference)
+ {
+ string message = "Reference not defined: ";
+ message = message + referenceName;
+ throwException(ServiceNotFoundException, message.c_str());
+ }
+
+ // --------------------
+ // Validate the request
+ // --------------------
+ switch (reference->getType()->getMultiplicity())
+ {
+ case ReferenceType::ZERO_MANY:
+ case ReferenceType::ONE_MANY:
+ {
+ string message = "getService() called for reference with multiplicity >1 :";
+ message = message + referenceName;
+ throwException(ServiceNotFoundException, message.c_str());
+ }
+ default:
+ {
+ }
+ } // end switch
+
+ // Get a service proxy from the binding configured on the reference
+ CPPServiceProxy* serviceProxy = (CPPServiceProxy*)reference->getBinding()->getServiceProxy();
+ if (serviceProxy == NULL)
+ {
+ string message = "Reference ";
+ message = message + referenceName + " not wired";
+ throwException(ServiceNotFoundException, message.c_str());
+ }
+
+ void* service = serviceProxy->getProxy();
+
+ return service;
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+
+ } // End getService()
+
+ // ==============================================
+ // getProperties: return the component properties
+ // ==============================================
+ DataObjectPtr ComponentContextImpl::getProperties()
+ {
+ logentry();
+ try
+ {
+ DataObjectPtr properties = component->getProperties();
+ return properties;
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ // ==============================================
+ // getDataFactory: return the data factory for the composite in which
+ // this component resides
+ // ==============================================
+ commonj::sdo::DataFactoryPtr ComponentContextImpl::getDataFactory()
+ {
+ logentry();
+ try
+ {
+ commonj::sdo::DataFactoryPtr dataFactory = component->getComposite()->getDataFactory();
+ return dataFactory;
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h
new file mode 100644
index 0000000000..412c276d8c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_componentcontextimpl_h
+#define tuscany_sca_cpp_componentcontextimpl_h
+
+#include "osoa/sca/ComponentContext.h"
+
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ /**
+ * Contains the actual implementation of a ComponentContext interface.
+ */
+ class ComponentContextImpl : public osoa::sca::ComponentContext
+ {
+
+ public:
+ /**
+ * Constructor that takes a Component which represents the runtime
+ * model for this context.
+ */
+ ComponentContextImpl(tuscany::sca::model::Component* component);
+
+ /**
+ * Default constructor.
+ */
+ virtual ~ComponentContextImpl();
+
+ /**
+ * See ComponentContext.
+ */
+ virtual void* getService(const std::string& referenceName);
+
+ /**
+ * See ComponentContext.
+ */
+ virtual std::list<void*> getServices(const std::string& referenceName);
+
+ /**
+ * See ComponentContext.
+ */
+ virtual commonj::sdo::DataObjectPtr getProperties();
+
+ /**
+ * See ComponentContext.
+ */
+ virtual commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Returns the contained Component.
+ * @return The Component to which this context refers.
+ */
+ virtual tuscany::sca::model::Component* getComponent() {return component;}
+
+ private:
+ ComponentContextImpl(const ComponentContextImpl&);
+ ComponentContextImpl& operator=(const ComponentContextImpl&);
+
+ /**
+ * Pointer to the runtime model Component to which this
+ * context refers.
+ */
+ tuscany::sca::model::Component* component;
+
+ /**
+ * Helper method to return a proxy to a service.
+ * @param serviceReference The source reference.
+ * @param target The target to which this source reference is wired.
+ * @return A pointer to an object which can be cast to the business
+ * class representing the target.
+ */
+ void* getServiceProxy(
+ tuscany::sca::model::Reference* serviceReference,
+ tuscany::sca::model::Service* target);
+
+ /**
+ * Helper method to return a wrapper for a target service.
+ * @param target The target for which this wrapper is to be created.
+ * @return The service wrapper.
+ */
+ ServiceWrapper* getServiceWrapper(tuscany::sca::model::Service* target);
+
+ };
+
+ } // End namespaca cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_componentcontextimpl_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp
new file mode 100644
index 0000000000..ae8183231e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp
@@ -0,0 +1,128 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/CompositeContextImpl.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace osoa::sca;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ===========
+ // Constructor
+ // ===========
+ CompositeContextImpl::CompositeContextImpl(Component* component)
+ : CompositeContext(0), component(component), composite((Composite*)component->getType())
+ {
+ logentry();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ CompositeContextImpl::~CompositeContextImpl()
+ {
+ logentry();
+ }
+
+ // ===========================================================================
+ // locateService: return a proxy connected to a wrapper for the target service
+ // ===========================================================================
+ void* CompositeContextImpl::locateService(const std::string& serviceName)
+ {
+ logentry();
+ try
+ {
+ // ----------------------------
+ // Locate the component service
+ // ----------------------------
+ Service* service = composite->findComponentService(serviceName);
+ string msg;
+ if (!service)
+ {
+ msg = "Service not found: ";
+ msg = msg + serviceName;
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+
+ // ----------------------------
+ // Get a Proxy for this service
+ // ----------------------------
+
+ // The locate service API is used from CPP clients so we are using
+ // our default service proxy here
+ CPPServiceProxy* serviceProxy = new CPPServiceProxy(service);
+ return serviceProxy->getProxy();
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ // ==============================================
+ // getDataFactory: return the data factory for the current composite
+ // ==============================================
+ DataFactoryPtr CompositeContextImpl::getDataFactory()
+ {
+ logentry();
+ try
+ {
+ DataFactoryPtr dataFactory = composite->getDataFactory();
+ return dataFactory;
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h
new file mode 100644
index 0000000000..ed0bb8b51c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_compositecontextimpl_h
+#define tuscany_sca_cpp_compositecontextimpl_h
+
+#include "osoa/sca/CompositeContext.h"
+
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace cpp
+ {
+
+ /**
+ * Contains the actual implementation of a CompositeContext interface.
+ */
+ class CompositeContextImpl : public osoa::sca::CompositeContext
+ {
+
+ public:
+ /**
+ * Constructor that takes a Composite which represents the runtime
+ * model for this context.
+ */
+ CompositeContextImpl(tuscany::sca::model::Component* component);
+
+ /**
+ * See CompositeContext#locateService.
+ */
+ virtual void* locateService(const std::string& serviceName);
+
+ /**
+ * See CompositeContext.
+ */
+ virtual commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Destructor.
+ */
+ virtual ~CompositeContextImpl();
+
+ private:
+ CompositeContextImpl(const CompositeContextImpl&);
+ CompositeContextImpl& operator=(const CompositeContextImpl&);
+
+ /**
+ * Pointer to the runtime model Composite object to which this
+ * context refers.
+ */
+ tuscany::sca::model::Composite* composite;
+
+ /**
+ * Pointer to the runtime model Component object to which this
+ * context refers.
+ */
+ tuscany::sca::model::Component* component;
+
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_compositecontextimpl_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp
new file mode 100644
index 0000000000..f8aad90f7a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/cpp/TuscanyRuntime.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ===================================================================
+ // Constructor for the TuscanyRuntime class.
+ // ===================================================================
+ TuscanyRuntime::TuscanyRuntime(const string& componentName, const string& root, const string& path)
+ {
+ logentry();
+ loginfo("System root: %s", root.c_str());
+ systemRoot = root;
+ loginfo("System path: %s", path.c_str());
+ systemPath = path;
+ loginfo("Default component name: %s", componentName.c_str());
+ defaultComponentName = componentName;
+
+ runtime = new SCARuntime("", systemRoot, systemPath, "", defaultComponentName);
+ }
+
+ // ===================================================================
+ // Destructor for the TuscanyRuntime class.
+ // ===================================================================
+ TuscanyRuntime::~TuscanyRuntime()
+ {
+ logentry();
+
+ delete (SCARuntime*)runtime;
+ }
+
+ // ===================================================================
+ // Start the runtime.
+ // ===================================================================
+ void TuscanyRuntime::start()
+ {
+ logentry();
+ SCARuntime::setCurrentRuntime((SCARuntime*)runtime);
+ }
+
+ // ===================================================================
+ // Stop the runtime.
+ // ===================================================================
+ void TuscanyRuntime::stop()
+ {
+ logentry();
+ SCARuntime::setCurrentRuntime(NULL);
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h
new file mode 100644
index 0000000000..b4cf31220a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_tuscanyruntime_h
+#define tuscany_sca_cpp_tuscanyruntime_h
+
+#include <string>
+
+#include "osoa/sca/export.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ /**
+ * A singleton which represents the executing SCA runtime.
+ */
+ class SCA_CPP_API TuscanyRuntime
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ TuscanyRuntime(const std::string& defaultComponentName = "",
+ const std::string& root = "", const std::string& path = "");
+
+ /**
+ * Destructor
+ */
+ virtual ~TuscanyRuntime();
+
+ /**
+ * start the runtime
+ */
+ void start();
+
+ /**
+ * stop the runtime
+ */
+ void stop();
+
+
+ private:
+ std::string systemRoot;
+ std::string systemPath;
+ std::string defaultComponentName;
+
+ void* defaultComponent;
+ void* runtime;
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_tuscanyruntime_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp
new file mode 100644
index 0000000000..9e5a227f01
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/cpp/model/CPPServiceBinding.h"
+#include "tuscany/sca/cpp/model/CPPReferenceBinding.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace cpp
+ {
+
+ // Constructor
+ CPPImplementation::CPPImplementation(Composite* composite, const string& library, const string& header,
+ const string&headerPath, const string& headerStub, const string& className, Scope scope)
+ : ComponentType(composite, headerPath + headerStub),
+ library(library), header(header), headerPath(headerPath),
+ headerStub(headerStub), className(className), scope(scope)
+ {
+ }
+
+ CPPImplementation::~CPPImplementation()
+ {
+ }
+
+ void CPPImplementation::initializeComponent(Component* component)
+ {
+ ComponentType::initializeComponent(component);
+
+ // Create CPP bindings for all the services
+ const Component::SERVICE_MAP& services = component->getServices();
+ Component::SERVICE_MAP::const_iterator iter = services.begin();
+ for (unsigned int i=0; i< services.size(); i++)
+ {
+ Service *service = iter->second;
+ CPPServiceBinding* binding = new CPPServiceBinding(service);
+ service->setBinding(binding);
+ iter++;
+ }
+
+ // Create CPP bindings for all the references
+ const Component::REFERENCE_MAP& references = component->getReferences();
+ Component::REFERENCE_MAP::const_iterator refiter = references.begin();
+ for (unsigned int ri=0; ri< references.size(); ri++)
+ {
+ Reference *reference = refiter->second;
+ CPPReferenceBinding* binding = new CPPReferenceBinding(reference);
+ reference->setBinding(binding);
+ refiter++;
+ }
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h
new file mode 100644
index 0000000000..11f487361d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_model_cppimplementation_h
+#define tuscany_sca_cpp_model_cppimplementation_h
+
+#include <map>
+#include <string>
+
+#include "tuscany/sca/model/ComponentType.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ /**
+ * Holds information about an SCA implementation written in C++
+ */
+ class CPPImplementation : public tuscany::sca::model::ComponentType
+ {
+
+ public:
+ /**
+ * Scope of the component implementation.
+ */
+ enum Scope
+ {
+ COMPOSITE,
+ STATELESS
+ };
+
+ /**
+ * Constructor.
+ * @param dllName Name of the shared library.
+ * @param header Name of the header file that contains the class declaring the
+ * implementation class.
+ * @param className Name of the class in the header file (could be a blank string
+ * if this is not specified).
+ */
+ CPPImplementation(tuscany::sca::model::Composite* composite,
+ const std::string& library, const std::string& header, const std::string&headerPath,
+ const std::string& headerStub, const std::string& className, Scope scope);
+
+ /**
+ * Destructor
+ */
+ virtual ~CPPImplementation();
+
+ /**
+ * Initialize a component of this type.
+ * @param component The component to initialize.
+ */
+ virtual void initializeComponent(tuscany::sca::model::Component* component);
+
+ /**
+ * Returns the name of the shared library.
+ * @return The name of the shared library.
+ */
+ const std::string& getLibrary() const { return library; }
+
+ /**
+ * Get the name of the header file.
+ * @return Name of the header file.
+ */
+ const std::string& getHeader() const { return header; }
+
+ /**
+ * Get the header file name without the extension.
+ * @return The name of the header file without any extension.
+ */
+ const std::string& getHeaderStub() const { return headerStub; }
+
+ /**
+ * Get the header path.
+ * @return The pathe element of the header.
+ */
+ const std::string& getHeaderPath() const { return headerPath; }
+
+ /**
+ * Get the name of the class.
+ * @return The class name if specified.
+ */
+ const std::string& getClass() const { return className; }
+
+ /**
+ * Returns the implementation scope
+ */
+ Scope getScope() { return scope; }
+
+ private:
+
+ /**
+ * Name of the shared library.
+ */
+ std::string library;
+
+ /**
+ * Name of the header file describing the interface.
+ */
+ std::string header;
+
+ /**
+ * Name of the header file without the extension.
+ */
+ std::string headerStub;
+
+ /**
+ * Path element of the header.
+ */
+ std::string headerPath;
+
+ /**
+ * Name of the class in the header file declaring the implementation.
+ * May be an empty string if not set in the SCDL file.
+ */
+ std::string className;
+
+ /**
+ * Scope of the implementation
+ */
+ Scope scope;
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_model_cppimplementation_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp
new file mode 100644
index 0000000000..2322d1bdf5
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/cpp/model/CPPInterface.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ const string CPPInterface::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPInterface");
+
+ // Constructor
+ CPPInterface::CPPInterface(
+ const string& header,
+ const string& className,
+ bool remotable,
+ bool conversational)
+ : Interface(remotable, conversational), header(header), className(className)
+ {
+ string::size_type dot = header.rfind(".h"); // this will also find .hpp
+ if (dot != string::npos)
+ {
+ headerStub = header.substr(0, dot);
+ }
+ else
+ {
+ headerStub = header;
+ }
+
+ }
+
+ CPPInterface::~CPPInterface()
+ {
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h
new file mode 100644
index 0000000000..fdbf314d3d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_model_cppinterface_h
+#define tuscany_sca_cpp_model_cppinterface_h
+
+#include <string>
+
+#include "tuscany/sca/model/Interface.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ /**
+ * Holds information about an interface described using a C++
+ * header file.
+ */
+ class CPPInterface : public tuscany::sca::model::Interface
+ {
+
+ public:
+ /**
+ * Constuctor.
+ * @param header Name of the header file containing the class that
+ * describes the interface.
+ * @param className Name of the class in the header file that
+ * describes the interface.
+ * @param scope The scope of the interface (stateless or composite).
+ * @param remotable True if the interface is remotable.
+ */
+ CPPInterface(
+ const std::string& header,
+ const std::string& className,
+ bool remotable,
+ bool conversational);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPInterface();
+
+ /**
+ * Get the name of the header file.
+ * @return The name of the header file containing the definition of the
+ * interface.
+ */
+ const std::string& getHeader() { return header; }
+
+ /**
+ * Return the name of the header file without the extension.
+ * @return Header file name without any extension.
+ */
+ const std::string& getHeaderStub() { return headerStub; }
+
+ /**
+ * Get the name of the class.
+ * @return The name of the class defining the interface.
+ */
+ const std::string& getClass() { return className; }
+
+ /**
+ * return the QName of the schema type for this interface type
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp")
+ */
+ virtual const std::string& getInterfaceTypeQName() { return typeQName; };
+
+ private:
+
+ /**
+ * Name of the header file containing the definition of the interface.
+ */
+ std::string header;
+
+ /**
+ * Name of the header file without the extension.
+ */
+ std::string headerStub;
+
+ /**
+ * Name of the class in the header file.
+ */
+ std::string className;
+
+ /**
+ * The QName of the schema type for this interface type.
+ */
+ static const std::string typeQName;
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_model_cppinterface_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp
new file mode 100644
index 0000000000..ba20a1d5a0
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/model/CPPReferenceBinding.h"
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+
+using namespace tuscany::sca::model;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // Constructor
+ CPPReferenceBinding::CPPReferenceBinding(Reference* reference)
+ : ReferenceBinding(reference, ""), serviceProxy(NULL), targetServiceBinding(NULL)
+ {
+ }
+
+ // Destructor
+ CPPReferenceBinding::~CPPReferenceBinding()
+ {
+ }
+
+ ServiceProxy* CPPReferenceBinding::getServiceProxy()
+ {
+ return serviceProxy;
+ }
+
+ void CPPReferenceBinding::configure(ServiceBinding* binding)
+ {
+ targetServiceBinding = binding;
+
+ serviceProxy = new CPPServiceProxy(getReference());
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h
new file mode 100644
index 0000000000..398417011f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_model_cppreferencebinding_h
+#define tuscany_sca_cpp_model_cppreferencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ /**
+ * Information about a CPP service binding for service or a reference.
+ */
+ class CPPReferenceBinding : public tuscany::sca::model::ReferenceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ * @param port The definition of the port to which the entrypoint
+ * or external service is to be bound. This is of the form
+ * "namespace"#endpoint("service"/"port")
+ */
+ CPPReferenceBinding(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPReferenceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#CPPImplementationBinding"; };
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ virtual ServiceProxy* getServiceProxy();
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding);
+
+ /**
+ * Returns the target service binding.
+ */
+ tuscany::sca::model::ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; };
+
+ private:
+
+ /**
+ * The proxy representing the reference to the client
+ * component.
+ */
+ ServiceProxy* serviceProxy;
+
+ /**
+ * The service binding of the target
+ */
+ tuscany::sca::model::ServiceBinding* targetServiceBinding;
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_model_cppreferencebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp
new file mode 100644
index 0000000000..45afea8375
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/model/CPPServiceBinding.h"
+#include "tuscany/sca/cpp/CPPServiceWrapper.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // Constructor
+ CPPServiceBinding::CPPServiceBinding(Service* service)
+ : ServiceBinding(service, "")
+ {
+ serviceWrapper = CPPServiceWrapper::getServiceWrapper(service);
+ }
+
+ // Destructor
+ CPPServiceBinding::~CPPServiceBinding()
+ {
+ }
+
+ ServiceWrapper* CPPServiceBinding::getServiceWrapper()
+ {
+ return (ServiceWrapper*)serviceWrapper;
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h
new file mode 100644
index 0000000000..13b88a84dd
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_model_cppservicebinding_h
+#define tuscany_sca_cpp_model_cppservicebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ServiceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ /**
+ * Information about a CPP service binding for service or a reference.
+ */
+ class CPPServiceBinding : public tuscany::sca::model::ServiceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ * @param port The definition of the port to which the entrypoint
+ * or external service is to be bound. This is of the form
+ * "namespace"#endpoint("service"/"port")
+ */
+ CPPServiceBinding(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPServiceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#CPPImplementationBinding"; };
+
+ /**
+ * Create a wrapper for the service configured by this
+ * binding.
+ */
+ virtual ServiceWrapper* getServiceWrapper();
+
+ private:
+
+ /**
+ * The wrapper for the service configured by this binding.
+ */
+ ServiceWrapper* serviceWrapper;
+
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_model_cppservicebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd
new file mode 100644
index 0000000000..7292f747b8
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd
@@ -0,0 +1,49 @@
+<?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.
+-->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <element name="implementation.cpp" type="sca:CPPImplementation" substitutionGroup="sca:implementation"/>
+ <complexType name="CPPImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="library" type="NCName" use="required"/>
+ <attribute name="path" type="NCName" use="optional"/>
+ <attribute name="header" type="NCName" use="required"/>
+ <attribute name="class" type="Name" use="optional"/>
+ <attribute name="scope" type="sca:CPPImplementationScope" use="optional" />
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="CPPImplementationScope">
+ <restriction base="string">
+ <enumeration value="stateless" />
+ <enumeration value="composite" />
+ </restriction>
+ </simpleType>
+</schema>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd
new file mode 100644
index 0000000000..585bac0dc4
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd
@@ -0,0 +1,43 @@
+<?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.
+-->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <element name="interface.cpp" type="sca:CPPInterface" substitutionGroup="sca:interface"/>
+ <complexType name="CPPInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="header" type="NCName" use="required" />
+ <attribute name="class" type="Name" use="optional" />
+ <attribute name="callbackHeader" type="NCName" use="optional" />
+ <attribute name="callbackClass" type="Name" use="optional" />
+ <attribute name="remotable" type="boolean" use="optional" />
+ <anyAttribute namespace="##any" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/AUTHORS b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/AUTHORS
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/AUTHORS
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/COPYING b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/COPYING
new file mode 100755
index 0000000000..6b0b1270ff
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/COPYING
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/ChangeLog b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/ChangeLog
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/ChangeLog
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/INSTALL b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/INSTALL
new file mode 100644
index 0000000000..059a43057b
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/INSTALL
@@ -0,0 +1,2 @@
+Please read the GettingStarted.html document for information on
+building and installing Tuscany SCA Native PHP extemstion
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/LICENSE b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/LICENSE
new file mode 100755
index 0000000000..f433b1a53f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/Makefile.am
new file mode 100644
index 0000000000..fb661fec63
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/Makefile.am
@@ -0,0 +1,24 @@
+# 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.
+
+SUBDIRS = src samples
+
+datadir=$(prefix)
+
+nobase_data_DATA = xsd/*.xsd
+
+EXTRA_DIST = xsd \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/NEWS b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/NEWS
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/NEWS
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/NOTICE b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/NOTICE
new file mode 100644
index 0000000000..b240b0a121
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/NOTICE
@@ -0,0 +1,5 @@
+Apache Tuscany SCA Native
+Copyright 2005, 2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/) \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/README b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/README
new file mode 100644
index 0000000000..ad96622516
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/README
@@ -0,0 +1,276 @@
+PHP Extension for C++ SCA README
+================================
+
+Overview
+--------
+
+The PHP extension for C++ SCA allows PHP scripts to be used to implement SCA components.
+This is achieved by using the C++ SCA extension API to drive script execution through the
+PHP embedding SAPI. In its current incarnation the PHP Extension requires that a full SCDL
+description is provided for each PHP component, i.e. we are not yet making use of the meta data
+provided by the annotations that can appear in PHP SCA components.
+
+There are various styles of PHP script that are supported. The examples here are taken from
+the PHPCalculator sample and if you look at the SCDL files provided with the sample you can
+see the component type and composite files that tie these components into the working system
+
+SCA Service
+-----------
+
+/**
+ * @service
+ * @binding.ws
+ */
+class Divide {
+
+ /**
+ * @reference
+ * @binding.tuscany cppDivideService
+ */
+ public $another_divide;
+
+ /**
+ * Division
+ *
+ * @param float $num1 (the first number)
+ * @param float $num2 (the second number)
+ * @return float The result
+ */
+ function div($num1, $num2) {
+ return $this->another_divide->div($num1, $num2);
+ }
+
+}
+
+PHP Class
+---------
+
+class Multiply {
+ function mul($num1, $num2) {
+ $result = $num1 * $num2;
+
+ $log_proxy = SCA::getService("log_service");
+ $log_proxy->log_message($result);
+
+ return $result;
+ }
+}
+
+PHP Function
+------------
+
+function sub($num1, $num2){
+ $result = $num1 - $num2;
+
+ $log_proxy = SCA::getService("log_service");
+ $log_proxy->log_message($result);
+
+ return $result;
+}
+
+PHP Script
+----------
+
+$num1 = $_REQUEST[0];
+$num2 = $_REQUEST[1];
+
+$result = $num1 + $num2;
+
+$log_proxy = SCA::getService("log_service");
+$log_proxy->log_message($result);
+
+echo $result;
+
+TODO
+----
+* I struggled for a long time with a missing symbol problem loading sdo.so at runtime on linux.
+ I got round this by creating a standalone Makefile for the CalculatorClient exe. All the
+ shared objects that are loaded are compiled with the normal automake toolchain still but this
+ solves the problem. I need to investigate in detail what's going on here. Having someone
+ else try building with the full automake configuration would be insteresting
+* The problem from above does appear when running SCA behind axis hence I am unable to test with
+ remote clients
+* The SCA_SDO build generates sdo.so and the Tuscany PHP Extension tries to load libsdo.so.
+ One side needs fixing. For now I just copy the library
+* SDO passing in and out of components is coded but not tested
+* Returning values from plain PHP scripts (scripts without classes and functions) is not
+ operating correctly
+* Error handling needs looking at. Many situations are not trapped and those
+ that are may not be reported correctly
+* Reorganize the extension code so that Tuscany SCA can be loaded by PHP running in Apache
+ and accessed through SCA references. This will play the same role as SCA running hosted
+ in Axis2C and will open up the service bindings implemented in PHP SCA_SDO.
+* Implement meta data exchange between the PHP SCA implementation and the Tuscany C++ SCA
+ implementations so that selected parts of the SCDL definition can be omitted.
+* There is a threading issue with the way that we are firing up the PHP embedding SAPI
+ TSRM should solve it fails on the embedding initialization for some reason.
+
+Dependencies
+------------
+PHP5.2.0 source code - - (http://php.net/)
+ The binary release of PHP doesn't ship with the header files required to build
+ against the PHP embedding SAPI and runtime libraries. So go get the PHP source
+ code and build PHP. PHP will need to be configured correctly in order to
+ work properly when embedded in C++ SCA. Here are some sample configuration
+ statements but they will need to be tailored for you specific environment:
+
+ Winodws
+ -------
+ cscript configure.js --with-extra-includes=win32build\include;
+ libxml2-2.6.26.threads\include;
+ iconv-1.9.1.win32\include;
+ libcurl-7.15.4-nossl\include
+ --with-extra-libs=win32build\lib;
+ libxml2-2.6.26.threads\lib;
+ iconv-1.9.1.win32\lib;
+ libcurl-7.15.4-nossl\lib
+ --enable-debug
+ --enable-soap
+ --enable-apache2handler=shared
+ --enable-embed
+ --with-curl=C:\simon\apps\libcurl-7.15.4-nossl
+
+ Note. This configure line is artificially broken across sever lines to aid
+ readability here. You will need to join it all back together on one line to
+ run it.
+
+ Linux
+ -----
+ ./configure --enable-debug \
+ --enable-soap \
+ --enable-fastcgi \
+ --with-zlib \
+ --enable-embed \
+ --with-tsrm-pthreads \
+ --enable-maintainer-zts
+ Note. debug, pthreads, maintainer-zts, fastcgi are not absolute requirements but just
+ represent the environment I was testing with when I wrote this.
+
+SCA_SDO PECL extension AVOCET branch source code - (http://pecl.php.net/package/SCA_SDO)
+ Provides the SCA framework for PHP and the necessary mediation code to translate
+ between Tuscany SCA and PHP SCA. Go get the AVOCET branch from PECL cvs
+
+ export CVSROOT=:pserver:cvsread@cvs.php.net/repository
+ cvs export -r AVOCET pecl/sdo
+
+ The process to build this code varies quite considerably between windows and Linux.
+ Take a look at the instructions in the SCA_SDO manual, follow the documentation link
+ from the projects PECL page (http://uk2.php.net/sdo/).
+
+ Once built you will need to copy the library sdo.so to
+ libsdo.so so that the Tuscany PHPExtension can load it given the makefile
+ configuration as it stands. For example, on linux
+
+ ln -s sdo.so libsdo.so
+
+
+Building on windows
+-------------------
+
+The Visual C++ Express solution provided with C++ SCA includes a project
+to build the PHP extension. This project relies on being able to access the
+PHP include files from the source code directory and the PHP lib files from the
+binary install. Make sure your environment is set as follows before you start
+Visual C++ Express (if you do this after you start Visual C++ Express it will
+not pick up the changes)
+
+PHP_HOME = the root directory of the PHP 5.2.0 source code install
+PATH = ensure that the root directory of the PHP 5.2.0 binary install appears
+
+PHP_SCA_SDO_HOME = the directory in which the SCA_SDO pecl extension source is installed
+
+These changes come over and above the environment changes you need to make
+to build the core C++ SCA software. I have the following set in my environment but
+of course the details depend on where you have the various bits of software installed.
+
+AXIS2C_HOME=c:\axis2c-bin-0.96-win32
+LIBXML2_HOME=c:\libxml2-2.6.26.ein32
+ICONV_HOME=c:\iconv-1.9.2.win32
+ZLIB_HOME=c:\zlib-1.2.3.win32
+TUSCANY_SCACPP=c:\sca\deploy
+TUSCANY_SDOCPP=c:\sdo\deploy
+
+Now compile the PHP extension. Compiling with VC++ Express requires some care
+
+1/ Ensure that the PHP include files are configured correctly for
+ compiling against C++ SCA in Visual C++ express
+
+ See - http://bugs.php.net/bug.php?id=39130
+
+ Comment out two lines in $(PHP_HOME)/main/config.w32.h:
+ #define _USE_32BIT_TIME_T 1
+ #define HAVE_STDLIB_H 1
+
+
+Building on Linux
+-----------------
+
+The PHP extension comes with a set of automake files so that the PHP extension is built
+at the same time as all of the other extensions assuming that appropriate environment
+variables are set. The build.sh script that can be found under the top level sca directory
+checks whether the PHP_LIB and PHP_INCLUDE variables are set and if so enables compilation
+of the PHP extension automatically by adding --enable-php to the configure line.
+
+There are a number of environment variables that the build depends on. I find setting the
+following variables useful.
+
+# the location of libxm2
+export LIBXML2_LIB=/usr/lib
+export LIBXML2_INCLUDE=/usr/include/libxml2
+
+# the location of PHP
+export PHP_LIB=/usr/local/lib
+export PHP_INCLUDE=/usr/local/include/php
+
+# the location of the PHP SCA_SDO extension source
+# the lib location depends oh the configuration options used
+# when building PHP so beware
+export PHP_SCA_SDO_INCLUDE=where ever you install the SCA_SDO package source
+export PHP_SCA_SDO_LIB=$PHP_LIB/php/extensions/no-debug-zts-20060613/
+
+# the location of axis2
+export AXIS2C_HOME=/usr/local/axis2c-bin-0.96-linux
+
+# the install directories for the tuscany sca and sdo projects
+export TUSCANY_SDOCPP=/usr/local/tuscany/cpp/sdo/deploy
+export TUSCANY_SCACPP=/usr/local/tuscany/cpp/sca/deploy
+
+Once these are set running sca/build.sh should compile and install the PHP extension.
+
+Testing the PHP Extension
+-------------------------
+
+In order to run the PHP extension successfully as an embedded component of the
+C++ SCA runtime the PHP environment must be configured correctly. This configuration
+is provided by the php.ini file. The location of this file depends on your installation
+of PHP but by default is as follows.
+
+/usr/local/bin - PHP executables
+/usr/local/lib/php.ini - the ini file that tell PHP where to look for scripts and
+ extension libraries
+/usr/local/lib/php - PHP runtime installation, extension files and tests
+
+As is usually the case your milage may vary but wherever PHP is installed you will find
+a similar set of directories. To force PHP to look in the correct place use the following
+setting
+
+# tell PHP specifically where to find php.ini rather than relying on the default
+set PHPRC=/usr/local/lib
+
+The php.ini file must be configured to load the SCA_SDO extension so you would expect to
+see the following modifications to the file.
+
+; around line 528 you need to set the variable that tells PHP where to
+; load extension libraries from. This varies depending on how PHP has been
+; compiled and installed, for example,
+extension_dir = "/usr/local/lib/php/extensions/no-debug-zts-20060613/"
+
+; around line 512 you need to set the variable that tells PHP where to
+; load included scripts from. There are windows and unix versions. Here
+; is a Unix example
+include_path=".:/usr/local/lib/php:/usr/local/lib/php/PEAR:/usr/local/tuscany/cppsca/samples/PHPCalculator/deploy/sample.calculator"
+
+; around line 673 you will find the end of the list of enabled extensions. We need to turn
+; on SDO so add the following line. sdo.so should be found in "extension_dir".
+extension=sdo.so
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/VSExpress/tuscany_sca_php.vcproj b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/VSExpress/tuscany_sca_php.vcproj
new file mode 100644
index 0000000000..1a8f668c19
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/VSExpress/tuscany_sca_php.vcproj
@@ -0,0 +1,273 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="tuscany_sca_php"
+ ProjectGUID="{28E45334-1F59-45CB-93EE-FB787D81B6D2}"
+ RootNamespace="tuscany_sca_php"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../runtime/extensions/php/src;../../../deploy/include;&quot;$(TUSCANY_SDOCPP)/include&quot;;&quot;$(PHP_HOME)/main&quot;;&quot;$(PHP_HOME)/sapi/embed&quot;;&quot;$(PHP_HOME)&quot;;&quot;$(PHP_HOME)/zend&quot;;&quot;$(PHP_HOME)/TSRM&quot;;&quot;$(PHP_SCA_SDO_HOME)&quot;"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TUSCANY_SCA_PHP_EXPORTS;ZEND_WIN32;PHP_WIN32;ZTS;ZEND_DEBUG=0"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ DisableLanguageExtensions="false"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="tuscany_sca.lib tuscany_sdo.lib php5embed.lib php_sdo.lib"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="..\..\..\deploy\lib,$(TUSCANY_SDOCPP)\lib,$(PHP_HOME)\Debug_Ts"
+ IgnoreDefaultLibraryNames="MSVCRT"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="..\..\..\runtime\extensions\php\deploy.bat ..\..\..\ Debug"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TUSCANY_SCA_PHP_EXPORTS"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="model"
+ >
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPImplementation.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPImplementation.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPInterface.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPInterface.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPReferenceBinding.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPReferenceBinding.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPServiceBinding.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPServiceBinding.h"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\export.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\php_sca.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPExtension.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPExtension.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPImplementationExtension.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPImplementationExtension.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPInterfaceExtension.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPInterfaceExtension.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPServiceProxy.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPServiceProxy.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPServiceWrapper.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPServiceWrapper.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\sca.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\sca.h"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/autogen.sh b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/autogen.sh
new file mode 100755
index 0000000000..af38864985
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/autogen.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# 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.
+
+for i in "libtoolize --force" aclocal autoconf autoheader
+do
+ echo -n "Running $i..."
+ $i || exit 1
+ echo 'done.'
+done
+
+echo -n 'Running automake...'
+automake --add-missing
+echo 'done.'
+exit 0
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/build.sh b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/build.sh
new file mode 100755
index 0000000000..41e96d0565
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/build.sh
@@ -0,0 +1,55 @@
+#!/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.
+
+SCA_PHP_EXTENSION_HOME=`pwd`
+
+if [ x$TUSCANY_SCACPP = x ]; then
+echo "TUSCANY_SCACPP not set"
+exit;
+fi
+
+echo "Using SCA installed at $TUSCANY_SCACPP"
+
+if [ x$PHP_LIB = x ]; then
+echo "PHP_LIB not set."
+exit;
+elif [ x$PHP_INCLUDE = x ]; then
+echo "PHP_INCLUDE not set."
+exit;
+elif [ x$PHP_SCA_SDO_INCLUDE = x ]; then
+echo "PHP_SCA_SDO_INCLUDE not set."
+exit;
+elif [ x$PHP_SCA_SDO_LIB = x ]; then
+echo "PHP_SCA_SDO_LIB not set."
+exit;
+fi
+echo "Building PHP extension with PHP installed at $PHP_LIB, $PHP_INCLUDE"
+echo "and PHP SCA and SDO installed at $PHP_SCA_SDO_LIB, $PHP_SCA_SDO_INCLUDE"
+
+#cd ${TUSCANY_SCACPP_HOME}/samples
+#./autogen.sh
+
+cd ${SCA_PHP_EXTENSION_HOME}
+./autogen.sh
+
+
+./configure --prefix=${TUSCANY_SCACPP}/extensions/php
+make
+make install
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/configure.ac b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/configure.ac
new file mode 100644
index 0000000000..d68d262b78
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/configure.ac
@@ -0,0 +1,79 @@
+# 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.
+
+dnl run autogen.sh to generate the configure script.
+
+AC_PREREQ(2.59)
+AC_INIT(tuscany_sca_php, 1.0-incubator-M3)
+AC_CANONICAL_SYSTEM
+AM_CONFIG_HEADER(tuscany_sca_php_config.h)
+AM_INIT_AUTOMAKE([tar-ustar])
+AC_PREFIX_DEFAULT(/usr/local/tuscany/sca/extensions/php)
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+AC_PROG_LIBTOOL
+
+# Check for running on Darwin
+AC_MSG_CHECKING([Checking if running on Darwin])
+UNAME=`uname -s`
+if test "x$UNAME" = "xDarwin"; then
+ AC_DEFINE([IS_DARWIN], [1], [Set to 1 when running on Darwin - Mac OSX])
+ AC_MSG_RESULT(yes)
+ AC_SUBST([libsuffix],[".dylib"])
+ is_darwin=true
+else
+ AC_MSG_RESULT(no)
+ AC_SUBST([libsuffix],[".so"])
+ is_darwin=false
+fi
+AM_CONDITIONAL([DARWIN], [test x$is_darmin = xtrue])
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_CHECK_HEADERS([inttypes.h stdlib.h string.h sys/time.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDBOOL
+AC_C_CONST
+AC_C_INLINE
+
+# Checks for library functions.
+AC_FUNC_CLOSEDIR_VOID
+AC_FUNC_STAT
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS([getcwd putenv strdup])
+# AC_CONFIG_SUBDIRS([samples])
+
+
+AC_CONFIG_FILES([Makefile
+ src/Makefile
+ samples/Makefile
+ samples/PHPCalculator/Makefile
+ samples/PHPCalculator/sample.calculator/Makefile
+ samples/PHPCalculator/sample.calculator.client/Makefile
+ ])
+AC_OUTPUT
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/deploy.bat
new file mode 100644
index 0000000000..32d8378803
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/deploy.bat
@@ -0,0 +1,67 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set phpextdir=%extdir%\php
+set srcdir=%rootdir%\runtime\extensions\php\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %phpextdir% mkdir %phpextdir%
+if not exist %phpextdir%\module mkdir %phpextdir%\module
+if not exist %phpextdir%\bin mkdir %phpextdir%\bin
+if not exist %phpextdir%\lib mkdir %phpextdir%\lib
+if not exist %phpextdir%\xsd mkdir %phpextdir%\xsd
+
+del %phpextdir%\bin\tuscany_sca_php.*
+del %phpextdir%\lib\*.lib
+
+@ copy %srcdir%\deploy.bat %phpextdir%
+copy %srcdir%\..\xsd\*.* %phpextdir%\xsd
+
+copy %inpath%\tuscany_sca_php.lib %phpextdir%\lib
+copy %inpath%\tuscany_sca_php.dll %phpextdir%\bin\tuscany_sca_php.dll
+copy %inpath%\tuscany_sca_php.dll %phpextdir%\module
+
+if exist %inpath%\tuscany_sca_php.pdb copy %inpath%\tuscany_sca_php.pdb %phpextdir%\bin
+if exist %inpath%\tuscany_sca_php.pdb copy %inpath%\tuscany_sca_php.pdb %phpextdir%\module
+
+goto end
+:usage
+echo "Usage: deploy <sca-root> <build-output>"
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/Makefile.am
new file mode 100644
index 0000000000..920828ef4f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/Makefile.am
@@ -0,0 +1,18 @@
+# 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.
+
+SUBDIRS = PHPCalculator \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/Makefile.am
new file mode 100644
index 0000000000..fd34c6442a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/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)/samples/PHPCalculator/deploy
+SUBDIRS = sample.calculator sample.calculator.client
+EXTRA_DIST = *.composite
+deploy_DATA = *.composite
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/README b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/README
new file mode 100644
index 0000000000..dbee1f5f85
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/README
@@ -0,0 +1,32 @@
+Tuscany SCA for C++ Samples - PHP Calculator Sample
+===================================================
+
+This is a simple sample to show how an SCA composite can wire together
+a number of components to implement a Calculator service and expose that service as
+to a number of different tpyes of client. The sample components are implemented in various
+ways to demonstrate the different features of the PHP SCA extension.
+
+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
+
+A Python client is used because the work to enable PHP to host SCA is not done yet
+
+Windows
+=======
+tba
+
+Linux
+=====
+
+The make install will deploy this under $TUSCANY_SCACPP/extensions/php/samples
+
+To run the sample
+
+cd $TUSCANY_SCACPP/extensions/php/samples/PHPCalculator/deploy/sample.calculator.client
+./runclient.sh
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.app.composite b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.app.composite
new file mode 100644
index 0000000000..ada4d89a1c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/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/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/Makefile.am
new file mode 100644
index 0000000000..548f9bdcb8
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/Makefile.am
@@ -0,0 +1,24 @@
+# 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)/samples/PHPCalculator/deploy
+clientdir=$(deploydir)/sample.calculator.client
+
+client_DATA = *.py
+client_SCRIPTS = runclient.sh
+EXTRA_DIST = *.py *.php runclient.sh
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/calculator_client.py b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/calculator_client.py
new file mode 100644
index 0000000000..d4b37ee2b2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/calculator_client.py
@@ -0,0 +1,50 @@
+# 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
+# client for the Calculator sample
+
+
+import sys
+import sca
+
+op = sys.argv[1]
+val1 = sys.argv[2]
+val2 = sys.argv[3]
+
+# Locate the calculator service
+calc = sca.locateservice("CalculatorComponent/CalculatorService")
+
+# Invoke the calculator operations
+if op == 'add':
+ result = calc.add(val1, val2)
+
+elif op == 'sub':
+ result = calc.sub(val1, val2)
+
+elif op == 'mul':
+ result = calc.mul(val1, val2)
+
+elif op == 'div':
+ result = calc.div(val1, val2)
+
+
+print "calculator_client: ",op,"(",val1,",",val2,") = ",result
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/runclient.sh b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/runclient.sh
new file mode 100755
index 0000000000..54ebfdbde4
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator.client/runclient.sh
@@ -0,0 +1,48 @@
+#!/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"
+
+if [ x$PYTHON_LIB != x ]; then
+echo "Using Python library installed at $PYTHON_LIB"
+export LD_LIBRARY_PATH=$PYTHON_LIB:$LD_LIBRARY_PATH
+export PATH=$PYTHON_LIB/../bin:$PATH
+fi
+
+export LD_LIBRARY_PATH=$PHP_SCA_SDO_LIB:$TUSCANY_SCACPP/lib:$TUSCANY_SCACPP/extensions/python/lib:$TUSCANY_SDOCPP/lib:$LD_LIBRARY_PATH
+export PYTHONPATH=$TUSCANY_SCACPP/extensions/python/lib:$PYTHONPATH
+
+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
+python calculator_client.py mul 7 6
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Calculator.componentType b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Calculator.componentType
new file mode 100644
index 0000000000..5a6c3a199e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Calculator.componentType
@@ -0,0 +1,31 @@
+<?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.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+
+ <service name="CalculatorService">
+ <interface.php/>
+ </service>
+
+ <reference name="div_service">
+ <interface.php/>
+ </reference>
+
+</componentType>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Calculator.php b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Calculator.php
new file mode 100644
index 0000000000..f0f35bab56
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Calculator.php
@@ -0,0 +1,89 @@
+<?php
+# 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.
+#
+#
+include 'SCA/SCA.php';
+
+/**
+ * @service
+ * @binding.ws
+ */
+class Calculator {
+
+
+ /**
+ * @reference
+ * @binding.php Multiply.php
+ */
+ public $mul_service;
+
+ /**
+ * @reference
+ * @binding.tuscany div_service
+ */
+ public $div_service;
+
+ /**
+ * Addition
+ *
+ * @param float $num1 (the first number)
+ * @param float $num2 (the second number)
+ * @return float The result
+ */
+ function add($num1, $num2) {
+ printf("in Calculator::add");
+ return $num1 + $num2;
+// return $this->add_service->add($num1, $num2);
+ }
+
+ /**
+ * Subtraction
+ *
+ * @param float $num1 (the first number)
+ * @param float $num2 (the second number)
+ * @return float The result
+ */
+ function sub($num1, $num2) {
+ return $num1 - $num2;
+// return $this->sub_service->sub($num1, $num2);
+ }
+
+ /**
+ * Multiplication
+ *
+ * @param float $num1 (the first number)
+ * @param float $num2 (the second number)
+ * @return float The result
+ */
+ function mul($num1, $num2) {
+ return $this->mul_service->mul($num1, $num2);
+ }
+
+ /**
+ * Division
+ *
+ * @param float $num1 (the first number)
+ * @param float $num2 (the second number)
+ * @return float The result
+ */
+ function div($num1, $num2) {
+ return $this->div_service->div($num1, $num2);
+ }
+}
+
+?>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Divide.componentType b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Divide.componentType
new file mode 100644
index 0000000000..b50b20d9c6
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Divide.componentType
@@ -0,0 +1,29 @@
+<?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.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+ <service name="DivideService">
+ <interface.php/>
+ </service>
+
+ <reference name="log_service">
+ <interface.php/>
+ </reference>
+</componentType>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Divide.php b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Divide.php
new file mode 100644
index 0000000000..5a08e5b063
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Divide.php
@@ -0,0 +1,47 @@
+<?php
+# 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.
+#
+#
+
+/**
+ * @service
+ * @binding.php
+ */
+class Divide {
+
+ /**
+ * Division
+ *
+ * @param float $num1 (the first number)
+ * @param float $num2 (the second number)
+ * @return float The result
+ */
+ function div($num1, $num2) {
+
+ $result = $num1 / $num2;
+
+ $log_proxy = SCA::getService("log_service");
+ $log_proxy->log_message($result);
+
+ return $result;
+
+ }
+
+}
+
+?>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Log.componentType b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Log.componentType
new file mode 100644
index 0000000000..f945c6af8c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Log.componentType
@@ -0,0 +1,25 @@
+<?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.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+ <service name="LogService">
+ <interface.php/>
+ </service>
+</componentType>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Log.php b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Log.php
new file mode 100644
index 0000000000..0a955f36d3
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Log.php
@@ -0,0 +1,36 @@
+<?php
+# 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.
+#
+#
+
+/**
+ * @service
+ */
+class Log {
+
+ /**
+ * Log
+ *
+ * @param string $message (the message to be logged)
+ */
+ function log_message($message) {
+ SCA::$logger->toLog('>>> ' . $message);
+ }
+}
+
+?>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Makefile.am
new file mode 100644
index 0000000000..10020c4f03
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/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)/samples/PHPCalculator/deploy
+compositedir=$(deploydir)/sample.calculator
+
+composite_DATA = *.composite *.componentType *.php
+EXTRA_DIST = *.composite *.componentType *.php
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Multiply.php b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Multiply.php
new file mode 100644
index 0000000000..ed2e75edc8
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/Multiply.php
@@ -0,0 +1,39 @@
+<?php
+# 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 'SCA/SCA.php';
+
+class Multiply {
+
+ /**
+ * @reference
+ * @binding.php Log.php
+ */
+ public $log_service;
+
+ function mul($num1, $num2) {
+ $result = $num1 * $num2;
+
+// $this->log_service->log_message($result);
+
+ return $result;
+ }
+}
+
+?>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/sample.calculator.composite b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/sample.calculator.composite
new file mode 100644
index 0000000000..f1a82a70db
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/samples/PHPCalculator/sample.calculator/sample.calculator.composite
@@ -0,0 +1,44 @@
+<?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.php module="Calculator" class="Calculator" scope="composite"/>
+ <reference name="div_service">DivideComponent</reference>
+ </component>
+
+
+ <component name="DivideComponent">
+ <implementation.php module="Divide" class="Divide" scope="composite"/>
+ <reference name="log_service">LogComponent</reference>
+ </component>
+
+ <component name="LogComponent">
+ <implementation.php module="Log" class="Log" scope="composite"/>
+ </component>
+
+
+
+
+
+</composite>
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/Makefile.am
new file mode 100644
index 0000000000..b3622779e6
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/Makefile.am
@@ -0,0 +1,59 @@
+# 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.
+
+libdir=$(prefix)/lib
+lib_LTLIBRARIES = libtuscany_sca_php.la
+
+noinst_HEADERS = \
+tuscany/sca/php/*.h \
+tuscany/sca/php/model/*.h
+
+libtuscany_sca_php_la_SOURCES = \
+tuscany/sca/php/PHPExtension.cpp \
+tuscany/sca/php/PHPImplementationExtension.cpp \
+tuscany/sca/php/PHPInterfaceExtension.cpp \
+tuscany/sca/php/PHPServiceWrapper.cpp \
+tuscany/sca/php/PHPServiceProxy.cpp \
+tuscany/sca/php/sca.cpp \
+tuscany/sca/php/model/PHPImplementation.cpp \
+tuscany/sca/php/model/PHPInterface.cpp \
+tuscany/sca/php/model/PHPReferenceBinding.cpp \
+tuscany/sca/php/model/PHPServiceBinding.cpp
+
+libtuscany_sca_php_la_LIBADD = -L${TUSCANY_SCACPP}/lib -ltuscany_sca \
+ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
+ -L${PHP_LIB} -lphp5 \
+ -L${PHP_SCA_SDO_LIB} -lsdo
+
+INCLUDES = -I${TUSCANY_SCACPP}/include \
+ -I${TUSCANY_SDOCPP}/include \
+ -I${PHP_INCLUDE} \
+ -I${PHP_INCLUDE}/main \
+ -I${PHP_INCLUDE}/Zend \
+ -I${PHP_INCLUDE}/TSRM \
+ -I${PHP_INCLUDE}/sapi/embed \
+ -I${PHP_SCA_SDO_INCLUDE}
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+moduledir=$(prefix)/module
+extension = libtuscany_sca_php$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension) \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp
new file mode 100644
index 0000000000..0ffb660139
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/php/PHPExtension.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/php/PHPImplementationExtension.h"
+#include "tuscany/sca/php/PHPInterfaceExtension.h"
+
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_php_initialize()
+ {
+ tuscany::sca::php::PHPExtension::initialize();
+ }
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+ // ===================================================================
+ // Constructor for the PHPExtension class.
+ // ===================================================================
+ PHPExtension::PHPExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the PHPExtension class.
+ // ===================================================================
+ PHPExtension::~PHPExtension()
+ {
+ logentry();
+ }
+
+ void PHPExtension::initialize()
+ {
+ logentry();
+ SCARuntime::getCurrentRuntime()->registerImplementationExtension(new PHPImplementationExtension());
+ SCARuntime::getCurrentRuntime()->registerInterfaceExtension(new PHPInterfaceExtension());
+ }
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.h
new file mode 100644
index 0000000000..971ed93c86
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.h
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_php_phpextension_h
+#define tuscany_sca_php_phpextension_h
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ class PHPExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ PHPExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~PHPExtension();
+
+ static void initialize();
+
+ private:
+
+ };
+
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_phpextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp
new file mode 100644
index 0000000000..101667302f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/php/PHPImplementationExtension.h"
+#include "tuscany/sca/php/model/PHPImplementation.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+ // ===================================================================
+ // Constructor for the PHPImplementationExtension class.
+ // ===================================================================
+ PHPImplementationExtension::PHPImplementationExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the PHPImplementationExtension class.
+ // ===================================================================
+ PHPImplementationExtension::~PHPImplementationExtension()
+ {
+ logentry();
+ }
+
+ const string PHPImplementationExtension::extensionName("php");
+ const string PHPImplementationExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#PHPImplementation");
+
+ // ===================================================================
+ // loadModelElement - load the info from implementation.php
+ // ===================================================================
+ ComponentType* PHPImplementationExtension::getImplementation(Composite *composite, DataObjectPtr scdlImplementation)
+ {
+ logentry();
+
+ string module = scdlImplementation->getCString("module");
+ string className = scdlImplementation->getCString("class");
+
+ PHPImplementation* phpImpl = new PHPImplementation(composite, module, className);
+
+ return phpImpl;
+ }
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h
new file mode 100644
index 0000000000..604c4ea102
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_php_phpimplementationextension_h
+#define tuscany_sca_php_phpimplementationextension_h
+
+#include "tuscany/sca/extension/ImplementationExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ class PHPImplementationExtension : public ImplementationExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ PHPImplementationExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~PHPImplementationExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema element for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.phpn")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ComponentType* getImplementation(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlImplementation);
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_phpimplementationextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPInterfaceExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPInterfaceExtension.cpp
new file mode 100644
index 0000000000..a07c499dec
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPInterfaceExtension.cpp
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/php/PHPInterfaceExtension.h"
+#include "tuscany/sca/php/model/PHPInterface.h"
+#include "tuscany/sca/util/Logging.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+ // ===================================================================
+ // Constructor for the PHPInterfaceExtension class.
+ // ===================================================================
+ PHPInterfaceExtension::PHPInterfaceExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the PHPInterfaceExtension class.
+ // ===================================================================
+ PHPInterfaceExtension::~PHPInterfaceExtension()
+ {
+ logentry();
+ }
+
+ const string PHPInterfaceExtension::extensionName("php");
+ const string PHPInterfaceExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#PHPInterface");
+
+ // ===================================================================
+ // loadModelElement - load the info from interface.php
+ // ===================================================================
+ tuscany::sca::model::Interface* PHPInterfaceExtension::getInterface(Composite* composite, DataObjectPtr scdlInterface)
+ {
+ logentry();
+
+ // Determine the type
+ string ifType = scdlInterface->getType().getName();
+ if (ifType == "PHPInterface")
+ {
+ bool remotable = scdlInterface->getBoolean("remotable");
+ bool conversational = scdlInterface->getBoolean("conversational");
+
+ return new PHPInterface(remotable, conversational);
+ }
+ return 0;
+ }
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPInterfaceExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPInterfaceExtension.h
new file mode 100644
index 0000000000..4279376300
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPInterfaceExtension.h
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_php_phpinterfaceextension_h
+#define tuscany_sca_php_phpinterfaceextension_h
+
+#include "tuscany/sca/extension/InterfaceExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ class PHPInterfaceExtension : public InterfaceExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ PHPInterfaceExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~PHPInterfaceExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#PHPInterface")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::Interface* getInterface(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlInterface);
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_phpinterfaceextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp
new file mode 100644
index 0000000000..4b66c42a5b
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/php/PHPServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/php/model/PHPReferenceBinding.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ // ============================================
+ // Constructor: Create a proxy from a reference
+ // ============================================
+ PHPServiceProxy::PHPServiceProxy(Reference* reference)
+ : ServiceProxy(reference)
+ {
+ logentry();
+
+ // Get the service wrapper
+ PHPReferenceBinding* referenceBinding = (PHPReferenceBinding*)reference->getBinding();
+ serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
+ }
+
+ // ==========================================
+ // Constructor: Create a proxy from a service
+ // ==========================================
+ PHPServiceProxy::PHPServiceProxy(Service* service)
+ : ServiceProxy(NULL)
+ {
+ logentry();
+
+ // Get the service wrapper
+ serviceWrapper = service->getBinding()->getServiceWrapper();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ PHPServiceProxy::~PHPServiceProxy()
+ {
+ logentry();
+ }
+
+ // =====================================================
+ // invokeService: invoke the service wired to this proxy
+ // =====================================================
+ void PHPServiceProxy::invokeService(Operation& operation)
+ {
+ logentry();
+
+ // Invoke the service
+ serviceWrapper->invoke(operation);
+ }
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h
new file mode 100644
index 0000000000..bddb262617
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_php_phpserviceproxy_h
+#define tuscany_sca_php_phpserviceproxy_h
+
+#include "tuscany/sca/php/export.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ /**
+ * Holds a proxy for a given reference from a component implemented in PHP.
+ */
+ class PHPServiceProxy : public ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a reference. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The reference on the source component.
+ */
+ PHPServiceProxy(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Create a new service proxy for a service. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param service The service on the target component.
+ */
+ PHPServiceProxy(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PHPServiceProxy();
+
+ /**
+ * Invoke the wired service.
+ */
+ virtual void invokeService(Operation& operation);
+
+ private:
+
+ /**
+ * The target service wrapper
+ */
+ ServiceWrapper* serviceWrapper;
+ };
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_phpserviceproxy_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp
new file mode 100644
index 0000000000..0236d3bc7f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp
@@ -0,0 +1,504 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifdef WIN32
+
+// some strangeness in the build that causes
+// WinSock.h and WinSock2.h to be included leading to redefinitions
+#define _WINSOCKAPI_
+
+// sdo.cpp also includes the math libraries and causes redeclarations
+// of all the math functions
+#define _INC_MATH
+
+#endif //WIN32
+
+#include <iostream>
+#include <sstream>
+
+#include <sapi/embed/php_embed.h>
+
+
+#include "tuscany/sca/php/PHPServiceWrapper.h"
+#include "tuscany/sca/php/PHPServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/php/model/PHPImplementation.h"
+
+
+#include "sca.h"
+#include "php_sdo_int.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ int embedSAPIInitializeCount = 0;
+
+ // Global callbacks used by the PHP engine
+
+ // Callback for SAPI error
+ void php_sapi_error(int type, const char *error_msg, ...)
+ {
+ logwarning("PHP sapi error: %s", error_msg);
+ //TODO - do something sensible with this output
+ zend_bailout();
+ }
+
+ // Callback for log messages
+ void php_log_message(char *message)
+ {
+ loginfo("PHP log: %s", message);
+ //TODO - do something sensible with this output
+ }
+
+ // Callback for unbuffered writes (echo, print etc.)
+ int php_ub_write(const char *str, unsigned int str_length TSRMLS_DC)
+ {
+ logentry();
+ loginfo("PHP Output: %s", str);
+ //TODO - do something sensible with this output
+ return str_length;
+ }
+
+ // Callback for errors
+ void php_error_cb(int type,
+ const char *error_filename,
+ const uint error_lineno,
+ const char *format, va_list args)
+ {
+ logentry();
+
+ char buffer[2048];
+ int len;
+
+ len = snprintf(buffer, 2048, "Error in file %s on line %d: ", error_filename, error_lineno);
+ vsnprintf(buffer + len, (2048 - len), format, args);
+ logwarning("PHP error: %s", buffer);
+ //TODO - do something sensible with this output
+ zend_bailout();
+ }
+
+
+ // ===========
+ // Constructor
+ // ===========
+ PHPServiceWrapper::PHPServiceWrapper(Service* service)
+ : ServiceWrapper(service)
+ {
+ logentry();
+
+ component = service->getComponent();
+ interf = service->getType()->getInterface();
+ remotable = interf->isRemotable();
+
+ // -----------------------------------------------
+ // Get the implementation for the target component
+ // -----------------------------------------------
+ PHPImplementation* impl = (PHPImplementation*)component->getType();
+ if (!impl)
+ {
+ string msg = "Component " + component->getName() + " has no implementation defined";
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ loginfo("Module: %s", impl->getModule().c_str());
+ loginfo("Class: %s", impl->getClass().c_str());
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ PHPServiceWrapper::~PHPServiceWrapper()
+ {
+ logentry();
+ }
+
+
+ // ======================================================================
+ // invoke: wrapper call to service with setting the component context
+ // ======================================================================
+ void PHPServiceWrapper::invoke(Operation& operation)
+ {
+ zval z_func_name, retval, z_component_name, z_class_name, z_operation_name, z_arg_array;
+ zval *params[5];
+
+ logentry();
+
+ // set the current component in the SCA runtime
+ // so that other things can get at it thorugh this
+ // static class
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ runtime->setCurrentComponent(component);
+
+ try
+ {
+ // get the component type information
+ PHPImplementation* impl = (PHPImplementation*)component->getType();
+
+ // get the directory containing the component type
+ const string &compositeDir = impl->getComposite()->getRoot();
+
+ // get some useful information that will be used later
+ // when we construct the wrapper script
+ string componentName = component->getName();
+ string className = impl->getClass();
+ string operationName = operation.getName();
+ loginfo("Component %s class %s operation: %s",
+ componentName.c_str(),
+ className.c_str(),
+ operationName.c_str());
+
+ // load the PHP logging and error callback methods
+ php_embed_module.log_message = php_log_message;
+ php_embed_module.ub_write = php_ub_write;
+ php_embed_module.sapi_error = php_sapi_error;
+
+ // would normally use the following macro before the embeded call
+ // but we need to take account of multiple nested calls
+ // and ZTS threading safety is not behaving itself
+ // PHP_EMBED_START_BLOCK(/* argc */ 0, /* argv */ NULL)
+ // =====================================================================
+ {
+#ifdef ZTS
+ static void ***tsrm_ls;
+ loginfo("ZTS enabled");
+#endif
+ printf("tsrm_ls = %x, embedSAPIInitializeCount = %d\n",
+ tsrm_ls, embedSAPIInitializeCount);
+
+ if ( embedSAPIInitializeCount == 0 )
+ {
+ embedSAPIInitializeCount = 1;
+
+ php_embed_init(0, NULL PTSRMLS_CC);
+
+ // load up the sca module that provides the interface between
+ // C++ and user space PHP
+ zend_first_try {
+ zend_startup_module(&sca_module_entry);
+ } zend_end_try();
+ } else {
+ embedSAPIInitializeCount++;
+ }
+
+ zend_try {
+ // set error handler
+ zend_error_cb = php_error_cb;
+
+ /*
+ * Open the include files
+ */
+ // includeFile("SCA/SCA.php" TSRMLS_CC);
+ // includeFile("SCA/Bindings/tuscany/SCA_TuscanyWrapper.php" TSRMLS_CC);
+
+ /* Instantiate a SCA_Tuscany (mediator) object, and
+ * set its operation property
+ */
+ zval z_tuscany_mediator;
+ zval *pz_mediator = &z_tuscany_mediator;
+ INIT_ZVAL(z_tuscany_mediator);
+ zend_class_entry *ce_mediator =
+ zend_fetch_class("SCA_Tuscany", sizeof("SCA_Tuscany") - 1, 0 TSRMLS_CC);
+ object_init_ex(pz_mediator, ce_mediator);
+ z_tuscany_mediator.value.obj.handlers->add_ref(pz_mediator TSRMLS_CC);
+
+ zend_update_property_long(ce_mediator, pz_mediator,
+ "operation", sizeof("operation") - 1, (long)&operation TSRMLS_CC);
+
+ /* get the class info loaded up */
+ zend_eval_string("include 'SCA/SCA.php';",
+ NULL, "Include SCA" TSRMLS_CC);
+ zend_eval_string("include 'SCA/Bindings/tuscany/SCA_TuscanyWrapper.php';",
+ NULL, "Include SCA_TuscanyWrapper" TSRMLS_CC);
+
+ /* Now instantiate an SCA_TuscanyWrapper object and call its constructor */
+ zval z_tuscany_wrapper;
+ zval *pz_tuscany_wrapper = &z_tuscany_wrapper;
+ INIT_ZVAL(z_tuscany_wrapper);
+ object_init_ex(pz_tuscany_wrapper,
+ zend_fetch_class("SCA_TuscanyWrapper", sizeof("SCA_TuscanyWrapper") - 1, 0 TSRMLS_CC));
+ z_tuscany_wrapper.value.obj.handlers->add_ref(pz_tuscany_wrapper TSRMLS_CC);
+
+ ZVAL_STRING(&z_func_name, "__construct", 1);
+ ZVAL_STRING(&z_component_name, (char *)componentName.c_str(), 1);
+ if( &className != NULL && className.size() > 0) {
+ ZVAL_STRING(&z_class_name, (char *)className.c_str(), 1);
+ } else {
+ ZVAL_NULL(&z_class_name);
+ }
+ ZVAL_STRING(&z_operation_name, (char *)operationName.c_str(), 1);
+
+ array_init(&z_arg_array);
+
+ // get the parameters from the operation structure
+ for(unsigned int i = 0; i < operation.getNParms(); i++)
+ {
+ const Operation::Parameter& parm = operation.getParameter(i);
+ //printf("Arg %d type %d\n", i, parm.getType());
+ switch(parm.getType())
+ {
+ case Operation::BOOL:
+ {
+ add_next_index_bool(&z_arg_array, (int)*(bool*)parm.getValue() );
+ break;
+ }
+ case Operation::SHORT:
+ case Operation::USHORT:
+ case Operation::LONG:
+ case Operation::ULONG:
+ {
+ add_next_index_long(&z_arg_array, *(long*)parm.getValue() );
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ add_next_index_double(&z_arg_array,( double)*(float*)parm.getValue() );
+ break;
+ }
+ case Operation::DOUBLE:
+ case Operation::LONGDOUBLE:
+ {
+ add_next_index_double(&z_arg_array, *(double*)parm.getValue() );
+ break;
+ }
+ case Operation::CHARS:
+ {
+ add_next_index_string(&z_arg_array, *(char**)parm.getValue(), 1 );
+ break;
+ }
+ case Operation::STRING:
+ {
+ add_next_index_string(&z_arg_array, (char*)(*(string*)parm.getValue()).c_str(), 1 );
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ // convert the tuscany SDO into a PHP SDO
+
+ // create the object
+ zval *sdo;
+ ALLOC_INIT_ZVAL(sdo);
+ sdo_do_new(sdo, *(DataObjectPtr*)parm.getValue() TSRMLS_CC);
+
+ // add it to the arg array
+ add_next_index_zval(&z_arg_array, sdo);
+ break;
+ }
+ default:
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Argument type %d not supported",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ parm.getType());
+ }
+ }
+ }
+
+ params[0] = &z_tuscany_mediator;
+ params[1] = &z_component_name;
+ params[2] = &z_class_name;
+ params[3] = &z_operation_name;
+ params[4] = &z_arg_array;
+
+ call_user_function(EG(function_table),
+ &pz_tuscany_wrapper,
+ &z_func_name,
+ &retval,
+ 5,
+ params TSRMLS_CC);
+
+ zval_dtor(&z_func_name);
+ zval_dtor(&z_component_name);
+ zval_dtor(&z_class_name);
+ zval_dtor(&z_operation_name);
+ zval_dtor(&z_arg_array);
+
+ string script;
+ script = "include '" + compositeDir + "/" + impl->getModule() + ".php';";
+ loginfo("Script: %s", script.c_str());
+
+ // call the dynamically created script
+ // I'm not trapping the return value here
+ // as it seems to prevent any kind of output
+ // being produced. Needs investigation.
+ //zval retval;
+ zend_eval_string((char *) script.c_str(),
+ NULL, //&retval,
+ "Include module" TSRMLS_CC);
+
+ loginfo(">>>> About to call SCA_TuscanyWrapper->invoke()");
+
+ /* Now call SCA_TuscanyWrapper->invoke() ... */
+ ZVAL_STRING(&z_func_name, "invoke", 1);
+ call_user_function(EG(function_table),
+ &pz_tuscany_wrapper, &z_func_name,
+ &retval, 0, NULL TSRMLS_CC);
+
+ loginfo("<<<< Return from SCA_TuscanyWrapper->invoke()");
+
+ zval_dtor(&z_func_name);
+
+ /* ... and copy the return value into the operation */
+ switch(Z_TYPE(retval))
+ {
+ case IS_NULL:
+ {
+ //printf("NULL response");
+ break;
+ }
+ case IS_BOOL:
+ {
+ bool *newBool = new bool;
+ *newBool = ZEND_TRUTH(Z_BVAL(retval));
+ operation.setReturnValue(newBool);
+ break;
+ }
+ case IS_LONG:
+ {
+ long *newLong = new long;
+ *newLong = Z_LVAL(retval);
+ operation.setReturnValue(newLong);
+ break;
+ }
+ case IS_DOUBLE:
+ {
+ //double *newDouble = new double;
+ float *newDouble = new float;
+ *newDouble = (float)Z_DVAL(retval);
+ operation.setReturnValue(newDouble);
+ break;
+ }
+ case IS_STRING:
+ {
+ string newString (Z_STRVAL(retval));
+ operation.setReturnValue(&newString);
+ break;
+ }
+ case IS_OBJECT:
+ {
+ // convert the PHP SDO into a Tuscany SDO
+ DataObjectPtr sdo = sdo_do_get(&retval TSRMLS_CC);
+ operation.setReturnValue(&sdo);
+ break;
+ }
+ default:
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Input argument type %d not supported on invoke",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ Z_TYPE(retval));
+ }
+ }
+ } zend_catch {
+ /* int exit_status = EG(exit_status); */
+ }
+ zend_end_try();
+
+ if ( embedSAPIInitializeCount == 1 )
+ {
+ php_embed_shutdown(TSRMLS_C);
+ loginfo("Engine shutdown");
+ }
+ else
+ {
+ embedSAPIInitializeCount--;
+ }
+ }
+ // =====================================================================
+ }
+ catch (...)
+ {
+ runtime->unsetCurrentComponent();
+ throw;
+ }
+ runtime->unsetCurrentComponent();
+
+ }
+
+ // ======================================================================
+ // getServiceWrapper: create a wrapper for the target ComponentService
+ // ======================================================================
+ PHPServiceWrapper* PHPServiceWrapper::getServiceWrapper(Service* service)
+ {
+ logentry();
+ PHPServiceWrapper* serviceWrapper = 0;
+
+ // ---------------------------------
+ // Create an instance of the wrapper
+ // ---------------------------------
+ serviceWrapper = new PHPServiceWrapper(service);
+ if (!serviceWrapper)
+ {
+ string msg = "Could not create new PHPServiceWrapper";
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ return serviceWrapper;
+ }
+
+ /* Not used at the moment
+ * Can find the include file and execute it,
+ * but doesn't make the contents available
+ */
+ void PHPServiceWrapper::includeFile(char *includeFileName TSRMLS_DC)
+ {
+ zend_file_handle include_file_handle;
+
+ include_file_handle.type = ZEND_HANDLE_FP;
+ include_file_handle.filename = includeFileName;
+ include_file_handle.opened_path = NULL;
+ include_file_handle.free_filename = 0;
+ if (!(include_file_handle.handle.fp = php_fopen_with_path(
+ include_file_handle.filename, "rb", PG(include_path),
+ &include_file_handle.opened_path TSRMLS_CC))) {
+ php_error(E_ERROR,
+ "Could not open %s", include_file_handle.filename);
+ return;
+ }
+ php_execute_script(&include_file_handle TSRMLS_CC);
+ }
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h
new file mode 100644
index 0000000000..be20f34217
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_php_phpservicewrapper_h
+#define tuscany_sca_php_phpservicewrapper_h
+
+#include "tuscany/sca/php/export.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Interface.h"
+
+#include <TSRM/TSRM.h>
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+ class PHPInterface;
+
+ /**
+ * Wraps the service on a component implementation.
+ * This abstract class is extended by generated code which provides
+ * the implementation of some of the methods.
+ * An instance of this class wraps the actual component implementation which
+ * has been written by a developer of an SCA application.
+ */
+ class SCA_PHP_API PHPServiceWrapper : public ServiceWrapper
+ {
+ public:
+ /**
+ * Factory method to create a new PHPServiceWrapper for a given target
+ * service. This method will provide all the loading of dlls required to
+ * create the target component.
+ * @param target The service on the component for which this wrapper is to be
+ * created.
+ * @return A wrapper that references the given target.
+ */
+ static PHPServiceWrapper* getServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Constructor.
+ * @param target The component service to which this wrapper refers.
+ */
+ PHPServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PHPServiceWrapper();
+
+ /**
+ * All business method calls to the target component go through the invoke method.
+ * @param operation The details of the method, paramaters and return value for the
+ * business method to be called on the target component.
+ */
+ virtual void invoke(Operation& operation);
+
+
+ protected:
+
+
+ private:
+
+ /**
+ * Utility method to execute a script on the include_path.
+ */
+ static void includeFile(char *includeFileName TSRMLS_DC);
+
+ /**
+ * The component to which this wrapper refers.
+ */
+ tuscany::sca::model::Component* component;
+
+ /**
+ * Set to true if the service is remotable.
+ */
+ bool remotable;
+
+ /**
+ * A pointer to the interface which the service exposes.
+ */
+ tuscany::sca::model::Interface* interf;
+
+ };
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_phpservicewrapper_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/export.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/export.h
new file mode 100644
index 0000000000..11a9519361
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/export.h
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_php_export_h
+#define tuscany_sca_php_export_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef TUSCANY_SCA_PHP_EXPORTS
+#define SCA_PHP_API __declspec(dllexport)
+#else
+#define SCA_PHP_API __declspec(dllimport)
+#endif
+
+#else
+#include <sys/time.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#define SCA_PHP_API
+#endif
+
+#endif // tuscany_sca_export_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp
new file mode 100644
index 0000000000..63f1672ec5
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/php/model/PHPImplementation.h"
+#include "tuscany/sca/php/model/PHPServiceBinding.h"
+#include "tuscany/sca/php/model/PHPReferenceBinding.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace php
+ {
+
+ // Constructor
+ PHPImplementation::PHPImplementation(Composite* composite, const string& module, const string& className)
+ : ComponentType(composite, module),
+ module(module), className(className)
+ {
+ logentry();
+ }
+
+ PHPImplementation::~PHPImplementation()
+ {
+ logentry();
+ }
+
+ void PHPImplementation::initializeComponent(Component* component)
+ {
+ logentry();
+ ComponentType::initializeComponent(component);
+
+ // Create PHP bindings for all the services
+ const Component::SERVICE_MAP& services = component->getServices();
+ Component::SERVICE_MAP::const_iterator iter = services.begin();
+ for (unsigned int i=0; i< services.size(); i++)
+ {
+ Service *service = iter->second;
+ PHPServiceBinding* binding = new PHPServiceBinding(service);
+ service->setBinding(binding);
+ iter++;
+ }
+
+ // Create PHP bindings for all the references
+ const Component::REFERENCE_MAP& references = component->getReferences();
+ Component::REFERENCE_MAP::const_iterator refiter = references.begin();
+ for (int ri=0; ri< references.size(); ri++)
+ {
+ Reference *reference = refiter->second;
+ PHPReferenceBinding* binding = new PHPReferenceBinding(reference);
+ reference->setBinding(binding);
+ refiter++;
+ }
+ }
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h
new file mode 100644
index 0000000000..78e678dff5
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_php_model_phpimplementation_h
+#define tuscany_sca_php_model_phpimplementation_h
+
+#include <string>
+
+#include "tuscany/sca/model/ComponentType.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+ /**
+ * Holds information about an SCA implementation written in PHP
+ */
+ class PHPImplementation : public tuscany::sca::model::ComponentType
+ {
+
+ public:
+ /**
+ * Constructor.
+ * @param composite Composite containing this implementation.
+ * @param module Name of the module.
+ * @param modulePath Path to the module (could be a blank string
+ * if this is not specified).
+ * @param className Name of the class in the module (could be a blank string
+ * if this is not specified).
+ */
+ PHPImplementation(tuscany::sca::model::Composite* composite, const std::string& module, const std::string& className);
+
+ /**
+ * Destructor
+ */
+ virtual ~PHPImplementation();
+
+ /**
+ * Initialize a component of this type.
+ * @param component The component to initialize.
+ */
+ virtual void initializeComponent(tuscany::sca::model::Component* component);
+
+ /**
+ * Returns the name of the module.
+ * @return The name of the module.
+ */
+ const std::string& getModule() const { return module; }
+
+ /**
+ * Get the name of the class.
+ * @return The class name if specified.
+ */
+ const std::string& getClass() const { return className; }
+
+ private:
+
+ /**
+ * Name of the module.
+ */
+ std::string module;
+
+ /**
+ * Name of the class in the header file declaring the implementation.
+ * May be an empty string if not set in the SCDL file.
+ */
+ std::string className;
+ };
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_model_phpimplementation_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPInterface.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPInterface.cpp
new file mode 100644
index 0000000000..cbea3f2b71
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPInterface.cpp
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/php/export.h"
+#include "tuscany/sca/php/model/PHPInterface.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+ const string PHPInterface::typeQName("http://www.osoa.org/xmlns/sca/1.0#PHPInterface");
+
+ // Constructor
+ PHPInterface::PHPInterface(
+ bool remotable,
+ bool conversational)
+ : Interface(remotable, conversational)
+ {
+ logentry();
+ }
+
+ PHPInterface::~PHPInterface()
+ {
+ logentry();
+ }
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPInterface.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPInterface.h
new file mode 100644
index 0000000000..9a4f658eb0
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPInterface.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_php_model_phpinterface_h
+#define tuscany_sca_php_model_phpinterface_h
+
+#include <string>
+
+#include "tuscany/sca/php/export.h"
+#include "tuscany/sca/model/Interface.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+ /**
+ * Holds information about an interface described using a PHP
+ * header file.
+ */
+ class PHPInterface : public tuscany::sca::model::Interface
+ {
+
+ public:
+ /**
+ * Constuctor.
+ * @param scope The scope of the interface (stateless or composite).
+ * @param remotable True if the interface is remotable.
+ */
+ PHPInterface(
+ bool remotable,
+ bool conversational);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PHPInterface();
+
+ /**
+ * return the QName of the schema type for this interface type
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp")
+ */
+ const std::string& getInterfaceTypeQName() { return typeQName; };
+
+ /**
+ * The QName of the schema type for this interface type.
+ */
+ SCA_PHP_API static const std::string typeQName;
+
+ };
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_model_phpinterface_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp
new file mode 100644
index 0000000000..8a8d15fe40
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/php/model/PHPReferenceBinding.h"
+#include "tuscany/sca/php/PHPServiceProxy.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ // Constructor
+ PHPReferenceBinding::PHPReferenceBinding(Reference* reference)
+ : ReferenceBinding(reference, ""), serviceProxy(NULL)
+ {
+ }
+
+ // Destructor
+ PHPReferenceBinding::~PHPReferenceBinding()
+ {
+ }
+
+ ServiceProxy* PHPReferenceBinding::getServiceProxy()
+ {
+ return serviceProxy;
+ }
+
+ void PHPReferenceBinding::configure(ServiceBinding* binding)
+ {
+ targetServiceBinding = binding;
+
+ serviceProxy = new PHPServiceProxy(getReference());
+ }
+
+ } // End namespace
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h
new file mode 100644
index 0000000000..8010752980
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_php_model_phpreferencebinding_h
+#define tuscany_sca_php_model_phpreferencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+ /**
+ * Information about a PHP service binding for service or a reference.
+ */
+ class PHPReferenceBinding : public tuscany::sca::model::ReferenceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ */
+ PHPReferenceBinding(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PHPReferenceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#PHPImplementationBinding"; };
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ virtual ServiceProxy* getServiceProxy();
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding);
+
+ /**
+ * Returns the target service binding.
+ */
+ tuscany::sca::model::ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; };
+
+ private:
+
+ /**
+ * The proxy representing the reference to the client
+ * component.
+ */
+ ServiceProxy* serviceProxy;
+
+ /**
+ * The service binding of the target
+ */
+ tuscany::sca::model::ServiceBinding* targetServiceBinding;
+ };
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_model_phpreferencebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.cpp
new file mode 100644
index 0000000000..4d18424ae2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/php/model/PHPServiceBinding.h"
+#include "tuscany/sca/php/PHPServiceWrapper.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ // Constructor
+ PHPServiceBinding::PHPServiceBinding(Service* service)
+ : ServiceBinding(service, "")
+ {
+ logentry();
+ serviceWrapper = PHPServiceWrapper::getServiceWrapper(service);
+ }
+
+ // Destructor
+ PHPServiceBinding::~PHPServiceBinding()
+ {
+ logentry();
+ }
+
+ ServiceWrapper* PHPServiceBinding::getServiceWrapper()
+ {
+ logentry();
+ return (ServiceWrapper*)serviceWrapper;
+ }
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.h
new file mode 100644
index 0000000000..ef3d6b1604
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.h
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_php_model_phpservicebinding_h
+#define tuscany_sca_php_model_phpservicebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ServiceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+ /**
+ * Information about a PHP service binding for service or a reference.
+ */
+ class PHPServiceBinding : public tuscany::sca::model::ServiceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ * @param port The definition of the port to which the entrypoint
+ * or external service is to be bound. This is of the form
+ * "namespace"#endpoint("service"/"port")
+ */
+ PHPServiceBinding(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PHPServiceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#PHPImplementationBinding"; };
+
+ /**
+ * Create a wrapper for the service configured by this
+ * binding.
+ */
+ virtual ServiceWrapper* getServiceWrapper();
+
+ private:
+
+ /**
+ * The wrapper for the service configured by this binding.
+ */
+ ServiceWrapper* serviceWrapper;
+
+ };
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_model_phpservicebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/php_sca.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/php_sca.h
new file mode 100644
index 0000000000..8aea8dadb2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/php_sca.h
@@ -0,0 +1,132 @@
+/*
+ * 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.
+ */
+
+/* $ Id: $ */
+
+#ifndef PHP_SCA_H
+#define PHP_SCA_H
+
+#include "tuscany/sca/core/Operation.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <main/php.h>
+
+#ifdef HAVE_SCA
+
+#include <main/php_ini.h>
+#include <main/SAPI.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_extensions.h>
+#ifdef __cplusplus
+} // extern "C"
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+//extern zend_module_entry sca_module_entry;
+#define phpext_sca_ptr &sca_module_entry
+
+#ifdef PHP_WIN32
+#define PHP_SCA_API __declspec(dllexport)
+#else
+#define PHP_SCA_API
+#endif
+
+PHP_MINIT_FUNCTION(sca);
+PHP_MSHUTDOWN_FUNCTION(sca);
+PHP_MINFO_FUNCTION(sca);
+
+#ifdef ZTS
+#include "TSRM/TSRM.h"
+#endif
+
+#define FREE_RESOURCE(resource) zend_list_delete(Z_LVAL_P(resource))
+
+#define PROP_GET_LONG(name) Z_LVAL_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
+#define PROP_SET_LONG(name, l) zend_update_property_long(_this_ce, _this_zval, #name, strlen(#name), l TSRMLS_CC)
+
+#define PROP_GET_DOUBLE(name) Z_DVAL_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
+#define PROP_SET_DOUBLE(name, d) zend_update_property_double(_this_ce, _this_zval, #name, strlen(#name), d TSRMLS_CC)
+
+#define PROP_GET_STRING(name) Z_STRVAL_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
+#define PROP_GET_STRLEN(name) Z_STRLEN_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
+#define PROP_SET_STRING(name, s) zend_update_property_string(_this_ce, _this_zval, #name, strlen(#name), s TSRMLS_CC)
+#define PROP_SET_STRINGL(name, s, l) zend_update_property_string(_this_ce, _this_zval, #name, strlen(#name), s, l TSRMLS_CC)
+
+
+PHP_METHOD(SCA_Tuscany, __construct);
+#if (PHP_MAJOR_VERSION >= 5)
+ZEND_BEGIN_ARG_INFO_EX(SCA_Tuscany____construct_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ZEND_END_ARG_INFO()
+#else /* PHP 4.x */
+#define SCA_Tuscany____construct_args NULL
+#endif
+
+PHP_METHOD(SCA_Tuscany, invoke);
+#if (PHP_MAJOR_VERSION >= 5)
+ZEND_BEGIN_ARG_INFO_EX(SCA_Tuscany__invoke_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 4)
+ ZEND_ARG_INFO(0, component_name)
+ ZEND_ARG_INFO(0, reference_name)
+ ZEND_ARG_INFO(0, method_name)
+#if (PHP_MINOR_VERSION > 0)
+ ZEND_ARG_ARRAY_INFO(0, arguments, 1)
+#else
+ ZEND_ARG_INFO(0, arguments)
+#endif
+ZEND_END_ARG_INFO()
+#else /* PHP 4.x */
+#define SCA_Tuscany__invoke_args NULL
+#endif
+
+PHP_METHOD(SCA_Tuscany, getArgArray);
+#if (PHP_MAJOR_VERSION >= 5)
+ZEND_BEGIN_ARG_INFO_EX(SCA_Tuscany__getArgArray_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+#else /* PHP 4.x */
+#define SCA_Tuscany__getArgArray_args NULL
+#endif
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+
+
+#endif /* PHP_HAVE_SCA */
+
+#endif /* PHP_SCA_H */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/sca.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/sca.cpp
new file mode 100644
index 0000000000..4078226f63
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/sca.cpp
@@ -0,0 +1,517 @@
+/*
+ * 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.
+ */
+
+/* $ Id: $ */
+
+#ifdef WIN32
+
+// some strangeness in the build that causes
+// WinSock.h and WinSock2.h to be included leading to redefinitions
+#define _WINSOCKAPI_
+
+#endif //WIN32
+
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/php/PHPServiceProxy.h"
+#include "commonj/sdo/RefCountingPointer.h"
+
+using namespace std;
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+using namespace tuscany::sca::php;
+using namespace commonj::sdo;
+
+#define HAVE_SCA 1
+
+
+#include "php_sca.h"
+#include "sca.h"
+
+#if HAVE_SCA
+
+#include "php_sdo.h"
+#include "php_sdo_int.h"
+/* {{{ Class definitions */
+
+/* {{{ Class SCA_Tuscany */
+
+static zend_class_entry * SCA_Tuscany_ce_ptr = NULL;
+
+/* {{{ Methods */
+
+/* {{{ proto void __construct(int operation_handle)
+ */
+PHP_METHOD(SCA_Tuscany, __construct)
+{
+ zval *_this_zval = getThis();
+ zend_class_entry *_this_ce = Z_OBJCE_P(_this_zval);
+
+ long operation_handle = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &operation_handle) == FAILURE) {
+ return;
+ }
+
+ if (!operation_handle) {
+ php_error(E_ERROR, "SCA_Tuscany ctor called with NULL operation");
+ }
+
+ PROP_SET_LONG(operation, operation_handle);
+}
+/* }}} __construct */
+
+/* {{{ proto int invoke(string component_name, string reference_name, string method_name, array arguments)
+ Invoke a Tuscany component */
+PHP_METHOD(SCA_Tuscany, invoke)
+{
+ //zval * _this_zval = NULL;
+ const char * component_name = NULL;
+ int component_name_len = 0;
+ const char * reference_name = NULL;
+ int reference_name_len = 0;
+ const char * method_name = NULL;
+ int method_name_len = 0;
+ zval * arguments = NULL;
+ HashTable * arguments_hash = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssa/",
+ &component_name, &component_name_len,
+ &reference_name, &reference_name_len,
+ &method_name, &method_name_len,
+ &arguments) == FAILURE) {
+ return;
+ }
+
+ arguments_hash = HASH_OF(arguments);
+
+ // find the correct service proxy
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ Component* component = runtime->getCurrentComponent();
+ Reference* ref = component->findReference(reference_name);
+ if(!ref) {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Can't find reference %s",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ reference_name);
+ return;
+ }
+
+ ReferenceBinding* refBinding = ref->getBinding();
+ PHPServiceProxy *serviceProxy = (PHPServiceProxy*) refBinding->getServiceProxy();
+
+ // construct an operation structure
+ Operation operation(method_name);
+
+ // add the parameters to the operation
+ for ( zend_hash_internal_pointer_reset(arguments_hash);
+ zend_hash_has_more_elements(arguments_hash) == SUCCESS;
+ zend_hash_move_forward(arguments_hash) )
+ {
+ zval **data;
+
+ if ( zend_hash_get_current_data(arguments_hash,
+ (void**)&data ) == FAILURE )
+ {
+ continue;
+ }
+
+ char *hashKey;
+ uint hashKeyLength;
+ ulong hashIndex;
+ int type;
+
+ type = zend_hash_get_current_key_ex(arguments_hash,
+ &hashKey,
+ &hashKeyLength,
+ &hashIndex,
+ 0,
+ NULL);
+
+ switch(Z_TYPE_PP(data))
+ {
+ case IS_NULL:
+ {
+ //printf("NULL argument");
+ break;
+ }
+ case IS_BOOL:
+ {
+ convert_to_boolean(*data);
+ bool *newBool = new bool;
+ *newBool = ZEND_TRUTH(Z_BVAL_PP(data));
+ operation.addParameter(newBool);
+ break;
+ }
+ case IS_LONG:
+ {
+ convert_to_long(*data);
+ long *newLong = new long;
+ *newLong = Z_LVAL_PP(data);
+ operation.addParameter(newLong);
+ break;
+ }
+ case IS_DOUBLE:
+ {
+ //convert_to_double(*data);
+ //double *newDouble = new double;
+ convert_to_double(*data);
+ float *newDouble = new float;
+ *newDouble = (float)Z_DVAL_PP(data);
+ operation.addParameter(newDouble);
+ break;
+ }
+ case IS_STRING:
+ {
+ convert_to_string(*data);
+ string newString (Z_STRVAL_PP(data));
+ operation.addParameter(&newString);
+ break;
+ }
+ case IS_OBJECT:
+ {
+ // convert the PHP SDO into a Tuscany SDO
+ DataObjectPtr sdo = sdo_do_get(*data TSRMLS_CC);
+ operation.addParameter(&sdo);
+ break;
+ }
+ default:
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Input argument type %d not supported on invoke",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ Z_TYPE_PP(data));
+ }
+ }
+ }
+
+ // call the proxy
+ serviceProxy->invokeService(operation);
+
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ ZVAL_BOOL(return_value, *(bool*)operation.getReturnValue());
+ break;
+ }
+ case Operation::SHORT:
+ case Operation::USHORT:
+ case Operation::LONG:
+ case Operation::ULONG:
+ {
+ ZVAL_LONG(return_value, *(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::FLOAT:
+ case Operation::DOUBLE:
+ case Operation::LONGDOUBLE:
+ {
+ ZVAL_DOUBLE(return_value, (double)*(float*)operation.getReturnValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ ZVAL_STRING(return_value, (char*)operation.getReturnValue(), 1);
+ break;
+ }
+ case Operation::STRING:
+ {
+ ZVAL_STRING(return_value, (char*)((string*)operation.getReturnValue())->c_str(), 1);
+ break;
+ }
+ case Operation::VOID_TYPE:
+ {
+ // do nothing
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ // convert the tuscany SDO into a PHP SDO
+ sdo_do_new(return_value, *(DataObjectPtr*)operation.getReturnValue() TSRMLS_CC);
+ break;
+ }
+ default:
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Response type %d not supported on invoke",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ operation.getReturnType());
+ }
+ }
+
+}
+/* }}} invoke */
+
+/* {{{ proto array getArgArray()
+ return the arguments for the operation as an array */
+PHP_METHOD(SCA_Tuscany, getArgArray)
+{
+ zval * _this_zval = getThis();
+ zend_class_entry *_this_ce = Z_OBJCE_P(_this_zval);
+
+ if (ZEND_NUM_ARGS() > 0) {
+ WRONG_PARAM_COUNT;
+ }
+
+ array_init(return_value);
+
+ // get the operation object from the object properties
+ Operation *operation = (Operation *)PROP_GET_LONG(operation);
+
+ // get the parameters from the operation structure
+ for(unsigned int i = 0; i < operation->getNParms(); i++)
+ {
+ const Operation::Parameter& parm = operation->getParameter(i);
+ //printf("Arg %d type %d\n", i, parm.getType());
+ switch(parm.getType())
+ {
+ case Operation::BOOL:
+ {
+ add_next_index_bool(return_value,(int)*(bool*)parm.getValue() );
+ break;
+ }
+ case Operation::SHORT:
+ case Operation::USHORT:
+ case Operation::LONG:
+ case Operation::ULONG:
+ {
+ add_next_index_long(return_value,*(long*)parm.getValue() );
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ add_next_index_double(return_value,(double)*(float*)parm.getValue() );
+ break;
+ }
+ case Operation::DOUBLE:
+ case Operation::LONGDOUBLE:
+ {
+ add_next_index_double(return_value,*(double*)parm.getValue() );
+ break;
+ }
+ case Operation::CHARS:
+ {
+ add_next_index_string(return_value,*(char**)parm.getValue(), 1 );
+ break;
+ }
+ case Operation::STRING:
+ {
+ add_next_index_string(return_value,(char*)(*(string*)parm.getValue()).c_str(), 1 );
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ // convert the tuscany SDO into a PHP SDO
+
+ // create the object
+ zval *sdo;
+ ALLOC_INIT_ZVAL(sdo);
+ sdo_do_new(sdo, *(DataObjectPtr*)parm.getValue() TSRMLS_CC);
+
+ // add it to the arg array
+ add_next_index_zval(return_value, sdo);
+ break;
+ }
+ default:
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Argument type %d not supported",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ parm.getType());
+ }
+ }
+ }
+}
+/* }}} getArgArray */
+
+static zend_function_entry SCA_Tuscany_methods[] = {
+ PHP_ME(SCA_Tuscany, __construct, SCA_Tuscany____construct_args, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
+ PHP_ME(SCA_Tuscany, invoke, SCA_Tuscany__invoke_args, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+ PHP_ME(SCA_Tuscany, getArgArray, SCA_Tuscany__getArgArray_args, ZEND_ACC_PUBLIC)
+ { NULL, NULL, NULL }
+};
+
+/* }}} Methods */
+
+static void class_init_SCA_Tuscany(TSRMLS_D)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "SCA_Tuscany", SCA_Tuscany_methods);
+ SCA_Tuscany_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
+
+ /* {{{ Property registration */
+
+ zend_declare_property_null(SCA_Tuscany_ce_ptr,
+ "operation", sizeof("operation") -1,
+ ZEND_ACC_PUBLIC TSRMLS_CC);
+
+ /* }}} Property registration */
+
+}
+
+/* }}} Class SCA_Tuscany */
+
+/* }}} Class definitions*/
+
+/* {{{ sca_functions[] */
+function_entry sca_functions[] = {
+ { NULL, NULL, NULL }
+};
+/* }}} */
+
+/* {{{ cross-extension dependencies */
+
+#if ZEND_EXTENSION_API_NO >= 220050617
+static zend_module_dep sca_deps[] = {
+ ZEND_MOD_REQUIRED("sdo")
+ {NULL, NULL, NULL, 0}
+};
+#endif
+/* }}} */
+
+/* {{{ sca_module_entry */
+zend_module_entry sca_module_entry = {
+#if ZEND_EXTENSION_API_NO >= 220050617
+ STANDARD_MODULE_HEADER_EX, NULL,
+ sca_deps,
+#else
+ STANDARD_MODULE_HEADER,
+#endif
+
+ "sca",
+ sca_functions,
+ PHP_MINIT(sca), /* Replace with NULL if there is nothing to do at php startup */
+ PHP_MSHUTDOWN(sca), /* Replace with NULL if there is nothing to do at php shutdown */
+ NULL, /* Replace with NULL if there is nothing to do at request start */
+ NULL, /* Replace with NULL if there is nothing to do at request end */
+ PHP_MINFO(sca),
+ "0.0.1",
+ STANDARD_MODULE_PROPERTIES
+};
+/* }}} */
+
+#ifdef COMPILE_DL_SCA
+extern "C" {
+ZEND_GET_MODULE(sca)
+} // extern "C"
+#endif
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(sca)
+{
+ /* We use the SDO extension for reference because it is a prereq */
+ zend_module_entry *req_module_entry;
+ char *req_module_name = "libxml";
+ if (zend_hash_find(&module_registry, req_module_name, strlen(req_module_name)+1, (void**)&req_module_entry) == SUCCESS) {
+ if (req_module_entry->zend_debug != ZEND_DEBUG ||
+ req_module_entry->zts != USING_ZTS ||
+ req_module_entry->zend_api != ZEND_MODULE_API_NO) {
+ php_error(E_ERROR,
+ "Cannot initialize module sca.\nModule sca compiled with module API=%d, debug=%d, thread-safety=%d\nModule %n compiled with module API=%d, debug=%d, thread-safety=%d\nThese options need to match",
+ req_module_name,
+ ZEND_MODULE_API_NO, ZEND_DEBUG, USING_ZTS,
+ req_module_entry->zend_api, req_module_entry->zend_debug, req_module_entry->zts);
+ return FAILURE;
+ }
+ } else {
+ /* The dependency checker should already have found this, but to be on the safe side ... */
+ php_error (E_ERROR,
+ "Cannot load module sca because required module %n is not loaded",
+ req_module_name);
+ return FAILURE;
+ }
+
+ class_init_SCA_Tuscany(TSRMLS_C);
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+/* {{{ PHP_MSHUTDOWN_FUNCTION */
+PHP_MSHUTDOWN_FUNCTION(sca)
+{
+ /*
+ * There is some corruption going on at shutdown.
+ * The following hack eliminates the symptom, but there's probably still
+ * an underlying problem.
+ */
+ free(SCA_Tuscany_ce_ptr->name);
+ SCA_Tuscany_ce_ptr->name = NULL;
+ destroy_zend_class(&SCA_Tuscany_ce_ptr);
+ SCA_Tuscany_ce_ptr = NULL;
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_MINFO_FUNCTION */
+PHP_MINFO_FUNCTION(sca)
+{
+ php_info_print_box_start(0);
+ php_printf("<p>SCA Extension</p>\n");
+ php_printf("<p>Version 0.0.1alpha (2007-01-15)</p>\n");
+ php_printf("<p><b>Authors:</b></p>\n");
+ php_printf("<p>Simon Laws &lt;slaws@php.net&gt; (lead)</p>\n");
+ php_printf("<p>Caroline Maynard &lt;cem@php.net&gt; (lead)</p>\n");
+ php_info_print_box_end();
+ php_info_print_table_start();
+ php_info_print_table_header(2, "SCA", "enabled");
+ php_info_print_table_row(2, "SCA Version", "0.0.1");
+ php_info_print_table_end();
+
+}
+/* }}} */
+
+/* Other functions not directly related to implementing the
+ SCA_Tuscany extension */
+
+#endif /* HAVE_SCA */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/sca.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/sca.h
new file mode 100644
index 0000000000..5bbc9001dc
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/src/tuscany/sca/php/sca.h
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/* $ Id: $ */
+
+#ifndef SCA_H
+#define SCA_H
+
+#include "tuscany/sca/core/Operation.h"
+
+#include <main/php.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern zend_module_entry sca_module_entry;
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif /* SCA_H */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/xsd/sca-implementation-php.xsd b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/xsd/sca-implementation-php.xsd
new file mode 100644
index 0000000000..0f32f120e6
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/php/xsd/sca-implementation-php.xsd
@@ -0,0 +1,39 @@
+<?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.
+-->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <element name="implementation.php" type="sca:PHPImplementation" substitutionGroup="sca:implementation"/>
+ <complexType name="PHPImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="module" type="NCName" use="required"/>
+ <attribute name="class" type="Name" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/Makefile.am
new file mode 100644
index 0000000000..83e70b4b94
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/Makefile.am
@@ -0,0 +1,24 @@
+# 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.
+
+SUBDIRS = src
+
+datadir=$(prefix)/extensions/python
+
+nobase_data_DATA = xsd/*.xsd
+
+EXTRA_DIST = xsd \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/deploy.bat
new file mode 100644
index 0000000000..43c7a45777
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/deploy.bat
@@ -0,0 +1,66 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set pythonextdir=%extdir%\python
+set srcdir=%rootdir%\runtime\extensions\python\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %pythonextdir% mkdir %pythonextdir%
+if not exist %pythonextdir%\module mkdir %pythonextdir%\module
+if not exist %pythonextdir%\bin mkdir %pythonextdir%\bin
+if not exist %pythonextdir%\lib mkdir %pythonextdir%\lib
+if not exist %pythonextdir%\xsd mkdir %pythonextdir%\xsd
+
+del %pythonextdir%\bin\tuscany_sca_python.*
+del %pythonextdir%\lib\*.lib
+
+copy %srcdir%\..\xsd\*.* %pythonextdir%\xsd
+
+copy %inpath%\tuscany_sca_python.lib %pythonextdir%\lib
+copy %inpath%\tuscany_sca_python.dll %pythonextdir%\bin
+copy %inpath%\tuscany_sca_python.dll %pythonextdir%\module
+
+if exist %inpath%\tuscany_sca_python.pdb copy %inpath%\tuscany_sca_python.pdb %pythonextdir%\bin
+if exist %inpath%\tuscany_sca_python.pdb copy %inpath%\tuscany_sca_python.pdb %pythonextdir%\module
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/deploymodule.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/deploymodule.bat
new file mode 100644
index 0000000000..4403b0ce6c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/deploymodule.bat
@@ -0,0 +1,61 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set pythonextdir=%extdir%\python
+set srcdir=%rootdir%\runtime\extensions\python\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %pythonextdir% mkdir %pythonextdir%
+if not exist %pythonextdir%\bin mkdir %pythonextdir%\bin
+if not exist %pythonextdir%\lib mkdir %pythonextdir%\lib
+if not exist %pythonextdir%\xsd mkdir %pythonextdir%\xsd
+
+del %pythonextdir%\bin\sca.pyd
+del %pythonextdir%\bin\sca_proxy.py
+
+copy %inpath%\sca.pyd %pythonextdir%\bin
+copy %srcdir%\tuscany\sca\python\sca_proxy.py %pythonextdir%\bin
+
+if exist %inpath%\sca.pdb copy %inpath%\sca.pdb %pythonextdir%\bin
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/Makefile.am
new file mode 100644
index 0000000000..ec81dd5840
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/Makefile.am
@@ -0,0 +1,66 @@
+# 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.
+
+libdir=$(prefix)/extensions/python/lib
+lib_LTLIBRARIES = libtuscany_sca_python.la
+
+pydir=$(prefix)/extensions/python/lib
+py_DATA = tuscany/sca/python/sca_proxy.py
+EXTRA_DIST = tuscany/sca/python/sca_proxy.py
+
+rootdir=$(prefix)/extensions/python
+
+noinst_HEADERS = \
+tuscany/sca/python/*.h \
+tuscany/sca/python/model/*.h
+
+libtuscany_sca_python_la_SOURCES = \
+tuscany/sca/python/PythonExtension.cpp \
+tuscany/sca/python/PythonImplementationExtension.cpp \
+tuscany/sca/python/PythonInterfaceExtension.cpp \
+tuscany/sca/python/PythonServiceWrapper.cpp \
+tuscany/sca/python/PythonServiceProxy.cpp \
+tuscany/sca/python/sca_module.cpp \
+tuscany/sca/python/model/PythonImplementation.cpp \
+tuscany/sca/python/model/PythonInterface.cpp \
+tuscany/sca/python/model/PythonReferenceBinding.cpp \
+tuscany/sca/python/model/PythonServiceBinding.cpp
+
+# Need python env varibles set. e.g:
+# PYTHON_LIB=/usr/lib
+# PYTHON_INCLUDE=/usr/include/python2.4
+# PYTHON_VERSION=python2.4
+libtuscany_sca_python_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca \
+ -L${PYTHON_LIB} -l${PYTHON_VERSION}
+
+INCLUDES = -Imodel -I$(top_builddir)/runtime/core/src \
+ -I${TUSCANY_SDOCPP}/include \
+ -I${PYTHON_INCLUDE}
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+
+moduledir=$(prefix)/extensions/python/module
+extension = libtuscany_sca_python$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension)
+ -rm -f $(libdir)/sca.so
+ $(LN_S) $(libdir)/libtuscany_sca_python$(libsuffix) $(libdir)/sca.so \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp
new file mode 100644
index 0000000000..0274ffc774
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#include "tuscany/sca/python/PythonExtension.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/python/PythonImplementationExtension.h"
+#include "tuscany/sca/python/PythonInterfaceExtension.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_python_initialize()
+ {
+ tuscany::sca::python::PythonExtension::initialize();
+ }
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+ // ===================================================================
+ // Constructor for the PythonExtension class.
+ // ===================================================================
+ PythonExtension::PythonExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the PythonExtension class.
+ // ===================================================================
+ PythonExtension::~PythonExtension()
+ {
+ logentry();
+ }
+
+ void PythonExtension::initialize()
+ {
+ logentry();
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ runtime->registerImplementationExtension(new PythonImplementationExtension());
+ runtime->registerInterfaceExtension(new PythonInterfaceExtension());
+ }
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.h
new file mode 100644
index 0000000000..783f37a228
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.h
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_python_pythonextension_h
+#define tuscany_sca_python_pythonextension_h
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+
+ class PythonExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ PythonExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~PythonExtension();
+
+ static void initialize();
+
+ private:
+
+ };
+
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_python_pythonextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.cpp
new file mode 100644
index 0000000000..84cc34c6a4
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.cpp
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#include "tuscany/sca/python/PythonImplementationExtension.h"
+#include "tuscany/sca/python/model/PythonImplementation.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+ // ===================================================================
+ // Constructor for the PythonImplementationExtension class.
+ // ===================================================================
+ PythonImplementationExtension::PythonImplementationExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the PythonImplementationExtension class.
+ // ===================================================================
+ PythonImplementationExtension::~PythonImplementationExtension()
+ {
+ logentry();
+ }
+
+ const string PythonImplementationExtension::extensionName("python");
+ const string PythonImplementationExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#PythonImplementation");
+
+ // ===================================================================
+ // loadModelElement - load the info from implementation.python
+ // ===================================================================
+ ComponentType* PythonImplementationExtension::getImplementation(Composite *composite, DataObjectPtr scdlImplementation)
+ {
+ logentry();
+
+ string module = scdlImplementation->getCString("module");
+ string path = scdlImplementation->getCString("path");
+ string className = scdlImplementation->getCString("class");
+ string scopeName = scdlImplementation->getCString("scope");
+
+ PythonImplementation::Scope scope;
+ if (scopeName == "composite")
+ {
+ scope = PythonImplementation::COMPOSITE;
+ }
+ else
+ {
+ scope = PythonImplementation::STATELESS;
+ }
+
+ PythonImplementation* pythonImpl = new PythonImplementation(composite, module, path, className, scope);
+
+ return pythonImpl;
+ }
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.h
new file mode 100644
index 0000000000..c94925c3fc
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.h
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_python_pythonimplementationextension_h
+#define tuscany_sca_python_pythonimplementationextension_h
+
+#include "tuscany/sca/extension/ImplementationExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+
+ class PythonImplementationExtension : public ImplementationExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ PythonImplementationExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~PythonImplementationExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.python")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ComponentType* getImplementation(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlImplementation);
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_python_pythonimplementationextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.cpp
new file mode 100644
index 0000000000..1d5e3b6361
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.cpp
@@ -0,0 +1,123 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/python/PythonInterfaceExtension.h"
+#include "tuscany/sca/python/model/PythonInterface.h"
+#include "tuscany/sca/util/Logging.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+ // ===================================================================
+ // Constructor for the PythonInterfaceExtension class.
+ // ===================================================================
+ PythonInterfaceExtension::PythonInterfaceExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the PythonInterfaceExtension class.
+ // ===================================================================
+ PythonInterfaceExtension::~PythonInterfaceExtension()
+ {
+ logentry();
+ }
+
+ const string PythonInterfaceExtension::extensionName("python");
+ const string PythonInterfaceExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#PythonInterface");
+
+ // ===================================================================
+ // loadModelElement - load the info from interface.python
+ // ===================================================================
+ tuscany::sca::model::Interface* PythonInterfaceExtension::getInterface(Composite* composite, DataObjectPtr scdlInterface)
+ {
+ logentry();
+
+ // Determine the type
+ string ifType = scdlInterface->getType().getName();
+ if (ifType == "PythonInterface")
+ {
+ bool remotable = scdlInterface->getBoolean("remotable");
+ bool conversational = scdlInterface->getBoolean("conversational");
+
+ return new PythonInterface(remotable, conversational);
+ //DataObjectList& operationList = scdlInterface->getList("operation");
+
+ //for(int i=0; i<operationList.size(); i++)
+ //{
+ // string opName = operationList[i]->getCString("name");
+
+ // if(operationList[i]->hasProperty("returnType"))
+ // {
+ // string returnType = operationList[i]->getCString("returnType");
+
+ // if(returnType == "string")
+ // {
+ // pythonInterface->addOperation(opName, PythonInterface::STRING);
+ // }
+ // else if(returnType == "int")
+ // {
+ // pythonInterface->addOperation(opName, PythonInterface::INT);
+ // }
+ // else if(returnType == "long")
+ // {
+ // pythonInterface->addOperation(opName, PythonInterface::LONG);
+ // }
+ // else if(returnType == "boolean")
+ // {
+ // pythonInterface->addOperation(opName, PythonInterface::BOOLEAN);
+ // }
+ // else if(returnType == "float")
+ // {
+ // pythonInterface->addOperation(opName, PythonInterface::FLOAT);
+ // }
+ // else if(returnType == "other")
+ // {
+ // pythonInterface->addOperation(opName, PythonInterface::OTHER);
+ // }
+ // else
+ // {
+ // pythonInterface->addOperation(opName, PythonInterface::NONE);
+ // }
+ // }
+ // else
+ // {
+ // // No return Type provided - set as NONE
+ // pythonInterface->addOperation(opName, PythonInterface::NONE);
+ // }
+ //}
+ //
+ //return pythonInterface;
+ }
+ return 0;
+ }
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.h
new file mode 100644
index 0000000000..803d94743d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.h
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_python_pythoninterfaceextension_h
+#define tuscany_sca_python_pythoninterfaceextension_h
+
+#include "tuscany/sca/extension/InterfaceExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+
+ class PythonInterfaceExtension : public InterfaceExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ PythonInterfaceExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~PythonInterfaceExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#PythonInterface")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::Interface* getInterface(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlInterface);
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_python_pythoninterfaceextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.cpp
new file mode 100644
index 0000000000..9282bb953c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.cpp
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/python/PythonServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/python/model/PythonReferenceBinding.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+
+ // ============================================
+ // Constructor: Create a proxy from a reference
+ // ============================================
+ PythonServiceProxy::PythonServiceProxy(Reference* reference)
+ : ServiceProxy(reference)
+ {
+ logentry();
+
+ // Get the service wrapper
+ PythonReferenceBinding* referenceBinding = (PythonReferenceBinding*)reference->getBinding();
+ serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
+ }
+
+ // ==========================================
+ // Constructor: Create a proxy from a service
+ // ==========================================
+ PythonServiceProxy::PythonServiceProxy(Service* service)
+ : ServiceProxy(NULL)
+ {
+ logentry();
+
+ // Get the service wrapper
+ serviceWrapper = service->getBinding()->getServiceWrapper();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ PythonServiceProxy::~PythonServiceProxy()
+ {
+ logentry();
+ }
+
+ // =====================================================
+ // invokeService: invoke the service wired to this proxy
+ // =====================================================
+ void PythonServiceProxy::invokeService(Operation& operation)
+ {
+ logentry();
+
+ // Invoke the service
+ serviceWrapper->invoke(operation);
+ }
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.h
new file mode 100644
index 0000000000..64f856f51d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.h
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_python_pythonserviceproxy_h
+#define tuscany_sca_python_pythonserviceproxy_h
+
+#include "export.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+
+ /**
+ * Holds a proxy for a given reference from a component implemented in Python.
+ */
+ class PythonServiceProxy : public ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a reference. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The reference on the source component.
+ */
+ PythonServiceProxy(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Create a new service proxy for a service. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param service The service on the target component.
+ */
+ SCA_PYTHON_API PythonServiceProxy(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PythonServiceProxy();
+
+ /**
+ * Invoke the wired service.
+ */
+ virtual void invokeService(Operation& operation);
+
+ private:
+
+ /**
+ * The target service wrapper
+ */
+ ServiceWrapper* serviceWrapper;
+ };
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_python_pythonserviceproxy_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
new file mode 100644
index 0000000000..57ac5baeb5
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
@@ -0,0 +1,1096 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/python/PythonServiceWrapper.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/python/model/PythonImplementation.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+
+ /**
+ * Prints out PyObject and dir(PyObject)
+ * for debugging purposes
+ */
+ void printPyObject(char * name, PyObject *pObj)
+ {
+ PyObject* pObjRepr = PyObject_Repr(pObj);
+ loginfo("PyObject %s: %s", name, PyString_AsString(pObjRepr));
+ Py_DECREF(pObjRepr);
+
+ PyObject* pObjDir = PyObject_Dir(pObj);
+ PyObject* pObjDirRepr = PyObject_Repr(pObjDir);
+ loginfo("PyObject dir(%s): %s", name, PyString_AsString(pObjDirRepr));
+ Py_DECREF(pObjDirRepr);
+ Py_DECREF(pObjDir);
+ }
+
+ // ===========
+ // Constructor
+ // ===========
+ PythonServiceWrapper::PythonServiceWrapper(Service* service)
+ : ServiceWrapper(service)
+ {
+ logentry();
+
+ component = service->getComponent();
+ implementation = (PythonImplementation*)component->getType();
+
+ pythonModule = NULL;
+ pythonClassInstance = NULL;
+
+ // -----------------------------------------------
+ // Get the implementation for the target component
+ // -----------------------------------------------
+ PythonImplementation* impl = (PythonImplementation*)component->getType();
+ if (!impl)
+ {
+ string msg = "Component " + component->getName() + " has no implementation defined";
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ // Initialize the Python environment
+ Py_Initialize();
+
+ // Add the path to the composite (+ any further path specified) to the Python sys.path
+ string path = component->getComposite()->getRoot();
+ if(impl->getModulePath().size() > 0)
+ {
+ path += "/" + impl->getModulePath();
+ }
+
+ loginfo("Module: %s", impl->getModule().c_str());
+ loginfo("Path: %s", path.c_str());
+ loginfo("Class: %s", impl->getClass().c_str());
+
+ PyObject* pSysName = PyString_FromString("sys");
+ PyObject* pSys = PyImport_Import(pSysName);
+ Py_DECREF(pSysName);
+
+ if(pSys != NULL)
+ {
+ PyObject* pSysPath = PyObject_GetAttrString(pSys, "path");
+
+ if(pSysPath != NULL && PyList_Check(pSysPath))
+ {
+ PyObject* pPath = PyString_FromString(path.c_str());
+ PyList_Append(pSysPath, pPath);
+
+ Py_DECREF(pPath);
+ Py_DECREF(pSysPath);
+ }
+ Py_DECREF(pSys);
+ }
+
+ if(&(impl->getModule()) != NULL && impl->getModule().size() > 0)
+ {
+ // Now import the module
+ PyObject* pModuleName = PyString_FromString(impl->getModule().c_str());
+
+ pythonModule = PyImport_Import(pModuleName);
+ Py_DECREF(pModuleName);
+ }
+
+ if (!pythonModule)
+ {
+ if(PyErr_Occurred())
+ {
+ PyErr_Print();
+ }
+ string msg = "Failed to load module named " + impl->getModule() + " on path " + path;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ printPyObject("pythonModule",pythonModule);
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ PythonServiceWrapper::~PythonServiceWrapper()
+ {
+ logentry();
+
+ Py_XDECREF(pythonClassInstance);
+ Py_XDECREF(pythonModule);
+ Py_Finalize();
+ }
+
+ // ======================================================================
+ // newInstance: create a new class instance
+ // ======================================================================
+ PyObject* PythonServiceWrapper::newInstance()
+ {
+ logentry();
+
+ PythonImplementation* impl = (PythonImplementation*)component->getType();
+ string className = impl->getClass();
+
+ PyObject* pClassInstance = NULL;
+ if (pythonModule != NULL)
+ {
+ if(&className != NULL && className.size() > 0)
+ {
+ // We have a class name, so create an instance and use this to invoke the correct function
+ PyObject* pClass = PyObject_GetAttrString(pythonModule, (char*) className.c_str());
+
+ if(pClass == NULL)
+ {
+ if(PyErr_Occurred())
+ {
+ PyErr_Print();
+ }
+ string msg = "Cannot find class named " + className + " in Python module";
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ pClassInstance = PyInstance_New(pClass, NULL, NULL);
+
+ if(pClassInstance == NULL || !PyInstance_Check(pClassInstance))
+ {
+ if(PyErr_Occurred())
+ {
+ PyErr_Print();
+ }
+ string msg = "Could not create new instance of class named " + className + " in Python module";
+ throwException(ServiceInvocationException, msg.c_str());
+ }
+ Py_XDECREF(pClass);
+ }
+ }
+ return pClassInstance;
+ }
+
+ // ======================================================================
+ // getInstance: get a class instance for this scope
+ // ======================================================================
+ PyObject* PythonServiceWrapper::getInstance()
+ {
+ logentry();
+
+ PythonImplementation::Scope scope = implementation->getScope();
+ if (scope == PythonImplementation::COMPOSITE)
+ {
+ if (!pythonClassInstance)
+ {
+ pythonClassInstance = newInstance();
+ }
+ return pythonClassInstance;
+ }
+ else // (scope == PythonImplementation::STATELESS)
+ {
+ return newInstance();
+ }
+ }
+
+ // ======================================================================
+ // releaseImplementation: release the implementation for this scope
+ // ======================================================================
+ void PythonServiceWrapper::releaseInstance()
+ {
+ logentry();
+
+ PythonImplementation::Scope scope = implementation->getScope();
+ if(scope == PythonImplementation::STATELESS)
+ {
+ // Delete the class instance if there is one
+ if(pythonClassInstance != NULL && PyInstance_Check(pythonClassInstance))
+ {
+ Py_DECREF(pythonClassInstance);
+ pythonClassInstance = NULL;
+ }
+
+ // Need to reload the module
+ PyObject* reloadedPythonModule = PyImport_ReloadModule(pythonModule);
+
+ if(reloadedPythonModule != NULL)
+ {
+ // Get rid of old pythonModule and replace with the reloaded one
+ Py_DECREF(pythonModule);
+ pythonModule = reloadedPythonModule;
+ }
+ }
+ }
+
+ // ======================================================================
+ // invoke: wrapper call to service with setting the component context
+ // ======================================================================
+ void PythonServiceWrapper::invoke(Operation& operation)
+ {
+ logentry();
+
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ runtime->setCurrentComponent(component);
+
+
+ // Load the references & properties into the module
+ addReferences(pythonModule);
+ addProperties(pythonModule);
+
+ try
+ {
+ loginfo("Operation: %s", operation.getName().c_str());
+
+ PyObject* pFunc = NULL;
+ pythonClassInstance = getInstance();
+
+ if(pythonClassInstance != NULL && PyInstance_Check(pythonClassInstance))
+ {
+ // Get the function from the instance
+ pFunc = PyObject_GetAttrString(pythonClassInstance, (char*) operation.getName().c_str());
+ }
+ if(pFunc == NULL && pythonModule != NULL)
+ {
+ // Get the function directly from the module if it could not be got from an instance
+ pFunc = PyObject_GetAttrString(pythonModule, (char*) operation.getName().c_str());
+ }
+ if(pFunc == NULL)
+ {
+ // Can't get the function from the class or module
+ string msg = "Python module or class instance has not been created";
+ throwException(ServiceInvocationException, msg.c_str());
+ }
+
+ if (pFunc && PyCallable_Check(pFunc))
+ {
+ PyObject* pArgs = PyTuple_New(operation.getNParms());
+ PyObject* pKeywordsDict = PyDict_New();
+ PyObject* pValue = NULL;
+
+ // Load up the xml.etree.ElementTree module for dealing with SDO params and return values
+ PyObject* elementTreeModuleName = PyString_FromString("xml.etree.ElementTree");
+ PyObject* elementTreeModule = PyImport_Import(elementTreeModuleName);
+
+ if(elementTreeModule == NULL)
+ {
+ // pre-Python2.5? - try to get an installed elementtree package
+ elementTreeModuleName = PyString_FromString("elementtree.ElementTree");
+ elementTreeModule = PyImport_Import(elementTreeModuleName);
+ }
+ if(elementTreeModule == NULL)
+ {
+ // Still null - throw a warning but carry on - user may not need XML
+ logwarning("Could not load Python ElementTree module - is it installed? SDO and XML will not be supported");
+ }
+
+ for(unsigned int i = 0; i < operation.getNParms(); i++)
+ {
+ const Operation::Parameter& parm = operation.getParameter(i);
+ switch(parm.getType())
+ {
+ case Operation::BOOL:
+ {
+ if( *(bool*)parm.getValue())
+ {
+ //boolean true
+ pValue = Py_True;
+ }
+ else
+ {
+ pValue = Py_False;
+ }
+ break;
+ }
+ case Operation::SHORT:
+ {
+ pValue = PyInt_FromLong(*(short*)parm.getValue());
+ break;
+ }
+ case Operation::USHORT:
+ {
+ pValue = PyInt_FromLong(*(unsigned short*)parm.getValue());
+ break;
+ }
+ case Operation::INT:
+ {
+ pValue = PyInt_FromLong(*(int*)parm.getValue());
+ break;
+ }
+ case Operation::UINT:
+ {
+ pValue = PyInt_FromLong(*(unsigned int*)parm.getValue());
+ break;
+ }
+ case Operation::LONG:
+ {
+ pValue = PyLong_FromLong(*(long*)parm.getValue());
+ break;
+ }
+ case Operation::ULONG:
+ {
+ pValue = PyLong_FromUnsignedLong(*(unsigned long*)parm.getValue());
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ pValue = PyFloat_FromDouble(*(float*)parm.getValue());
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ pValue = PyFloat_FromDouble(*(double*)parm.getValue());
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ pValue = PyFloat_FromDouble(*(long double*)parm.getValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ pValue = PyString_FromString(*(char**)parm.getValue());
+ break;
+ }
+ case Operation::STRING:
+ {
+ pValue = PyString_FromString((*(string*)parm.getValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ if(elementTreeModule != NULL)
+ {
+ DataObjectPtr dob = *(DataObjectPtr*)parm.getValue();
+
+ // Convert a DataObject to a xml.etree.ElementTree Element object
+ Composite* composite = component->getComposite();
+ XMLHelper* xmlHelper = composite->getXMLHelper();
+ char* str = xmlHelper->save(
+ dob,
+ dob->getType().getURI(),
+ dob->getType().getName());
+
+ loginfo("Converting SDO DataObject to Python ElementTree: %s", str);
+
+ // Get the xml.etree.ElementTree.XML function
+ PyObject* elementTreeXMLFunc = PyObject_GetAttrString(elementTreeModule, "XML");
+
+ // Call the XML() function with the XML string
+ pValue = PyObject_CallFunction(elementTreeXMLFunc, "s", str);
+
+ Py_DECREF(elementTreeXMLFunc);
+ }
+ else
+ {
+ throwException(ServiceDataException, "Could not convert SDO DataObject to Python ElementTree as ElementTree module could not be loaded");
+ }
+ break;
+ }
+ default:
+ throwException(ServiceDataException, "Operation parameter type not supported");
+ }
+
+ if (!pValue)
+ {
+ Py_DECREF(pArgs);
+
+ if(PyErr_Occurred())
+ {
+ PyErr_Print();
+ }
+
+ string msg = "Error converting parameter into Python type";
+ throwException(ServiceDataException, msg.c_str());
+
+ }
+ //printPyObject("Param value", pValue);
+
+ // If we have a param name, put it in the keyword args
+ if(parm.hasName())
+ {
+ PyDict_SetItemString(pKeywordsDict, parm.getName().c_str(), pValue);
+ Py_DECREF(pValue);
+ }
+ else
+ {
+ /* pValue reference stolen here: */
+ PyTuple_SetItem(pArgs, i, pValue);
+ }
+ }
+
+ // Resize the args to the correct length
+ _PyTuple_Resize(&pArgs, operation.getNParms() - PyDict_Size(pKeywordsDict));
+
+ loginfo("Calling python func with %d args and %d keyword args", PyTuple_Size(pArgs), PyDict_Size(pKeywordsDict));
+
+ pValue = PyObject_Call(pFunc, pArgs, pKeywordsDict);
+ //printPyObject("Return value", pValue);
+
+ Py_DECREF(pArgs);
+ if (pValue != NULL)
+ {
+ char buf[20];
+ if(PyInt_Check(pValue) || PyLong_Check(pValue))
+ {
+ long* data = new long;
+ if(PyInt_Check(pValue))
+ {
+ loginfo("Int return value: %d", PyInt_AsLong(pValue));
+ *data = PyInt_AsLong(pValue);
+ }
+ else
+ {
+ loginfo("Long return value: %l", PyLong_AsLong(pValue));
+ *data = PyLong_AsLong(pValue);
+ }
+
+ // Check if the return type has already been set (for typed languages)
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ *(bool*)operation.getReturnValue() = (*data != 0);
+ break;
+ }
+ case Operation::SHORT:
+ {
+ *(short*)operation.getReturnValue() = (short)*data;
+ break;
+ }
+ case Operation::USHORT:
+ {
+ *(unsigned short*)operation.getReturnValue() = (unsigned short)*data;
+ break;
+ }
+ case Operation::INT:
+ {
+ *(int*)operation.getReturnValue() = (int)*data;
+ break;
+ }
+ case Operation::UINT:
+ {
+ *(unsigned int*)operation.getReturnValue() = (unsigned int)*data;
+ break;
+ }
+ case Operation::LONG:
+ {
+ *(long*)operation.getReturnValue() = (long)*data;
+ break;
+ }
+ case Operation::ULONG:
+ {
+ *(unsigned long*)operation.getReturnValue() = (unsigned long)*data;
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ *(float*)operation.getReturnValue() = (float)*data;
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ *(double*)operation.getReturnValue() = (double)*data;
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ *(long double*)operation.getReturnValue() = (long double)*data;
+ break;
+ }
+ case Operation::CHARS:
+ {
+ sprintf(buf, "%d", *data);
+ *(char**)operation.getReturnValue() = buf;
+ break;
+ }
+ case Operation::STRING:
+ {
+ sprintf(buf, "%d", *data);
+ *(string*)operation.getReturnValue() = buf;
+ break;
+ }
+ default:
+ {
+ // The type is set as something else or has not been set
+ operation.setReturnValue(data);
+ }
+ }
+ }
+ else if(PyBool_Check(pValue))
+ {
+ loginfo("Bool return value: %d", (pValue == Py_True));
+ bool* data = new bool;
+ *data = (pValue == Py_True);
+
+ // Check if the return type has already been set (for typed languages)
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ *(bool*)operation.getReturnValue() = *data;
+ break;
+ }
+ case Operation::SHORT:
+ {
+ *(short*)operation.getReturnValue() = (short)*data;
+ break;
+ }
+ case Operation::USHORT:
+ {
+ *(unsigned short*)operation.getReturnValue() = (unsigned short)*data;
+ break;
+ }
+ case Operation::INT:
+ {
+ *(int*)operation.getReturnValue() = (int)*data;
+ break;
+ }
+ case Operation::UINT:
+ {
+ *(unsigned int*)operation.getReturnValue() = (unsigned int)*data;
+ break;
+ }
+ case Operation::LONG:
+ {
+ *(long*)operation.getReturnValue() = (long)*data;
+ break;
+ }
+ case Operation::ULONG:
+ {
+ *(unsigned long*)operation.getReturnValue() = (unsigned long)*data;
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ *(float*)operation.getReturnValue() = (float)*data;
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ *(double*)operation.getReturnValue() = (double)*data;
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ *(long double*)operation.getReturnValue() = (long double)*data;
+ break;
+ }
+ case Operation::CHARS:
+ {
+ if(*data)
+ {
+ *(char**)operation.getReturnValue() = "true";
+ }
+ else
+ {
+ *(char**)operation.getReturnValue() = "false";
+ }
+ break;
+ }
+ case Operation::STRING:
+ {
+ if(*data)
+ {
+ *(string*)operation.getReturnValue() = "true";
+ }
+ else
+ {
+ *(string*)operation.getReturnValue() = "false";
+ }
+ break;
+ }
+ default:
+ {
+ // The type is set as something else or has not been set
+ operation.setReturnValue(data);
+ }
+ }
+ }
+ else if(PyFloat_Check(pValue))
+ {
+ loginfo("Float return value: %f", PyFloat_AsDouble(pValue));
+
+ double* data = new double;
+ *data = PyFloat_AsDouble(pValue);
+
+ // Check if the return type has already been set (for typed languages)
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ *(bool*)operation.getReturnValue() = (*data != 0.0);
+ break;
+ }
+ case Operation::SHORT:
+ {
+ *(short*)operation.getReturnValue() = (short)*data;
+ break;
+ }
+ case Operation::USHORT:
+ {
+ *(unsigned short*)operation.getReturnValue() = (unsigned short)*data;
+ break;
+ }
+ case Operation::INT:
+ {
+ *(int*)operation.getReturnValue() = (int)*data;
+ break;
+ }
+ case Operation::UINT:
+ {
+ *(unsigned int*)operation.getReturnValue() = (unsigned int)*data;
+ break;
+ }
+ case Operation::LONG:
+ {
+ *(long*)operation.getReturnValue() = (long)*data;
+ break;
+ }
+ case Operation::ULONG:
+ {
+ *(unsigned long*)operation.getReturnValue() = (unsigned long)*data;
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ *(float*)operation.getReturnValue() = (float)*data;
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ *(double*)operation.getReturnValue() = (double)*data;
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ *(long double*)operation.getReturnValue() = (long double)*data;
+ break;
+ }
+ case Operation::CHARS:
+ {
+ sprintf(buf, "%f", *data);
+ *(char**)operation.getReturnValue() = buf;
+ break;
+ }
+ case Operation::STRING:
+ {
+ sprintf(buf, "%f", *data);
+ *(string*)operation.getReturnValue() = buf;
+ break;
+ }
+ default:
+ {
+ // The type is set as something else or has not been set
+ operation.setReturnValue(data);
+ }
+ }
+ }
+ else if(PyString_Check(pValue))
+ {
+ loginfo("String return value: %s", PyString_AsString(pValue));
+ const char** data = new const char*;
+ *data = PyString_AsString(pValue);
+
+ // Check if the return type has already been set (for typed languages)
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ // If the string is empty or "0" or "false" set to false, otherwise true
+ if(strlen(*data) == 0 || strcmp(*data, "0") == 0 || strcmp(*data, "false") == 0)
+ {
+ *(bool*)operation.getReturnValue() = false;
+ }
+ else
+ {
+ *(bool*)operation.getReturnValue() = true;
+ }
+ break;
+ }
+ case Operation::SHORT:
+ {
+ *(short*)operation.getReturnValue() = (short)atoi(*data);
+ break;
+ }
+ case Operation::USHORT:
+ {
+ *(unsigned short*)operation.getReturnValue() = (unsigned short)atoi(*data);
+ break;
+ }
+ case Operation::INT:
+ {
+ *(int*)operation.getReturnValue() = (int)atoi(*data);
+ break;
+ }
+ case Operation::UINT:
+ {
+ *(unsigned int*)operation.getReturnValue() = (unsigned int)atoi(*data);
+ break;
+ }
+ case Operation::LONG:
+ {
+ *(long*)operation.getReturnValue() = (long)atol(*data);
+ break;
+ }
+ case Operation::ULONG:
+ {
+ *(unsigned long*)operation.getReturnValue() = (unsigned long)atol(*data);
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ *(float*)operation.getReturnValue() = (float)atof(*data);
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ *(double*)operation.getReturnValue() = (double)atof(*data);
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ *(long double*)operation.getReturnValue() = (long double)atof(*data);
+ break;
+ }
+ case Operation::CHARS:
+ {
+ *(const char**)operation.getReturnValue() = *data;
+ break;
+ }
+ case Operation::STRING:
+ {
+ *(string*)operation.getReturnValue() = *data;
+ break;
+ }
+ default:
+ {
+ // The type is set as something else or has not been set
+ string* stringData = new string;
+ *stringData = *data;
+ operation.setReturnValue(stringData);
+ }
+ }
+ }
+ else
+ {
+ PyObject* pIsElement = Py_False;
+
+ if(elementTreeModule != NULL)
+ {
+ // Get the xml.etree.ElementTree.iselement function
+ PyObject* elementTreeIsElementFunc = PyObject_GetAttrString(elementTreeModule, "iselement");
+
+ // Call the iselement() function with pValue to check it
+ pIsElement = PyObject_CallFunction(elementTreeIsElementFunc, "O", pValue);
+ Py_DECREF(elementTreeIsElementFunc);
+ }
+
+ if(PyObject_IsTrue(pIsElement) == 1)
+ {
+ // pValue is an xml.etree.ElementTree.Element - convert to SDO
+ PyObject* elementTreeToStringFunc = PyObject_GetAttrString(elementTreeModule, "tostring");
+ PyObject* pElemString = PyObject_CallFunction(elementTreeToStringFunc, "O", pValue);
+ char* data = PyString_AsString(pElemString);
+
+ loginfo("Converting Python ElementTree to SDO DataObject: %s", data);
+
+ Composite* composite = component->getComposite();
+ XMLHelper* xmlHelper = composite->getXMLHelper();
+ XMLDocumentPtr xmlDoc = xmlHelper->load(data);
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ if (xmlDoc != NULL)
+ {
+ *dataObjectData = xmlDoc->getRootDataObject();
+ }
+ else
+ {
+ *dataObjectData = NULL;
+ }
+
+ if (*dataObjectData != NULL)
+ {
+ operation.setReturnValue(dataObjectData);
+ }
+ else
+ {
+ string msg = "xml.etree.ElementTree.Element could not be converted to a DataObject";
+ throwException(ServiceDataException, msg.c_str());
+ }
+
+ Py_DECREF(elementTreeToStringFunc);
+ Py_DECREF(pElemString);
+ }
+ else
+ {
+ PyObject* valueRepr = PyObject_Repr(pValue);
+ PyObject* valueType = PyObject_Type(pValue);
+ PyObject* valueTypeRepr = PyObject_Repr(valueType);
+ loginfo("Return value of unknown type (%s) has repr: %s", PyString_AsString(valueTypeRepr), PyString_AsString(valueRepr));
+ Py_DECREF(valueTypeRepr);
+ Py_DECREF(valueType);
+ Py_DECREF(valueRepr);
+ }
+
+ Py_DECREF(pIsElement);
+ }
+
+ Py_DECREF(elementTreeModule);
+ Py_DECREF(elementTreeModuleName);
+ Py_DECREF(pValue);
+ }
+ else
+ {
+ Py_DECREF(pFunc);
+ Py_XDECREF(elementTreeModule);
+ Py_XDECREF(elementTreeModuleName);
+
+ string msg = "Error whilst calling Python function "+operation.getName()+": ";
+ if(PyErr_Occurred())
+ {
+ PyObject *pErrorType, *pErrorValue, *pErrorTraceback;
+ PyErr_Fetch(&pErrorType, &pErrorValue, &pErrorTraceback);
+
+ if (pErrorType != NULL && pErrorValue != NULL)
+ {
+ PyObject* pErrorTypeStr = PyObject_Str(pErrorType);
+ PyObject* pErrorValueStr = PyObject_Str(pErrorValue);
+ msg += PyString_AsString(pErrorTypeStr);
+ msg += " : ";
+ msg += PyString_AsString(pErrorValueStr);
+ Py_DECREF(pErrorTypeStr);
+ Py_DECREF(pErrorValueStr);
+ }
+ else
+ {
+ msg += "No Python Error information provided";
+ }
+ Py_XDECREF(pErrorType);
+ Py_XDECREF(pErrorValue);
+ Py_XDECREF(pErrorTraceback);
+
+ PyErr_Print();
+ }
+
+ throwException(ServiceInvocationException, msg.c_str());
+ }
+ }
+ else
+ {
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ }
+ string msg = "Cannot find the operation named " + operation.getName() + " in the Python module";
+ throwException(ServiceInvocationException, msg.c_str());
+ }
+ Py_XDECREF(pFunc);
+
+ }
+ catch (...)
+ {
+ releaseInstance();
+ runtime->unsetCurrentComponent();
+ throw;
+ }
+ releaseInstance();
+ runtime->unsetCurrentComponent();
+ }
+
+
+ // ==========================================================================
+ // Add any properties into the loaded implementation module as Python objects
+ // ==========================================================================
+ void PythonServiceWrapper::addProperties(PyObject* module)
+ {
+ logentry();
+
+ // Set all the configured properties
+ DataObjectPtr properties = component->getProperties();
+ PropertyList pl = properties->getInstanceProperties();
+
+ for (unsigned int i = 0; i < pl.size(); i++)
+ {
+ if (properties->isSet(pl[i]))
+ {
+ string propName = pl[i].getName();
+ string propValue = properties->getCString(pl[i]);
+ PyObject* property;
+
+ if(pl[i].isMany())
+ {
+ //TODO - deal with properties that are many
+ }
+
+ switch(pl[i].getTypeEnum())
+ {
+ case Type::BooleanType:
+ {
+ if(properties->getBoolean(pl[i]))
+ {
+ property = Py_True;
+ }
+ else
+ {
+ property = Py_False;
+ }
+ Py_INCREF(property);
+ break;
+ }
+ case Type::BigIntegerType:
+ case Type::BigDecimalType:
+ case Type::LongType:
+ {
+ property = PyLong_FromLongLong(properties->getLong(pl[i]));
+ break;
+ }
+ case Type::ShortType:
+ case Type::IntegerType:
+ {
+ property = PyInt_FromLong(properties->getInteger(pl[i]));
+ break;
+ }
+ case Type::DoubleType:
+ case Type::FloatType:
+ {
+ property = PyFloat_FromDouble(properties->getDouble(pl[i]));
+ break;
+ }
+ case Type::DataObjectType:
+ case Type::OpenDataObjectType:
+ {
+ // Serialize a DataObject and create a python string object from the XML
+ DataObjectPtr data = properties->getDataObject(pl[i]);
+ XMLHelperPtr helper = HelperProvider::getXMLHelper(properties->getDataFactory());
+ string serializedData = helper->save(data,
+ data->getType().getURI(),
+ data->getType().getName());
+
+ loginfo("Converting SDO DataObject to Python ElementTree: %s", serializedData.c_str());
+
+ // Get the xml.etree.ElementTree.XML function
+ PyObject* elementTreeModuleName = PyString_FromString("xml.etree.ElementTree");
+ PyObject* elementTreeModule = PyImport_Import(elementTreeModuleName);
+ PyObject* elementTreeXMLFunc = PyObject_GetAttrString(elementTreeModule, "XML");
+
+ // Call the XML() function with the XML string
+ property = PyObject_CallFunction(elementTreeXMLFunc, "s", serializedData.c_str());
+
+ Py_DECREF(elementTreeXMLFunc);
+ Py_DECREF(elementTreeModule);
+ Py_DECREF(elementTreeModuleName);
+ break;
+ }
+ case Type::CharacterType:
+ case Type::StringType:
+ case Type::TextType:
+ case Type::UriType:
+ default:
+ {
+ // For strings and by default create a python string object
+ property = PyString_FromString(propValue.c_str());
+ break;
+ }
+ }
+
+ int success = PyModule_AddObject(module, (char*)propName.c_str(), property);
+
+ if(success == 0)
+ {
+ loginfo("Added property named %s with type %s and value %s to python module", propName.c_str(), pl[i].getType().getName(), propValue.c_str());
+ }
+ else
+ {
+ logwarning("Failed to add property named %s to python module", propName.c_str());
+ }
+ }
+ }
+ }
+
+
+ // ======================================================================
+ // Add any references into the loaded implementation module as class instances that look like
+ // the classes defined in the interface.python xml
+ // ======================================================================
+ void PythonServiceWrapper::addReferences(PyObject* module)
+ {
+ logentry();
+
+ // Import the TuscanySCA python-extension module
+ PyObject* pModuleName = PyString_FromString("sca_proxy");
+ PyObject* sca_proxy_module = PyImport_Import(pModuleName);
+ Py_DECREF(pModuleName);
+
+ if(!sca_proxy_module)
+ {
+ if(PyErr_Occurred())
+ {
+ PyErr_Print();
+ }
+ string msg = "Failed to load the sca_proxy Python module - has it been successfully installed?\nReferences from Python components will not be supported";
+ logwarning(msg.c_str());
+ }
+ else
+ {
+ // Get the sca_proxy class
+ PyObject* sca_proxy_class = PyObject_GetAttrString(sca_proxy_module, "sca_proxy_class");
+
+ // Iterate through the references of the current component, adding
+ // each reference to the module
+ Component::REFERENCE_MAP references = component->getReferences();
+ Component::REFERENCE_MAP::iterator pos;
+ for( pos = references.begin(); pos != references.end(); ++pos)
+ {
+ ReferenceType* referenceType = ((Reference*) pos->second)->getType();
+ string referenceName = referenceType->getName();
+
+ PyObject* tuscanySCAArgs = PyTuple_New(2);
+ PyObject* refName = PyString_FromString(referenceType->getName().c_str());
+ PyTuple_SetItem(tuscanySCAArgs, 0, refName);
+ Py_INCREF(Py_True);
+ PyTuple_SetItem(tuscanySCAArgs, 1, Py_True);
+
+ // Create the instance of the TuscanySCAReference class
+ PyObject* sca_proxy_classInstance = PyInstance_New(sca_proxy_class, tuscanySCAArgs, NULL);
+ Py_DECREF(tuscanySCAArgs);
+
+ int success = PyModule_AddObject(module, (char*)referenceName.c_str(), sca_proxy_classInstance);
+
+ if(success == 0)
+ {
+ loginfo("Successfully added sca_proxy_class instance as %s to pythonModule", referenceName.c_str());
+ }
+ else
+ {
+ logwarning("Failed to add sca_proxy_class instance as %s to pythonModule", referenceName.c_str());
+ }
+ }
+ Py_DECREF(sca_proxy_module);
+ }
+ }
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h
new file mode 100644
index 0000000000..fbf75b3223
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h
@@ -0,0 +1,142 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_python_pythonservicewrapper_h
+#define tuscany_sca_python_pythonservicewrapper_h
+
+
+// undefine _DEBUG so Python does not need it's deebug dll
+#ifdef _DEBUG
+#undef _DEBUG
+#define _SCA_PYTHON_DEBUG
+#endif
+#include <Python.h>
+#ifdef _SCA_PYTHON_DEBUG
+#define _DEBUG
+#endif
+
+#include "tuscany/sca/python/export.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/python/model/PythonImplementation.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+ class PythonInterface;
+
+ /**
+ * Wraps the service on a component implementation.
+ * This abstract class is extended by generated code which provides
+ * the implementation of some of the methods.
+ * An instance of this class wraps the actual component implementation which
+ * has been written by a developer of an SCA application.
+ */
+ class PythonServiceWrapper : public ServiceWrapper
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param target The component service to which this wrapper refers.
+ */
+ PythonServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PythonServiceWrapper();
+
+ /**
+ * All business method calls to the target component go through the invoke method.
+ * @param operation The details of the method, paramaters and return value for the
+ * business method to be called on the target component.
+ */
+ virtual void invoke(Operation& operation);
+
+
+ protected:
+
+ /**
+ * Return the current instance of the python class.
+ * @return A pointer to an instance of the python class.
+ */
+ virtual PyObject* getInstance();
+
+ /**
+ * Creates a new instance of the python class.
+ * @return A pointer to a new instance of the python class.
+ */
+ virtual PyObject* newInstance();
+
+ /**
+ * Indicates that the current instance of the python module or class
+ * has been finished with.
+ */
+ virtual void releaseInstance();
+
+
+ private:
+ /**
+ * Holds a class instance if a classname is provided.
+ * Will be constructed each time if scope is set to STATELESS
+ */
+ PyObject* pythonClassInstance;
+
+ /**
+ * Holds the module
+ */
+ PyObject* pythonModule;
+
+ /**
+ * Adds references to the provided implementation module or class instance
+ */
+ void addReferences(PyObject* module);
+
+ /**
+ * Adds properties to the provided implementation module or class instance
+ */
+ void addProperties(PyObject* module);
+
+ /**
+ * The component to which this wrapper refers.
+ */
+ tuscany::sca::model::Component* component;
+
+ /**
+ * The component implementation
+ */
+ PythonImplementation* implementation;
+
+ };
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_python_pythonservicewrapper_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/export.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/export.h
new file mode 100644
index 0000000000..b608a50711
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/export.h
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_python_export_h
+#define tuscany_sca_python_export_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef TUSCANY_SCA_PYTHON_EXPORTS
+#define SCA_PYTHON_API __declspec(dllexport)
+#else
+#define SCA_PYTHON_API __declspec(dllimport)
+#endif
+
+#else
+#include <sys/time.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#define SCA_PYTHON_API
+#endif
+
+#endif // tuscany_sca_export_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.cpp
new file mode 100644
index 0000000000..235468eca9
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.cpp
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/python/model/PythonImplementation.h"
+#include "tuscany/sca/python/model/PythonServiceBinding.h"
+#include "tuscany/sca/python/model/PythonReferenceBinding.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace python
+ {
+
+ // Constructor
+ PythonImplementation::PythonImplementation(
+ Composite* composite, const string& module, const string& modulePath, const string& className, Scope scope)
+ : ComponentType(composite, modulePath + "/" + module),
+ module(module), modulePath(modulePath), className(className), scope(scope)
+ {
+ logentry();
+
+ // Create a default service for this componentType
+ ServiceType* defaultServiceType = new ServiceType(this, "", NULL, NULL);
+ addServiceType(defaultServiceType);
+ }
+
+ PythonImplementation::~PythonImplementation()
+ {
+ logentry();
+ }
+
+ /**
+ * Overrides the findReferenceType method in ComponentType.
+ * This allows us to create references without needing a componentType file.
+ */
+ ReferenceType* PythonImplementation::findReferenceType(const string& referenceName)
+ {
+ logentry();
+
+ ReferenceType* refType = ComponentType::findReferenceType(referenceName);
+ if(!refType)
+ {
+ // The reference has not yet been created - try creating it
+ refType = new ReferenceType(this, referenceName, NULL, NULL, ReferenceType::ONE_ONE);
+ addReferenceType(refType);
+ }
+
+ return refType;
+ }
+
+ /**
+ * Overrides the findPropertyType method in ComponentType.
+ * This allows us to create properties without needing a componentType file.
+ */
+ const commonj::sdo::Property* PythonImplementation::findPropertyType(const string& propertyName)
+ {
+ logentry();
+
+ const commonj::sdo::Property* prop = ComponentType::findPropertyType(propertyName);
+ if(!prop)
+ {
+ ComponentType::addPropertyType(propertyName, "http://www.w3.org/2001/XMLSchema#string", false, NULL);
+ // Just added it so it should now be available
+ prop = ComponentType::findPropertyType(propertyName);
+ loginfo("Added string property named %s to Python component", propertyName.c_str());
+ }
+
+ return prop;
+ }
+
+ void PythonImplementation::initializeComponent(Component* component)
+ {
+ logentry();
+ ComponentType::initializeComponent(component);
+
+ // Create Python bindings for all the services
+ const Component::SERVICE_MAP& services = component->getServices();
+ Component::SERVICE_MAP::const_iterator iter = services.begin();
+ for (unsigned int i=0; i< services.size(); i++)
+ {
+ Service *service = iter->second;
+ PythonServiceBinding* binding = new PythonServiceBinding(service);
+ service->setBinding(binding);
+ iter++;
+ }
+
+ // Create Python bindings for all the references
+ const Component::REFERENCE_MAP& references = component->getReferences();
+ Component::REFERENCE_MAP::const_iterator refiter = references.begin();
+ for (int ri=0; ri< references.size(); ri++)
+ {
+ Reference *reference = refiter->second;
+ PythonReferenceBinding* binding = new PythonReferenceBinding(reference);
+ reference->setBinding(binding);
+ refiter++;
+ }
+ }
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.h
new file mode 100644
index 0000000000..75b14529bf
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.h
@@ -0,0 +1,145 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_python_model_pythonimplementation_h
+#define tuscany_sca_python_model_pythonimplementation_h
+
+#include <string>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/model/ComponentType.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+ /**
+ * Holds information about an SCA implementation written in Python
+ */
+ class PythonImplementation : public tuscany::sca::model::ComponentType
+ {
+
+ public:
+ /**
+ * Scope of the component implementation.
+ */
+ enum Scope
+ {
+ COMPOSITE,
+ STATELESS
+ };
+
+ /**
+ * Constructor.
+ * @param composite The composite containing this implementation.
+ * @param module Name of the module.
+ * @param modulePath Path to the module (could be a blank string
+ * if this is not specified).
+ * @param className Name of the class in the module (could be a blank string
+ * if this is not specified).
+ */
+ PythonImplementation(tuscany::sca::model::Composite* composite,
+ const std::string& module, const std::string& modulePath, const std::string& className,
+ Scope scope);
+
+ /**
+ * Destructor
+ */
+ virtual ~PythonImplementation();
+
+ /**
+ * Initialize a component of this type.
+ * @param component The component to initialize.
+ */
+ virtual void initializeComponent(tuscany::sca::model::Component* component);
+
+ /**
+ * Override the ComponentType::findReferenceType method
+ * to allow Python components to be defined without requiring
+ * a componentType side-file
+ */
+ virtual tuscany::sca::model::ReferenceType* findReferenceType(const std::string& referenceName);
+
+ /**
+ * Override the ComponentType::findPropertyType method
+ * to allow Python components to be defined without requiring
+ * a componentType side-file
+ */
+ virtual const commonj::sdo::Property* findPropertyType(const std::string& propertyName);
+
+
+ /**
+ * Returns the name of the module.
+ * @return The name of the module.
+ */
+ const std::string& getModule() const { return module; }
+
+ /**
+ * Get the header path.
+ * @return The pathe element of the header.
+ */
+ const std::string& getModulePath() const { return modulePath; }
+
+ /**
+ * Get the name of the class.
+ * @return The class name if specified.
+ */
+ const std::string& getClass() const { return className; }
+
+ /**
+ * Returns the implementation scope
+ */
+ Scope getScope() const { return scope; }
+
+ private:
+
+ /**
+ * Name of the module.
+ */
+ std::string module;
+
+ /**
+ * Path to the module.
+ */
+ std::string modulePath;
+
+ /**
+ * Name of the class in the header file declaring the implementation.
+ * May be an empty string if not set in the SCDL file.
+ */
+ std::string className;
+
+ /**
+ * The implementation scope
+ */
+ Scope scope;
+ };
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_python_model_pythonimplementation_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.cpp
new file mode 100644
index 0000000000..3c30f363b8
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.cpp
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/python/export.h"
+#include "tuscany/sca/python/model/PythonInterface.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+ const string PythonInterface::typeQName("http://www.osoa.org/xmlns/sca/1.0#PythonInterface");
+
+ // Constructor
+ PythonInterface::PythonInterface(
+ bool remotable,
+ bool conversational)
+ : Interface(remotable, conversational)
+ {
+ logentry();
+ }
+
+ PythonInterface::~PythonInterface()
+ {
+ logentry();
+ }
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.h
new file mode 100644
index 0000000000..cfc2ca8914
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_python_model_pythoninterface_h
+#define tuscany_sca_python_model_pythoninterface_h
+
+#include <string>
+
+#include "tuscany/sca/python/export.h"
+#include "tuscany/sca/model/Interface.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+ /**
+ * Holds information about an interface described using a Python
+ * header file.
+ */
+ class PythonInterface : public tuscany::sca::model::Interface
+ {
+
+ public:
+ /**
+ * Constuctor.
+ * @param scope The scope of the interface (stateless or composite).
+ * @param remotable True if the interface is remotable.
+ */
+ PythonInterface(
+ bool remotable,
+ bool conversational);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PythonInterface();
+
+ /**
+ * return the QName of the schema type for this interface type
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp")
+ */
+ const std::string& getInterfaceTypeQName() { return typeQName; };
+
+ /**
+ * The QName of the schema type for this interface type.
+ */
+ SCA_PYTHON_API static const std::string typeQName;
+
+ };
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_python_model_pythoninterface_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.cpp
new file mode 100644
index 0000000000..c2564c4db1
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/python/model/PythonReferenceBinding.h"
+#include "tuscany/sca/python/PythonServiceProxy.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+
+ // Constructor
+ PythonReferenceBinding::PythonReferenceBinding(Reference* reference)
+ : ReferenceBinding(reference, ""), serviceProxy(NULL)
+ {
+ }
+
+ // Destructor
+ PythonReferenceBinding::~PythonReferenceBinding()
+ {
+ }
+
+ ServiceProxy* PythonReferenceBinding::getServiceProxy()
+ {
+ return serviceProxy;
+ }
+
+ void PythonReferenceBinding::configure(ServiceBinding* binding)
+ {
+ targetServiceBinding = binding;
+
+ serviceProxy = new PythonServiceProxy(getReference());
+ }
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.h
new file mode 100644
index 0000000000..f993730d8e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.h
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_python_model_pythonreferencebinding_h
+#define tuscany_sca_python_model_pythonreferencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+ /**
+ * Information about a Python service binding for service or a reference.
+ */
+ class PythonReferenceBinding : public tuscany::sca::model::ReferenceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ */
+ PythonReferenceBinding(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PythonReferenceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#PythonImplementationBinding"; };
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ virtual ServiceProxy* getServiceProxy();
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding);
+
+ /**
+ * Returns the target service binding.
+ */
+ tuscany::sca::model::ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; };
+
+ private:
+
+ /**
+ * The proxy representing the reference to the client
+ * component.
+ */
+ ServiceProxy* serviceProxy;
+
+ /**
+ * The service binding of the target
+ */
+ tuscany::sca::model::ServiceBinding* targetServiceBinding;
+ };
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_python_model_pythonreferencebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.cpp
new file mode 100644
index 0000000000..061aeb7515
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/python/model/PythonServiceBinding.h"
+#include "tuscany/sca/python/PythonServiceWrapper.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+
+ // Constructor
+ PythonServiceBinding::PythonServiceBinding(Service* service)
+ : ServiceBinding(service, "")
+ {
+ logentry();
+ serviceWrapper = new PythonServiceWrapper(service);
+ }
+
+ // Destructor
+ PythonServiceBinding::~PythonServiceBinding()
+ {
+ logentry();
+ }
+
+ ServiceWrapper* PythonServiceBinding::getServiceWrapper()
+ {
+ logentry();
+ return (ServiceWrapper*)serviceWrapper;
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.h
new file mode 100644
index 0000000000..9a803cdced
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.h
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_python_model_pythonservicebinding_h
+#define tuscany_sca_python_model_pythonservicebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ServiceBinding.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace python
+ {
+ /**
+ * Information about a Python service binding for service or a reference.
+ */
+ class PythonServiceBinding : public tuscany::sca::model::ServiceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ * @param port The definition of the port to which the entrypoint
+ * or external service is to be bound. This is of the form
+ * "namespace"#endpoint("service"/"port")
+ */
+ PythonServiceBinding(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PythonServiceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#PythonImplementationBinding"; };
+
+ /**
+ * Create a wrapper for the service configured by this
+ * binding.
+ */
+ virtual ServiceWrapper* getServiceWrapper();
+
+ private:
+
+ /**
+ * The wrapper for the service configured by this binding.
+ */
+ ServiceWrapper* serviceWrapper;
+
+ };
+
+ } // End namespace python
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_python_model_pythonservicebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp
new file mode 100644
index 0000000000..bd34549f8a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp
@@ -0,0 +1,540 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <string>
+#include <iostream>
+#include <sstream>
+
+// undefine _DEBUG so Python does not need it's debug dll
+#ifdef _DEBUG
+#undef _DEBUG
+#define _SCA_PYTHON_DEBUG
+#endif
+#include <Python.h>
+#ifdef _SCA_PYTHON_DEBUG
+#define _DEBUG
+#endif
+
+#include "commonj/sdo/SDO.h"
+
+#include "PythonServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/core/Operation.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+static PyObject* scaError;
+
+/**
+* Prints out PyObject and dir(PyObject)
+* for debugging purposes
+*/
+static void printPyObject(char* prefix, char* name, PyObject* pObj)
+{
+ PyObject* pObjRepr = PyObject_Repr(pObj);
+ PyTypeObject* type = pObj->ob_type;
+ loginfo("%s printPyObject (%s) %s = %s", prefix, type->tp_name, name, PyString_AsString(pObjRepr));
+ Py_XDECREF(pObjRepr);
+
+ if(pObj != NULL)
+ {
+ PyObject* pObjDir = PyObject_Dir(pObj);
+ PyObject* pObjDirRepr = PyObject_Repr(pObjDir);
+ loginfo("%s printPyObject dir(%s): %s", prefix, name, PyString_AsString(pObjDirRepr));
+ Py_DECREF(pObjDirRepr);
+ Py_DECREF(pObjDir);
+ }
+}
+
+static PyObject* sca_locateservice(PyObject *self, PyObject *args)
+{
+ logentry();
+
+ // Get the service name
+ PyObject* pServiceName = PyTuple_GetItem(args, 0);
+
+ // Import the SCA python-extension module
+ PyObject* pModuleName = PyString_FromString("sca_proxy");
+ PyObject* sca_proxy_module = PyImport_Import(pModuleName);
+ Py_DECREF(pModuleName);
+
+ if(!sca_proxy_module)
+ {
+ if(PyErr_Occurred())
+ {
+ PyErr_Print();
+ }
+ string msg = "Failed to load the sca_proxy Python module - has it been successfully installed?\nReferences from Python components will not be supported";
+ logerror(msg.c_str());
+ }
+ else
+ {
+ // Get the sca_proxy class
+ PyObject* sca_proxy_class = PyObject_GetAttrString(sca_proxy_module, "sca_proxy_class");
+
+ PyObject* scaArgs = PyTuple_New(2);
+ PyTuple_SetItem(scaArgs, 0, pServiceName);
+ Py_INCREF(Py_True);
+ PyTuple_SetItem(scaArgs, 1, Py_False);
+
+ // Create the instance of the scaReference class
+ PyObject* sca_proxy_classInstance = PyInstance_New(sca_proxy_class, scaArgs, NULL);
+ Py_DECREF(scaArgs);
+
+ return sca_proxy_classInstance;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+static tuscany::sca::python::PythonServiceProxy* getServiceProxy(PyObject *args)
+{
+ logentry();
+
+ tuscany::sca::python::PythonServiceProxy* serviceProxy = NULL;
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+
+ // The first argument holds the name
+ string name;
+ PyObject* pName = PyTuple_GetItem(args, 0);
+ if(pName && PyString_Check(pName))
+ {
+ name = PyString_AsString(pName);
+ }
+ if(name.size() > 0)
+ {
+ loginfo("Service/Reference name is %s", name.c_str());
+ }
+ else
+ {
+ string msg = "Service/Reference name has not been set";
+ logwarning(msg.c_str());
+ PyErr_SetString(scaError, msg.c_str());
+ return NULL;
+ }
+
+ // The second argument is a boolean
+ PyObject* isReference = PyTuple_GetItem(args, 1);
+
+ // Get the serviceProxy from the reference or service name provided
+ if(PyObject_IsTrue(isReference))
+ {
+ Component* component = runtime->getCurrentComponent();
+ Reference* ref = component->findReference(name);
+ if(!ref)
+ {
+ string msg = "Could not find the reference: "+name;
+ logwarning(msg.c_str());
+ PyErr_SetString(scaError, msg.c_str());
+
+ return NULL;
+ }
+
+ ReferenceBinding* refBinding = ref->getBinding();
+ serviceProxy = (tuscany::sca::python::PythonServiceProxy*) refBinding->getServiceProxy();
+ }
+ else
+ {
+ Component* component = runtime->getDefaultComponent();
+ Composite* composite = (Composite*)component->getType();
+ Service* service = composite->findComponentService(name);
+
+ if(!service)
+ {
+ string msg = "Could not find service: "+name;
+ logwarning(msg.c_str());
+ PyErr_SetString(scaError, msg.c_str());
+ return NULL;
+ }
+
+ serviceProxy = new tuscany::sca::python::PythonServiceProxy(service);
+ }
+
+ return serviceProxy;
+}
+
+
+static PyObject* sca_invoke(PyObject *self, PyObject *args)
+{
+ logentry();
+
+ tuscany::sca::python::PythonServiceProxy* pythonServiceProxy = getServiceProxy(args);
+ if(!pythonServiceProxy)
+ {
+ return NULL;
+ }
+
+ // Get the component from the reference or service provided
+ Component* component = NULL;
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+
+ PyObject* isReference = PyTuple_GetItem(args, 1);
+ if(PyObject_IsTrue(isReference))
+ {
+ component = runtime->getCurrentComponent();
+ }
+ else
+ {
+ component = runtime->getDefaultComponent();
+ }
+
+ // Get the name of the operation to invoke
+ string operationName;
+ PyObject* opName = PyTuple_GetItem(args, 2);
+ if(opName && PyString_Check(opName))
+ {
+ operationName = PyString_AsString(opName);
+ }
+
+ if(operationName.size() > 0)
+ {
+ loginfo("sca_invoke Operation name: %s", operationName.c_str());
+ }
+ else
+ {
+ string msg = "Operation name has not been set";
+ logwarning(msg.c_str());
+ PyErr_SetString(scaError, msg.c_str());
+ return NULL;
+ }
+
+ // Create the Operation object
+ Operation operation(operationName.c_str());
+
+ // Load up the xml.etree.ElementTree module for dealing with SDO params and return values
+ PyObject* elementTreeModuleName = PyString_FromString("xml.etree.ElementTree");
+ PyObject* elementTreeModule = PyImport_Import(elementTreeModuleName);
+
+ if(elementTreeModule == NULL)
+ {
+ // pre-Python2.5? - try to get an installed elementtree package
+ elementTreeModuleName = PyString_FromString("elementtree.ElementTree");
+ elementTreeModule = PyImport_Import(elementTreeModuleName);
+ }
+ if(elementTreeModule == NULL)
+ {
+ // Still null - throw a warning but carry on - user may not need XML
+ logwarning("Could not load Python ElementTree module - is it installed? SDO and XML will not be supported");
+ }
+
+ // Parameters are the fourth argument
+ PyObject* paramTuple = PyTuple_GetItem(args, 3);
+ unsigned int numberOfArgs = (unsigned int) PyTuple_Size(paramTuple);
+ loginfo("sca_invoke %d arg parameters supplied", numberOfArgs);
+
+ // Keyword parameters (AKA named arguments) are the fifth argument
+ PyObject* keywordParamDict = PyTuple_GetItem(args, 4);
+ loginfo("sca_invoke %d keyword parameters supplied", PyDict_Size(keywordParamDict));
+
+ PyObject* paramKeys = PyDict_Keys(keywordParamDict);
+
+ // Go through all the supplied parameters (args and keyword args)
+ for(unsigned int i=0; i < (numberOfArgs + PyList_Size(paramKeys)); i++)
+ {
+ string* paramName;
+ PyObject* param;
+
+ if(i < PyTuple_Size(paramTuple))
+ {
+ param = PyTuple_GetItem(paramTuple, i);
+ paramName = new string();
+ }
+ else
+ {
+ PyObject* key = PyList_GetItem(paramKeys, i-numberOfArgs);
+ param = PyDict_GetItem(keywordParamDict, key);
+ paramName = new string(PyString_AsString(key));
+ }
+
+ if(PyInt_Check(param))
+ {
+ loginfo("Int param %d %s: %d", i, (*paramName).c_str(), PyInt_AsLong(param));
+ long* intData = new long;
+ *intData = PyInt_AsLong(param);
+ operation.addParameter(*paramName, intData);
+ }
+ else if(PyBool_Check(param))
+ {
+ loginfo("Bool param %d %s: %d", i, (*paramName).c_str(), (param == Py_True));
+ bool* boolData = new bool;
+ *boolData = (param == Py_True);
+ operation.addParameter(*paramName, boolData);
+ }
+ else if(PyLong_Check(param))
+ {
+ loginfo("Long param %d %s: %l", i, (*paramName).c_str(), PyLong_AsLong(param));
+ long* longData = new long;
+ *longData = PyLong_AsLong(param);
+ operation.addParameter(*paramName, longData);
+ }
+ else if(PyFloat_Check(param))
+ {
+ loginfo("Float param %d %s: %f", i, (*paramName).c_str(), PyFloat_AsDouble(param));
+ double* doubleData = new double;
+ *doubleData = PyFloat_AsDouble(param);
+ operation.addParameter(*paramName, doubleData);
+ }
+ else if(PyString_Check(param))
+ {
+ loginfo("String param %d %s: %s", i, (*paramName).c_str(), PyString_AsString(param));
+ const char** stringData = new const char*;
+ *stringData = PyString_AsString(param);
+ operation.addParameter(*paramName, stringData);
+ }
+ else
+ {
+ PyObject* pIsElement = Py_False;
+ if(elementTreeModule != NULL)
+ {
+ // Get the xml.etree.ElementTree.iselement function
+ PyObject* elementTreeIsElementFunc = PyObject_GetAttrString(elementTreeModule, "iselement");
+
+ // Call the iselement() function with pValue to check it
+ pIsElement = PyObject_CallFunction(elementTreeIsElementFunc, "O", param);
+ }
+
+ if(PyObject_IsTrue(pIsElement) == 1)
+ {
+ // pValue is an xml.etree.ElementTree.Element - convert to SDO
+ PyObject* elementTreeToStringFunc = PyObject_GetAttrString(elementTreeModule, "tostring");
+ PyObject* pElemString = PyObject_CallFunction(elementTreeToStringFunc, "O", param);
+ char* data = PyString_AsString(pElemString);
+ loginfo("SDO param %d %s: %s", i, (*paramName).c_str(), data);
+
+ loginfo("Converting Python ElementTree to SDO DataObject: %s", data);
+
+ Composite* composite = component->getComposite();
+ XMLHelper* xmlHelper = composite->getXMLHelper();
+ XMLDocumentPtr xmlDoc = xmlHelper->load(data);
+
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ if (xmlDoc != NULL)
+ {
+ *dataObjectData = xmlDoc->getRootDataObject();
+ }
+ else
+ {
+ *dataObjectData = NULL;
+ }
+ if (*dataObjectData != NULL)
+ {
+ operation.addParameter(*paramName, dataObjectData);
+ }
+ else
+ {
+ string msg = "xml.etree.ElementTree.Element could not be converted to a DataObject";
+ logerror(msg.c_str());
+ PyErr_SetString(scaError, msg.c_str());
+ return NULL;
+ }
+ Py_DECREF(elementTreeToStringFunc);
+ Py_DECREF(pElemString);
+ }
+ else
+ {
+
+ PyObject* paramRepr = PyObject_Repr(param);
+ PyObject* paramType = PyObject_Type(param);
+ PyObject* paramTypeRepr = PyObject_Repr(paramType);
+
+ string msg = "sca_invoke Param ";
+ msg += i;
+ msg += "is of unknown type (";
+ msg += PyString_AsString(paramTypeRepr);
+ msg += ") and has repr: ";
+ msg += PyString_AsString(paramRepr);
+
+ logerror(msg.c_str());
+ PyErr_SetString(scaError, msg.c_str());
+
+ Py_DECREF(paramTypeRepr);
+ Py_DECREF(paramType);
+ Py_DECREF(paramRepr);
+
+ return NULL;
+ }
+ }
+ }
+
+ PyObject* returnValue = NULL;
+
+ try
+ {
+ // Invoke the wired service
+ pythonServiceProxy->invokeService(operation);
+ }
+ catch(TuscanyRuntimeException& ex)
+ {
+ string msg = "Exception whilst invoking the ";
+ msg += operationName.c_str();
+ msg += " operation on an SCA service/reference: ";
+ msg += ex.getEClassName();
+ msg += ": ";
+ msg += ex.getMessageText();
+ logwarning(msg.c_str());
+ PyErr_SetString(scaError, msg.c_str());
+ return NULL;
+ }
+ catch(...)
+ {
+ string msg = "Exception whilst invoking the ";
+ msg += operationName.c_str();
+ msg += " operation on an SCA service/reference";
+
+ logwarning(msg.c_str());
+ PyErr_SetString(scaError, msg.c_str());
+ return NULL;
+ }
+
+
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ if(*(bool*)operation.getReturnValue())
+ {
+ returnValue = Py_True;
+ }
+ else
+ {
+ returnValue = Py_False;
+ }
+ break;
+ }
+ case Operation::SHORT:
+ {
+ returnValue = PyInt_FromLong(*(short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONG:
+ {
+ returnValue = PyLong_FromLong(*(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::USHORT:
+ {
+ returnValue = PyInt_FromLong(*(unsigned short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::ULONG:
+ {
+ returnValue = PyLong_FromLong(*(unsigned long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ returnValue = PyFloat_FromDouble(*(float*)operation.getReturnValue());
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ returnValue = PyFloat_FromDouble(*(double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ returnValue = PyFloat_FromDouble(*(long double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ returnValue = PyString_FromString(*(char**)operation.getReturnValue());
+ break;
+ }
+ case Operation::STRING:
+ {
+ returnValue = PyString_FromString((*(string*)operation.getReturnValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ if(elementTreeModule != NULL)
+ {
+ DataObjectPtr dob = *(DataObjectPtr*)operation.getReturnValue();
+
+ // Convert a DataObject to a xml.etree.ElementTree Element object
+ Composite* composite = component->getComposite();
+ XMLHelper* xmlHelper = composite->getXMLHelper();
+ char* str = xmlHelper->save(
+ dob,
+ dob->getType().getURI(),
+ dob->getType().getName());
+
+ loginfo("Converting SDO DataObject to Python ElementTree: %s", str);
+
+ // Get the xml.etree.ElementTree.XML function
+ PyObject* elementTreeXMLFunc = PyObject_GetAttrString(elementTreeModule, "XML");
+
+ // Call the XML() function with the XML string
+ returnValue = PyObject_CallFunction(elementTreeXMLFunc, "s", str);
+
+ Py_DECREF(elementTreeXMLFunc);
+ }
+ else
+ {
+ logwarning("Could not convert SDO DataObject to Python ElementTree as ElementTree module could not be loaded. Returning NONE");
+ Py_INCREF(Py_None);
+ returnValue = Py_None;
+ }
+ break;
+ }
+ default:
+ {
+ Py_INCREF(Py_None);
+ returnValue = Py_None;
+ }
+
+ }
+
+ Py_XDECREF(elementTreeModuleName);
+ Py_XDECREF(elementTreeModule);
+
+ return returnValue;
+}
+static PyMethodDef ModuleMethods[] =
+{
+ {"locateservice", (PyCFunction) sca_locateservice, METH_VARARGS, "Locates an SCA service & returns an sca_proxy_class instance"},
+ {"invoke", (PyCFunction) sca_invoke, METH_VARARGS, "Invoke an operation on an SCA service or reference"},
+ {NULL, NULL, 0, NULL} /* Sentinel */
+};
+
+PyMODINIT_FUNC initsca(void)
+{
+ logentry();
+
+ // Create a new module
+ PyObject* module = Py_InitModule("sca", ModuleMethods);
+
+ scaError = PyErr_NewException("sca.error", NULL, NULL);
+ Py_INCREF(scaError);
+ PyModule_AddObject(module, "error", scaError);
+}
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py
new file mode 100644
index 0000000000..92a224275e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py
@@ -0,0 +1,57 @@
+# 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 used in the SCA package and
+# provides the proxy objects to a Python SCA component or SCA
+# client.
+#
+# This is done by overloading the __getattr__ method which makes
+# calls to myProxy.anyMethod go to __getattr__ which will return
+# the invokeFunction defined inside the invoke method
+
+import sca
+
+class sca_proxy_class:
+
+ sca_proxy_name = ''
+ sca_proxy_is_reference = 1
+
+ def __init__(self, name, isReference):
+ self.sca_proxy_name = name
+ self.sca_proxy_is_reference = isReference
+ return
+
+ def invoke(self, operationName):
+
+ def invokeFunction(*args, **kwargs):
+ # Pass the args and keywords in to the invoke method as arguments
+ return sca.invoke(self.sca_proxy_name, self.sca_proxy_is_reference, operationName, args, kwargs)
+
+ return invokeFunction
+
+ def __getattr__(self, operationName):
+ return self.invoke(operationName)
+
+ def __str__(self):
+ return '<sca_proxy.sca_proxy_class instance for ' + self.sca_proxy_name + '>'
+
+ def __repr__(self):
+ return '<sca_proxy.sca_proxy_class instance for ' + self.sca_proxy_name + '>'
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/xsd/sca-implementation-python.xsd b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/xsd/sca-implementation-python.xsd
new file mode 100644
index 0000000000..e1c7247992
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/xsd/sca-implementation-python.xsd
@@ -0,0 +1,49 @@
+<?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.
+-->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+
+ <element name="implementation.python" type="sca:PythonImplementation" substitutionGroup="sca:implementation"/>
+ <complexType name="PythonImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="module" type="NCName" use="required"/>
+ <attribute name="path" type="NCName" use="optional"/>
+ <attribute name="class" type="Name" use="optional"/>
+ <attribute name="scope" type="sca:PythonImplementationScope" use="optional" />
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="PythonImplementationScope">
+ <restriction base="string">
+ <enumeration value="stateless" />
+ <enumeration value="composite" />
+ </restriction>
+ </simpleType>
+</schema>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/xsd/sca-interface-python.xsd b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/xsd/sca-interface-python.xsd
new file mode 100644
index 0000000000..dd9075c7fb
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/python/xsd/sca-interface-python.xsd
@@ -0,0 +1,62 @@
+<?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.
+-->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <element name="interface.python" type="sca:PythonInterface" substitutionGroup="sca:interface"/>
+ <complexType name="PythonInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <element name="operation" type="sca:PythonOperation" minOccurs="0" maxOccurs="unbounded" />
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="remotable" type="boolean" use="optional" />
+ <attribute name="conversational" type="boolean" use="optional" />
+ <anyAttribute namespace="##any" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="PythonOperation">
+ <complexContent>
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="string" use="required" />
+ <attribute name="returnType" type="sca:PythonReturnTypes" use="optional" />
+ <anyAttribute namespace="##any" processContents="lax" />
+ </complexContent>
+ </complexType>
+
+ <simpleType name="PythonReturnTypes">
+ <restriction base="string">
+ <enumeration value="string" />
+ <enumeration value="int" />
+ <enumeration value="long" />
+ <enumeration value="boolean" />
+ <enumeration value="float" />
+ <enumeration value="other" />
+ </restriction>
+ </simpleType>
+</schema>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/Makefile.am
new file mode 100644
index 0000000000..742a8152ad
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/Makefile.am
@@ -0,0 +1,6 @@
+SUBDIRS = interface reference service
+datadir=$(prefix)/extensions/rest
+
+nobase_data_DATA = xsd/*.xsd
+
+EXTRA_DIST = xsd \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/deploy.bat
new file mode 100644
index 0000000000..6ad4ef66ea
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/deploy.bat
@@ -0,0 +1,45 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set restextdir=%extdir%\rest
+set srcdir=%rootdir%\runtime\extensions\rest
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %restextdir% mkdir %restextdir%
+if not exist %restextdir%\xsd mkdir %restextdir%\xsd
+
+copy %srcdir%\xsd\*.* %restextdir%\xsd
+
+goto end
+:usage
+echo Usage: deploy <sca-root>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/Makefile.am
new file mode 100644
index 0000000000..f963effea2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = src \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/deploy.bat
new file mode 100644
index 0000000000..07c74d9e81
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/deploy.bat
@@ -0,0 +1,66 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set restextdir=%extdir%\rest
+set intfextdir=%restextdir%\interface
+set srcdir=%rootdir%\runtime\extensions\rest\interface\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %restextdir% mkdir %restextdir%
+if not exist %intfextdir% mkdir %intfextdir%
+if not exist %intfextdir%\module mkdir %intfextdir%\module
+if not exist %intfextdir%\bin mkdir %intfextdir%\bin
+if not exist %intfextdir%\lib mkdir %intfextdir%\lib
+
+set libname=tuscany_sca_rest_interface
+
+del %intfextdir%\bin\%libname%.*
+del %intfextdir%\lib\%libname%.*
+
+copy %inpath%\%libname%.lib %intfextdir%\lib
+copy %inpath%\%libname%.dll %intfextdir%\bin
+copy %inpath%\%libname%.dll %intfextdir%\module
+
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %intfextdir%\bin
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %intfextdir%\module
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/Makefile.am
new file mode 100644
index 0000000000..8007a89d13
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/Makefile.am
@@ -0,0 +1,25 @@
+libdir=$(prefix)/extensions/rest/interface/lib
+lib_LTLIBRARIES = libtuscany_sca_rest_interface.la
+
+noinst_HEADERS = tuscany/sca/rest/*.h tuscany/sca/rest/model/*.h
+
+libtuscany_sca_rest_interface_la_SOURCES = \
+tuscany/sca/rest/RESTInterfaceExtension.cpp \
+tuscany/sca/rest/model/RESTInterface.cpp
+
+libtuscany_sca_rest_interface_la_LIBADD = \
+ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca
+
+INCLUDES = -I$(top_builddir)/runtime/core/src \
+ -I${TUSCANY_SDOCPP}/include
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+moduledir=$(prefix)/extensions/rest/interface/module
+extension = libtuscany_sca_rest_interface$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension) \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.cpp
new file mode 100644
index 0000000000..c69febf39a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.cpp
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/rest/RESTInterfaceExtension.h"
+#include "tuscany/sca/rest/model/RESTInterface.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_rest_interface_initialize()
+ {
+ tuscany::sca::rest::RESTInterfaceExtension::initialize();
+ }
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+ // ===================================================================
+ // Constructor for the RESTInterfaceExtension class.
+ // ===================================================================
+ RESTInterfaceExtension::RESTInterfaceExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the RESTInterfaceExtension class.
+ // ===================================================================
+ RESTInterfaceExtension::~RESTInterfaceExtension()
+ {
+ logentry();
+ }
+
+ const string RESTInterfaceExtension::extensionName("rest");
+ const string RESTInterfaceExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#RESTInterface");
+
+ // ===================================================================
+ // loadModelElement - load the info from interface.rest
+ // ===================================================================
+ tuscany::sca::model::Interface* RESTInterfaceExtension::getInterface(Composite* composite, DataObjectPtr scdlInterface)
+ {
+ logentry();
+
+ return new RESTInterface();
+ }
+
+ void RESTInterfaceExtension::initialize()
+ {
+ logentry();
+ SCARuntime::getCurrentRuntime()->registerInterfaceExtension(new RESTInterfaceExtension());
+ }
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.h
new file mode 100644
index 0000000000..de61ee5751
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.h
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_rest_restinterfaceextension_h
+#define tuscany_sca_rest_restinterfaceextension_h
+
+#include "tuscany/sca/extension/InterfaceExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+
+ class RESTInterfaceExtension : public InterfaceExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ RESTInterfaceExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~RESTInterfaceExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema type for this interface extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.rest")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::Interface* getInterface(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlInterface);
+
+ static void initialize();
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_rest_restinterfaceextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/exportinterface.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/exportinterface.h
new file mode 100644
index 0000000000..f3636f0d39
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/exportinterface.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_rest_exportinterface_h
+#define tuscany_sca_rest_exportinterface_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef TUSCANY_SCA_REST_INTERFACE_EXPORTS
+#define SCA_REST_INTERFACE_API __declspec(dllexport)
+#else
+#define SCA_REST_INTERFACE_API __declspec(dllimport)
+#endif
+
+#else
+#define SCA_REST_INTERFACE_API
+#endif
+
+#endif // tuscany_sca_rest_exportinterface_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/model/RESTInterface.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/model/RESTInterface.cpp
new file mode 100644
index 0000000000..34feda2049
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/model/RESTInterface.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/rest/model/RESTInterface.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+
+ const string RESTInterface::typeQName("http://www.osoa.org/xmlns/sca/1.0#RESTInterface");
+
+ // Constructor
+ RESTInterface::RESTInterface()
+ : Interface(true, false)
+ {
+ logentry();
+ }
+
+ RESTInterface::~RESTInterface()
+ {
+ logentry();
+ }
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/model/RESTInterface.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/model/RESTInterface.h
new file mode 100644
index 0000000000..88aacecc16
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/interface/src/tuscany/sca/rest/model/RESTInterface.h
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_rest_model_restinterface_h
+#define tuscany_sca_rest_model_restinterface_h
+
+#include <string>
+
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/rest/exportinterface.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+ /**
+ * Holds information about a REST interface
+ */
+ class RESTInterface : public tuscany::sca::model::Interface
+ {
+
+ public:
+ /**
+ * Constuctor.
+ * @param header Name of the header file containing the class that
+ * describes the interface.
+ * @param className Name of the class in the header file that
+ * describes the interface.
+ * @param scope The scope of the interface (stateless or composite).
+ * @param remotable True if the interface is remotable.
+ */
+ RESTInterface();
+
+ /**
+ * Destructor.
+ */
+ virtual ~RESTInterface();
+
+ /**
+ * return the QName of the schema type for this interface type
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.rest")
+ */
+ virtual const std::string& getInterfaceTypeQName() { return typeQName; };
+
+ /**
+ * The QName of the schema type for this interface type.
+ */
+ SCA_REST_INTERFACE_API static const std::string typeQName;
+
+ private:
+
+ };
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_rest_model_restinterface_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/Makefile.am
new file mode 100644
index 0000000000..2a0247f16f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = curl \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/Makefile.am
new file mode 100644
index 0000000000..f963effea2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = src \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/Makefile.am
new file mode 100644
index 0000000000..834853a6cf
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/Makefile.am
@@ -0,0 +1,31 @@
+libdir=$(prefix)/extensions/rest/reference/lib
+lib_LTLIBRARIES = libtuscany_sca_rest_reference.la
+
+noinst_HEADERS = tuscany/sca/rest/*.h tuscany/sca/rest/model/*.h
+
+libtuscany_sca_rest_reference_la_SOURCES = \
+tuscany/sca/rest/RESTServiceBindingExtension.cpp \
+tuscany/sca/rest/model/RESTServiceBinding.cpp \
+tuscany/sca/rest/RESTServiceWrapper.cpp
+
+libtuscany_sca_rest_reference_la_LIBADD = \
+ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca \
+ -L$(top_builddir)/runtime/extensions/rest/interface/src -ltuscany_sca_rest_interface \
+ -L${CURL_LIB} -lcurl
+
+INCLUDES = -I$(top_builddir)/runtime/core/src \
+ -I$(top_builddir)/runtime/extensions/rest/interface/src \
+ -I${TUSCANY_SDOCPP}/include \
+ -I${CURL_INCLUDE}
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+
+moduledir=$(prefix)/extensions/rest/reference/module
+extension = libtuscany_sca_rest_reference$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension) \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.cpp
new file mode 100644
index 0000000000..f8eb9ad05c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.cpp
@@ -0,0 +1,89 @@
+/*
+* 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.
+*/
+
+#include "RESTServiceBindingExtension.h"
+#include "model/RESTServiceBinding.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_rest_reference_initialize()
+ {
+ tuscany::sca::rest::RESTServiceBindingExtension::initialize();
+ }
+}
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+ // ===================================================================
+ // Constructor for the RESTServiceBinding class.
+ // ===================================================================
+ RESTServiceBindingExtension::RESTServiceBindingExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the RESTServiceBindingExtension class.
+ // ===================================================================
+ RESTServiceBindingExtension::~RESTServiceBindingExtension()
+ {
+ logentry();
+ }
+
+ const string RESTServiceBindingExtension::extensionName("rest");
+ const string RESTServiceBindingExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#RESTBinding");
+
+
+ // ===================================================================
+ // loadModelElement - load the info from binding.rest
+ // ===================================================================
+ ServiceBinding* RESTServiceBindingExtension::getServiceBinding(Composite *composite, Service* service, DataObjectPtr scdlBinding)
+ {
+ string uri = scdlBinding->getCString("uri");
+
+ RESTServiceBinding* serviceBinding = new RESTServiceBinding(service, uri);
+
+ return serviceBinding;
+ }
+
+ void RESTServiceBindingExtension::initialize()
+ {
+ logentry();
+ SCARuntime::getCurrentRuntime()->registerServiceBindingExtension(new RESTServiceBindingExtension());
+ }
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.h
new file mode 100644
index 0000000000..ad1d861d95
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.h
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+#ifndef tuscany_sca_extension_rest_restservicebindingextension_h
+#define tuscany_sca_extension_rest_restservicebindingextension_h
+
+#include "tuscany/sca/extension/ServiceBindingExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+
+ class RESTServiceBindingExtension : public ServiceBindingExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ RESTServiceBindingExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~RESTServiceBindingExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#binding.rest")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ServiceBinding* getServiceBinding(
+ tuscany::sca::model::Composite* composite,
+ tuscany::sca::model::Service* service,
+ commonj::sdo::DataObjectPtr scdlBinding);
+
+ static void initialize();
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif //tuscany_sca_extension_rest_restservicebindingextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp
new file mode 100644
index 0000000000..424039666f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp
@@ -0,0 +1,1222 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.
+ */
+
+/* $Rev$ $Date$ */
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4091)
+#endif
+
+#include <curl/curl.h>
+#include <curl/types.h>
+#include <curl/easy.h>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "RESTServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/CompositeReference.h"
+#include "model/RESTServiceBinding.h"
+#include "tuscany/sca/rest/model/RESTInterface.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+
+ class ResponseChunk {
+ public:
+ ResponseChunk() : memory(NULL), size(0)
+ {
+ }
+
+ ~ResponseChunk()
+ {
+ if (memory)
+ {
+ free(memory);
+ }
+ }
+
+ char *memory;
+ int size;
+ };
+
+ class RequestChunk {
+ public:
+ RequestChunk() : memory(NULL), size(0), read(0)
+ {
+ }
+
+ ~RequestChunk()
+ {
+ }
+
+ const char *memory;
+ int size;
+ int read;
+ };
+
+ class HeaderChunk {
+ public:
+ HeaderChunk() : location("")
+ {
+ }
+
+ ~HeaderChunk()
+ {
+ }
+
+ string location;
+ };
+
+ size_t write_callback(void *ptr, size_t size, size_t nmemb, void *data)
+ {
+ int realsize = size * nmemb;
+ ResponseChunk *mem = (ResponseChunk *)data;
+
+ if (mem->memory != NULL)
+ {
+ mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1);
+ }
+ else
+ {
+ mem->memory = (char *)malloc(mem->size + realsize + 1);
+ }
+ memcpy(&(mem->memory[mem->size]), ptr, realsize);
+ mem->size += realsize;
+ mem->memory[mem->size] = 0;
+ return realsize;
+ }
+
+ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *data)
+ {
+ int realsize = size * nmemb;
+ RequestChunk *mem = (RequestChunk *)data;
+
+ if (realsize > mem->size - mem->read)
+ {
+ realsize = mem->size - mem->read;
+ }
+ if (realsize != 0)
+ {
+ memcpy(ptr, &(mem->memory[mem->read]), realsize);
+ mem->read += realsize;
+ }
+ return realsize;
+ }
+
+ size_t header_callback(void *ptr, size_t size, size_t nmemb, void *data)
+ {
+ int realsize = size * nmemb;
+ HeaderChunk* mem = (HeaderChunk*)data;
+
+ char* str = new char[realsize + 1];
+ memcpy(str, ptr, realsize);
+ str[realsize] = 0;
+
+ if (strlen(str) > 10 && !strncmp(str, "Location: ", 10))
+ {
+ string s = &str[10];
+ mem->location = s.substr(0,s.find_last_not_of("\r\n")+1);
+ }
+
+ delete str;
+
+ return realsize;
+ }
+
+ bool RESTServiceWrapper::initialized = false;
+
+ RESTServiceWrapper::RESTServiceWrapper(Service* service) : ServiceWrapper(service)
+ {
+ logentry();
+
+ DataFactoryPtr dataFactory = service->getComponent()->getComposite()->getDataFactory();
+ try {
+ const Type& tempType = dataFactory->getType("http://tempuri.org", "RootType");
+ } catch (SDORuntimeException&)
+ {
+ dataFactory->addType("http://tempuri.org", "RootType", false, false, false);
+ dataFactory->addType("http://tempuri.org", "Wrapper", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://tempuri.org", "RootType",
+ "Wrapper",
+ "http://tempuri.org", "Wrapper",
+ false, false, true);
+ dataFactory->addType("http://tempuri.org", "Part", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://tempuri.org", "RootType",
+ "Part",
+ "http://tempuri.org", "Part",
+ false, false, true);
+ }
+
+ if (!initialized)
+ {
+ curl_global_init(CURL_GLOBAL_ALL);
+ initialized = true;
+ }
+ }
+
+ RESTServiceWrapper::~RESTServiceWrapper()
+ {
+ }
+
+ ///
+ /// This method will be called when a service call needs to be made.
+ ///
+ void RESTServiceWrapper::invoke(Operation& operation)
+ {
+ logentry();
+
+ const string& operationName = operation.getName();
+
+ loginfo("Service: %s, operation: %s", getService()->getType()->getName().c_str() , operationName.c_str());
+
+ for (unsigned int i=0; i<operation.getNParms(); i++)
+ {
+ loginfo("Parameter: %p, type %u", operation.getParameterValue(i),(int) operation.getParameterType(i));
+ }
+
+ // Get the service, composite reference and composite
+ Service* service = getService();
+ CompositeReference* compositeReference = (CompositeReference*)service->getComponent();
+ Composite* composite = compositeReference->getComposite();
+ XMLHelper* xmlHelper = composite->getXMLHelper();
+
+ // Get the REST binding
+ RESTServiceBinding* binding = (RESTServiceBinding *)service->getBinding();
+ Interface* iface = service->getType()->getInterface();
+
+ // Init the curl session
+ CURL *curl_handle = curl_easy_init();
+
+ RequestChunk requestChunk;
+ ResponseChunk responseChunk;
+ HeaderChunk headerChunk;
+
+ // Some servers don't like requests that are made without a user-agent
+ curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
+
+ // Get the operation name
+ string opName = operation.getName();
+
+ // If we have a REST interface, the operation name translates to an HTTP verb
+ if (iface != NULL && iface->getInterfaceTypeQName() == RESTInterface::typeQName)
+ {
+
+ // HTTP GET
+ if (opName == "retrieve")
+ {
+ // Build the request URL
+ bool firstParm = 0;
+ string uri;
+ if (operation.getNParms() !=0)
+ {
+
+ // If the first parameter is a URI, then we'll use it,
+ // otherwise we'll use the binding URI
+ ostringstream s0;
+ writeParameter(xmlHelper, s0, operation.getParameter(0));
+ string p0 = s0.str();
+ if (p0.find("://") != string::npos)
+ {
+ firstParm = 1;
+ uri = p0;
+ }
+ else
+ {
+ uri = getBindingURI();
+ }
+ }
+ else
+ {
+ uri = getBindingURI();
+ }
+ // Add the parameters to the end of the URI
+ ostringstream os;
+ if (uri[uri.length()-1] == '?')
+ {
+ // If the URI ends with a "?" then we use the query
+ // form param=value&
+ os << uri;
+ for (unsigned int i = firstParm; i < operation.getNParms(); i++)
+ {
+ Operation::Parameter param = operation.getParameter(i);
+
+ if(param.hasName())
+ {
+ os << param.getName() << "=";
+ }
+ else
+ {
+ // No name - use "param1", etc
+ os << "param" << (i + 1) << "=";
+ }
+ writeParameter(xmlHelper, os, param);
+ if (i < operation.getNParms()-1)
+ os << "&";
+ }
+ }
+ else
+ {
+ // Add the parameters in the form
+ // value1 / value2 / value3
+ os << uri;
+ for (unsigned int i = firstParm; i < operation.getNParms(); i++)
+ {
+ os << "/";
+ writeParameter(xmlHelper, os, operation.getParameter(i));
+ }
+ }
+
+ string url = os.str();
+ //loginfo("RESTServiceWrapper: HTTP GET %s", url.c_str());
+ curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str());
+
+ // Send all data to this function
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&responseChunk);
+
+ // Send all headers to this function
+ curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, header_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, (void *)&headerChunk);
+
+ // Perform the HTTP GET
+ CURLcode rc = curl_easy_perform(curl_handle);
+
+ if (rc)
+ {
+ throwException(ServiceInvocationException, curl_easy_strerror(rc));
+ }
+
+ // Get the output data out of the returned document
+ long httprc;
+ curl_easy_getinfo (curl_handle, CURLINFO_RESPONSE_CODE, &httprc);
+
+ string responsePayload = "";
+ if (responseChunk.memory)
+ {
+ responsePayload = string((const char*)responseChunk.memory, responseChunk.size);
+ }
+
+ if (httprc == 200)
+ {
+ if (responsePayload != "")
+ {
+ //TODO Remove this workaround once SDO supports loading of open top level content
+ // The workaround is to wrap the open content in a wrapper element
+ string xmldecl;
+ string xml;
+ Utils::rTokeniseString("?>", responsePayload, xmldecl, xml);
+ string part = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ part += "<Part xmlns=\"http://tempuri.org\" xmlns:tns=\"http://tempuri.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
+ part += xml;
+ part += "\n</Part>";
+
+ setReturn(xmlHelper, part, operation);
+ }
+ else
+ {
+ throwException(ServiceInvocationException, "Failed to retrieve resource, empty response");
+ }
+ }
+ else
+ {
+ ostringstream msg;
+ msg << "Failed to retrieve REST resource, HTTP code: " << httprc;
+ if (responsePayload != "")
+ {
+ msg << ", payload: " << responsePayload;
+ }
+ throwException(ServiceInvocationException, msg.str().c_str());
+ }
+ }
+ else if (opName == "create")
+ {
+ // HTTP POST
+
+ // Set the target URL
+ string url = getBindingURI();
+ curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str());
+
+ // Create the input payload
+ ostringstream spayload;
+ writeParameter(xmlHelper, spayload, operation.getParameter(0));
+ const string& requestPayload = spayload.str();
+ requestChunk.memory = requestPayload.c_str();
+ requestChunk.size = requestPayload.size();
+
+ curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, requestChunk.size);
+
+ // Read all data using this function
+ curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, read_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_READDATA, (void *)&requestChunk);
+
+ // Send all data to this function
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&responseChunk);
+
+ // Send all headers to this function
+ curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, header_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, (void *)&headerChunk);
+
+ // Configure headers
+ curl_slist *requestHeaders = NULL;
+ requestHeaders = curl_slist_append(requestHeaders, "Expect:");
+ requestHeaders = curl_slist_append(requestHeaders, "Content-Type: text/xml");
+ curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, requestHeaders);
+
+ // Perform the HTTP POST
+ curl_easy_setopt(curl_handle, CURLOPT_POST, true);
+ CURLcode rc = curl_easy_perform(curl_handle);
+
+ curl_slist_free_all(requestHeaders);
+
+ if (rc)
+ {
+ throwException(ServiceInvocationException, curl_easy_strerror(rc));
+ }
+
+ // Get the output and location of the created resource
+ string responsePayload = "";
+ if (responseChunk.memory)
+ {
+ responsePayload = string((const char*)responseChunk.memory, responseChunk.size);
+ }
+
+ long httprc;
+ curl_easy_getinfo (curl_handle, CURLINFO_RESPONSE_CODE, &httprc);
+ if (httprc == 201)
+ {
+ string* location = new string;
+ *location = headerChunk.location;
+ operation.setReturnValue(location);
+ }
+ else
+ {
+ ostringstream msg;
+ msg << "Failed to create REST resource, HTTP code: " << httprc;
+ if (responsePayload != "")
+ {
+ msg << ", payload: " << responsePayload;
+ }
+ throwException(ServiceInvocationException, msg.str().c_str());
+ }
+ }
+ else if (opName == "update")
+ {
+ // HTTP PUT
+
+ // Build the request URL
+ bool firstParm = 0;
+ string uri;
+ if (operation.getNParms() > 1)
+ {
+
+ // If the first parameter is a URI, then we'll use it,
+ // otherwise we'll use the binding URI
+ ostringstream s0;
+ writeParameter(xmlHelper, s0, operation.getParameter(0));
+ string p0 = s0.str();
+ if (p0.find("://") != string::npos)
+ {
+ firstParm = 1;
+ uri = p0;
+ }
+ else
+ {
+ uri = getBindingURI();
+ }
+ }
+ else
+ {
+ uri = getBindingURI();
+ }
+ // Add the parameters to the end of the URI
+ ostringstream os;
+ if (uri[uri.length()-1] == '?')
+ {
+ // If the URI ends with a "?" then we use the query
+ // form param=value&
+ os << uri;
+ for (unsigned int i = firstParm; i < operation.getNParms()-1; i++)
+ {
+ Operation::Parameter param = operation.getParameter(i);
+ if(param.hasName())
+ {
+ os << param.getName() << "=";
+ }
+ else
+ {
+ // No name - use "param1", etc
+ os << "param" << (i + 1) << "=";
+ }
+ writeParameter(xmlHelper, os, param);
+ if (i < operation.getNParms()-1)
+ os << "&";
+ }
+ }
+ else
+ {
+ // Add the parameters in the form
+ // value1 / value2 / value3
+ os << uri;
+ for (unsigned int i = firstParm; i < operation.getNParms()-1; i++)
+ {
+ os << "/";
+ writeParameter(xmlHelper, os, operation.getParameter(i));
+ }
+ }
+
+ string url = os.str();
+ curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str());
+
+ // Create the input payload
+ ostringstream spayload;
+ writeParameter(xmlHelper, spayload, operation.getParameter(operation.getNParms()-1));
+ const string& requestPayload = spayload.str();
+ requestChunk.memory = requestPayload.c_str();
+ requestChunk.size = requestPayload.size();
+
+ // Read all data using this function
+ curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, read_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_READDATA, (void *)&requestChunk);
+
+ // Send all data to this function
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&responseChunk);
+
+ // Send all headers to this function
+ curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, header_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, (void *)&headerChunk);
+
+ // Configure headers
+ curl_slist *requestHeaders = NULL;
+ requestHeaders = curl_slist_append(requestHeaders, "Expect:");
+ requestHeaders = curl_slist_append(requestHeaders, "Content-Type: text/xml");
+ curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, requestHeaders);
+
+ // Perform the HTTP PUT
+ curl_easy_setopt(curl_handle, CURLOPT_PUT, true);
+ curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, true) ;
+ long size = (long)requestChunk.size;
+ curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE, size);
+
+ CURLcode rc = curl_easy_perform(curl_handle);
+
+ curl_slist_free_all(requestHeaders);
+
+ if (rc)
+ {
+ throwException(ServiceInvocationException, curl_easy_strerror(rc));
+ }
+
+ // Get the output and location of the created resource
+ string responsePayload = "";
+ if (responseChunk.memory)
+ {
+ responsePayload = string((const char*)responseChunk.memory, responseChunk.size);
+ }
+
+ long httprc;
+ curl_easy_getinfo (curl_handle, CURLINFO_RESPONSE_CODE, &httprc);
+ if (httprc != 200)
+ {
+ ostringstream msg;
+ msg << "Failed to update REST resource, HTTP code: " << httprc;
+ if (responsePayload != "")
+ {
+ msg << ", payload: " << responsePayload;
+ }
+ throwException(ServiceInvocationException, msg.str().c_str());
+ }
+ }
+ else if (opName == "delete")
+ {
+ // HTTP DELETE
+
+ // Build the request URL
+ bool firstParm = 0;
+ string uri;
+ if (operation.getNParms() !=0)
+ {
+
+ // If the first parameter is a URI, then we'll use it,
+ // otherwise we'll use the binding URI
+ ostringstream s0;
+ writeParameter(xmlHelper, s0, operation.getParameter(0));
+ string p0 = s0.str();
+ if (p0.find("://") != string::npos)
+ {
+ firstParm = 1;
+ uri = p0;
+ }
+ else
+ {
+ uri = getBindingURI();
+ }
+ }
+ else
+ {
+ uri = getBindingURI();
+ }
+ // Add the parameters to the end of the URI
+ ostringstream os;
+ if (uri[uri.length()-1] == '?')
+ {
+ // If the URI ends with a "?" then we use the query
+ // form param=value&
+ os << uri;
+ for (unsigned int i = firstParm; i < operation.getNParms(); i++)
+ {
+ Operation::Parameter param = operation.getParameter(i);
+
+ if(param.hasName())
+ {
+ os << param.getName() << "=";
+ }
+ else
+ {
+ // No name - use "param1", etc
+ os << "param" << (i + 1) << "=";
+ }
+ writeParameter(xmlHelper, os, param);
+ if (i < operation.getNParms()-1)
+ os << "&";
+ }
+ }
+ else
+ {
+ // Add the parameters in the form
+ // value1 / value2 / value3
+ os << uri;
+ for (unsigned int i = firstParm; i < operation.getNParms(); i++)
+ {
+ os << "/";
+ writeParameter(xmlHelper, os, operation.getParameter(i));
+ }
+ }
+
+ string url = os.str();
+ curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str());
+
+ // Send all data to this function
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&responseChunk);
+
+ // Send all headers to this function
+ curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, header_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_HEADERDATA, (void *)&headerChunk);
+
+ // Perform the HTTP DELETE
+ curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, "DELETE");
+ CURLcode rc = curl_easy_perform(curl_handle);
+ if (rc)
+ {
+ throwException(ServiceInvocationException, curl_easy_strerror(rc));
+ }
+
+ // Get the output data out of the returned document
+ string responsePayload = "";
+ if (responseChunk.memory)
+ {
+ responsePayload = string((const char*)responseChunk.memory, responseChunk.size);
+ }
+
+ long httprc;
+ curl_easy_getinfo (curl_handle, CURLINFO_RESPONSE_CODE, &httprc);
+ if (httprc != 200)
+ {
+ ostringstream msg;
+ msg << "Failed to delete REST resource, HTTP code: " << httprc;
+ if (responsePayload != "")
+ {
+ msg << ", payload: " << responsePayload;
+ }
+ throwException(ServiceInvocationException, msg.str().c_str());
+ }
+ }
+ else
+ {
+ string msg = "Unknown REST verb: " + opName;
+ throwException(ServiceInvocationException, msg.c_str());
+ }
+ }
+ else
+ {
+ // Not a REST interface, XML / HTTP command style
+ curl_slist *requestHeaders = NULL;
+ struct curl_httppost *formpost = NULL;
+ ostringstream spayload;
+ string requestPayload;
+ string url;
+
+ // If the request contains complex content then we'll use
+ // a POST, otherwise we use a GET with a query string
+ bool complexContent = false;
+ for (unsigned int i=0; i<operation.getNParms(); i++)
+ {
+ if (operation.getParameter(i).getType() == Operation::DATAOBJECT)
+ {
+ complexContent = true;
+ break;
+ }
+ }
+
+ if (complexContent)
+ {
+ // Set the target URL
+ string uri = getBindingURI();
+ ostringstream os;
+ os << uri << "/" << opName;
+ url = os.str();
+ curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str());
+
+ // Disable the 100 continue handshake
+ requestHeaders = curl_slist_append(requestHeaders, "Expect:");
+
+ if (operation.getNParms() == 1)
+ {
+ // Single parameter, send it as the body of the POST
+
+ // Create the input payload
+ writeParameter(xmlHelper, spayload, operation.getParameter(0));
+ requestPayload = spayload.str();
+ requestChunk.memory = requestPayload.c_str();
+ requestChunk.size = requestPayload.size();
+
+ curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, requestChunk.size);
+
+ // Read all data using this function
+ curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, read_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_READDATA, (void *)&requestChunk);
+
+ // Set the content type
+ requestHeaders = curl_slist_append(requestHeaders, "Content-Type: text/xml");
+
+ // This will be a POST
+ curl_easy_setopt(curl_handle, CURLOPT_POST, true);
+ }
+ else
+ {
+
+ // Multiple parameters, use a form type POST
+ struct curl_httppost *lastptr = NULL;
+ for (unsigned int i=0; i<operation.getNParms(); i++)
+ {
+ ostringstream pname;
+ Operation::Parameter param = operation.getParameter(i);
+
+ if(param.hasName())
+ {
+ pname << param.getName();
+ }
+ else
+ {
+ // No name - use "param1", etc
+ pname << "param" << (i+1);
+ }
+
+ const char* ctype;
+ if (param.getType() == Operation::DATAOBJECT)
+ {
+ ctype ="text/xml";
+ }
+ else
+ {
+ ctype = "text/plain";
+ }
+
+ ostringstream pvalue;
+ writeParameter(xmlHelper, pvalue, param);
+
+ curl_formadd(&formpost,
+ &lastptr,
+ CURLFORM_CONTENTTYPE, ctype,
+ CURLFORM_COPYNAME, pname.str().c_str(),
+ CURLFORM_COPYCONTENTS, pvalue.str().c_str(),
+ CURLFORM_END);
+ }
+
+ // Set the form into the request
+ curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, formpost);
+ }
+ }
+ else
+ {
+
+ // Build the request URL, uri / opName ? params
+ string uri = getBindingURI();
+ ostringstream os;
+ os << uri << "/" << opName;
+
+ // Add the parameters to the end of the URL in the form
+ // param=value&
+ for (unsigned int i=0; i<operation.getNParms(); i++)
+ {
+ if (i == 0)
+ os << "?";
+
+ Operation::Parameter param = operation.getParameter(i);
+ if(param.hasName())
+ {
+ os << param.getName() << "=";
+ }
+ else
+ {
+ // No name - use "param1", etc
+ os << "param" << (i + 1) << "=";
+ }
+ writeParameter(xmlHelper, os, param);
+ if (i < operation.getNParms()-1)
+ os << "&";
+ }
+
+ url = os.str();
+ loginfo("RESTServiceWrapper: HTTP GET %s", url.c_str());
+
+ curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str());
+ }
+
+ // Send all data to this function
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback);
+
+ // Pass our 'chunk' struct to the callback function
+ curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&responseChunk);
+
+ // Configure the headers
+ if (requestHeaders)
+ {
+ curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, requestHeaders);
+ }
+
+ loginfo("RESTServiceWrapper: Performing HTTP request");
+ // Perform the HTTP request
+ CURLcode rc = curl_easy_perform(curl_handle);
+
+ loginfo("RESTServiceWrapper: Completed HTTP request");
+ // Free any headers
+ if (requestHeaders)
+ {
+ curl_slist_free_all(requestHeaders);
+ }
+
+ // Cleanup the form
+ if (complexContent)
+ {
+ curl_formfree(formpost);
+ }
+
+ if (rc)
+ {
+ throwException(ServiceInvocationException, curl_easy_strerror(rc));
+ }
+
+ if (responseChunk.memory)
+ {
+ string responsePayload((const char*)responseChunk.memory, responseChunk.size);
+
+
+ loginfo("RESTServiceWrapper: responsePayload: %s", responsePayload.c_str());
+
+ //TODO Remove this workaround once SDO supports loading of open top level content
+ // The workaround is to wrap the open content in a wrapper element
+ string xmldecl;
+ string xml;
+ Utils::rTokeniseString("?>", responsePayload, xmldecl, xml);
+ string part = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ part += "<Part xmlns=\"http://tempuri.org\" xmlns:tns=\"http://tempuri.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
+ part += xml;
+ part += "\n</Part>";
+
+ setReturn(xmlHelper, part, operation);
+ }
+ }
+
+ // Cleanup curl session
+ curl_easy_cleanup(curl_handle);
+ }
+
+
+ const string RESTServiceWrapper::getBindingURI()
+ {
+ string bindingURI = "";
+
+ // Get the binding URI configured on the top level component
+ Service* service = getService();
+ CompositeReference* compositeReference = (CompositeReference*)service->getComponent();
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ Component* component = runtime->getDefaultComponent();
+ Reference* reference = component->findReference(compositeReference->getName());
+ if (reference != NULL)
+ {
+ ReferenceBinding* binding = reference->getBinding();
+ if (binding != NULL && binding->getURI() != "")
+ {
+ bindingURI = binding->getURI();
+ }
+ }
+ if (bindingURI == "")
+ {
+ // Get the binding URI configured on the binding
+ RESTServiceBinding* binding = (RESTServiceBinding *)service->getBinding();
+ bindingURI = binding->getURI();
+ }
+ if (bindingURI != "")
+ {
+
+ // Prepend the default base URI if the URI is not absolute
+ if (bindingURI.find("://") == string::npos)
+ {
+ bindingURI = runtime->getDefaultBaseURI() + string("/rest/") + bindingURI;
+ }
+ }
+ return bindingURI;
+ }
+
+
+ void RESTServiceWrapper::writeParameter(XMLHelper* xmlHelper, ostringstream& os, const Operation::Parameter& parm)
+ {
+ logentry();
+
+ switch(parm.getType())
+ {
+ case Operation::BOOL:
+ {
+ os << *(bool*)parm.getValue();
+ break;
+ }
+ case Operation::SHORT:
+ {
+ os << *(short*)parm.getValue();
+ break;
+ }
+ case Operation::INT:
+ {
+ os << *(long*)parm.getValue();
+ break;
+ }
+ case Operation::LONG:
+ {
+ os << *(long*)parm.getValue();
+ break;
+ }
+ case Operation::USHORT:
+ {
+ os << *(short*)parm.getValue();
+ break;
+ }
+ case Operation::UINT:
+ {
+ os << *(long*)parm.getValue();
+ break;
+ }
+ case Operation::ULONG:
+ {
+ os << *(long*)parm.getValue();
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ os << *(float*)parm.getValue();
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ os << *(long double*)parm.getValue();
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ os << *(long double*)parm.getValue();
+ break;
+ }
+ case Operation::CHARS:
+ {
+ os << *(char**)parm.getValue();
+ break;
+ }
+ case Operation::STRING:
+ {
+ os << (*(string*)parm.getValue()).c_str();
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ DataObjectPtr dob = *(DataObjectPtr*)parm.getValue();
+ XMLDocumentPtr doc = xmlHelper->createDocument(dob, NULL, NULL);
+ xmlHelper->save(doc, os);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+
+ void RESTServiceWrapper::setReturn(XMLHelper* xmlHelper, string& payload,
+ Operation& operation)
+ {
+ logentry();
+
+ //TODO Remove this workaround once SDO supports loading of open top level content
+ // The workaround is to wrap the open content in a wrapper element
+ string xmldecl;
+ string xml;
+ Utils::rTokeniseString("?>", payload, xmldecl, xml);
+ string body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ body += "<Wrapper xmlns=\"http://tempuri.org\" xmlns:tns=\"http://tempuri.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
+ body += xml;
+ body += "\n</Wrapper>";
+
+ // Convert the body to an SDO DataObject
+ DataObjectPtr outputWrapperDataObject = NULL;
+ XMLDocumentPtr theXMLDocument = xmlHelper->load(body.c_str(), NULL);
+ if (theXMLDocument != 0)
+ {
+ outputWrapperDataObject = theXMLDocument->getRootDataObject();
+ }
+ if(!outputWrapperDataObject)
+ {
+ ostringstream msg;
+ msg << "Could not convert received document to SDO: " << body;
+ throwException(ServiceDataException, msg.str().c_str());
+ }
+
+ // Get the body part
+ DataObjectPtr outputDataObject = NULL;
+ PropertyList bpl = outputWrapperDataObject->getInstanceProperties();
+ if (bpl.size()!=0)
+ {
+ if (bpl[0].isMany())
+ {
+ DataObjectList& parts = outputWrapperDataObject->getList((unsigned int)0);
+ outputDataObject = parts[0];
+ }
+ else
+ {
+ outputDataObject = outputWrapperDataObject->getDataObject(bpl[0]);
+ }
+ }
+ if (outputDataObject == NULL)
+ {
+ ostringstream msg;
+ msg << "Could not convert body part to SDO: " << body;
+ throwException(ServiceDataException, msg.str().c_str());
+ }
+
+ PropertyList pl = outputDataObject->getInstanceProperties();
+ unsigned int i = 0;
+
+ switch(pl[i].getTypeEnum())
+ {
+ case Type::BooleanType:
+ {
+ bool* boolData = new bool;
+ *boolData = outputDataObject->getBoolean(pl[i]);
+ operation.setReturnValue(boolData);
+ }
+ break;
+ case Type::ByteType:
+ {
+ char* byteData = new char;
+ *byteData = outputDataObject->getByte(pl[i]);
+ operation.setReturnValue(byteData);
+ }
+ break;
+ case Type::BytesType:
+ {
+ int len = outputDataObject->getLength(pl[i]);
+ char* bytesData = new char[len+1];
+ int bytesWritten = outputDataObject->getBytes(pl[i], bytesData, len);
+ // Ensure the bytes end with the null char. Not sure if this is neccessary
+ if(bytesWritten <= len)
+ {
+ bytesData[bytesWritten] = 0;
+ }
+ else
+ {
+ bytesData[len] = 0;
+ }
+ operation.setReturnValue(&bytesData);
+ }
+ break;
+ case Type::CharacterType:
+ {
+ // This code should work but won't be used as there is no mapping from an XSD type to the SDO CharacterType
+ wchar_t* charData = new wchar_t;
+ *charData = outputDataObject->getCharacter(pl[i]);
+ operation.setReturnValue(charData);
+ }
+ break;
+ case Type::DoubleType:
+ {
+ long double* doubleData = new long double;
+ *doubleData = outputDataObject->getDouble(pl[i]);
+ operation.setReturnValue(doubleData);
+ }
+ break;
+ case Type::FloatType:
+ {
+ float* floatData = new float;
+ *floatData = outputDataObject->getFloat(pl[i]);
+ operation.setReturnValue(floatData);
+ }
+ break;
+ case Type::IntegerType:
+ {
+ long* intData = new long;
+ *intData = outputDataObject->getInteger(pl[i]);
+ operation.setReturnValue(intData);
+ }
+ break;
+ case Type::ShortType:
+ {
+ short* shortData = new short;
+ *shortData = outputDataObject->getShort(pl[i]);
+ operation.setReturnValue(shortData);
+ }
+ break;
+ case Type::StringType:
+ {
+ string* str = new string(outputDataObject->getCString(pl[i]));
+ operation.setReturnValue(str);
+ }
+ break;
+ case Type::DataObjectType:
+ {
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = outputDataObject->getDataObject(pl[i]);
+ if(!*dataObjectData)
+ {
+ loginfo("Null SDO DataObject return value");
+ }
+ else
+ {
+ (*dataObjectData)->detach();
+ }
+ operation.setReturnValue(dataObjectData);
+ }
+ break;
+ case Type::OpenDataObjectType:
+ {
+ /*
+ * This code deals with xsd:any element parameters
+ * Get each element as a DataObject and add in to the parameter list
+ */
+ DataObjectList& dataObjectList = outputDataObject->getList(pl[i]);
+
+ for(unsigned int j=0; j<dataObjectList.size(); j++)
+ {
+ DataObjectPtr dob = dataObjectList[j];
+ if(!dob)
+ {
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = NULL;
+ operation.setReturnValue(dataObjectData);
+ loginfo("Null OpenDataObject return value");
+ }
+ else
+ {
+
+ SequencePtr sequence = dob->getSequence();
+ if (sequence->size()!=0)
+ {
+ // Return a text element
+ if (sequence->isText(0))
+ {
+ string* stringData = new string(sequence->getCStringValue(0));
+ operation.setReturnValue(stringData);
+ }
+ else
+ {
+ // Return a DataObject representing a complex element
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = sequence->getDataObjectValue(0);
+ if(!*dataObjectData)
+ {
+ loginfo("Null DataObject return value");
+ }
+ else
+ {
+ (*dataObjectData)->detach();
+ }
+ operation.setReturnValue(dataObjectData);
+ }
+ }
+ else
+ {
+ // Empty content, add an empty string
+ loginfo("Null OpenDataObject return value");
+ string *stringData = new string("");
+ operation.setReturnValue(stringData);
+ }
+ }
+ }
+ }
+ break;
+ default:
+ {
+ ostringstream msg;
+ msg << "Unsupported result type: " << pl[i].getTypeEnum();
+ throwException(ServiceDataException, msg.str().c_str());
+ }
+ }
+ }
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.h
new file mode 100644
index 0000000000..af2fbcfc94
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.h
@@ -0,0 +1,90 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_rest_restservicewrapper_h
+#define tuscany_sca_extension_rest_restservicewrapper_h
+
+#include <sstream>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/Service.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace rest
+ {
+
+ class RESTServiceWrapper : public ServiceWrapper
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param target The service wrapper represents a Web service.
+ */
+ RESTServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor
+ */
+ virtual ~RESTServiceWrapper();
+
+ /**
+ * All business method calls on the target service are performed through
+ * this invoke method.
+ * @param operation The details of the method, paramaters and return value for the
+ * business method to be called on the target service.
+ */
+ virtual void invoke(Operation& operation);
+
+ private:
+
+ /**
+ * Used to track initialization of the CURL library
+ */
+ static bool initialized;
+
+ /**
+ * Get the configured binding URI
+ */
+ const std::string getBindingURI();
+
+ /**
+ * Write a parameter into a URL
+ */
+ void writeParameter(commonj::sdo::XMLHelper* xmlHelper, std::ostringstream& os, const Operation::Parameter& parm);
+
+ /**
+ * Set the return value on the given operation
+ */
+ void setReturn(commonj::sdo::XMLHelper* xmlHelper, std::string& payload, Operation& operation);
+
+ };
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_rest_restservicewrapper_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/model/RESTServiceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/model/RESTServiceBinding.cpp
new file mode 100644
index 0000000000..72701bfa65
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/model/RESTServiceBinding.cpp
@@ -0,0 +1,59 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/rest/model/RESTServiceBinding.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/rest/RESTServiceWrapper.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+
+ // Constructor
+ RESTServiceBinding::RESTServiceBinding(Service* service, const string& uri)
+ : ServiceBinding(service, uri)
+ {
+ logentry();
+
+ serviceWrapper = new RESTServiceWrapper(service);
+ }
+
+ // Destructor
+ RESTServiceBinding::~RESTServiceBinding()
+ {
+ logentry();
+ }
+
+ ServiceWrapper* RESTServiceBinding::getServiceWrapper()
+ {
+ logentry();
+
+ return serviceWrapper;
+ }
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/model/RESTServiceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/model/RESTServiceBinding.h
new file mode 100644
index 0000000000..d19bcdacf5
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/model/RESTServiceBinding.h
@@ -0,0 +1,76 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_rest_model_restservicebinding_h
+#define tuscany_sca_extension_rest_model_restservicebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/model/Service.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+ /**
+ * Information about a REST binding for a service or a reference.
+ */
+ class RESTServiceBinding : public tuscany::sca::model::ServiceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ */
+ RESTServiceBinding(tuscany::sca::model::Service* service, const std::string& uri);
+
+ /**
+ * Destructor.
+ */
+ virtual ~RESTServiceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#RESTBinding"; };
+
+ /**
+ * Create a wrapper for the service configured by this
+ * binding.
+ */
+ virtual ServiceWrapper* getServiceWrapper();
+
+ private:
+
+ /**
+ * The wrapper for the service configured by this binding.
+ */
+ ServiceWrapper* serviceWrapper;
+
+ };
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_rest_model_restservicebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/deploy.bat
new file mode 100644
index 0000000000..6717749990
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/reference/deploy.bat
@@ -0,0 +1,68 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set restextdir=%extdir%\rest
+set refextdir=%restextdir%\reference
+set srcdir=%rootdir%\runtime\extensions\rest\reference
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+call %srcdir%\..\deploy.bat %rootdir%
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %restextdir% mkdir %restextdir%
+if not exist %refextdir% mkdir %refextdir%
+if not exist %refextdir%\module mkdir %refextdir%\module
+if not exist %refextdir%\bin mkdir %refextdir%\bin
+if not exist %refextdir%\lib mkdir %refextdir%\lib
+
+set libname=tuscany_sca_rest_reference
+
+del %refextdir%\bin\%libname%.*
+del %refextdir%\lib\%libname%.*
+
+copy %inpath%\%libname%.lib %refextdir%\lib
+copy %inpath%\%libname%.dll %refextdir%\bin
+copy %inpath%\%libname%.dll %refextdir%\module
+
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %refextdir%\bin
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %refextdir%\module
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/Makefile.am
new file mode 100644
index 0000000000..2ecfda6c6c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = httpd \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/deploy.bat
new file mode 100644
index 0000000000..bea89aa81d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/deploy.bat
@@ -0,0 +1,66 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set restextdir=%extdir%\rest
+set svcextdir=%restextdir%\service
+set srcdir=%rootdir%\runtime\extensions\rest\service\httpd\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %restextdir% mkdir %restextdir%
+if not exist %svcextdir% mkdir %svcextdir%
+if not exist %svcextdir%\module mkdir %svcextdir%\module
+if not exist %svcextdir%\bin mkdir %svcextdir%\bin
+if not exist %svcextdir%\lib mkdir %svcextdir%\lib
+
+set libname=tuscany_sca_rest_service
+
+del %svcextdir%\bin\%libname%.*
+del %svcextdir%\lib\%libname%.*
+
+copy %inpath%\%libname%.lib %svcextdir%\lib
+copy %inpath%\%libname%.dll %svcextdir%\bin
+copy %inpath%\%libname%.dll %svcextdir%\module
+
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %svcextdir%\bin
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %svcextdir%\module
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/deploymod.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/deploymod.bat
new file mode 100644
index 0000000000..b10b15d5c1
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/deploymod.bat
@@ -0,0 +1,63 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set restextdir=%extdir%\rest
+set svcextdir=%restextdir%\service
+set srcdir=%rootdir%\runtime\extensions\rest\service\httpd\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %restextdir% mkdir %restextdir%
+if not exist %svcextdir% mkdir %svcextdir%
+if not exist %svcextdir%\bin mkdir %svcextdir%\bin
+if not exist %svcextdir%\lib mkdir %svcextdir%\lib
+
+set libname=tuscany_sca_mod_rest
+
+del %svcextdir%\bin\%libname%.*
+del %svcextdir%\lib\%libname%.*
+
+copy %inpath%\%libname%.lib %svcextdir%\lib
+copy %inpath%\%libname%.dll %svcextdir%\bin
+
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %svcextdir%\bin
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/Makefile.am
new file mode 100644
index 0000000000..f963effea2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = src \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/Makefile.am
new file mode 100644
index 0000000000..49d11faee3
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/Makefile.am
@@ -0,0 +1,44 @@
+libdir=$(prefix)/extensions/rest/service/lib
+lib_LTLIBRARIES = \
+libtuscany_sca_rest_service.la \
+libtuscany_sca_mod_rest.la
+
+noinst_HEADERS = \
+tuscany/sca/rest/*.h \
+tuscany/sca/rest/model/*.h
+
+libtuscany_sca_rest_service_la_SOURCES = \
+tuscany/sca/rest/RESTReferenceBindingExtension.cpp \
+tuscany/sca/rest/model/RESTReferenceBinding.cpp \
+tuscany/sca/rest/RESTServiceProxy.cpp
+
+libtuscany_sca_rest_service_la_LIBADD = \
+ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca \
+ -L$(top_builddir)/runtime/extensions/rest/interface/src -ltuscany_sca_rest_interface
+
+rootdir=$(prefix)/extensions/rest/service
+
+libtuscany_sca_mod_rest_la_SOURCES = \
+tuscany/sca/rest/ModREST.cpp
+
+libtuscany_sca_mod_rest_la_LIBADD = \
+ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca \
+ -L$(top_builddir)/runtime/extensions/rest/service/httpd/src -ltuscany_sca_rest_service \
+ -L$(top_builddir)/runtime/extensions/rest/interface/src -ltuscany_sca_rest_interface
+
+INCLUDES = -I$(top_builddir)/runtime/core/src \
+ -I$(top_builddir)/runtime/extensions/rest/interface/src \
+ -I${TUSCANY_SDOCPP}/include \
+ -I${HTTPD_INCLUDE} -I${APR_INCLUDE}
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+moduledir=$(prefix)/extensions/rest/service/module
+extension = libtuscany_sca_rest_service$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension) \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/ModREST.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/ModREST.cpp
new file mode 100644
index 0000000000..eb3ac60e01
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/ModREST.cpp
@@ -0,0 +1,1351 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+#include <sstream>
+
+#include "apr_strings.h"
+#include "apr_fnmatch.h"
+#include "apr_lib.h"
+
+#define APR_WANT_STRFUNC
+#include "apr_want.h"
+#include "ap_config.h"
+#include "httpd.h"
+
+// This section removes the windows/httpd build error "strtoul_is_not_a_portable_function_use_strtol_instead"
+#if defined(WIN32) || defined (_WINDOWS)
+#ifdef strtoul
+#undef strtoul
+#endif
+#define strtoul strtoul
+#endif
+
+#include "http_config.h"
+#include "http_core.h"
+#include "http_request.h"
+#include "http_protocol.h"
+#include "http_log.h"
+#include "http_main.h"
+#include "util_script.h"
+#include "util_md5.h"
+
+#include "mod_core.h"
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+#include "RESTServiceProxy.h"
+#include "model/RESTReferenceBinding.h"
+#include "tuscany/sca/rest/model/RESTInterface.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/CompositeService.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/WSDLDefinition.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+#include "tuscany/sca/model/WSDLInterface.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+using namespace tuscany::sca::util;
+
+
+extern "C"
+{
+ extern module AP_MODULE_DECLARE_DATA sca_rest_module;
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+
+ typedef struct rest_server_config_rec
+ {
+ char * home;
+ } rest_server_config_rec_t;
+
+ typedef struct rest_dir_config_rec
+ {
+ char * root;
+ char * path;
+ char * base_uri;
+ char * component;
+ } rest_dir_config_rec_t;
+
+ CompositeService* initializeSCARuntime(const char* home, const char* root,
+ const char* path, const char* baseURI, const char *component, const char* service);
+
+ DataObjectPtr createPayload(DataFactoryPtr dataFactory,
+ Operation& operation, const WSDLOperation& wsdlOperation);
+
+ void addPart(XMLHelper* xmlHelper, string& payload, Operation& operation);
+
+ int logHeaders(void* request, const char* key, const char* value);
+
+ /**
+ * Initialize the SCA runtime
+ */
+ CompositeService* initializeSCARuntime(const char* home, const char* root,
+ const char* path, const char* baseURI, const char *component, const char* service)
+ {
+ logentry();
+ loginfo("Home: %s", home);
+ loginfo("Root: %s", root);
+ loginfo("Path: %s", path);
+ loginfo("Base URI: %s", baseURI);
+ loginfo("Component: %s", component);
+ loginfo("Service: %s", service);
+
+ try
+ {
+ SCARuntime* runtime = SCARuntime::initializeSharedRuntime(home, root, path, baseURI);
+
+ string componentName;
+ if (strlen(component))
+ {
+ componentName = component;
+ }
+ else
+ {
+ componentName = runtime->getDefaultComponentName();
+ }
+ string serviceName = service;
+
+ loginfo("Resolving composite: %s, service: %s", componentName.c_str(), serviceName.c_str());
+ Component* compositeComponent = runtime->getSystem()->findComponent(componentName);
+ if (compositeComponent == NULL)
+ {
+ string msg = "Component not found " + componentName;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ runtime->setDefaultComponent(compositeComponent);
+
+ Composite* composite = (Composite*)compositeComponent->getType();
+ CompositeService* compositeService = (CompositeService*)composite->findComponent(serviceName);
+ if (compositeService == NULL)
+ {
+ string msg = "Composite service not found " + serviceName;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ return compositeService;
+ }
+ catch(TuscanyRuntimeException &ex)
+ {
+ ostringstream msg;
+ msg << ex;
+ logerror("Failed to initialize SCA runtime: %s", msg.str().c_str());
+ throw;
+ }
+ }
+
+ bool printRequest = false;
+
+ int logHeaders(void* request, const char* key, const char* value)
+ {
+ loginfo("Header key: %s, value: %s", key, value);
+ if (printRequest)
+ {
+ ap_rprintf((request_rec*)request, "<br>Header key: %s, value: %s", key, value);
+ }
+ return 1;
+ }
+
+ int rest_handler(request_rec *request)
+ {
+ logentry();
+
+ if (strcmp(request->handler, "sca_rest_module"))
+ {
+ return DECLINED;
+ }
+
+ try {
+
+ // Set up the read policy
+ int rc = ap_setup_client_block(request, REQUEST_CHUNKED_DECHUNK);
+ if (rc != OK)
+ {
+ return rc;
+ }
+ ap_should_client_block(request);
+ if (request->read_chunked == true && request->remaining == 0)
+ {
+ request->chunked = true;
+ }
+
+ apr_table_setn(request->headers_out, "Connection", "close");
+
+ if (printRequest)
+ {
+ // Set the content type
+ ap_set_content_type(request, "text/html");
+
+ // Send the response document
+ ap_rputs("<html><body><p>Tuscany Mod_rest works!", request);
+ }
+
+ rest_server_config_rec_t* server_conf = (rest_server_config_rec_t*)ap_get_module_config(request->server->module_config, &sca_rest_module);
+ loginfo("Tuscany home: %s", server_conf->home);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>Tuscany home: %s", server_conf->home);
+ }
+
+ rest_dir_config_rec_t* dir_conf = (rest_dir_config_rec_t*)ap_get_module_config(request->per_dir_config, &sca_rest_module);
+ loginfo("Tuscany root: %s", dir_conf->root);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>Tuscany root: %s", dir_conf->root);
+ }
+ loginfo("Tuscany path: %s", dir_conf->path);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>Tuscany path: %s", dir_conf->path);
+ }
+ loginfo("SCA component: %s", dir_conf->component);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>SCA component: %s", dir_conf->component);
+ }
+
+ if (request->protocol)
+ {
+ loginfo("Protocol: %s", request->protocol);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>Protocol: %s", request->protocol);
+ }
+ }
+
+ if (request->method)
+ {
+ loginfo("HTTP method: %s", request->method);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>HTTP method: %s", request->method);
+ }
+ }
+
+ loginfo("HTTP method number: %d", request->method_number);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>HTTP method number: %d", request->method_number);
+ }
+
+ const char* content_type = apr_table_get(request->headers_in, "Content-Type");
+ if (content_type)
+ {
+ loginfo("Content type: %s", content_type);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>Content type: %s", content_type);
+ }
+ }
+ else
+ {
+ content_type = "text/plain";
+ }
+
+ if (request->content_encoding)
+ {
+ loginfo("Content encoding: %s", request->content_encoding);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>Content encoding: %s", request->content_encoding);
+ }
+ }
+
+ if (printRequest)
+ {
+ ap_rputs("<p>", request);
+ }
+ apr_table_do(logHeaders, request, request->headers_in, NULL);
+
+ if (request->uri)
+ {
+ loginfo("URI: %s", request->uri);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>URI: %s", request->uri);
+ }
+ }
+
+ if (request->path_info)
+ {
+ loginfo("Path info: %s", request->path_info);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>Path info: %s", request->path_info);
+ }
+ }
+
+ if (request->args)
+ {
+ loginfo("Args: %s", request->args);
+ if (printRequest)
+ {
+ ap_rprintf(request, "<p>Args: %s", request->args);
+ }
+ }
+
+ if (printRequest)
+ {
+ ap_rputs("</body></html>", request);
+ }
+
+ // Extract the service and component names from the HTTP URI path
+ string path;
+ if (strlen(request->path_info) != 0 && *(request->path_info) == '/')
+ {
+ path = request->path_info + 1;
+ }
+ else
+ {
+ path = request->path_info;
+ }
+ string uri;
+
+ string component;
+ string service;
+ if (strlen(dir_conf->component))
+ {
+ // The path only specifies the service, the component name
+ // is configured in the directory/location configured
+ component = dir_conf->component;
+ Utils::tokeniseString("/", path, service, uri);
+ }
+ else
+ {
+ // The path must be in the form component / service
+ string path2;
+ Utils::tokeniseString("/", path, component, path2);
+ Utils::tokeniseString("/", path2, service, uri);
+ }
+
+ loginfo("Component name: %s", component.c_str());
+ loginfo("Service name: %s", service.c_str());
+
+ // Initialize the SCA runtime
+ CompositeService* compositeService = initializeSCARuntime(
+ server_conf->home, dir_conf->root, dir_conf->path, dir_conf->base_uri, component.c_str(), service.c_str());
+
+ if(!compositeService)
+ {
+ throwException(SystemConfigurationException,
+ "Failed to initialize SCA runtime, could not initialize CompositeService");
+ }
+
+ Composite* composite = compositeService->getComposite();
+ DataFactoryPtr dataFactory = composite->getDataFactory();
+ if (dataFactory == 0)
+ {
+ throwException(SystemConfigurationException,
+ "Failed to initialize SCA runtime, could not get DataFactory");
+ }
+ XMLHelper* xmlHelper = composite->getXMLHelper();
+
+ // Get the REST binding
+ Reference* reference = compositeService->getReference();
+ RESTReferenceBinding* binding = (RESTReferenceBinding*)reference->getBinding();
+
+ // Get the REST proxy
+ RESTServiceProxy* proxy = (RESTServiceProxy*)binding->getServiceProxy();
+
+ // Get the component interface
+ Interface* iface = reference->getType()->getInterface();
+
+ if (request->method_number == M_GET)
+ {
+ // Handle an HTTP GET
+
+ // Determine the operation to invoke
+ WSDLOperation wsdlOperation;
+ string wsdlNamespace = "";
+ string op_name = "";
+ string uriArgs = "";
+ if (iface != NULL)
+ {
+ // If we have a REST interface, the operation name is "retrieve"
+ if (iface->getInterfaceTypeQName() == RESTInterface::typeQName)
+ {
+ op_name = "retrieve";
+ uriArgs = uri;
+ }
+ else if (iface->getInterfaceTypeQName() == WSDLInterface::typeQName)
+ {
+ // we have a WSDL interface, the operation name is part of the URI
+ Utils::tokeniseString("/", uri, op_name, uriArgs);
+
+ // look for the WSDL operation definition
+ WSDLInterface* wsdlInterface = (WSDLInterface*)iface;
+ wsdlNamespace = wsdlInterface->getNamespaceURI();
+
+ if (wsdlNamespace != "")
+ {
+ WSDLDefinition* wsdl = composite->findWSDLDefinition(wsdlNamespace);
+ if (wsdl == 0)
+ {
+ string msg = "WSDL not found for: " + wsdlNamespace;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ try
+ {
+ wsdlOperation = wsdl->findOperation(wsdlInterface->getName(), op_name.c_str());
+ }
+ catch(SystemConfigurationException&)
+ {
+ throw;
+ }
+
+ if (!wsdlOperation.isDocumentStyle() || !wsdlOperation.isWrappedStyle())
+ {
+ throwException(ServiceInvocationException,
+ "Only wrapped document style WSDL operations are currentlysupported");
+ }
+ }
+ }
+ }
+ else
+ {
+ Utils::tokeniseString("/", uri, op_name, uriArgs);
+ }
+
+ // Create a default document literal wrapped WSDL operation
+ if (wsdlNamespace == "")
+ {
+ wsdlNamespace = compositeService->getName();
+ wsdlOperation = WSDLOperation();
+ wsdlOperation.setOperationName(op_name.c_str());
+ wsdlOperation.setSoapAction(wsdlNamespace+ "#" +op_name);
+ wsdlOperation.setEndpoint("");
+ wsdlOperation.setSoapVersion(WSDLOperation::SOAP11);
+ wsdlOperation.setDocumentStyle(true);
+ wsdlOperation.setWrappedStyle(true);
+ wsdlOperation.setEncoded(false);
+ wsdlOperation.setInputType(string("http://tempuri.org") + "#" + op_name);
+ wsdlOperation.setOutputType(string("http://tempuri.org") + "#" + op_name + "Response");
+ }
+
+ // Create the input DataObject
+ Operation operation(op_name.c_str());
+
+ // Parse the args part of the URI
+ if (uriArgs != "")
+ {
+ string args = uriArgs;
+ for (; args != ""; )
+ {
+ string param;
+ string next;
+ Utils::tokeniseString("/", args, param, next);
+ if (param != "")
+ {
+ string* data = new string;
+ *data = param;
+ operation.addParameter(data);
+ }
+ args = next;
+ }
+ }
+
+ // Parse the query string
+ if (request->args)
+ {
+ string query = request->args;
+ for (; query != ""; )
+ {
+ string param;
+ string next;
+ Utils::tokeniseString("&", query, param, next);
+ if (param != "")
+ {
+ string n;
+ string* data = new string;
+ Utils::tokeniseString("=", param, n, *data);
+ operation.addParameter(data);
+ }
+ query = next;
+ }
+ }
+ DataObjectPtr inputDataObject = createPayload(dataFactory, operation, wsdlOperation);
+
+ // Dispatch to the REST proxy
+ DataObjectPtr outputDataObject = proxy->invoke(wsdlOperation, inputDataObject);
+
+ // Send the output DataObject
+ if (iface!=NULL &&
+ iface->getInterfaceTypeQName() == RESTInterface::typeQName)
+ {
+ if (outputDataObject == NULL)
+ {
+ throwException(ServiceInvocationException, "Null output from REST create operation");
+ }
+ else
+ {
+
+ // Pure REST, send the response document
+ XMLHelperPtr xm = HelperProvider::getXMLHelper(dataFactory);
+ DataObjectList& l = outputDataObject->getList("return");
+ if (l.size() != 0)
+ {
+ DataObjectPtr resourceDataObject = l[0];
+ XMLDocumentPtr doc = xm->createDocument(
+ resourceDataObject,
+ resourceDataObject->getType().getURI(),
+ resourceDataObject->getType().getName());
+ char* str = xm->save(doc);
+
+ // Calculate an Etag hash for the response
+ char* etag = ap_md5(request->pool, (const unsigned char*)str);
+
+ // Handle a conditional GET, if the etag matches the etag
+ // sent by the client, we don't need to send the whole response
+ const char* match = apr_table_get(request->headers_in, "If-None-Match");
+ if (match != NULL && !strcmp(etag, match))
+ {
+ loginfo("REST resource matches ETag, sending HTTP 304 response code");
+ request->status = HTTP_NOT_MODIFIED;
+ }
+ else
+ {
+ loginfo("Sending response: %s", str);
+ ap_set_content_type(request, "text/xml");
+ apr_table_setn(request->headers_out, "ETag", etag);
+
+ // Send an Etag header to allow caching and
+ // conditional gets
+ apr_table_setn(request->headers_out, "ETag", etag);
+
+ ap_rputs(str, request);
+ }
+ }
+ else
+ {
+ loginfo("REST resource not found, sending HTTP 404 response code");
+ request->status = HTTP_NOT_FOUND;
+
+ return OK;
+ }
+ }
+ }
+ else
+ {
+ // Command style, send the response wrapper element
+
+ if (outputDataObject == NULL)
+ {
+ loginfo("Sending empty response");
+ //request->status = HTTP_NO_CONTENT;
+ }
+ else
+ {
+ XMLHelperPtr xm = HelperProvider::getXMLHelper(dataFactory);
+ DataObjectList& l = outputDataObject->getList("return");
+ if (l.size() != 0)
+ {
+ DataObjectPtr resultDataObject = l[0];
+ XMLDocumentPtr doc = xm->createDocument(
+ resultDataObject,
+ resultDataObject->getType().getURI(),
+ resultDataObject->getType().getName());
+ char* str = xm->save(doc);
+
+ loginfo("Sending response: %s", str);
+ ap_set_content_type(request, "text/xml");
+ ap_rputs(str, request);
+ }
+ else
+ {
+ loginfo("Sending empty response");
+ //request->status = HTTP_NO_CONTENT;
+ }
+ }
+ }
+
+ return OK;
+ }
+ else if (request->method_number == M_POST)
+ {
+ // Handle an HTTP POST
+
+ // Determine the operation to invoke
+ WSDLOperation wsdlOperation;
+ string wsdlNamespace = "";
+ string op_name = "";
+ string uriArgs = "";
+ if (iface != NULL)
+ {
+ // If we have a REST interface, the operation name is "create"
+ if (iface->getInterfaceTypeQName() == RESTInterface::typeQName)
+ {
+ op_name = "create";
+ }
+ else if (iface->getInterfaceTypeQName() == WSDLInterface::typeQName)
+ {
+ // we have a WSDL interface, the operation name is part of the URI
+ Utils::tokeniseString("/", uri, op_name, uriArgs);
+
+ // look for the WSDL operation definition
+ WSDLInterface* wsdlInterface = (WSDLInterface*)iface;
+ wsdlNamespace = wsdlInterface->getNamespaceURI();
+
+ if (wsdlNamespace != "")
+ {
+ WSDLDefinition* wsdl = composite->findWSDLDefinition(wsdlNamespace);
+ if (wsdl == 0)
+ {
+ string msg = "WSDL not found for: " + wsdlNamespace;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ try
+ {
+ wsdlOperation = wsdl->findOperation(wsdlInterface->getName(), op_name.c_str());
+ }
+ catch(SystemConfigurationException&)
+ {
+ throw;
+ }
+
+ if (!wsdlOperation.isDocumentStyle() || !wsdlOperation.isWrappedStyle())
+ {
+ throwException(ServiceInvocationException,
+ "Only wrapped document style WSDL operations are currentlysupported");
+ }
+ }
+ }
+ }
+ else
+ {
+ Utils::tokeniseString("/", uri, op_name, uriArgs);
+ }
+
+ // Create a default document literal wrapped WSDL operation
+ if (wsdlNamespace == "")
+ {
+ wsdlNamespace = compositeService->getName();
+ wsdlOperation = WSDLOperation();
+ wsdlOperation.setOperationName(op_name.c_str());
+ wsdlOperation.setSoapAction(wsdlNamespace+ "#" +op_name);
+ wsdlOperation.setEndpoint("");
+ wsdlOperation.setSoapVersion(WSDLOperation::SOAP11);
+ wsdlOperation.setDocumentStyle(true);
+ wsdlOperation.setWrappedStyle(true);
+ wsdlOperation.setEncoded(false);
+ wsdlOperation.setInputType(string("http://tempuri.org") + "#" + op_name);
+ wsdlOperation.setOutputType(string("http://tempuri.org") + "#" + op_name + "Response");
+ }
+
+ // Create the input DataObject
+ Operation operation(op_name.c_str());
+
+ // Parse the args part of the URI
+ if (uriArgs != "")
+ {
+ string args = uriArgs;
+ for (; args != ""; )
+ {
+ string param;
+ string next;
+ Utils::tokeniseString("/", args, param, next);
+ if (param != "")
+ {
+ string* data = new string;
+ *data = param;
+ operation.addParameter(data);
+ }
+ args = next;
+ }
+ }
+
+ // Parse the query string
+ if (request->args)
+ {
+ string query = request->args;
+ for (; query != ""; )
+ {
+ string param;
+ string next;
+ Utils::tokeniseString("&", query, param, next);
+ if (param != "")
+ {
+ string n;
+ string* data = new string;
+ Utils::tokeniseString("=", param, n, *data);
+ operation.addParameter(data);
+ }
+ query = next;
+ }
+ }
+
+ // Read the POST input
+ ostringstream sinput;
+ char buffer[2049];
+ for ( ; ; )
+ {
+ int size = ap_get_client_block(request, buffer, 2048);
+ if (size > 0)
+ {
+ buffer[size] = '\0';
+ sinput << buffer;
+ }
+ else if (size == 0)
+ {
+ break;
+ }
+ else if (size < 0)
+ {
+ throwException(ServiceInvocationException, "Error reading POST input");
+ }
+ }
+ string input = sinput.str();
+
+ string contentType = content_type;
+ if (contentType.find("multipart/form-data") == 0)
+ {
+ // This is a multipart POST, extract each part from the
+ // POST body
+ string begin;
+ string boundary;
+ Utils::tokeniseString("boundary=", contentType, begin, boundary);
+
+ for (;;)
+ {
+ // Read each part
+ string part;
+ string next;
+ Utils::tokeniseString(boundary, input, part, next);
+ input = next;
+
+ // Skip first and last empty parts
+ if (part.length() == 0 || part == "--")
+ continue;
+
+ // Read headers
+ bool xml = false;
+ int empty = -1;
+ for (;;)
+ {
+ string header;
+ Utils::tokeniseString("\r\n", part, header, next);
+ part = next;
+ if (header == "")
+ {
+ // Two empty lines signal the beginning of the content
+ empty++;
+ if (empty == 1)
+ break;
+ }
+ else
+ {
+ empty = 0;
+
+ // Detect XML content
+ if (header == "Content-Type: text/xml")
+ xml = true;
+ }
+ }
+
+ // Read the part content
+ if (part.length())
+ {
+ // Strip the trailer
+ string value;
+ Utils::tokeniseString("\r\n--", part, value, next);
+
+ if (xml)
+ {
+ // Add an XML parameter to the operation
+ addPart(xmlHelper, value, operation);
+ }
+ else
+ {
+ // Add a text parameter to the operation
+ string* stringData = new string;
+ *stringData = value;
+ operation.addParameter(stringData);
+ }
+ }
+
+ // Read till the end of the POST body
+ if (input.length() == 0)
+ break;
+ }
+ }
+ else
+ {
+ // The POST body represents a single part
+ addPart(xmlHelper, input, operation);
+ }
+
+ DataObjectPtr inputDataObject = createPayload(dataFactory, operation, wsdlOperation);
+
+ // Dispatch to the REST proxy
+ DataObjectPtr outputDataObject = proxy->invoke(wsdlOperation, inputDataObject);
+
+ // Send the response back to the client
+ if (iface!=NULL &&
+ iface->getInterfaceTypeQName() == RESTInterface::typeQName)
+ {
+ // Pure REST, send the location of the created resource
+
+ if (outputDataObject == NULL)
+ {
+ throwException(ServiceInvocationException, "Null output from REST create operation");
+ }
+
+ string location = "";
+
+ DataObjectList& l = outputDataObject->getList("return");
+ if (l.size())
+ {
+ location = l.getCString(0);
+ }
+
+ if (location == "")
+ {
+ loginfo("No resource location, sending HTTP 400 response code");
+ request->status = HTTP_BAD_REQUEST;
+
+ return OK;
+ }
+
+ string locuri = request->uri;
+ locuri += '/';
+ locuri += location;
+
+ const char* loc = ap_construct_url(request->pool, locuri.c_str(), request);
+ loginfo("Sending resource location: %s", loc);
+ apr_table_setn(request->headers_out, "Location", loc);
+ apr_table_setn(request->headers_out, "Content-Location", loc);
+ request->status = HTTP_CREATED;
+
+ // Send the created resource entity back to the client
+ ap_set_content_type(request, "text/xml");
+ ap_rputs(input.c_str(), request);
+
+ }
+ else
+ {
+ // Command style, send the response element
+
+ if (outputDataObject == NULL)
+ {
+ loginfo("Sending empty response");
+ //request->status = HTTP_NO_CONTENT;
+ }
+ else
+ {
+ XMLHelperPtr xm = HelperProvider::getXMLHelper(dataFactory);
+ DataObjectList& l = outputDataObject->getList("return");
+ if (l.size() != 0)
+ {
+ DataObjectPtr resultDataObject = l[0];
+ XMLDocumentPtr doc = xm->createDocument(
+ resultDataObject,
+ resultDataObject->getType().getURI(),
+ resultDataObject->getType().getName());
+ char* str = xm->save(doc);
+
+ loginfo("Sending response: %s", str);
+ ap_set_content_type(request, "text/xml");
+ ap_rputs(str, request);
+ }
+ else
+ {
+ loginfo("Sending empty response");
+ //request->status = HTTP_NO_CONTENT;
+ }
+ }
+ }
+
+ return OK;
+ }
+ else if (request->method_number == M_PUT)
+ {
+
+ // Handle an HTTP PUT
+
+ // Determine the operation to invoke
+ WSDLOperation wsdlOperation;
+ string wsdlNamespace = "";
+ string op_name = "update";
+ string uriArgs = uri;
+
+ // Create a default document literal wrapped WSDL operation
+ wsdlNamespace = compositeService->getName();
+ wsdlOperation = WSDLOperation();
+ wsdlOperation.setOperationName(op_name.c_str());
+ wsdlOperation.setSoapAction(wsdlNamespace+ "#" +op_name);
+ wsdlOperation.setEndpoint("");
+ wsdlOperation.setSoapVersion(WSDLOperation::SOAP11);
+ wsdlOperation.setDocumentStyle(true);
+ wsdlOperation.setWrappedStyle(true);
+ wsdlOperation.setEncoded(false);
+ wsdlOperation.setInputType(string("http://tempuri.org") + "#" + op_name);
+ wsdlOperation.setOutputType(string("http://tempuri.org") + "#" + op_name + "Response");
+
+ // Create the input DataObject
+ Operation operation(op_name.c_str());
+
+ // Parse the args part of the URI
+ if (uriArgs != "")
+ {
+ string args = uriArgs;
+ for (; args != ""; )
+ {
+ string param;
+ string next;
+ Utils::tokeniseString("/", args, param, next);
+ if (param != "")
+ {
+ string* data = new string;
+ *data = param;
+ operation.addParameter(data);
+ }
+ args = next;
+ }
+ }
+
+ // Parse the query string
+ if (request->args)
+ {
+ string query = request->args;
+ for (; query != ""; )
+ {
+ string param;
+ string next;
+ Utils::tokeniseString("&", query, param, next);
+ if (param != "")
+ {
+ string n;
+ string* data = new string;
+ Utils::tokeniseString("=", param, n, *data);
+ operation.addParameter(data);
+ }
+ query = next;
+ }
+ }
+
+ // Read the PUT input
+ ostringstream sinput;
+ char buffer[2049];
+ for ( ; ; )
+ {
+ int size = ap_get_client_block(request, buffer, 2048);
+ if (size > 0)
+ {
+ buffer[size] = '\0';
+ sinput << buffer;
+ }
+ else if (size == 0)
+ {
+ break;
+ }
+ else if (size < 0)
+ {
+ throwException(ServiceInvocationException, "Error reading PUT input");
+ }
+ }
+ string input = sinput.str();
+ addPart(xmlHelper, input, operation);
+
+ DataObjectPtr inputDataObject = createPayload(dataFactory, operation, wsdlOperation);
+
+ // Dispatch to the REST proxy
+ DataObjectPtr outputDataObject = proxy->invoke(wsdlOperation, inputDataObject);
+
+ // Empty response
+ //request->status = HTTP_NO_CONTENT;
+ return OK;
+ }
+ else if (request->method_number == M_DELETE)
+ {
+
+ // Determine the operation to invoke
+ WSDLOperation wsdlOperation;
+ string wsdlNamespace = "";
+ string op_name = "delete";
+ string uriArgs = uri;
+
+ // Create a default document literal wrapped WSDL operation
+ wsdlNamespace = compositeService->getName();
+ wsdlOperation = WSDLOperation();
+ wsdlOperation.setOperationName(op_name.c_str());
+ wsdlOperation.setSoapAction(wsdlNamespace+ "#" +op_name);
+ wsdlOperation.setEndpoint("");
+ wsdlOperation.setSoapVersion(WSDLOperation::SOAP11);
+ wsdlOperation.setDocumentStyle(true);
+ wsdlOperation.setWrappedStyle(true);
+ wsdlOperation.setEncoded(false);
+ wsdlOperation.setInputType(string("http://tempuri.org") + "#" + op_name);
+ wsdlOperation.setOutputType(string("http://tempuri.org") + "#" + op_name + "Response");
+
+ // Create the input DataObject
+ Operation operation(op_name.c_str());
+
+ // Parse the args part of the URI
+ if (uriArgs != "")
+ {
+ string args = uriArgs;
+ for (; args != ""; )
+ {
+ string param;
+ string next;
+ Utils::tokeniseString("/", args, param, next);
+ if (param != "")
+ {
+ string* data = new string;
+ *data = param;
+ operation.addParameter(data);
+ }
+ args = next;
+ }
+ }
+
+ // Parse the query string
+ if (request->args)
+ {
+ string query = request->args;
+ for (; query != ""; )
+ {
+ string param;
+ string next;
+ Utils::tokeniseString("&", query, param, next);
+ if (param != "")
+ {
+ string n;
+ string* data = new string;
+ Utils::tokeniseString("=", param, n, *data);
+ operation.addParameter(data);
+ }
+ query = next;
+ }
+ }
+
+ DataObjectPtr inputDataObject = createPayload(dataFactory, operation, wsdlOperation);
+
+ // Dispatch to the REST proxy
+ DataObjectPtr outputDataObject = proxy->invoke(wsdlOperation, inputDataObject);
+
+ // Empty response
+ //request->status = HTTP_NO_CONTENT;
+ return OK;
+ }
+ else
+ {
+ if (request->method)
+ {
+ logerror("Unsupported HTTP method: %s", request->method);
+ }
+ else
+ {
+ logerror("Unsupported HTTP method: %d", request->method_number);
+ }
+ return HTTP_NOT_IMPLEMENTED;
+ }
+ }
+ catch(TuscanyRuntimeException& ex)
+ {
+ ostringstream msg;
+ msg << ex;
+ logerror("Failed to process REST request: %s", msg.str().c_str());
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+ }
+
+ DataObjectPtr createPayload(DataFactoryPtr dataFactory, Operation& operation, const WSDLOperation& wsdlOperation)
+ {
+ logentry();
+
+ DataObjectPtr inputDataObject;
+ try
+ {
+
+ // Create the input wrapper
+ const Type& rootType = dataFactory->getType(wsdlOperation.getInputTypeUri().c_str(), "RootType");
+ const Property& prop = rootType.getProperty(wsdlOperation.getInputTypeName().c_str());
+ const Type& inputType = prop.getType();
+ inputDataObject = dataFactory->create(inputType);
+ }
+ catch (SDORuntimeException&)
+ {
+ try
+ {
+ // Create the input wrapper
+ const Type& inputType = dataFactory->getType(wsdlOperation.getInputTypeUri().c_str(),
+ wsdlOperation.getInputTypeName().c_str());
+ inputDataObject = dataFactory->create(inputType);
+ }
+ catch (SDORuntimeException&)
+ {
+
+ // The input wrapper type is not known, create an open DataObject
+ inputDataObject = dataFactory->create("http://tempuri.org", "Wrapper");
+ }
+ }
+
+ // Go through data object to set the input parameters
+ PropertyList pl = inputDataObject->getType().getProperties();
+
+ if(pl.size() == 0)
+ {
+ if(inputDataObject->getType().isOpenType() && inputDataObject->getType().isDataObjectType())
+ {
+ /*
+ * This code deals with sending xsd:any elements
+ */
+ for (int i=0; i<operation.getNParms(); i++)
+ {
+ ostringstream pname;
+ pname << "param" << (i+1);
+ DataObjectList& l = inputDataObject->getList(pname.str());
+
+ const Operation::Parameter& parm = operation.getParameter(i);
+ switch(parm.getType())
+ {
+ case Operation::STRING:
+ {
+ l.append((*(string*)parm.getValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ l.append(*(DataObjectPtr*)parm.getValue());
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+ else {
+
+ // Each parameter in the operation should be a property on the request dataobject
+ for (unsigned int i=0; i<operation.getNParms(); i++)
+ {
+ const Operation::Parameter& parm = operation.getParameter(i);
+ switch(parm.getType())
+ {
+ case Operation::STRING:
+ {
+ inputDataObject->setCString(i, (*(string*)parm.getValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ inputDataObject->setDataObject(i, *(DataObjectPtr*)parm.getValue());
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ return inputDataObject;
+ }
+
+ void addPart(XMLHelper* xmlHelper, string& payload, Operation& operation)
+ {
+ logentry();
+
+
+ //TODO Remove this workaround once SDO supports loading of open top level content
+ // The workaround is to wrap the open content in a wrapper element
+ string xmldecl;
+ string xml;
+ Utils::rTokeniseString("?>", payload, xmldecl, xml);
+ string body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ body += "<Wrapper xmlns=\"http://tempuri.org\" xmlns:tns=\"http://tempuri.org\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
+ body += xml;
+ body += "\n</Wrapper>";
+
+ // Convert the body to an SDO DataObject
+ DataObjectPtr inputWrapperDataObject = NULL;
+ XMLDocumentPtr theXMLDocument = xmlHelper->load(body.c_str(), NULL);
+ if (theXMLDocument != 0)
+ {
+ inputWrapperDataObject = theXMLDocument->getRootDataObject();
+ }
+ if(!inputWrapperDataObject)
+ {
+ ostringstream msg;
+ msg << "Could not convert received document to SDO: " << body;
+ throwException(ServiceDataException, msg.str().c_str());
+ }
+
+ // Get the body part
+ DataObjectPtr inputDataObject = NULL;
+ PropertyList bpl = inputWrapperDataObject->getInstanceProperties();
+ if (bpl.size()!=0)
+ {
+ if (bpl[0].isMany())
+ {
+ DataObjectList& parts = inputWrapperDataObject->getList((unsigned int)0);
+ inputDataObject = parts[0];
+ }
+ else
+ {
+ inputDataObject = inputWrapperDataObject->getDataObject(bpl[0]);
+ }
+ }
+ if (inputDataObject == NULL)
+ {
+ ostringstream msg;
+ msg << "Could not convert received document to SDO: " << body;
+ throwException(ServiceDataException, msg.str().c_str());
+ }
+
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = inputDataObject;
+ (*dataObjectData)->detach();
+ operation.addParameter(dataObjectData);
+ }
+
+ const char *rest_set_home(cmd_parms *cmd, void *dummy,
+ const char *arg)
+ {
+ rest_server_config_rec_t *conf = (rest_server_config_rec_t*)ap_get_module_config(
+ cmd->server->module_config, &sca_rest_module);
+ conf->home = apr_pstrdup(cmd->pool, arg);
+ return NULL;
+ }
+
+ const char *rest_set_path(cmd_parms *cmd, void *c,
+ const char *arg)
+ {
+ rest_dir_config_rec_t *conf = (rest_dir_config_rec_t*)c;
+ conf->path = apr_pstrdup(cmd->pool, arg);
+ return NULL;
+ }
+
+ const char *rest_set_root(cmd_parms *cmd, void *c,
+ const char *arg)
+ {
+ rest_dir_config_rec_t *conf = (rest_dir_config_rec_t*)c;
+ conf->root = apr_pstrdup(cmd->pool, arg);
+ return NULL;
+ }
+
+ const char *rest_set_base_uri(cmd_parms *cmd, void *c,
+ const char *arg)
+ {
+ rest_dir_config_rec_t *conf = (rest_dir_config_rec_t*)c;
+ conf->base_uri = apr_pstrdup(cmd->pool, arg);
+ return NULL;
+ }
+
+ const char *rest_set_component(cmd_parms *cmd, void *c,
+ const char *arg)
+ {
+ rest_dir_config_rec_t *conf = (rest_dir_config_rec_t*)c;
+ conf->component = apr_pstrdup(cmd->pool, arg);
+ return NULL;
+ }
+
+ const command_rec rest_module_cmds[] =
+ {
+ AP_INIT_TAKE1("TuscanyHome", (const char*(*)())tuscany::sca::rest::rest_set_home, NULL, RSRC_CONF,
+ "Tuscany home directory"),
+ AP_INIT_TAKE1("TuscanyPath", (const char*(*)())tuscany::sca::rest::rest_set_path, NULL, ACCESS_CONF,
+ "Tuscany SCA composite search path"),
+ AP_INIT_TAKE1("TuscanyRoot", (const char*(*)())tuscany::sca::rest::rest_set_root, NULL, ACCESS_CONF,
+ "Tuscany root SCA configuration path"),
+ AP_INIT_TAKE1("TuscanyBaseURI", (const char*(*)())tuscany::sca::rest::rest_set_base_uri, NULL, ACCESS_CONF,
+ "Tuscany SCA system base URI"),
+ AP_INIT_TAKE1("TuscanyComponent", (const char*(*)())tuscany::sca::rest::rest_set_component, NULL, ACCESS_CONF,
+ "SCA component name"),
+ {NULL}
+ };
+
+ int rest_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp,
+ server_rec *s)
+ {
+ return OK;
+ }
+
+ void rest_child_init(apr_pool_t* p, server_rec* svr_rec)
+ {
+ rest_server_config_rec_t *conf = (rest_server_config_rec_t*)ap_get_module_config(
+ svr_rec->module_config, &sca_rest_module);
+
+ if(false)
+ {
+ fprintf(stderr, "[Tuscany] Due to one or more errors mod_rest loading"
+ " failed. Causing apache2 to stop loading\n");
+ exit(APEXIT_CHILDFATAL);
+ }
+ }
+
+ void register_hooks(apr_pool_t *p)
+ {
+ ap_hook_handler(rest_handler, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_post_config(rest_init, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_child_init(rest_child_init, NULL, NULL, APR_HOOK_MIDDLE);
+ }
+
+ void *rest_create_dir_config(apr_pool_t *p, char *dirspec)
+ {
+ rest_dir_config_rec_t* conf = (rest_dir_config_rec_t* )apr_palloc(p, sizeof(*conf));
+ conf->path = "";
+ conf->root = "";
+ conf->base_uri = "";
+ conf->component = "";
+ return conf;
+ }
+
+ void* rest_create_server_config(apr_pool_t *p, server_rec *s)
+ {
+ rest_server_config_rec_t* conf = (rest_server_config_rec_t* )apr_palloc(p, sizeof(*conf));
+ conf->home = "";
+ return conf;
+ }
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
+
+extern "C"
+{
+
+ module AP_MODULE_DECLARE_DATA sca_rest_module =
+ {
+ STANDARD20_MODULE_STUFF,
+ tuscany::sca::rest::rest_create_dir_config, /* dir config */
+ NULL, /* dir merger --- default is to override */
+ tuscany::sca::rest::rest_create_server_config, /* server config */
+ NULL, /* merge server config */
+ tuscany::sca::rest::rest_module_cmds, /* command table */
+ tuscany::sca::rest::register_hooks /* register_hooks */
+ };
+
+}
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.cpp
new file mode 100644
index 0000000000..18720f42f5
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.cpp
@@ -0,0 +1,86 @@
+/*
+* 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.
+*/
+
+#include "RESTReferenceBindingExtension.h"
+#include "model/RESTReferenceBinding.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_rest_service_initialize()
+ {
+ tuscany::sca::rest::RESTReferenceBindingExtension::initialize();
+ }
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+ // ===================================================================
+ // Constructor for the RESTReferenceBinding class.
+ // ===================================================================
+ RESTReferenceBindingExtension::RESTReferenceBindingExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the RESTReferenceBindingExtension class.
+ // ===================================================================
+ RESTReferenceBindingExtension::~RESTReferenceBindingExtension()
+ {
+ logentry();
+ }
+
+ const string RESTReferenceBindingExtension::extensionName("rest");
+ const string RESTReferenceBindingExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#RESTBinding");
+
+ // ===================================================================
+ // loadModelElement - load the info from binding.rest
+ // ===================================================================
+ ReferenceBinding* RESTReferenceBindingExtension::getReferenceBinding(Composite *composite, Reference* reference, DataObjectPtr scdlBinding)
+ {
+ string uri = scdlBinding->getCString("uri");
+
+ RESTReferenceBinding* referenceBinding = new RESTReferenceBinding(reference, uri);
+
+ return referenceBinding;
+ }
+
+ void RESTReferenceBindingExtension::initialize()
+ {
+ logentry();
+ SCARuntime::getCurrentRuntime()->registerReferenceBindingExtension(new RESTReferenceBindingExtension());
+ }
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.h
new file mode 100644
index 0000000000..0d9e41841b
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.h
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+#ifndef tuscany_sca_extension_rest_restreferencebindingextension_h
+#define tuscany_sca_extension_rest_restreferencebindingextension_h
+
+#include "tuscany/sca/extension/ReferenceBindingExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+
+ class RESTReferenceBindingExtension : public ReferenceBindingExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ RESTReferenceBindingExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~RESTReferenceBindingExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#binding.rest")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ReferenceBinding* getReferenceBinding(
+ tuscany::sca::model::Composite* composite,
+ tuscany::sca::model::Reference *reference,
+ commonj::sdo::DataObjectPtr scdlBinding);
+
+ static void initialize();
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_rest_restreferencebindingextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTServiceProxy.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTServiceProxy.cpp
new file mode 100644
index 0000000000..5806c83773
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTServiceProxy.cpp
@@ -0,0 +1,559 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <sstream>
+
+#include "commonj/sdo/SDO.h"
+
+#include "RESTServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/model/WSDLDefinition.h"
+#include "tuscany/sca/model/WSDLInterface.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+#include "model/RESTReferenceBinding.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ RESTServiceProxy::RESTServiceProxy(Reference* reference)
+ : ServiceProxy(reference)
+ {
+ logentry();
+
+ // Get the target service wrapper
+ RESTReferenceBinding* referenceBinding = (RESTReferenceBinding*)reference->getBinding();
+ serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
+
+ DataFactoryPtr dataFactory = reference->getComponent()->getComposite()->getDataFactory();
+ try {
+ const Type& tempType = dataFactory->getType("http://tempuri.org", "RootType");
+ } catch (SDORuntimeException&)
+ {
+ dataFactory->addType("http://tempuri.org", "RootType", false, false, false);
+ dataFactory->addType("http://tempuri.org", "Wrapper", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://tempuri.org", "RootType",
+ "Wrapper",
+ "http://tempuri.org", "Wrapper",
+ false, false, true);
+ dataFactory->addType("http://tempuri.org", "Part", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://tempuri.org", "RootType",
+ "Part",
+ "http://tempuri.org", "Part",
+ false, false, true);
+ }
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ RESTServiceProxy::~RESTServiceProxy()
+ {
+ logentry();
+ }
+
+ ///
+ /// This method will be called to process an operation invocation.
+ ///
+ DataObjectPtr RESTServiceProxy::invoke(const WSDLOperation& wsdlOperation, DataObjectPtr inputDataObject)
+ {
+ logentry();
+
+ Reference* reference = getReference();
+ Component* component = reference->getComponent();
+ Composite* composite = component ->getComposite();
+
+ RESTReferenceBinding* referenceBinding = (RESTReferenceBinding*)reference->getBinding();
+ DataFactoryPtr dataFactoryPtr = reference->getComponent()->getComposite()->getDataFactory();
+
+ const char* outputTypeURI = wsdlOperation.getOutputTypeUri().c_str();
+ const char* outputTypeName = wsdlOperation.getOutputTypeName().c_str();
+
+ loginfo("WSDLOperation inputType: %s#%s",
+ wsdlOperation.getInputTypeUri().c_str(),
+ wsdlOperation.getInputTypeName().c_str());
+ loginfo("WSDLOperation outputType: %s#%s",
+ outputTypeURI,
+ outputTypeName);
+
+ // Create new Operation object and set parameters and return value
+ Operation operation(wsdlOperation.getOperationName().c_str());
+
+ try
+ {
+
+ // Go through the input data object to set the operation parameters
+ PropertyList pl = inputDataObject->getInstanceProperties();
+
+ for(int i=0; i<pl.size(); i++)
+ {
+ const char* name = pl[i].getName();
+
+ switch (pl[i].getTypeEnum())
+ {
+ case Type::BooleanType:
+ {
+ bool* boolData = new bool;
+ *boolData = inputDataObject->getBoolean(pl[i]);
+ operation.addParameter(boolData);
+ }
+ break;
+ case Type::ByteType:
+ {
+ char* byteData = new char;
+ *byteData = inputDataObject->getByte(pl[i]);
+ operation.addParameter(byteData);
+ }
+ break;
+ case Type::BytesType:
+ {
+ int len = inputDataObject->getLength(pl[i]);
+ char** bytesData = new char*;
+ *bytesData = new char[len+1];
+ int bytesWritten = inputDataObject->getBytes(pl[i], *bytesData, len);
+ // Ensure the bytes end with the null char. Not sure if this is neccessary
+ if(bytesWritten <= len)
+ {
+ (*bytesData)[bytesWritten] = 0;
+ }
+ else
+ {
+ (*bytesData)[len] = 0;
+ }
+ operation.addParameter(bytesData);
+ }
+ break;
+ case Type::CharacterType:
+ {
+ // This code should work but won't be used as there is no mapping from an XSD type to the SDO CharacterType
+ wchar_t* charData = new wchar_t;
+ *charData = inputDataObject->getCharacter(pl[i]);
+ operation.addParameter(charData);
+ }
+ break;
+ case Type::DoubleType:
+ {
+ long double* doubleData = new long double;
+ *doubleData = inputDataObject->getDouble(pl[i]);
+ operation.addParameter(doubleData);
+ }
+ break;
+ case Type::FloatType:
+ {
+ float* floatData = new float;
+ *floatData = inputDataObject->getFloat(pl[i]);
+ operation.addParameter(floatData);
+ }
+ break;
+ case Type::IntegerType:
+ {
+ long* intData = new long;
+ *intData = inputDataObject->getInteger(pl[i]);
+ operation.addParameter(intData);
+ }
+ break;
+ case Type::ShortType:
+ {
+ short* shortData = new short;
+ *shortData = inputDataObject->getShort(pl[i]);
+ operation.addParameter(shortData);
+ }
+ break;
+ case Type::StringType:
+ {
+ string* stringData;
+ if (pl[i].isMany())
+ {
+ DataObjectList& l = inputDataObject->getList(pl[i]);
+ stringData = new string(l.getCString(0));
+ }
+ else
+ {
+ if(inputDataObject->isSet(pl[i]))
+ {
+ stringData = new string(inputDataObject->getCString(pl[i]));
+ }
+ else
+ {
+ // The data is not set, so pass an empty string as the parameter
+ stringData = new string();
+ }
+ }
+ operation.addParameter(stringData);
+ }
+ break;
+ case Type::DataObjectType:
+ {
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ if (pl[i].isMany())
+ {
+ DataObjectList& l = inputDataObject->getList((unsigned int)i);
+ *dataObjectData = l[0];
+ }
+ else
+ {
+ *dataObjectData = inputDataObject->getDataObject(pl[i]);
+ }
+ if(!*dataObjectData)
+ {
+ loginfo("Null DataObject parameter named %s", name);
+ }
+ else
+ {
+ (*dataObjectData)->detach();
+ }
+ operation.addParameter(dataObjectData);
+ }
+ break;
+ case Type::OpenDataObjectType:
+ {
+ /*
+ * This code deals with xsd:any element parameters
+ * Get each element as a DataObject and add in to the parameter list
+ */
+
+ DataObjectList& dataObjectList = inputDataObject->getList(pl[i]);
+
+ for(int j=0; j<dataObjectList.size(); j++)
+ {
+ DataObjectPtr dob = dataObjectList[j];
+ if(!dob)
+ {
+
+ // Add a null DataObject ptr
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = NULL;
+ loginfo("Null OpenDataObject parameter named %s[%d]", name, j);
+ operation.addParameter(dataObjectData);
+ }
+ else
+ {
+
+ SequencePtr sequence = dob->getSequence();
+ if (sequence->size()!=0)
+ {
+ // Add a text element
+ if (sequence->isText(0))
+ {
+ string* stringData = new string(sequence->getCStringValue(0));
+ operation.addParameter(stringData);
+ }
+ else
+ {
+ // Add a complex element DataObject
+ DataObjectPtr* dataObjectData =new DataObjectPtr;
+ *dataObjectData = sequence->getDataObjectValue(0);
+ if(!*dataObjectData)
+ {
+ loginfo("Null DataObject parameter named %s", name);
+ }
+ else
+ {
+ (*dataObjectData)->detach();
+ }
+ operation.addParameter(dataObjectData);
+ }
+ }
+ else
+ {
+ // Empty content, add an empty string
+ loginfo("Empty OpenDataObject parameter named %s[%d]", name, j);
+ string* stringData = new string("");
+ operation.addParameter(stringData);
+ }
+ }
+ }
+ }
+ break;
+ default:
+ {
+ ostringstream msg;
+ msg << "Unsupported param type: " << pl[i].getTypeEnum();
+ throwException(SystemConfigurationException, msg.str().c_str());
+ }
+ }
+ }
+
+ // Call into the target service wrapper
+ serviceWrapper->invoke(operation);
+
+ // Set the data in the outputDataObject to be returned
+ DataObjectPtr outputDataObject;
+ try {
+
+ // Create the output wrapper
+ const Type& rootType = dataFactoryPtr->getType(outputTypeURI, "RootType");
+ const Property& prop = rootType.getProperty(outputTypeName);
+ const Type& outputType = prop.getType();
+ outputDataObject = dataFactoryPtr->create(outputType);
+ }
+ catch (SDORuntimeException&)
+ {
+ try
+ {
+
+ // Create the output wrapper
+ const Type& outputType = dataFactoryPtr->getType(outputTypeURI, outputTypeName);
+ outputDataObject = dataFactoryPtr->create(outputType);
+ }
+ catch (SDORuntimeException&)
+ {
+ // The output wrapper type is not known, create an open DataObject
+ outputDataObject = dataFactoryPtr->create("http://tempuri.org", "Wrapper");
+ }
+ }
+
+ setOutputData(operation, outputDataObject, dataFactoryPtr);
+
+ return outputDataObject;
+ }
+ catch(SDORuntimeException& ex)
+ {
+ throwException(ServiceInvocationException, ex);
+ }
+ catch(TuscanyRuntimeException& ex)
+ {
+ throw;
+ }
+ }
+
+
+ void RESTServiceProxy::setOutputData(Operation& operation, DataObjectPtr outputDataObject, DataFactoryPtr dataFactoryPtr)
+ {
+ logentry();
+
+ // Go through data object to set the return value
+ PropertyList pl = outputDataObject->getType().getProperties();
+
+ if(pl.size() == 0)
+ {
+ if(outputDataObject->getType().isOpenType() && outputDataObject->getType().isDataObjectType())
+ {
+ /*
+ * This code deals with returning xsd:any elements
+ */
+ DataObjectList& l = outputDataObject->getList("return");
+ Operation::ParameterType resultType = operation.getReturnType();
+ switch(resultType)
+ {
+ case Operation::BOOL:
+ {
+ l.append(*(bool*)operation.getReturnValue());
+ break;
+ }
+ case Operation::SHORT:
+ {
+ l.append(*(short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::INT:
+ {
+ l.append(*(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONG:
+ {
+ l.append(*(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::USHORT:
+ {
+ l.append(*(short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::UINT:
+ {
+ l.append(*(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::ULONG:
+ {
+ l.append(*(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ l.append(*(float*)operation.getReturnValue());
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ l.append(*(long double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ l.append(*(long double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ l.append(*(char**)operation.getReturnValue());
+ break;
+ }
+ case Operation::STRING:
+ {
+ l.append((*(string*)operation.getReturnValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ l.append(*(DataObjectPtr*)operation.getReturnValue());
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ loginfo("No return values defined");
+ }
+ }
+ else {
+
+ // Should only be one return value.. This goes through all return values
+ for(int i=0; i<pl.size(); i++)
+ {
+ const char* name = pl[i].getName();
+
+ Operation::ParameterType resultType = operation.getReturnType();
+ switch(resultType)
+ {
+ case Operation::BOOL:
+ {
+ outputDataObject->setBoolean(pl[i], *(bool*)operation.getReturnValue());
+ break;
+ }
+ case Operation::SHORT:
+ {
+ outputDataObject->setShort(pl[i], *(short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::INT:
+ {
+ outputDataObject->setInteger(pl[i], *(int*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONG:
+ {
+ outputDataObject->setInteger(pl[i], *(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::USHORT:
+ {
+ outputDataObject->setInteger(pl[i], *(unsigned short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::UINT:
+ {
+ outputDataObject->setInteger(pl[i], *(unsigned int*)operation.getReturnValue());
+ break;
+ }
+ case Operation::ULONG:
+ {
+ outputDataObject->setInteger(pl[i], *(unsigned long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ outputDataObject->setFloat(pl[i], *(float*)operation.getReturnValue());
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ outputDataObject->setDouble(pl[i], *(double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ outputDataObject->setDouble(pl[i], *(long double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ if(*(char**)operation.getReturnValue() != NULL)
+ {
+ outputDataObject->setCString(pl[i], *(char**)operation.getReturnValue());
+ }
+ else
+ {
+ loginfo("Null return value, leaving property %s unset", pl[i].getName());
+ }
+ break;
+ }
+ case Operation::STRING:
+ {
+ outputDataObject->setCString(pl[i], (*(string*)operation.getReturnValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+
+ if(*(DataObjectPtr*)operation.getReturnValue() != NULL)
+ {
+ outputDataObject->setDataObject(pl[i], *(DataObjectPtr*)operation.getReturnValue());
+ }
+ else
+ {
+ loginfo("Null return value, leaving property %s unset", pl[i].getName());
+ }
+
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTServiceProxy.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTServiceProxy.h
new file mode 100644
index 0000000000..387add3f35
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTServiceProxy.h
@@ -0,0 +1,95 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_rest_restserviceproxy_h
+#define tuscany_sca_extension_rest_restserviceproxy_h
+
+#include "commonj/sdo/SDO.h"
+
+#include "export.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+#include "model/RESTReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+
+ /**
+ * Holds a proxy for a given component and reference.
+ * The proxy which is held inside a ServiceProxy will be specific to the programming
+ * interface expected by the client. In this particular case the client is an Axis2
+ * Web service skeleton.
+ */
+ class RESTServiceProxy : public ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a reference. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The reference on the source component.
+ * @param target The wrapper of the service which is wired to this reference.
+ */
+ RESTServiceProxy(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Create a new service proxy for a service. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The service on the target component.
+ * @param target The wrapper of the target service.
+ */
+ RESTServiceProxy(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~RESTServiceProxy();
+
+ /**
+ * Invoke the specified operation
+ */
+ SCA_REST_SERVICE_API commonj::sdo::DataObjectPtr invoke(
+ const tuscany::sca::model::WSDLOperation& wsdlOperation,
+ commonj::sdo::DataObjectPtr inputDataObject);
+
+ private:
+
+ void setOutputData(Operation& operation,
+ commonj::sdo::DataObjectPtr outputDataObject, commonj::sdo::DataFactoryPtr dataFactoryPtr);
+
+ /**
+ * The target service wrapper
+ */
+ ServiceWrapper* serviceWrapper;
+
+ };
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_rest_restserviceproxy_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/export.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/export.h
new file mode 100644
index 0000000000..802218a2fe
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/export.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_rest_service_export_h
+#define tuscany_sca_rest_service_export_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef TUSCANY_SCA_REST_SERVICE_EXPORTS
+#define SCA_REST_SERVICE_API __declspec(dllexport)
+#else
+#define SCA_REST_SERVICE_API __declspec(dllimport)
+#endif
+
+#else
+#define SCA_REST_SERVICE_API
+#endif
+
+#endif // tuscany_sca_rest_service_export_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/model/RESTReferenceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/model/RESTReferenceBinding.cpp
new file mode 100644
index 0000000000..1b4b2d3403
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/model/RESTReferenceBinding.cpp
@@ -0,0 +1,66 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/rest/model/RESTReferenceBinding.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/rest/RESTServiceProxy.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+
+ // Constructor
+ RESTReferenceBinding::RESTReferenceBinding(Reference* reference, const string& uri)
+ : ReferenceBinding(reference, uri)
+ {
+ logentry();
+ }
+
+ // Destructor
+ RESTReferenceBinding::~RESTReferenceBinding()
+ {
+ logentry();
+ }
+
+ void RESTReferenceBinding::configure(ServiceBinding *binding)
+ {
+ logentry();
+
+ targetServiceBinding = binding;
+
+ serviceProxy = new RESTServiceProxy(getReference());
+ }
+
+ ServiceProxy* RESTReferenceBinding::getServiceProxy()
+ {
+ logentry();
+
+ return serviceProxy;
+ }
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/model/RESTReferenceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/model/RESTReferenceBinding.h
new file mode 100644
index 0000000000..d19f3926a1
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/model/RESTReferenceBinding.h
@@ -0,0 +1,90 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_rest_model_restreferencebinding_h
+#define tuscany_sca_extension_rest_model_restreferencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace rest
+ {
+ /**
+ * Information about a web service binding for service or a reference.
+ */
+ class RESTReferenceBinding : public tuscany::sca::model::ReferenceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ */
+ RESTReferenceBinding(tuscany::sca::model::Reference* reference, const std::string& uri);
+
+ /**
+ * Destructor.
+ */
+ virtual ~RESTReferenceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#RESTBinding"; };
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding);
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ virtual ServiceProxy* getServiceProxy();
+
+ /**
+ * Returns the target service binding.
+ */
+ tuscany::sca::model::ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; };
+
+ private:
+
+ /**
+ * The proxy representing the reference to the client
+ * component.
+ */
+ ServiceProxy* serviceProxy;
+
+ /**
+ * The service binding of the target
+ */
+ tuscany::sca::model::ServiceBinding* targetServiceBinding;
+ };
+
+ } // End namespace rest
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_rest_model_restreferencebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/xsd/sca-binding-rest.xsd b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/xsd/sca-binding-rest.xsd
new file mode 100644
index 0000000000..a2fd41121c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/xsd/sca-binding-rest.xsd
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed 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.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <element name="binding.rest" type="sca:RESTBinding" substitutionGroup="sca:binding"/>
+ <complexType name="RESTBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/xsd/sca-interface-rest.xsd b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/xsd/sca-interface-rest.xsd
new file mode 100644
index 0000000000..3f1aca6ecd
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/rest/xsd/sca-interface-rest.xsd
@@ -0,0 +1,38 @@
+<?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.
+-->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <element name="interface.rest" type="sca:RESTInterface" substitutionGroup="sca:interface"/>
+ <complexType name="RESTInterface">
+ <complexContent>
+ <extension base="sca:Interface">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/Makefile.am
new file mode 100644
index 0000000000..08ba2f553f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/Makefile.am
@@ -0,0 +1,24 @@
+# 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.
+
+SUBDIRS = src extension
+
+datadir=$(prefix)/extensions/ruby
+
+nobase_data_DATA = xsd/*.xsd
+
+EXTRA_DIST = xsd
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/deploy.bat
new file mode 100644
index 0000000000..c126025bb6
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/deploy.bat
@@ -0,0 +1,66 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set rubyextdir=%extdir%\ruby
+set srcdir=%rootdir%\runtime\extensions\ruby\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %rubyextdir% mkdir %rubyextdir%
+if not exist %rubyextdir%\module mkdir %rubyextdir%\module
+if not exist %rubyextdir%\bin mkdir %rubyextdir%\bin
+if not exist %rubyextdir%\lib mkdir %rubyextdir%\lib
+if not exist %rubyextdir%\xsd mkdir %rubyextdir%\xsd
+
+del %rubyextdir%\bin\tuscany_sca_ruby_lang.*
+del %rubyextdir%\lib\tuscany_sca_ruby_lang.lib
+
+copy %srcdir%\..\xsd\*.* %rubyextdir%\xsd
+
+copy %inpath%\tuscany_sca_ruby_lang.lib %rubyextdir%\lib
+copy %inpath%\tuscany_sca_ruby_lang.dll %rubyextdir%\bin
+copy %inpath%\tuscany_sca_ruby_lang.dll %rubyextdir%\module
+
+if exist %inpath%\tuscany_sca_ruby_lang.pdb copy %inpath%\tuscany_sca_ruby_lang.pdb %rubyextdir%\bin
+if exist %inpath%\tuscany_sca_ruby_lang.pdb copy %inpath%\tuscany_sca_ruby_lang.pdb %rubyextdir%\module
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/Makefile.am
new file mode 100644
index 0000000000..41ce75925b
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/Makefile.am
@@ -0,0 +1,34 @@
+# 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.
+SUBDIRS =
+
+libdir=$(prefix)/extensions/ruby/lib
+BUILT_SOURCES = extension_build
+
+EXTRA_DIST = src
+
+extension_build: src/Extension.cpp src/extconf.rb
+ cd src; ruby extconf.rb; make
+ touch extension_build
+
+clean:
+ cd src;make clean
+ rm -f extension_build
+
+install-exec-hook:
+ cp src/tuscany_sca_ruby.* $(libdir)
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/deploy.bat
new file mode 100644
index 0000000000..8c8d1e0794
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/deploy.bat
@@ -0,0 +1,59 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set rubyextdir=%extdir%\ruby
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %rubyextdir% mkdir %rubyextdir%
+if not exist %rubyextdir%\bin mkdir %rubyextdir%\bin
+if not exist %rubyextdir%\lib mkdir %rubyextdir%\lib
+
+del %rubyextdir%\bin\tuscany_sca_ruby.*
+del %rubyextdir%\lib\tuscany_sca_ruby.lib
+
+copy %inpath%\tuscany_sca_ruby.lib %rubyextdir%\lib
+copy %inpath%\tuscany_sca_ruby.dll %rubyextdir%\bin
+
+if exist %inpath%\tuscany_sca_ruby.pdb copy %inpath%\tuscany_sca_ruby.pdb %rubyextdir%\bin
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/src/Extension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/src/Extension.cpp
new file mode 100644
index 0000000000..458700e5f1
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/src/Extension.cpp
@@ -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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#define SCA_RUBYEXTENSION_API __declspec(dllexport)
+#else
+#define SCA_RUBYEXTENSION_API
+#endif
+
+#include "tuscany/sca/ruby/Ruby.h"
+#include "tuscany/sca/ruby/RubyCompositeContext.h"
+
+extern "C"
+{
+
+ // Implement the Sca::locateService module function
+ SCA_RUBYEXTENSION_API VALUE tuscany_sca_ruby_locateService(VALUE module, VALUE value)
+ {
+ // Locate the service
+ const char* serviceName = rb_string_value_cstr(&value);
+ return tuscany::sca::ruby::RubyCompositeContext::locateService(serviceName);
+ }
+
+ // Initialize the Ruby extension
+ SCA_RUBYEXTENSION_API void Init_tuscany_sca_ruby()
+ {
+
+ // Define the Sca::locateService() function
+ VALUE module = rb_define_module("SCA");
+ rb_define_module_function(module, "locateService", (VALUE(*)(ANYARGS))tuscany_sca_ruby_locateService, 1);
+
+ }
+
+ SCA_RUBYEXTENSION_API void Init_libtuscany_sca_ruby()
+ {
+ Init_tuscany_sca_ruby();
+ }
+}
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/src/extconf.rb b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/src/extconf.rb
new file mode 100644
index 0000000000..9c41843d63
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/extension/src/extconf.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 'mkmf'
+ CONFIG["CC"] = "g++"
+ $CPPFLAGS << " -I../../src "
+ $LIBPATH << "../../src/.libs"
+ $LIBS << " -ltuscany_sca_ruby_lang "
+ create_makefile 'tuscany_sca_ruby'
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/Makefile.am
new file mode 100644
index 0000000000..50dd2d15b8
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/Makefile.am
@@ -0,0 +1,55 @@
+# 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.
+
+libdir=$(prefix)/extensions/ruby/lib
+lib_LTLIBRARIES = libtuscany_sca_ruby_lang.la
+
+install-exec-hook:
+
+rootdir=$(prefix)/extensions/ruby
+
+noinst_HEADERS = \
+tuscany/sca/ruby/*.h \
+tuscany/sca/ruby/model/*.h
+
+libtuscany_sca_ruby_lang_la_SOURCES = \
+tuscany/sca/ruby/RubyExtension.cpp \
+tuscany/sca/ruby/RubyImplementationExtension.cpp \
+tuscany/sca/ruby/RubyServiceProxy.cpp \
+tuscany/sca/ruby/RubyServiceWrapper.cpp \
+tuscany/sca/ruby/model/RubyImplementation.cpp \
+tuscany/sca/ruby/model/RubyReferenceBinding.cpp \
+tuscany/sca/ruby/model/RubyServiceBinding.cpp \
+tuscany/sca/ruby/RubyCompositeContext.cpp
+
+libtuscany_sca_ruby_lang_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca \
+ -L${RUBY_LIB} -lruby -lpthread
+
+INCLUDES = -Imodel -I$(top_builddir)/runtime/core/src \
+ -I${TUSCANY_SDOCPP}/include \
+ -I${RUBY_INCLUDE}
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+moduledir=$(prefix)/extensions/ruby/module
+extension = libtuscany_sca_ruby_lang$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension) \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/Ruby.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/Ruby.h
new file mode 100644
index 0000000000..a6b8ee8ffa
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/Ruby.h
@@ -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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_ruby_ruby_h
+#define tuscany_sca_ruby_ruby_h
+
+// Ruby inists on MS VC6 ... we'll see about that!
+#if defined(WIN32) || defined (_WINDOWS)
+#define _REAL_MSC_VER _MSC_VER
+#undef _MSC_VER
+#define _MSC_VER 1200
+#endif
+
+#include <ruby.h>
+
+#if defined(WIN32) || defined (_WINDOWS)
+#undef _MSC_VER
+#define _MSC_VER _REAL_MSC_VER
+#endif
+
+#endif // tuscany_sca_ruby_ruby_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp
new file mode 100644
index 0000000000..5554ac6756
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/ruby/RubyServiceProxy.h"
+#include "tuscany/sca/ruby/RubyCompositeContext.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+
+ VALUE RubyCompositeContext::locateService(const char* serviceName)
+ {
+ // Get the default component
+ Component* defaultComponent = tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent();
+ Composite* composite = (Composite*)defaultComponent->getType();
+
+ // Locate the service
+ Service* service = composite->findComponentService(serviceName);
+ string msg;
+ if (!service)
+ {
+ string msg = "Service not found: ";
+ msg = msg + serviceName;
+ rb_raise(rb_eRuntimeError, msg.c_str());
+ }
+
+ // Get a Proxy for this service
+ tuscany::sca::ruby::RubyServiceProxy* serviceProxy = new tuscany::sca::ruby::RubyServiceProxy(service);
+
+ // Return the Ruby proxy value object
+ return serviceProxy->getProxyValue();
+ }
+
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.h
new file mode 100644
index 0000000000..2414b66fb1
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.h
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_ruby_RubyCompositeContext_h
+#define tuscany_sca_ruby_RubyCompositeContext_h
+
+#include "tuscany/sca/ruby/Ruby.h"
+#include "tuscany/sca/ruby/export.h"
+
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+
+ class RubyCompositeContext
+ {
+ public:
+ SCA_RUBY_API static VALUE locateService(const char* serviceName);
+
+ };
+
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_ruby_RubyCompositeContext_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp
new file mode 100644
index 0000000000..5789517cfd
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/ruby/RubyExtension.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/ruby/RubyImplementationExtension.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_ruby_lang_initialize()
+ {
+ tuscany::sca::ruby::RubyExtension::initialize();
+ }
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+ // ===================================================================
+ // Constructor for the RubyExtension class.
+ // ===================================================================
+ RubyExtension::RubyExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the RubyExtension class.
+ // ===================================================================
+ RubyExtension::~RubyExtension()
+ {
+ logentry();
+ }
+
+ void RubyExtension::initialize()
+ {
+ logentry();
+ SCARuntime::getCurrentRuntime()->registerImplementationExtension(new RubyImplementationExtension());
+ }
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.h
new file mode 100644
index 0000000000..232431ca1e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.h
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_ruby_rubyextension_h
+#define tuscany_sca_ruby_rubyextension_h
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+
+ class RubyExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ RubyExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~RubyExtension();
+
+ static void initialize();
+
+ private:
+
+ };
+
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_ruby_rubyextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.cpp
new file mode 100644
index 0000000000..aa416f139a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.cpp
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/ruby/RubyImplementationExtension.h"
+#include "tuscany/sca/ruby/model/RubyImplementation.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+ // ===================================================================
+ // Constructor for the RubyImplementationExtension class.
+ // ===================================================================
+ RubyImplementationExtension::RubyImplementationExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the RubyImplementationExtension class.
+ // ===================================================================
+ RubyImplementationExtension::~RubyImplementationExtension()
+ {
+ logentry();
+ }
+
+ const string RubyImplementationExtension::extensionName("ruby");
+ const string RubyImplementationExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#RubyImplementation");
+
+ // ===================================================================
+ // loadModelElement - load the info from implementation.ruby
+ // ===================================================================
+ ComponentType* RubyImplementationExtension::getImplementation(Composite *composite, DataObjectPtr scdlImplementation)
+ {
+ logentry();
+
+ string module = scdlImplementation->getCString("module");
+ string className = scdlImplementation->getCString("class");
+ string script = scdlImplementation->getCString("script");
+
+ RubyImplementation* rubyImpl = new RubyImplementation(composite, module, className, script);
+
+ return rubyImpl;
+ }
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.h
new file mode 100644
index 0000000000..79d9ed2dbe
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.h
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_ruby_rubyimplementationextension_h
+#define tuscany_sca_ruby_rubyimplementationextension_h
+
+#include "tuscany/sca/extension/ImplementationExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+
+ class RubyImplementationExtension : public ImplementationExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ RubyImplementationExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~RubyImplementationExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.ruby")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ComponentType* getImplementation(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlImplementation);
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_ruby_rubyimplementationextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp
new file mode 100644
index 0000000000..bf160cc821
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp
@@ -0,0 +1,384 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#include <sstream>
+
+#include "tuscany/sca/ruby/RubyServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/ruby/model/RubyImplementation.h"
+#include "tuscany/sca/ruby/model/RubyReferenceBinding.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+extern "C"
+{
+
+ // Initialize a Ruby proxy
+ SCA_RUBY_API VALUE tuscany_sca_ruby_proxy_initialize(VALUE self, VALUE serviceProxy)
+ {
+ rb_iv_set(self, "@cppProxy", serviceProxy);
+ return self;
+ }
+
+ // Handle a method_missing message and dispatch to
+ // our C++ proxy
+ SCA_RUBY_API VALUE tuscany_sca_ruby_proxy_method_missing(int argc, VALUE* argv, VALUE self)
+ {
+ VALUE proxy = rb_iv_get(self, "@cppProxy");
+
+ // Get the target service wrapper
+ tuscany::sca::ruby::RubyServiceProxy *serviceProxy;
+ Data_Get_Struct(proxy, tuscany::sca::ruby::RubyServiceProxy, serviceProxy);
+
+ // Handle the invocation
+ return serviceProxy->invoke(argc, argv);
+
+ }
+
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+
+ VALUE RubyServiceProxy::proxyClass = Qnil;
+
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ RubyServiceProxy::RubyServiceProxy(Reference* reference)
+ : ServiceProxy(reference)
+ {
+ logentry();
+
+ // ----------------------
+ // Get the component
+ // ----------------------
+ component = reference->getComponent();
+ string name = reference->getType()->getName();
+
+ // Get the service wrapper
+ RubyReferenceBinding* referenceBinding = (RubyReferenceBinding*)reference->getBinding();
+
+ serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
+
+ // Create the Ruby proxy
+ createProxy();
+ }
+
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ RubyServiceProxy::RubyServiceProxy(Service* service)
+ : ServiceProxy(0)
+ {
+ logentry();
+
+ // ----------------------
+ // Get the component
+ // ----------------------
+ component = service->getComponent();
+ string name = service->getType()->getName();
+
+ // Get the service wrapper
+ serviceWrapper = service->getBinding()->getServiceWrapper();
+
+ // Create the Ruby proxy
+ createProxy();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ RubyServiceProxy::~RubyServiceProxy()
+ {
+ logentry();
+ }
+
+ void RubyServiceProxy::createProxy()
+ {
+ logentry();
+
+ // Create the Ruby proxy class
+ if (RubyServiceProxy::proxyClass == Qnil)
+ {
+ VALUE module = rb_define_module("Tuscany");
+ proxyClass = rb_define_class_under(module, "ServiceProxy", rb_cObject);
+ rb_define_method(proxyClass, "initialize", (VALUE(*)(ANYARGS))tuscany_sca_ruby_proxy_initialize, 1);
+ rb_define_method(proxyClass, "method_missing", (VALUE(*)(ANYARGS))tuscany_sca_ruby_proxy_method_missing, -1);
+ }
+
+ // Create the Ruby proxy instance, pass the service wrapper to it
+ VALUE* args = new VALUE[1];
+ args[0] = Data_Wrap_Struct(rb_cObject, NULL, NULL, this);
+ proxyValue = rb_class_new_instance(1, args, proxyClass);
+
+ // Mark proxyValue busy so that it doesn't get GC'ed by Ruby
+ rb_gc_register_address(&proxyValue);
+ }
+
+
+ VALUE RubyServiceProxy::invoke(int argc, VALUE* argv)
+ {
+ logentry();
+
+ // Get the method name
+ char* methodName = rb_id2name(SYM2ID(argv[0]));
+
+ // Get the block passed by the caller
+ VALUE block =rb_block_given_p() ? rb_block_proc() : Qnil;
+
+ // Create new Operation object
+ Operation operation(methodName);
+
+ // Convert the Ruby parameters to C++
+ for (int i = 1; i < argc; i++)
+ {
+ VALUE value = argv[i];
+
+ int valueType = TYPE(value);
+
+ switch (valueType)
+ {
+ case T_FLOAT:
+ {
+ float* data = new float;
+ *data = rb_num2dbl(value);
+ operation.addParameter(data);
+ break;
+ }
+ case T_STRING:
+ {
+ string* data = new string(rb_string_value_cstr(&value));
+ const char** cdata = new const char*;
+ *cdata = data->c_str();
+ operation.addParameter(cdata);
+ break;
+ }
+ case T_FIXNUM:
+ {
+ long* data = new long;
+ *data = rb_num2long(value);
+ operation.addParameter(data);
+ break;
+ }
+ case T_BIGNUM:
+ {
+ long double* data = new long double;
+ *data = rb_num2dbl(value);
+ operation.addParameter(data);
+ break;
+ }
+ case T_TRUE:
+ {
+ bool* data = new bool;
+ *data = true;
+ operation.addParameter(data);
+ break;
+ }
+ case T_FALSE:
+ {
+ bool* data = new bool;
+ *data = false;
+ operation.addParameter(data);
+ break;
+ }
+ case T_OBJECT:
+ {
+ VALUE klass = rb_obj_class(value);
+ if (klass == RubyImplementation::getXMLDocumentClass())
+ {
+ // Convert a REXML::Document to a DataObject
+ ID to_s = rb_intern("to_s");
+ VALUE vstr = rb_funcall(value, to_s, 0);
+ string str = string(rb_string_value_cstr(&vstr));
+
+ loginfo("Converting Ruby Rexml document to SDO DataObject: %s", str.c_str());
+
+ Composite* composite = getReference()->getComponent()->getComposite();
+ commonj::sdo::XMLHelper* xmlHelper = composite->getXMLHelper();
+ commonj::sdo::XMLDocumentPtr xmlDoc = xmlHelper->load(str.c_str());
+
+ DataObjectPtr dob;
+ if (xmlDoc != NULL)
+ {
+ dob = xmlDoc->getRootDataObject();
+ }
+ if (dob != NULL)
+ {
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = dob;
+ operation.addParameter(dataObjectData);
+ }
+ else
+ {
+ string msg = "Document could not be converted to a DataObject";
+ rb_raise(rb_eTypeError, msg.c_str());
+ return Qnil;
+ }
+ }
+ else
+ {
+ string msg = "Ruby type not supported: " + valueType;
+ rb_raise(rb_eTypeError, msg.c_str());
+ return Qnil;
+ }
+ break;
+ }
+ default:;
+ string msg = "Ruby type not supported: " + valueType;
+ rb_raise(rb_eTypeError, msg.c_str());
+ return Qnil;
+ }
+
+ }
+
+ try
+ {
+ // Call into the target service wrapper
+ serviceWrapper->invoke(operation);
+
+ // Convert the result to a Ruby value
+ VALUE value;
+ Operation::ParameterType resultType = operation.getReturnType();
+ switch(resultType)
+ {
+ case Operation::BOOL:
+ {
+ if( *(bool*)operation.getReturnValue())
+ {
+ //boolean true
+ value = rb_int2inum(1);
+ }
+ else
+ {
+ value = rb_int2inum(0);
+ }
+ break;
+ }
+ case Operation::SHORT:
+ {
+ value = rb_int2inum(*(short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::USHORT:
+ {
+ value = rb_uint2inum(*(unsigned short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONG:
+ {
+ value = rb_int2inum(*(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::ULONG:
+ {
+ value = rb_uint2inum(*(unsigned long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ value = rb_float_new(*(float*)operation.getReturnValue());
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ value = rb_float_new(*(double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ value = rb_float_new(*(long double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ value = rb_str_new2(*(char**)operation.getReturnValue());
+ break;
+ }
+ case Operation::STRING:
+ {
+ value = rb_str_new2((*(string*)operation.getReturnValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ DataObjectPtr dob = *(DataObjectPtr*)operation.getReturnValue();
+
+ // Convert a DataObject to a REXML Document object
+ Composite* composite = component->getComposite();
+ commonj::sdo::XMLHelper* xmlHelper = composite->getXMLHelper();
+ char* str = xmlHelper->save(
+ dob,
+ dob->getType().getURI(),
+ dob->getType().getName());
+
+ loginfo("Converting SDO DataObject to Ruby Rexml document: %s", str);
+
+ VALUE vstr[1];
+ vstr[0] = rb_str_new2(str);
+
+ value = rb_class_new_instance(1, vstr, RubyImplementation::getXMLDocumentClass());
+ break;
+ }
+ default:
+ {
+ value = Qnil;
+ break;
+ }
+ }
+
+ return value;
+
+ }
+ catch(TuscanyRuntimeException& ex)
+ {
+ string msg = "Exception while invoking a service: ";
+ msg += ex.getEClassName();
+ msg += ": ";
+ msg += ex.getMessageText();
+ rb_raise(rb_eRuntimeError, msg.c_str());
+ return Qnil;
+ }
+
+ return Qnil;
+ }
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h
new file mode 100644
index 0000000000..e6c37cf1da
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_ruby_rubyserviceproxy_h
+#define tuscany_sca_ruby_rubyserviceproxy_h
+
+#include "tuscany/sca/ruby/Ruby.h"
+#include "tuscany/sca/ruby/export.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+
+ /**
+ * Holds a proxy for a given component and reference.
+ * The proxy which is held inside a ServiceProxy will be specific to the component
+ * and reference and will have been code generated and be contained in a dll
+ * created by a developer of an SCA application.
+ */
+ class RubyServiceProxy : public ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a reference. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The reference on the source component.
+ * @param target The wrapper of the service which is wired to this reference.
+ */
+ RubyServiceProxy(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Create a new service proxy for a service. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The service on the target component.
+ * @param target The wrapper of the target service.
+ */
+ RubyServiceProxy(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~RubyServiceProxy();
+
+ /**
+ * Returns the Ruby value of the proxy
+ */
+ VALUE getProxyValue() const { return proxyValue; };
+
+ /**
+ * Handles the invocation of a Ruby method.
+ */
+ VALUE invoke(int argc, VALUE* argv);
+
+ private:
+
+ /**
+ * Create the Ruby proxy object
+ */
+ void createProxy();
+
+ /**
+ * The target service wrapper
+ */
+ ServiceWrapper* serviceWrapper;
+
+ /**
+ * The Ruby value of the proxy
+ */
+ VALUE proxyValue;
+
+ /**
+ * The component owning the proxy
+ */
+ tuscany::sca::model::Component* component;
+
+ /**
+ * The Ruby proxy class
+ */
+ static VALUE proxyClass;
+
+ };
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_ruby_rubyserviceproxy_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
new file mode 100644
index 0000000000..ee87bdd132
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
@@ -0,0 +1,794 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#include <sstream>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/ruby/RubyServiceWrapper.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/ruby/model/RubyImplementation.h"
+#include "tuscany/sca/ruby/model/RubyServiceBinding.h"
+#include "tuscany/sca/ruby/RubyServiceProxy.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+
+ class RubyServiceInvocation
+ {
+ public:
+ VALUE instance;
+ ID method;
+ int argc;
+ const VALUE* argv;
+ };
+ }
+ }
+}
+
+extern "C"
+{
+
+ static VALUE safe_rb_funcall(VALUE value)
+ {
+ tuscany::sca::ruby::RubyServiceInvocation* call = (tuscany::sca::ruby::RubyServiceInvocation*)value;
+ if (call->argc == 0)
+ {
+ VALUE result = rb_funcall(call->instance, call->method, 0);
+ return result;
+ }
+ else
+ {
+ VALUE result = rb_funcall2(call->instance, call->method, call->argc, call->argv);
+ return result;
+ }
+ }
+
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+
+ // ===========
+ // Constructor
+ // ===========
+ RubyServiceWrapper::RubyServiceWrapper(Service* service)
+ : ServiceWrapper(service)
+ {
+ logentry();
+
+ component = service->getComponent();
+ implementation = (RubyImplementation*)component->getType();
+ interf = service->getType()->getInterface();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ RubyServiceWrapper::~RubyServiceWrapper()
+ {
+ logentry();
+ }
+
+ // ======================================================================
+ // invoke: wrapper call to service with setting the component context
+ // ======================================================================
+ void RubyServiceWrapper::invoke(Operation& operation)
+ {
+ logentry();
+
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ runtime->setCurrentComponent(component);
+
+ try
+ {
+
+ // Create a new instance of the Ruby implementation class
+ VALUE instance = rb_class_new_instance(0, NULL, implementation->getImplementationClass());
+
+ // Set all the references
+ const Component::REFERENCE_MAP& references = component->getReferences();
+ Component::REFERENCE_MAP::const_iterator refiter = references.begin();
+ for (int ri=0; ri< references.size(); ri++)
+ {
+ Reference* reference = refiter->second;
+ RubyServiceProxy* proxy = (RubyServiceProxy*)reference->getBinding()->getServiceProxy();
+ if (proxy != NULL)
+ {
+ VALUE proxyValue = proxy->getProxyValue();
+ string varName = "@" + refiter->first;
+ rb_iv_set(instance, varName.c_str(), proxyValue);
+ }
+ refiter++;
+ }
+
+ // Set all the configured properties
+ DataObjectPtr properties = component->getProperties();
+ PropertyList pl = properties->getInstanceProperties();
+ for (int i = 0; i < pl.size(); i++)
+ {
+ if (properties->isSet(pl[i]))
+ {
+ string varName = "@";
+ varName += pl[i].getName();
+ string cstr = properties->getCString(pl[i]);
+ VALUE propertyValue;
+ if (cstr == "true")
+ {
+ propertyValue = Qtrue;
+ }
+ else if (cstr == "false")
+ {
+ propertyValue = Qfalse;
+ }
+ else
+ {
+ //TODO use one of the rb_str_to_inum() functions
+ // to convert a numeric value to a Ruby numeric
+ propertyValue = rb_str_new2(cstr.c_str());
+ }
+ rb_iv_set(instance, varName.c_str(), propertyValue);
+ }
+ }
+
+ // Get the ID of the specified method
+ ID method = rb_intern(operation.getName().c_str());
+
+ // Convert C++ parameters to Ruby parameters
+ VALUE *args = NULL;
+ int n = operation.getNParms();
+ if (n != 0)
+ {
+ args=new VALUE[n];
+
+ for(int i = 0; i < operation.getNParms(); i++)
+ {
+ VALUE value;
+
+ const Operation::Parameter& parm = operation.getParameter(i);
+ Operation::ParameterType parmType = parm.getType();
+ switch(parmType)
+ {
+ case Operation::BOOL:
+ {
+ if( *(bool*)parm.getValue())
+ {
+ //boolean true
+ value = rb_int2inum(1);
+ }
+ else
+ {
+ value = rb_int2inum(0);
+ }
+ break;
+ }
+ case Operation::SHORT:
+ {
+ value = rb_int2inum(*(short*)parm.getValue());
+ break;
+ }
+ case Operation::USHORT:
+ {
+ value = rb_uint2inum(*(unsigned short*)parm.getValue());
+ break;
+ }
+ case Operation::LONG:
+ {
+ value = rb_int2inum(*(long*)parm.getValue());
+ break;
+ }
+ case Operation::ULONG:
+ {
+ value = rb_uint2inum(*(unsigned long*)parm.getValue());
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ value = rb_float_new(*(float*)parm.getValue());
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ value = rb_float_new(*(double*)parm.getValue());
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ value = rb_float_new(*(long double*)parm.getValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ value = rb_str_new2(*(char**)parm.getValue());
+ break;
+ }
+ case Operation::STRING:
+ {
+ value = rb_str_new2((*(string*)parm.getValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ DataObjectPtr dob = *(DataObjectPtr*)parm.getValue();
+
+ // Convert a DataObject to a REXML Document object
+ Composite* composite = component->getComposite();
+ commonj::sdo::XMLHelper* xmlHelper = composite->getXMLHelper();
+ char* str = xmlHelper->save(
+ dob,
+ dob->getType().getURI(),
+ dob->getType().getName());
+
+ loginfo("Converting SDO DataObject to Ruby Rexml document: %s", str);
+
+ VALUE vstr[1];
+ vstr[0] = rb_str_new2(str);
+
+ value = rb_class_new_instance(1, vstr, RubyImplementation::getXMLDocumentClass());
+ break;
+ }
+ default:
+ {
+ ostringstream msg;
+ msg << "Operation parameter type not supported: " << parmType;
+ throwException(ServiceDataException, msg.str().c_str());
+ }
+ }
+
+ args[i] = value;
+ }
+ }
+
+
+ // Invoke the specified method
+ RubyServiceInvocation call;
+ call.instance = instance;
+ call.method = method;
+ call.argc = n;
+ call.argv = args;
+ int error = 0;
+ VALUE result = rb_protect(safe_rb_funcall, (VALUE)&call, &error);
+ if (error)
+ {
+ // Convert a Ruby error to a C++ exception
+ VALUE lasterr = rb_gv_get("$!");
+ ostringstream msg;
+
+ // class
+ VALUE klass = rb_class_path(CLASS_OF(lasterr));
+ msg << "Ruby Exception " << RSTRING(klass)->ptr << ": ";
+
+ // message
+ VALUE message = rb_obj_as_string(lasterr);
+ msg << RSTRING(message)->ptr << endl;
+
+ // backtrace
+ if(!NIL_P(ruby_errinfo)) {
+ VALUE ary = rb_funcall(ruby_errinfo, rb_intern("backtrace"), 0);
+ int c;
+ for (c=0; c<RARRAY(ary)->len; c++) {
+ msg << "from " << RSTRING(RARRAY(ary)->ptr[c])->ptr << endl;
+ }
+ }
+ throwException(ServiceInvocationException, msg.str().c_str());
+ }
+
+ // Convert the Ruby result value to a C++ result
+ int resultType = TYPE(result);
+ char buf[20];
+ switch(resultType)
+ {
+ case T_FLOAT:
+ {
+ float* data = new float;
+ *data = rb_num2dbl(result);
+
+ // Check if the return type has already been set for typed languages
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ *(bool*)operation.getReturnValue() = (*data != 0.0);
+ break;
+ }
+ case Operation::SHORT:
+ {
+ *(short*)operation.getReturnValue() = (short)*data;
+ break;
+ }
+ case Operation::USHORT:
+ {
+ *(unsigned short*)operation.getReturnValue() = (unsigned short)*data;
+ break;
+ }
+ case Operation::INT:
+ {
+ *(int*)operation.getReturnValue() = (int)*data;
+ break;
+ }
+ case Operation::UINT:
+ {
+ *(unsigned int*)operation.getReturnValue() = (unsigned int)*data;
+ break;
+ }
+ case Operation::LONG:
+ {
+ *(long*)operation.getReturnValue() = (long)*data;
+ break;
+ }
+ case Operation::ULONG:
+ {
+ *(unsigned long*)operation.getReturnValue() = (unsigned long)*data;
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ *(float*)operation.getReturnValue() = (float)*data;
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ *(double*)operation.getReturnValue() = (double)*data;
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ *(long double*)operation.getReturnValue() = (long double)*data;
+ break;
+ }
+ case Operation::CHARS:
+ {
+ sprintf(buf, "%f", *data);
+ *(char**)operation.getReturnValue() = buf;
+ break;
+ }
+ case Operation::STRING:
+ {
+ sprintf(buf, "%f", *data);
+ *(string*)operation.getReturnValue() = buf;
+ break;
+ }
+ default:
+ {
+ // The type is set as something else or has not been set
+ operation.setReturnValue(data);
+ }
+ }
+ break;
+ }
+ case T_STRING:
+ {
+ string* stringdata = new string(rb_string_value_cstr(&result));
+ const char** data = new const char*;
+ *data = stringdata->c_str();
+
+ // Check if the return type has already been set (for typed languages)
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ // If the string is empty or "0" or "false" set to false, otherwise true
+ if(strlen(*data) == 0 || strcmp(*data, "0") == 0 || strcmp(*data, "false") == 0)
+ {
+ *(bool*)operation.getReturnValue() = false;
+ }
+ else
+ {
+ *(bool*)operation.getReturnValue() = true;
+ }
+ break;
+ }
+ case Operation::SHORT:
+ {
+ *(short*)operation.getReturnValue() = (short)atoi(*data);
+ break;
+ }
+ case Operation::USHORT:
+ {
+ *(unsigned short*)operation.getReturnValue() = (unsigned short)atoi(*data);
+ break;
+ }
+ case Operation::INT:
+ {
+ *(int*)operation.getReturnValue() = (int)atoi(*data);
+ break;
+ }
+ case Operation::UINT:
+ {
+ *(unsigned int*)operation.getReturnValue() = (unsigned int)atoi(*data);
+ break;
+ }
+ case Operation::LONG:
+ {
+ *(long*)operation.getReturnValue() = (long)atol(*data);
+ break;
+ }
+ case Operation::ULONG:
+ {
+ *(unsigned long*)operation.getReturnValue() = (unsigned long)atol(*data);
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ *(float*)operation.getReturnValue() = (float)atof(*data);
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ *(double*)operation.getReturnValue() = (double)atof(*data);
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ *(long double*)operation.getReturnValue() = (long double)atof(*data);
+ break;
+ }
+ case Operation::CHARS:
+ {
+ *(const char**)operation.getReturnValue() = *data;
+ break;
+ }
+ case Operation::STRING:
+ {
+ *(string*)operation.getReturnValue() = *data;
+ break;
+ }
+ default:
+ {
+ // The type is set as something else or has not been set
+ operation.setReturnValue(data);
+ }
+ }
+ break;
+ }
+ case T_FIXNUM:
+ {
+ long* data = new long;
+ *data = rb_num2long(result);
+
+ // Check if the return type has already been (set for typed languages)
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ *(bool*)operation.getReturnValue() = (*data != 0);
+ break;
+ }
+ case Operation::SHORT:
+ {
+ *(short*)operation.getReturnValue() = (short)*data;
+ break;
+ }
+ case Operation::USHORT:
+ {
+ *(unsigned short*)operation.getReturnValue() = (unsigned short)*data;
+ break;
+ }
+ case Operation::INT:
+ {
+ *(int*)operation.getReturnValue() = (int)*data;
+ break;
+ }
+ case Operation::UINT:
+ {
+ *(unsigned int*)operation.getReturnValue() = (unsigned int)*data;
+ break;
+ }
+ case Operation::LONG:
+ {
+ *(long*)operation.getReturnValue() = (long)*data;
+ break;
+ }
+ case Operation::ULONG:
+ {
+ *(unsigned long*)operation.getReturnValue() = (unsigned long)*data;
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ *(float*)operation.getReturnValue() = (float)*data;
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ *(double*)operation.getReturnValue() = (double)*data;
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ *(long double*)operation.getReturnValue() = (long double)*data;
+ break;
+ }
+ case Operation::CHARS:
+ {
+ sprintf(buf, "%d", *data);
+ *(char**)operation.getReturnValue() = buf;
+ break;
+ }
+ case Operation::STRING:
+ {
+ sprintf(buf, "%d", *data);
+ *(string*)operation.getReturnValue() = buf;
+ break;
+ }
+ default:
+ {
+ // The type is set as something else or has not been set
+ operation.setReturnValue(data);
+ }
+ }
+
+ break;
+ }
+ case T_BIGNUM:
+ {
+ long double* data = new long double;
+ *data = rb_num2dbl(result);
+
+ // Check if the return type has already been set (for typed languages)
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ *(bool*)operation.getReturnValue() = (*data != 0.0);
+ break;
+ }
+ case Operation::SHORT:
+ {
+ *(short*)operation.getReturnValue() = (short)*data;
+ break;
+ }
+ case Operation::USHORT:
+ {
+ *(unsigned short*)operation.getReturnValue() = (unsigned short)*data;
+ break;
+ }
+ case Operation::INT:
+ {
+ *(int*)operation.getReturnValue() = (int)*data;
+ break;
+ }
+ case Operation::UINT:
+ {
+ *(unsigned int*)operation.getReturnValue() = (unsigned int)*data;
+ break;
+ }
+ case Operation::LONG:
+ {
+ *(long*)operation.getReturnValue() = (long)*data;
+ break;
+ }
+ case Operation::ULONG:
+ {
+ *(unsigned long*)operation.getReturnValue() = (unsigned long)*data;
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ *(float*)operation.getReturnValue() = (float)*data;
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ *(double*)operation.getReturnValue() = (double)*data;
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ *(long double*)operation.getReturnValue() = (long double)*data;
+ break;
+ }
+ case Operation::CHARS:
+ {
+ sprintf(buf, "%f", *data);
+ *(char**)operation.getReturnValue() = buf;
+ break;
+ }
+ case Operation::STRING:
+ {
+ sprintf(buf, "%f", *data);
+ *(string*)operation.getReturnValue() = buf;
+ break;
+ }
+ default:
+ {
+ // The type is set as something else or has not been set
+ operation.setReturnValue(data);
+ }
+ }
+ break;
+ }
+ case T_TRUE:
+ case T_FALSE:
+ {
+ bool* data = new bool;
+ *data = (resultType == T_TRUE);
+ // Check if the return type has already been set (for typed languages)
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ *(bool*)operation.getReturnValue() = *data;
+ break;
+ }
+ case Operation::SHORT:
+ {
+ *(short*)operation.getReturnValue() = (short)*data;
+ break;
+ }
+ case Operation::USHORT:
+ {
+ *(unsigned short*)operation.getReturnValue() = (unsigned short)*data;
+ break;
+ }
+ case Operation::INT:
+ {
+ *(int*)operation.getReturnValue() = (int)*data;
+ break;
+ }
+ case Operation::UINT:
+ {
+ *(unsigned int*)operation.getReturnValue() = (unsigned int)*data;
+ break;
+ }
+ case Operation::LONG:
+ {
+ *(long*)operation.getReturnValue() = (long)*data;
+ break;
+ }
+ case Operation::ULONG:
+ {
+ *(unsigned long*)operation.getReturnValue() = (unsigned long)*data;
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ *(float*)operation.getReturnValue() = (float)*data;
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ *(double*)operation.getReturnValue() = (double)*data;
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ *(long double*)operation.getReturnValue() = (long double)*data;
+ break;
+ }
+ case Operation::CHARS:
+ {
+ if(*data)
+ {
+ *(char**)operation.getReturnValue() = "true";
+ }
+ else
+ {
+ *(char**)operation.getReturnValue() = "false";
+ }
+ break;
+ }
+ case Operation::STRING:
+ {
+ if(*data)
+ {
+ *(string*)operation.getReturnValue() = "true";
+ }
+ else
+ {
+ *(string*)operation.getReturnValue() = "false";
+ }
+ break;
+ }
+ default:
+ {
+ // The type is set as something else or has not been set
+ operation.setReturnValue(data);
+ }
+ }
+
+ break;
+ }
+ case T_OBJECT:
+ {
+ VALUE klass = rb_obj_class(result);
+ if (klass == RubyImplementation::getXMLDocumentClass())
+ {
+ // Convert a REXML::Document to a DataObject
+ ID to_s = rb_intern("to_s");
+ VALUE vstr = rb_funcall(result, to_s, 0);
+ string str = string(rb_string_value_cstr(&vstr));
+
+ loginfo("Converting Ruby Rexml document to SDO DataObject: %s", str.c_str());
+
+ Composite* composite = component->getComposite();
+ commonj::sdo::XMLHelper* xmlHelper = composite->getXMLHelper();
+ commonj::sdo::XMLDocumentPtr xmlDoc = xmlHelper->load(str.c_str());
+
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ if (xmlDoc != NULL)
+ {
+ *dataObjectData = xmlDoc->getRootDataObject();
+ }
+ else
+ {
+ *dataObjectData = NULL;
+ }
+ if (*dataObjectData != NULL)
+ {
+ operation.setReturnValue(dataObjectData);
+ }
+ else
+ {
+ string msg = "Document could not be converted to a DataObject";
+ throwException(ServiceDataException, msg.c_str());
+ }
+ }
+ else
+ {
+ string msg = "Ruby type not supported: " + resultType;
+ throwException(ServiceDataException, msg.c_str());
+ }
+ break;
+ }
+ default:
+ {
+ string msg = "Ruby type not supported: " + resultType;
+ throwException(ServiceDataException, msg.c_str());
+ }
+ }
+
+ }
+ catch (...)
+ {
+ runtime->unsetCurrentComponent();
+ throw;
+ }
+
+ runtime->unsetCurrentComponent();
+ }
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.h
new file mode 100644
index 0000000000..2526084a72
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.h
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_ruby_rubyservicewrapper_h
+#define tuscany_sca_ruby_rubyservicewrapper_h
+
+#include "tuscany/sca/ruby/export.h"
+#include "tuscany/sca/ruby/Ruby.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/ruby/model/RubyImplementation.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+ class RubyInterface;
+
+ /**
+ * Wraps the service on a component implementation.
+ * This abstract class is extended by generated code which provides
+ * the implementation of some of the methods.
+ * An instance of this class wraps the actual component implementation which
+ * has been written by a developer of an SCA application.
+ */
+ class SCA_RUBY_API RubyServiceWrapper : public ServiceWrapper
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param target The component service to which this wrapper refers.
+ */
+ RubyServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~RubyServiceWrapper();
+
+ /**
+ * All business method calls to the target component go through the invoke method.
+ * @param operation The details of the method, paramaters and return value for the
+ * business method to be called on the target component.
+ */
+ virtual void invoke(Operation& operation);
+
+ private:
+
+ /**
+ * The component to which this wrapper refers.
+ */
+ tuscany::sca::model::Component* component;
+
+ /**
+ * A pointer to the interface which the service exposes.
+ */
+ tuscany::sca::model::Interface* interf;
+
+ /**
+ * The Ruby implementation
+ */
+ RubyImplementation* implementation;
+
+ };
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_ruby_rubyservicewrapper_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/export.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/export.h
new file mode 100644
index 0000000000..5db72a1ebe
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/export.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_ruby_export_h
+#define tuscany_sca_ruby_export_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef TUSCANY_SCA_RUBY_LANG_EXPORTS
+#define SCA_RUBY_API __declspec(dllexport)
+#else
+#define SCA_RUBY_API __declspec(dllimport)
+#endif
+
+#else
+#define SCA_RUBY_API
+#endif
+
+#endif // tuscany_sca_ruby_export_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.cpp
new file mode 100644
index 0000000000..fa30642318
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.cpp
@@ -0,0 +1,171 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/ruby/model/RubyImplementation.h"
+#include "tuscany/sca/ruby/model/RubyServiceBinding.h"
+#include "tuscany/sca/ruby/model/RubyReferenceBinding.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace ruby
+ {
+
+ bool RubyImplementation::initialized = false;
+ VALUE RubyImplementation::xmlDocumentClass = 0;
+
+ // Constructor
+ RubyImplementation::RubyImplementation(Composite* composite, const string& module, const string& className, const string& script)
+ : ComponentType(composite, script.substr(0, script.find_last_of('.'))),
+ module(module), className(className), script(script)
+ {
+ loadClass();
+ }
+
+ RubyImplementation::~RubyImplementation()
+ {
+ }
+
+ VALUE RubyImplementation::getXMLDocumentClass()
+ {
+ logentry();
+
+ // Initialize the Ruby runtime
+ if (!initialized)
+ {
+ ruby_init();
+ ruby_init_loadpath();
+
+ // Load the Rexml module. Rexml is used to handle XML documents.
+ //rb_require("rexml/document");
+ // Use rb_eval_string for now as it provides better error reporting
+ rb_eval_string("require(\"rexml/document\")");
+
+ xmlDocumentClass = rb_path2class("REXML::Document");
+ initialized = true;
+ }
+
+ return xmlDocumentClass;
+ }
+
+ void RubyImplementation::loadClass()
+ {
+ logentry();
+
+ // Ensure xmlDocumentClass is initialized
+ getXMLDocumentClass();
+
+ ID to_s = rb_intern("to_s");
+ VALUE xstr = rb_funcall(xmlDocumentClass, to_s, 0);
+ loginfo("Got Ruby Rexml class: %s", rb_string_value_cstr(&xstr));
+
+ // Load the specified Ruby script
+ if (script != "")
+ {
+ // Convert any windows slashes \ in the root path to unix slashes /
+ string rootpath = getComposite()->getRoot();
+ int pos = 0;
+ while((pos = rootpath.find('\\', pos)) != string::npos)
+ {
+ rootpath = rootpath.replace(pos, 1, "/");
+ }
+
+ // Use rb_eval_string for now as it provides better error reporting
+ string path = "require(\"" + rootpath + "/" + script +"\")";
+ //rb_require((char *)path.c_str());
+ rb_eval_string(path.c_str());
+ }
+
+ // Load the Ruby implementation class
+ implementationClass = rb_path2class(className.c_str());
+
+ // Create a default service
+ ServiceType* defaultServiceType = new ServiceType(this, "", NULL, NULL);
+ addServiceType(defaultServiceType);
+
+ // Introspect the Ruby class and create references and properties for
+ // all public attributes
+ VALUE methods = rb_class_public_instance_methods(0, NULL, implementationClass);
+ int n = RARRAY(methods)->len;
+ for (int i = 0; i<n; i++)
+ {
+ VALUE method = rb_ary_entry(methods, i);
+ string methodName = string(rb_string_value_cstr(&method));
+
+ // Create a reference type for each setter method
+ int s = methodName.size();
+ if (s > 1 && methodName[s-1] == '=' && methodName[0] != '=')
+ {
+ string variableName = methodName.substr(0, s-1);
+ ReferenceType* referenceType = new ReferenceType(
+ this, variableName, NULL, NULL, ReferenceType::ONE_ONE);
+ addReferenceType(referenceType);
+
+ // Create a property type as well
+ addPropertyType(variableName, "http://www.w3.org/2001/XMLSchema#string", false, NULL);
+
+ }
+ }
+ }
+
+ void RubyImplementation::initializeComponent(Component* component)
+ {
+ ComponentType::initializeComponent(component);
+
+ // Create Ruby bindings for all the services
+ const Component::SERVICE_MAP& services = component->getServices();
+ Component::SERVICE_MAP::const_iterator iter = services.begin();
+ for (int i=0; i< services.size(); i++)
+ {
+ Service *service = iter->second;
+ RubyServiceBinding* binding = new RubyServiceBinding(service);
+ service->setBinding(binding);
+ iter++;
+ }
+
+ // Create Ruby bindings for all the references
+ const Component::REFERENCE_MAP& references = component->getReferences();
+ Component::REFERENCE_MAP::const_iterator refiter = references.begin();
+ for (int ri=0; ri< references.size(); ri++)
+ {
+ Reference *reference = refiter->second;
+ RubyReferenceBinding* binding = new RubyReferenceBinding(reference);
+ reference->setBinding(binding);
+ refiter++;
+ }
+ }
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.h
new file mode 100644
index 0000000000..c7bc851635
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.h
@@ -0,0 +1,136 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_ruby_model_rubyimplementation_h
+#define tuscany_sca_ruby_model_rubyimplementation_h
+
+#include <string>
+
+#include "tuscany/sca/ruby/Ruby.h"
+#include "tuscany/sca/model/ComponentType.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+ /**
+ * Holds information about an SCA implementation written in Ruby
+ */
+ class RubyImplementation : public tuscany::sca::model::ComponentType
+ {
+
+ public:
+ /**
+ * Constructor.
+ * @param composite The composite containing this implementation.
+ * @param module Name of the Ruby module.
+ * @param className Name of the Ruby implementation class.
+ * @param script Path of the Ruby script.
+ */
+ RubyImplementation(tuscany::sca::model::Composite* composite,
+ const std::string& module, const std::string& className, const std::string& script);
+
+ /**
+ * Destructor
+ */
+ virtual ~RubyImplementation();
+
+ /**
+ * Initialize a component of this type.
+ * @param component The component to initialize.
+ */
+ virtual void initializeComponent(tuscany::sca::model::Component* component);
+
+ /**
+ * Returns the name of the Ruby module.
+ * @return The name of the Ruby module.
+ */
+ const std::string& getModule() const { return module; }
+
+ /**
+ * Returns the name of Ruby class.
+ * @return Name of the Ruby class.
+ */
+ const std::string& getClass() const { return className; }
+
+ /**
+ * Returns the path of the Ruby script.
+ * @return The path of the Ruby script.
+ */
+ const std::string& getScript() const { return script; }
+
+ /**
+ * Returns the Ruby implementation class
+ */
+ VALUE getImplementationClass() const { return implementationClass; }
+
+ /**
+ * Returns the Ruby REXML::Document class
+ */
+ static VALUE getXMLDocumentClass();
+
+ private:
+
+ /**
+ * Load the Ruby implementation class
+ */
+ void loadClass();
+
+ /**
+ * Name of the Ruby module.
+ */
+ std::string module;
+
+ /**
+ * Name of the Ruby class.
+ */
+ std::string className;
+
+ /**
+ * Path of the Ruby script.
+ */
+ std::string script;
+
+ /**
+ * The Ruby implementation class
+ */
+ VALUE implementationClass;
+
+ /**
+ * True if the Ruby runtime has been initialized
+ */
+ static bool initialized;
+
+ /**
+ * The Ruby REXML::Document class.
+ */
+ static VALUE xmlDocumentClass;
+
+ };
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_ruby_model_rubyimplementation_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.cpp
new file mode 100644
index 0000000000..d1dda36cb5
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.cpp
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/ruby/model/RubyReferenceBinding.h"
+#include "tuscany/sca/ruby/RubyServiceProxy.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+
+ // Constructor
+ RubyReferenceBinding::RubyReferenceBinding(Reference* reference)
+ : ReferenceBinding(reference, ""), serviceProxy(NULL), targetServiceBinding(NULL)
+ {
+ }
+
+ // Destructor
+ RubyReferenceBinding::~RubyReferenceBinding()
+ {
+ }
+
+ ServiceProxy* RubyReferenceBinding::getServiceProxy()
+ {
+ return serviceProxy;
+ }
+
+ void RubyReferenceBinding::configure(ServiceBinding* binding)
+ {
+ targetServiceBinding = binding;
+
+ serviceProxy = new RubyServiceProxy(getReference());
+ }
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.h
new file mode 100644
index 0000000000..e71d69506c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.h
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_ruby_model_rubyreferencebinding_h
+#define tuscany_sca_ruby_model_rubyreferencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+ /**
+ * Information about a Ruby service binding for service or a reference.
+ */
+ class RubyReferenceBinding : public tuscany::sca::model::ReferenceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ */
+ RubyReferenceBinding(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Destructor.
+ */
+ virtual ~RubyReferenceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#RubyImplementationBinding"; };
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ virtual ServiceProxy* getServiceProxy();
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding);
+
+ /**
+ * Returns the target service binding.
+ */
+ tuscany::sca::model::ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; };
+
+ private:
+
+ /**
+ * The proxy representing the reference to the client
+ * component.
+ */
+ ServiceProxy* serviceProxy;
+
+ /**
+ * The service binding of the target
+ */
+ tuscany::sca::model::ServiceBinding* targetServiceBinding;
+ };
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_ruby_model_rubyreferencebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.cpp
new file mode 100644
index 0000000000..163f8a9d8b
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/ruby/model/RubyServiceBinding.h"
+#include "tuscany/sca/ruby/RubyServiceWrapper.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+
+ // Constructor
+ RubyServiceBinding::RubyServiceBinding(Service* service)
+ : ServiceBinding(service, "")
+ {
+ serviceWrapper = new RubyServiceWrapper(service);
+ }
+
+ // Destructor
+ RubyServiceBinding::~RubyServiceBinding()
+ {
+ }
+
+ ServiceWrapper* RubyServiceBinding::getServiceWrapper()
+ {
+ return (ServiceWrapper*)serviceWrapper;
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.h
new file mode 100644
index 0000000000..b772daf712
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_ruby_model_rubyservicebinding_h
+#define tuscany_sca_ruby_model_rubyservicebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ServiceBinding.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ruby
+ {
+ /**
+ * Information about a Ruby service binding for service or a reference.
+ */
+ class RubyServiceBinding : public tuscany::sca::model::ServiceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ */
+ RubyServiceBinding(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~RubyServiceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#RubyImplementationBinding"; };
+
+ /**
+ * Create a wrapper for the service configured by this
+ * binding.
+ */
+ virtual ServiceWrapper* getServiceWrapper();
+
+ private:
+
+ /**
+ * The wrapper for the service configured by this binding.
+ */
+ ServiceWrapper* serviceWrapper;
+
+ };
+
+ } // End namespace ruby
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_ruby_model_rubyservicebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/xsd/sca-implementation-ruby.xsd b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/xsd/sca-implementation-ruby.xsd
new file mode 100644
index 0000000000..3508b23f94
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ruby/xsd/sca-implementation-ruby.xsd
@@ -0,0 +1,40 @@
+<?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.
+-->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <element name="implementation.ruby" type="sca:RubyImplementation" substitutionGroup="sca:implementation"/>
+ <complexType name="RubyImplementation">
+ <complexContent>
+ <extension base="sca:Implementation">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="script" type="NCName" use="optional"/>
+ <attribute name="module" type="NCName" use="optional"/>
+ <attribute name="class" type="Name" use="optional"/>
+ <anyAttribute namespace="##any" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/Makefile.am
new file mode 100644
index 0000000000..50dfb45557
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/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.
+
+SUBDIRS = reference service
+datadir=$(prefix)/extensions/sca
+
+nobase_data_DATA = xsd/*.xsd
+
+EXTRA_DIST = xsd
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/deploy.bat
new file mode 100644
index 0000000000..b3a33a8011
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/deploy.bat
@@ -0,0 +1,45 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set scaextdir=%extdir%\sca
+set srcdir=%rootdir%\runtime\extensions\sca
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %scaextdir% mkdir %scaextdir%
+if not exist %scaextdir%\xsd mkdir %scaextdir%\xsd
+
+copy %srcdir%\xsd\*.* %scaextdir%\xsd
+
+goto end
+:usage
+echo Usage: deploy <sca-root>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/Makefile.am
new file mode 100644
index 0000000000..2b9491ec1c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/Makefile.am
@@ -0,0 +1,18 @@
+# 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.
+
+SUBDIRS = src
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/deploy.bat
new file mode 100644
index 0000000000..0afc3ff4ea
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/deploy.bat
@@ -0,0 +1,68 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set scaextdir=%extdir%\sca
+set refextdir=%scaextdir%\reference
+set srcdir=%rootdir%\runtime\extensions\sca\reference
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+call %srcdir%\..\deploy.bat %rootdir%
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %scaextdir% mkdir %scaextdir%
+if not exist %refextdir% mkdir %refextdir%
+if not exist %refextdir%\module mkdir %refextdir%\module
+if not exist %refextdir%\bin mkdir %refextdir%\bin
+if not exist %refextdir%\lib mkdir %refextdir%\lib
+
+set libname=tuscany_sca_binding_reference
+
+del %refextdir%\bin\%libname%.*
+del %refextdir%\lib\%libname%.*
+
+copy %inpath%\%libname%.lib %refextdir%\lib
+copy %inpath%\%libname%.dll %refextdir%\bin
+copy %inpath%\%libname%.dll %refextdir%\module
+
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %refextdir%\bin
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %refextdir%\module
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/Makefile.am
new file mode 100644
index 0000000000..ee1b9ea5e8
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/Makefile.am
@@ -0,0 +1,44 @@
+# 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.
+
+libdir=$(prefix)/extensions/sca/reference/lib
+lib_LTLIBRARIES = libtuscany_sca_binding_reference.la
+
+noinst_HEADERS = \
+tuscany/sca/binding/*.h \
+tuscany/sca/binding/model/*.h
+
+libtuscany_sca_binding_reference_la_SOURCES = \
+tuscany/sca/binding/SCAServiceBindingExtension.cpp \
+tuscany/sca/binding/model/SCAServiceBinding.cpp
+
+libtuscany_sca_binding_reference_la_LIBADD = \
+ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -ltuscany_sdo_axiom \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca
+
+INCLUDES = -I$(top_builddir)/runtime/core/src \
+ -I${TUSCANY_SDOCPP}/include
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+moduledir=$(prefix)/extensions/sca/reference/module
+extension = libtuscany_sca_binding_reference$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension) \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp
new file mode 100644
index 0000000000..7d70f595cc
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "SCAServiceBindingExtension.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/core/Exceptions.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_binding_reference_initialize()
+ {
+ tuscany::sca::binding::SCAServiceBindingExtension::initialize();
+ }
+}
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace binding
+ {
+ // ===================================================================
+ // Constructor for the SCAServiceBinding class.
+ // ===================================================================
+ SCAServiceBindingExtension::SCAServiceBindingExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the SCAServiceBindingExtension class.
+ // ===================================================================
+ SCAServiceBindingExtension::~SCAServiceBindingExtension()
+ {
+ logentry();
+ }
+
+ const string SCAServiceBindingExtension::extensionName("sca");
+ const string SCAServiceBindingExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#SCABinding");
+
+
+ // ===================================================================
+ // loadModelElement - load the info from binding.ws
+ // ===================================================================
+ ServiceBinding* SCAServiceBindingExtension::getServiceBinding(Composite *composite, Service* service, DataObjectPtr scdlBinding)
+ {
+ logentry();
+
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+
+ ServiceBindingExtension* bindingExtension = NULL; // runtime->getServiceBindingExtension("http://www.osoa.org/xmlns/sca/1.0#RESTBinding");
+ if (bindingExtension == NULL)
+ {
+ bindingExtension = runtime->getServiceBindingExtension("http://www.osoa.org/xmlns/sca/1.0#WebServiceBinding");
+ if (bindingExtension == NULL)
+ {
+ logerror("SCA default binding requires the REST or WS binding to be available");
+
+ string message = "SCA default binding requires the REST or WS binding to be available";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ }
+
+ return bindingExtension->getServiceBinding(composite, service, scdlBinding);
+ }
+
+ void SCAServiceBindingExtension::initialize()
+ {
+ logentry();
+ SCARuntime::getCurrentRuntime()->registerServiceBindingExtension(new SCAServiceBindingExtension());
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/SCAServiceBindingExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/SCAServiceBindingExtension.h
new file mode 100644
index 0000000000..389541061a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/SCAServiceBindingExtension.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_binding_scaservicebindingextension_h
+#define tuscany_sca_extension_binding_scaservicebindingextension_h
+
+#include "tuscany/sca/extension/ServiceBindingExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace binding
+ {
+
+ class SCAServiceBindingExtension : public ServiceBindingExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ SCAServiceBindingExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~SCAServiceBindingExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#binding.ws")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ServiceBinding* getServiceBinding(
+ tuscany::sca::model::Composite* composite,
+ tuscany::sca::model::Service* service,
+ commonj::sdo::DataObjectPtr scdlBinding);
+
+ static void initialize();
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace binding
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif //tuscany_sca_extension_binding_scaservicebindingextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/model/SCAServiceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/model/SCAServiceBinding.cpp
new file mode 100644
index 0000000000..3b5564a765
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/model/SCAServiceBinding.cpp
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/binding/model/SCAServiceBinding.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace binding
+ {
+
+ // Constructor
+ SCAServiceBinding::SCAServiceBinding(Composite* composite, Service* service, const string& uri, DataObjectPtr scdlBinding)
+ : ServiceBinding(service, uri)
+ {
+ }
+
+ // Destructor
+ SCAServiceBinding::~SCAServiceBinding()
+ {
+ }
+
+ ServiceWrapper* SCAServiceBinding::getServiceWrapper()
+ {
+ logentry();
+
+ throwException(SystemConfigurationException, "Not supported");
+ }
+
+ } // End namespace binding
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/model/SCAServiceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/model/SCAServiceBinding.h
new file mode 100644
index 0000000000..d73a10f202
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/reference/src/tuscany/sca/binding/model/SCAServiceBinding.h
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_binding_model_scaservicebinding_h
+#define tuscany_sca_extension_binding_model_scaservicebinding_h
+
+#include <string>
+
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace binding
+ {
+ /**
+ * Information about an SCA service binding for service or a reference.
+ */
+ class SCAServiceBinding : public tuscany::sca::model::ServiceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ */
+ SCAServiceBinding(tuscany::sca::model::Composite* composite, tuscany::sca::model::Service* service, const std::string& uri, commonj::sdo::DataObjectPtr scdlBinding);
+
+ /**
+ * Destructor.
+ */
+ virtual ~SCAServiceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#SCABinding"; };
+
+ /**
+ * Create a service wrapper handling the interaction
+ * with the service configured with this binding.
+ */
+ virtual tuscany::sca::ServiceWrapper* getServiceWrapper();
+
+ private:
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_ws_model_wsservicebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/Makefile.am
new file mode 100644
index 0000000000..2b9491ec1c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/Makefile.am
@@ -0,0 +1,18 @@
+# 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.
+
+SUBDIRS = src
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/deploy.bat
new file mode 100644
index 0000000000..e65ccb7715
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/deploy.bat
@@ -0,0 +1,66 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set wsextdir=%extdir%\sca
+set svcextdir=%wsextdir%\service
+set srcdir=%rootdir%\runtime\extensions\sca\service\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %wsextdir% mkdir %wsextdir%
+if not exist %svcextdir% mkdir %svcextdir%
+if not exist %svcextdir%\module mkdir %svcextdir%\module
+if not exist %svcextdir%\bin mkdir %svcextdir%\bin
+if not exist %svcextdir%\lib mkdir %svcextdir%\lib
+
+set libname=tuscany_sca_binding_service
+
+del %svcextdir%\bin\%libname%.*
+del %svcextdir%\lib\%libname%.*
+
+copy %inpath%\%libname%.lib %svcextdir%\lib
+copy %inpath%\%libname%.dll %svcextdir%\bin
+copy %inpath%\%libname%.dll %svcextdir%\module
+
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %svcextdir%\bin
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %svcextdir%\module
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/Makefile.am
new file mode 100644
index 0000000000..2b062f199b
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/Makefile.am
@@ -0,0 +1,44 @@
+# 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.
+
+libdir=$(prefix)/extensions/sca/service/lib
+lib_LTLIBRARIES = libtuscany_sca_binding_service.la
+
+noinst_HEADERS = \
+tuscany/sca/binding/*.h \
+tuscany/sca/binding/model/*.h
+
+libtuscany_sca_binding_service_la_SOURCES = \
+tuscany/sca/binding/SCAReferenceBindingExtension.cpp \
+tuscany/sca/binding/model/SCAReferenceBinding.cpp
+
+libtuscany_sca_binding_service_la_LIBADD = \
+ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -ltuscany_sdo_axiom \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca
+
+INCLUDES = -I$(top_builddir)/runtime/core/src \
+ -I${TUSCANY_SDOCPP}/include
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+moduledir=$(prefix)/extensions/sca/service/module
+extension = libtuscany_sca_binding_service$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension) \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp
new file mode 100644
index 0000000000..789d8794df
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#include "SCAReferenceBindingExtension.h"
+#include "model/SCAReferenceBinding.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/core/Exceptions.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_binding_service_initialize()
+ {
+ tuscany::sca::binding::SCAReferenceBindingExtension::initialize();
+ }
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace binding
+ {
+ // ===================================================================
+ // Constructor for the SCAReferenceBinding class.
+ // ===================================================================
+ SCAReferenceBindingExtension::SCAReferenceBindingExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the SCAReferenceBindingExtension class.
+ // ===================================================================
+ SCAReferenceBindingExtension::~SCAReferenceBindingExtension()
+ {
+ logentry();
+ }
+
+ const string SCAReferenceBindingExtension::extensionName("sca");
+ const string SCAReferenceBindingExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#SCABinding");
+
+ // ===================================================================
+ // loadModelElement - load the info from binding.ws
+ // ===================================================================
+ ReferenceBinding* SCAReferenceBindingExtension::getReferenceBinding(Composite *composite, Reference* reference, DataObjectPtr scdlBinding)
+ {
+ logentry();
+
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+
+ ReferenceBindingExtension* bindingExtension = NULL; // runtime->getReferenceBindingExtension("http://www.osoa.org/xmlns/sca/1.0#RESTBinding");
+ if (bindingExtension == NULL)
+ {
+ bindingExtension = runtime->getReferenceBindingExtension("http://www.osoa.org/xmlns/sca/1.0#WebServiceBinding");
+ if (bindingExtension == NULL)
+ {
+ logerror("SCA default binding requires the REST or WS binding to be available");
+
+ string message = "SCA default binding requires the REST or WS binding to be available";
+ throwException(SystemConfigurationException, message.c_str());
+ }
+ }
+
+ return bindingExtension->getReferenceBinding(composite, reference, scdlBinding);
+ }
+
+ void SCAReferenceBindingExtension::initialize()
+ {
+ logentry();
+ SCARuntime::getCurrentRuntime()->registerReferenceBindingExtension(new SCAReferenceBindingExtension());
+ }
+
+ } // End namespace binding
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/SCAReferenceBindingExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/SCAReferenceBindingExtension.h
new file mode 100644
index 0000000000..8cde2fbef4
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/SCAReferenceBindingExtension.h
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_binding_scareferencebindingextension_h
+#define tuscany_sca_extension_binding_scareferencebindingextension_h
+
+#include "tuscany/sca/extension/ReferenceBindingExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace binding
+ {
+
+ class SCAReferenceBindingExtension : public ReferenceBindingExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ SCAReferenceBindingExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~SCAReferenceBindingExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#binding.ws")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ReferenceBinding* getReferenceBinding(
+ tuscany::sca::model::Composite* composite,
+ tuscany::sca::model::Reference *reference,
+ commonj::sdo::DataObjectPtr scdlBinding);
+
+ static void initialize();
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace binding
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_binding_scareferencebindingextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/model/SCAReferenceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/model/SCAReferenceBinding.cpp
new file mode 100644
index 0000000000..b8eaaaa1f9
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/model/SCAReferenceBinding.cpp
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/binding/model/SCAReferenceBinding.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace binding
+ {
+
+ // Constructor
+ SCAReferenceBinding::SCAReferenceBinding(Composite* composite, Reference* reference, const string& uri, DataObjectPtr scdlBinding)
+ : ReferenceBinding(reference, uri)
+ {
+ }
+
+ // Destructor
+ SCAReferenceBinding::~SCAReferenceBinding()
+ {
+ }
+
+ ServiceProxy* SCAReferenceBinding::getServiceProxy()
+ {
+ throwException(SystemConfigurationException, "Not supported");
+ }
+
+ void SCAReferenceBinding::configure(ServiceBinding* serviceBinding)
+ {
+ throwException(SystemConfigurationException, "Not supported");
+ }
+
+ void SCAReferenceBinding::configure(const std::string& uri)
+ {
+ throwException(SystemConfigurationException, "Not supported");
+ }
+
+ } // End namespace binding
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/model/SCAReferenceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/model/SCAReferenceBinding.h
new file mode 100644
index 0000000000..f3e699e2ee
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/service/src/tuscany/sca/binding/model/SCAReferenceBinding.h
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_binding_model_scareferencebinding_h
+#define tuscany_sca_extension_binding_model_scareferencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ReferenceBinding.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace binding
+ {
+ /**
+ * Information about a web service binding for service or a reference.
+ */
+ class SCAReferenceBinding : public tuscany::sca::model::ReferenceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ */
+ SCAReferenceBinding(tuscany::sca::model::Composite* composite, tuscany::sca::model::Reference* reference, const std::string&uri, commonj::sdo::DataObjectPtr scdlBinding);
+
+ /**
+ * Destructor.
+ */
+ virtual ~SCAReferenceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#SCABinding"; };
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ virtual tuscany::sca::ServiceProxy* getServiceProxy();
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding);
+
+ /**
+ * Configure this binding from a URI.
+ */
+ virtual void configure(const std::string& uri);
+
+ private:
+
+ };
+
+ } // End namespace binding
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_binding_model_scareferencebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/xsd/sca-binding-sca.xsd b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/xsd/sca-binding-sca.xsd
new file mode 100644
index 0000000000..1051c3910c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/sca/xsd/sca-binding-sca.xsd
@@ -0,0 +1,37 @@
+<?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.
+-->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <element name="binding.sca" type="sca:SCABinding" substitutionGroup="sca:binding"/>
+ <complexType name="SCABinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##any" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/Makefile.am
new file mode 100644
index 0000000000..806786ce04
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/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.
+
+SUBDIRS = reference service
+datadir=$(prefix)/extensions/ws
+
+nobase_data_DATA = xsd/*.xsd
+
+EXTRA_DIST = xsd
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/deploy.bat
new file mode 100644
index 0000000000..567875624f
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/deploy.bat
@@ -0,0 +1,45 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set wsextdir=%extdir%\ws
+set srcdir=%rootdir%\runtime\extensions\ws
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %wsextdir% mkdir %wsextdir%
+if not exist %wsextdir%\xsd mkdir %wsextdir%\xsd
+
+copy %srcdir%\xsd\*.* %wsextdir%\xsd
+
+goto end
+:usage
+echo Usage: deploy <sca-root>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/Makefile.am
new file mode 100644
index 0000000000..18e9ba89b9
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/Makefile.am
@@ -0,0 +1,18 @@
+# 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.
+
+SUBDIRS = axis2c
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/Makefile.am
new file mode 100644
index 0000000000..2b9491ec1c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/Makefile.am
@@ -0,0 +1,18 @@
+# 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.
+
+SUBDIRS = src
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/Makefile.am
new file mode 100644
index 0000000000..4996d72c77
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/Makefile.am
@@ -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.
+
+libdir=$(prefix)/extensions/ws/reference/lib
+lib_LTLIBRARIES = libtuscany_sca_ws_reference.la
+
+noinst_HEADERS = tuscany/sca/ws/*.h tuscany/sca/ws/model/*.h
+
+libtuscany_sca_ws_reference_la_SOURCES = \
+tuscany/sca/ws/WSServiceBindingExtension.cpp \
+tuscany/sca/ws/model/WSServiceBinding.cpp \
+tuscany/sca/ws/WSServiceWrapper.cpp \
+tuscany/sca/ws/Axis2Client.cpp
+
+libtuscany_sca_ws_reference_la_LIBADD = \
+ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -ltuscany_sdo_axiom \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca \
+ -L$(AXIS2C_HOME)/lib \
+ -laxis2_util \
+ -laxis2_axiom \
+ -laxis2_wsdl \
+ -laxis2_engine \
+ -laxis2_parser \
+ -laxis2_minizip \
+ -lpthread \
+ -lwoden \
+ -laxis2_http_sender \
+ -laxis2_http_receiver
+
+INCLUDES = -I$(top_builddir)/runtime/core/src \
+ -I${TUSCANY_SDOCPP}/include \
+ -I${AXIS2C_HOME}/include
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+moduledir=$(prefix)/extensions/ws/reference/module
+extension = libtuscany_sca_ws_reference$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension) \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
new file mode 100644
index 0000000000..20ceba5a87
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
@@ -0,0 +1,803 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4091)
+#pragma warning(disable: 4786)
+#endif
+
+#include <sstream>
+
+#include <axis2_client.h>
+
+#include <axis2_error_default.h>
+#include <axis2_log_default.h>
+#include <axis2_defines.h>
+#include <axiom_soap_const.h>
+#include <platforms/axis2_platform_auto_sense.h>
+
+#include <sdo_axiom.h>
+
+#include "Axis2Client.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "model/WSServiceBinding.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/WSDLDefinition.h"
+#include "tuscany/sca/model/WSDLInterface.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace commonj::sdo_axiom;
+using namespace tuscany::sca::model;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ Axis2Client::Axis2Client(CompositeReference* compositeReference)
+ : compositeReference(compositeReference)
+ {
+ logentry();
+ }
+
+ Axis2Client::~Axis2Client()
+ {
+ logentry();
+ }
+
+ void Axis2Client::invoke(tuscany::sca::Operation& operation)
+ {
+ logentry();
+
+ // Initialize Axis2 stuff
+ axis2_env_t *env = axis2_env_create_all("tuscany_ws_reference.log",AXIS2_LOG_LEVEL_TRACE);
+ axis2_error_init();
+
+ // Get the WS service binding and WSDLOperation
+ Composite* composite=compositeReference->getComposite();
+ Service* service = compositeReference->getService();
+ WSServiceBinding* binding = (WSServiceBinding *)service->getBinding();
+ const string& operationName = operation.getName();
+ WSDLOperation wsdlOperation;
+
+ // Get the WSDL namespace
+ string wsdlNamespace = binding->getWSDLNamespaceURL();
+ if (wsdlNamespace != "")
+ {
+
+ // Lookup the wsdl model from the composite, keyed on the namespace
+ // (the wsdl will have been loaded at startup)
+ WSDLDefinition* wsdlDefinition = composite->findWSDLDefinition(wsdlNamespace);
+ if (wsdlDefinition == 0)
+ {
+ string msg = "WSDL not found for " + wsdlNamespace;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ // Match the operation in Operation to the operation in the wsdl port type.
+ try
+ {
+ wsdlOperation = wsdlDefinition->findOperation(
+ binding->getServiceName(),
+ binding->getEndpointName(),
+ operationName);
+ }
+ catch(SystemConfigurationException&)
+ {
+ throw;
+ }
+ }
+ else
+ {
+ Interface* iface = service->getType()->getInterface();
+ if (iface != NULL &&
+ iface->getInterfaceTypeQName() == WSDLInterface::typeQName)
+ {
+ WSDLInterface* wsdlInterface = (WSDLInterface*)iface;
+ wsdlNamespace = wsdlInterface->getNamespaceURI();
+
+ if (wsdlNamespace != "")
+ {
+
+ WSDLDefinition* wsdl = composite->findWSDLDefinition(wsdlNamespace);
+ if (wsdl == 0)
+ {
+ string msg = "WSDL not found for " + wsdlNamespace;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ try
+ {
+ wsdlOperation = wsdl->findOperation(wsdlInterface->getName(), operationName);
+ }
+ catch(SystemConfigurationException&)
+ {
+ throw;
+ }
+ }
+ }
+ }
+
+ if (wsdlNamespace == "")
+ {
+
+ // Create a default document literal wrapped WSDL operation
+ wsdlNamespace = compositeReference->getName();
+ wsdlOperation = WSDLOperation();
+ wsdlOperation.setOperationName(operationName);
+ wsdlOperation.setSoapAction(wsdlNamespace+ "#" +operationName);
+ wsdlOperation.setEndpoint("");
+ wsdlOperation.setSoapVersion(WSDLOperation::SOAP11);
+ wsdlOperation.setDocumentStyle(true);
+ wsdlOperation.setWrappedStyle(true);
+ wsdlOperation.setEncoded(false);
+ wsdlOperation.setInputType(string("http://tempuri.org") + "#" + operationName);
+ wsdlOperation.setOutputType(string("http://tempuri.org") + "#" + operationName + "Response");
+ }
+ else if (!wsdlOperation.isDocumentStyle() || !wsdlOperation.isWrappedStyle())
+ {
+ throwException(ServiceInvocationException,
+ "Only wrapped document style WSDL operations are currentlysupported");
+ }
+
+ // The URI specified in the binding overrides the address specified in
+ // the WSDL
+ axis2_char_t* address;
+
+ // Get the URI configured on the top level component
+ string bindingURI = "";
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ Component* component = runtime->getDefaultComponent();
+ Reference* reference = component->findReference(compositeReference->getName());
+ if (reference != NULL)
+ {
+ ReferenceBinding* referenceBinding = reference->getBinding();
+ if (referenceBinding != NULL && referenceBinding->getURI() != "")
+ {
+ bindingURI = referenceBinding->getURI();
+ }
+ }
+ if (bindingURI == "")
+ {
+ // Get the URI configured on the binding
+ if (binding->getURI() != "")
+ {
+ bindingURI = binding->getURI();
+ }
+ }
+ if (bindingURI != "")
+ {
+ // Prepend the default base URI if the URI is not absolute
+ if (bindingURI.find("://") == string::npos)
+ {
+ bindingURI = runtime->getDefaultBaseURI() + string("/axis2/services/") + bindingURI;
+ }
+ address = (axis2_char_t*)bindingURI.c_str();
+ }
+ else
+ {
+ address = (axis2_char_t*)wsdlOperation.getEndpoint().c_str();
+ }
+
+ axis2_char_t* opName = (axis2_char_t*)operationName.c_str();
+ axis2_char_t* soap_action = (axis2_char_t*)wsdlOperation.getSoapAction().c_str();
+
+ // create OM from Operation and wsdlOperation
+ axiom_node_t* payload = createPayload(operation, wsdlOperation, env);
+ /* Create EPR with given address */
+ axis2_endpoint_ref_t* endpoint_ref = axis2_endpoint_ref_create(env, address);
+
+ /* Setup options */
+ axis2_options_t* options = axis2_options_create(env);
+ AXIS2_OPTIONS_SET_TO(options, env, endpoint_ref);
+ int soap_version = AXIOM_SOAP11;
+ if (binding->getSOAPVersion() == "1.2")
+ {
+ soap_version = AXIOM_SOAP12;
+ }
+ else
+ {
+ if (wsdlOperation.getSoapVersion() == WSDLOperation::SOAP12)
+ {
+ soap_version = AXIOM_SOAP12;
+ }
+ }
+
+ AXIS2_OPTIONS_SET_SOAP_VERSION(options, env, soap_version);
+ AXIS2_OPTIONS_SET_ACTION(options, env, soap_action);
+ AXIS2_OPTIONS_SET_XML_PARSER_RESET(options, env, AXIS2_FALSE);
+
+ loginfo("WS SOAP action: %s", soap_action);
+ loginfo("WS Endpoint address: %s", address);
+ if(soap_version == AXIOM_SOAP11)
+ {
+ // Only set the SOAP action when using SOAP1.1
+ AXIS2_OPTIONS_SET_SOAP_ACTION(options, env, soap_action);
+ loginfo("Set soap version: 1.1");
+ }
+ else if(soap_version == AXIOM_SOAP12)
+ {
+ loginfo("Set soap version: 1.2");
+ }
+ else
+ {
+ loginfo("Set soap version: unset");
+ }
+ /* Create service client */
+
+ axis2_char_t* client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home)
+ {
+ throwException(SystemConfigurationException, "AXIS2C_HOME not set");
+ }
+ axis2_svc_client_t* svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ ostringstream msg;
+ msg << "Axis2 svc_client_create failed, error: " << env->error->error_number <<
+ ", " << AXIS2_ERROR_GET_MESSAGE(env->error);
+ throwException(SystemConfigurationException, msg.str().c_str());
+ }
+
+ /* Set service client options */
+ AXIS2_SVC_CLIENT_SET_OPTIONS(svc_client, env, options);
+
+ /* Engage addressing module */
+ AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ loginfo("Sending WS request");
+ /* Send request */
+ axiom_node_t* ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE(svc_client, env, payload);
+ if(ret_node)
+ {
+ setReturn(ret_node, operation, wsdlOperation, env);
+
+ // Set return value - now need to detach the node from the Axiom document
+ // for clean-up
+ axiom_document_t *document = AXIOM_NODE_GET_DOCUMENT(ret_node, env);
+ if (document)
+ {
+ AXIOM_DOCUMENT_BUILD_ALL (document, env);
+ }
+ AXIOM_NODE_DETACH (ret_node, env);
+ }
+ else
+ {
+ ostringstream msg;
+ msg << "Axis2 client_send_received failed, error: " << env->error->error_number <<
+ ", " << AXIS2_ERROR_GET_MESSAGE(env->error);
+ throwException(ServiceInvocationException, msg.str().c_str());
+ }
+
+ if (svc_client)
+ {
+ AXIS2_SVC_CLIENT_FREE(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if(env)
+ {
+ axis2_env_free((axis2_env_t *) env);
+ env = NULL;
+ }
+ loginfo("Freed env");
+
+ }
+
+ axiom_node_t* Axis2Client::createPayload(Operation& operation,
+ const WSDLOperation& wsdlOperation,
+ axis2_env_t* env)
+ {
+ logentry();
+
+ axiom_node_t* request_node = NULL;
+
+ // Build up the payload as an SDO
+
+ // Get the data factory for the composite (it will already have the typecreates loaded for the xsds)
+ DataFactoryPtr dataFactory = compositeReference->getComposite()->getDataFactory();
+
+ DataObjectPtr inputDataObject;
+ try
+ {
+
+ // Create the input wrapper
+ const Type& rootType = dataFactory->getType(wsdlOperation.getInputTypeUri().c_str(), "RootType");
+ const Property& prop = rootType.getProperty(wsdlOperation.getInputTypeName().c_str());
+ const Type& inputType = prop.getType();
+ inputDataObject = dataFactory->create(inputType);
+ }
+ catch (SDORuntimeException&)
+ {
+ try
+ {
+ // Create the input wrapper
+ const Type& inputType = dataFactory->getType(wsdlOperation.getInputTypeUri().c_str(),
+ wsdlOperation.getInputTypeName().c_str());
+ inputDataObject = dataFactory->create(inputType);
+ }
+ catch (SDORuntimeException&)
+ {
+
+ // The input wrapper type is not known, create an open DataObject
+ //inputDataObject = dataFactory->create("http://tempuri.org", "Wrapper");
+ inputDataObject = dataFactory->create(Type::SDOTypeNamespaceURI, "OpenDataObject");
+ }
+ }
+
+ // Go through data object to set the input parameters
+ PropertyList pl = inputDataObject->getType().getProperties();
+
+ if(pl.size() == 0)
+ {
+ if(inputDataObject->getType().isOpenType() && inputDataObject->getType().isDataObjectType())
+ {
+ /*
+ * This code deals with sending xsd:any elements
+ */
+ for (unsigned int i=0; i<operation.getNParms(); i++)
+ {
+ ostringstream pname;
+ pname << "param" << (i+1);
+ DataObjectList& l = inputDataObject->getList(pname.str());
+
+ const Operation::Parameter& parm = operation.getParameter(i);
+ switch(parm.getType())
+ {
+ case Operation::BOOL:
+ {
+ l.append(*(bool*)parm.getValue());
+ break;
+ }
+ case Operation::SHORT:
+ {
+ l.append(*(short*)parm.getValue());
+ break;
+ }
+ case Operation::INT:
+ {
+ l.append(*(long*)parm.getValue());
+ break;
+ }
+ case Operation::LONG:
+ {
+ l.append(*(long*)parm.getValue());
+ break;
+ }
+ case Operation::USHORT:
+ {
+ l.append(*(short*)parm.getValue());
+ break;
+ }
+ case Operation::UINT:
+ {
+ l.append(*(long*)parm.getValue());
+ break;
+ }
+ case Operation::ULONG:
+ {
+ l.append(*(long*)parm.getValue());
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ l.append(*(float*)parm.getValue());
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ l.append(*(long double*)parm.getValue());
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ l.append(*(long double*)parm.getValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ l.append(*(char**)parm.getValue());
+ break;
+ }
+ case Operation::STRING:
+ {
+ l.append((*(string*)parm.getValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ l.append(*(DataObjectPtr*)parm.getValue());
+ break;
+ }
+ default:
+ {
+ ostringstream msg;
+ msg << "Unsupported parameter type: " << parm.getType();
+ throwException(ServiceDataException, msg.str().c_str());
+ }
+ }
+ }
+ }
+ }
+ else {
+
+ // Each parameter in the operation should be a property on the request dataobject
+ for (unsigned int i=0; i<operation.getNParms(); i++)
+ {
+ const Operation::Parameter& parm = operation.getParameter(i);
+ switch(parm.getType())
+ {
+ case Operation::BOOL:
+ {
+ inputDataObject->setBoolean(i, *(bool*)parm.getValue());
+ break;
+ }
+ case Operation::SHORT:
+ {
+ inputDataObject->setShort(i, *(short*)parm.getValue());
+ break;
+ }
+ case Operation::INT:
+ {
+ inputDataObject->setInteger(i, *(int*)parm.getValue());
+ break;
+ }
+ case Operation::LONG:
+ {
+ inputDataObject->setLong(i, *(long*)parm.getValue());
+ break;
+ }
+ case Operation::USHORT:
+ {
+ inputDataObject->setInteger(i, *(unsigned short*)parm.getValue());
+ break;
+ }
+ case Operation::UINT:
+ {
+ inputDataObject->setInteger(i, *(unsigned int*)parm.getValue());
+ break;
+ }
+ case Operation::ULONG:
+ {
+ inputDataObject->setInteger(i, *(unsigned long*)parm.getValue());
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ inputDataObject->setFloat(i, *(float*)parm.getValue());
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ inputDataObject->setDouble(i, *(double*)parm.getValue());
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ inputDataObject->setDouble(i, *(long double*)parm.getValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ inputDataObject->setCString(i, *(char**)parm.getValue());
+ break;
+ }
+ case Operation::STRING:
+ {
+ inputDataObject->setCString(i, (*(string*)parm.getValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ inputDataObject->setDataObject(i, *(DataObjectPtr*)parm.getValue());
+ break;
+ }
+ default:
+ ostringstream msg;
+ msg << "Unsupported parameter type: " << parm.getType();
+ throwException(ServiceDataException, msg.str().c_str());
+ }
+ }
+ }
+
+ // Create the Axiom object from the request dataobject
+ AxiomHelper* axiomHelper = AxiomHelper::getHelper();
+ request_node = axiomHelper->toAxiomNode(inputDataObject,
+ wsdlOperation.getInputTypeUri().c_str(), wsdlOperation.getInputTypeName().c_str());
+ AxiomHelper::releaseHelper(axiomHelper);
+
+ char* str = AXIOM_NODE_TO_STRING(request_node, env);
+ loginfo("Sending Axis2 OM: %s ", str);
+
+ return request_node;
+
+ }
+
+ void Axis2Client::setReturn(axiom_node_t* ret_node,
+ Operation& operation,
+ const WSDLOperation& wsdlOperation,
+ axis2_env_t* env)
+ {
+ logentry();
+
+ DataFactoryPtr dataFactory = compositeReference->getComposite()->getDataFactory();
+
+ // Get the AXIOM node representing the SOAP Body
+ axiom_node_t* body = AXIOM_NODE_GET_PARENT(ret_node, env);
+
+ // Convert the AXIOM node to an SDO DataObject
+ char* str = NULL;
+ str = AXIOM_NODE_TO_STRING(body, env);
+ if (str)
+ {
+ loginfo("Received Axis2 OM: %s ", str);
+ }
+
+ // Convert the SOAP body to an SDO DataObject
+ AxiomHelper* axiomHelper = AxiomHelper::getHelper();
+ DataObjectPtr outputBodyDataObject = axiomHelper->toSdo(body, dataFactory);
+ AxiomHelper::releaseHelper(axiomHelper);
+
+ if(!outputBodyDataObject)
+ {
+ string msg = "Could not convert Axis2 OM node to SDO";
+ throwException(ServiceInvocationException, msg.c_str());
+ }
+ else
+ {
+ ostringstream os;
+ os << outputBodyDataObject;
+ loginfo("Converted Axis2 OM node to SDO: %s", os.str().c_str());
+ }
+
+ XMLHelperPtr xmlHelper = compositeReference->getComposite()->getXMLHelper();
+
+ // Get the first body part representing the doc-lit-wrapped wrapper element
+ DataObjectPtr outputDataObject = NULL;
+ PropertyList bpl = outputBodyDataObject->getInstanceProperties();
+ if (bpl.size()!=0)
+ {
+ if (bpl[0].isMany())
+ {
+ DataObjectList& parts = outputBodyDataObject->getList((unsigned int)0);
+ outputDataObject = parts[0];
+ }
+ else
+ {
+ outputDataObject = outputBodyDataObject->getDataObject(bpl[0]);
+ }
+ }
+ if (outputDataObject == NULL)
+ {
+ string msg = "Could not convert Axis2 body part to SDO";
+ throwException(ServiceInvocationException, msg.c_str());
+ }
+
+ PropertyList pl = outputDataObject->getType().getProperties();
+ if (pl.size() == 0)
+ {
+ if (outputDataObject->getType().isOpenType() && outputDataObject->getType().isDataObjectType())
+ {
+ SequencePtr sequence = outputDataObject->getSequence();
+ if (sequence != NULL && sequence->size() != 0)
+ {
+ // Return a text element
+ if (sequence->isText(0))
+ {
+ string* stringData = new string(sequence->getCStringValue(0));
+ operation.setReturnValue(stringData);
+ }
+ else
+ {
+ // Return a DataObject representing a complex element
+ DataObjectPtr *dataObjectData = new DataObjectPtr;
+ *dataObjectData = sequence->getDataObjectValue(0);
+ if(!*dataObjectData)
+ {
+ loginfo("Null DataObject return value");
+ }
+ else
+ {
+ (*dataObjectData)->detach();
+ }
+ operation.setReturnValue(dataObjectData);
+ }
+ }
+ }
+ }
+ else
+ {
+ const Property* p = &pl[0];
+
+ switch(pl[0].getTypeEnum())
+ {
+ case Type::BooleanType:
+ {
+ bool* boolData = new bool;
+ *boolData = outputDataObject->getBoolean(pl[0]);
+ operation.setReturnValue(boolData);
+ }
+ break;
+ case Type::ByteType:
+ {
+ char* byteData = new char;
+ *byteData = outputDataObject->getByte(pl[0]);
+ operation.setReturnValue(byteData);
+ }
+ break;
+ case Type::BytesType:
+ {
+ int len = outputDataObject->getLength(pl[0]);
+ char** bytesData = new char*;
+ *bytesData = new char[len+1];
+ int bytesWritten = outputDataObject->getBytes(pl[0], *bytesData, len);
+ // Ensure the bytes end with the null char. Not sure if this is neccessary
+ if(bytesWritten <= len)
+ {
+ (*bytesData)[bytesWritten] = 0;
+ }
+ else
+ {
+ (*bytesData)[len] = 0;
+ }
+ //printf("outputDataObject has BytesType named %s with length %d\n", name, bytesWritten);
+ operation.setReturnValue(bytesData);
+ }
+ break;
+ case Type::CharacterType:
+ {
+ // This code should work but won't be used as there is no mapping from an XSD type to the SDO CharacterType
+ wchar_t* charData = new wchar_t;
+ *charData = outputDataObject->getCharacter(pl[0]);
+ operation.setReturnValue(charData);
+ }
+ break;
+ case Type::DoubleType:
+ {
+ long double* doubleData = new long double;
+ *doubleData = outputDataObject->getDouble(pl[0]);
+ operation.setReturnValue(doubleData);
+ }
+ break;
+ case Type::FloatType:
+ {
+ float* floatData = new float;
+ *floatData = outputDataObject->getFloat(pl[0]);
+ operation.setReturnValue(floatData);
+ }
+ break;
+ case Type::IntegerType:
+ {
+ long* intData = new long;
+ *intData = outputDataObject->getInteger(pl[0]);
+ operation.setReturnValue(intData);
+ }
+ break;
+ case Type::ShortType:
+ {
+ short* shortData = new short;
+ *shortData = outputDataObject->getShort(pl[0]);
+ operation.setReturnValue(shortData);
+ }
+ break;
+ case Type::StringType:
+ {
+ string* stringData = new string(outputDataObject->getCString(pl[0]));
+ operation.setReturnValue(stringData);
+ }
+ break;
+ case Type::DataObjectType:
+ {
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = outputDataObject->getDataObject(pl[0]);
+ if(!*dataObjectData)
+ {
+ loginfo("Null DataObject return value");
+ }
+ else
+ {
+ (*dataObjectData)->detach();
+ }
+ operation.setReturnValue(dataObjectData);
+ }
+ break;
+ case Type::OpenDataObjectType:
+ {
+ /*
+ * This code deals with xsd:any element parameters
+ */
+
+ DataObjectList& dataObjectList = outputDataObject->getList(pl[0]);
+
+ for(unsigned int j=0; j<dataObjectList.size(); j++)
+ {
+ DataObjectPtr dob = dataObjectList[j];
+ if(!dob)
+ {
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = NULL;
+ operation.setReturnValue(dataObjectData);
+ loginfo("Null OpenDataObject return value");
+ }
+ else
+ {
+
+ SequencePtr sequence = dob->getSequence();
+ if (sequence->size()!=0)
+ {
+ // Return a text element
+ if (sequence->isText(0))
+ {
+ string* stringData = new string(sequence->getCStringValue(0));
+ operation.setReturnValue(stringData);
+ }
+ else
+ {
+ // Return a DataObject representing a complex element
+ DataObjectPtr *dataObjectData = new DataObjectPtr;
+ *dataObjectData = sequence->getDataObjectValue(0);
+ if(!*dataObjectData)
+ {
+ loginfo("Null DataObject return value");
+ }
+ else
+ {
+ (*dataObjectData)->detach();
+ }
+ operation.setReturnValue(dataObjectData);
+ }
+ }
+ else
+ {
+ // Empty content, add an empty string
+ loginfo("Null OpenDataObject return value");
+ string *stringData = new string("");
+ operation.setReturnValue(stringData);
+ }
+ }
+ }
+ }
+ break;
+ default:
+ {
+ ostringstream msg;
+ msg << "Unsupported result type: " << pl[0].getTypeEnum();
+ throwException(SystemConfigurationException, msg.str().c_str());
+ }
+ }
+ }
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.h
new file mode 100644
index 0000000000..397440dd5d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.h
@@ -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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_extension_ws_axis2client_h
+#define tuscany_sca_extension_ws_axis2client_h
+
+#include <axiom.h>
+
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/CompositeReference.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ class Axis2Client
+ {
+ public:
+ Axis2Client(tuscany::sca::model::CompositeReference* compositeReference);
+ virtual ~Axis2Client();
+
+ virtual void invoke(Operation& operation);
+
+ private:
+ tuscany::sca::model::CompositeReference* compositeReference;
+
+ axiom_node_t* createPayload(Operation& operation,
+ const tuscany::sca::model::WSDLOperation& wsdlOp,
+ axis2_env_t* env);
+
+ void setReturn(axiom_node_t* returnNode,
+ Operation& operation,
+ const tuscany::sca::model::WSDLOperation& wsdlOp,
+ axis2_env_t* env);
+
+ };
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_ws_axis2client_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp
new file mode 100644
index 0000000000..53d6075bbd
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "WSServiceBindingExtension.h"
+#include "model/WSServiceBinding.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_ws_reference_initialize()
+ {
+ tuscany::sca::ws::WSServiceBindingExtension::initialize();
+ }
+}
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+ // ===================================================================
+ // Constructor for the WSServiceBinding class.
+ // ===================================================================
+ WSServiceBindingExtension::WSServiceBindingExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the WSServiceBindingExtension class.
+ // ===================================================================
+ WSServiceBindingExtension::~WSServiceBindingExtension()
+ {
+ logentry();
+ }
+
+ const string WSServiceBindingExtension::extensionName("ws");
+ const string WSServiceBindingExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#WebServiceBinding");
+
+
+ // ===================================================================
+ // loadModelElement - load the info from binding.ws
+ // ===================================================================
+ ServiceBinding* WSServiceBindingExtension::getServiceBinding(Composite *composite, Service* service, DataObjectPtr scdlBinding)
+ {
+ logentry();
+
+ string uri = scdlBinding->getCString("uri");
+ string endpoint;
+ try
+ {
+ endpoint = scdlBinding->getCString("endpoint");
+ }
+ catch (SDORuntimeException&)
+ {
+ endpoint = "";
+ }
+ string version;
+ try
+ {
+ commonj::sdo::DataObjectList& soap = scdlBinding->getList("soapbinding");
+ if (soap.size()!=0)
+ {
+ version = soap.getCString(0);
+ }
+ else
+ {
+ version = "";
+ }
+ }
+ catch (SDORuntimeException&)
+ {
+ version = "";
+ }
+
+ WSServiceBinding* serviceBinding = new WSServiceBinding(service, uri, endpoint, version);
+
+ return serviceBinding;
+ }
+
+ void WSServiceBindingExtension::initialize()
+ {
+ logentry();
+ SCARuntime::getCurrentRuntime()->registerServiceBindingExtension(new WSServiceBindingExtension());
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.h
new file mode 100644
index 0000000000..68dd657657
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.h
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_extension_ws_wsservicebindingextension_h
+#define tuscany_sca_extension_ws_wsservicebindingextension_h
+
+#include "tuscany/sca/extension/ServiceBindingExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ class WSServiceBindingExtension : public ServiceBindingExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ WSServiceBindingExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~WSServiceBindingExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#binding.ws")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ServiceBinding* getServiceBinding(
+ tuscany::sca::model::Composite* composite,
+ tuscany::sca::model::Service* service,
+ commonj::sdo::DataObjectPtr scdlBinding);
+
+ static void initialize();
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif //tuscany_sca_extension_ws_wsservicebindingextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp
new file mode 100644
index 0000000000..4adcd5b4ff
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4091)
+#endif
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "Axis2Client.h"
+#include "WSServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceType.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ WSServiceWrapper::WSServiceWrapper(Service* service) : ServiceWrapper(service)
+ {
+ logentry();
+
+ // Define the SOAP Body type and element to allow a SOAP body to
+ // be loaded in a DataObject
+ DataFactoryPtr dataFactory = service->getComponent()->getComposite()->getDataFactory();
+ try {
+ const Type& bodyType = dataFactory->getType("http://www.w3.org/2003/05/soap-envelope", "Body");
+ } catch (SDORuntimeException&)
+ {
+ dataFactory->addType("http://www.w3.org/2003/05/soap-envelope", "RootType", false, false, false);
+ dataFactory->addType("http://www.w3.org/2003/05/soap-envelope", "Body", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://www.w3.org/2003/05/soap-envelope", "RootType",
+ "Body",
+ "http://www.w3.org/2003/05/soap-envelope", "Body",
+ false, false, true);
+
+ dataFactory->addType("http://schemas.xmlsoap.org/soap/envelope/", "RootType", false, false, false);
+ dataFactory->addType("http://schemas.xmlsoap.org/soap/envelope/", "Body", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/soap/envelope/", "RootType",
+ "Body",
+ "http://schemas.xmlsoap.org/soap/envelope/", "Body",
+ false, false, true);
+ }
+
+ try {
+ const Type& tempType = dataFactory->getType("http://tempuri.org", "RootType");
+ } catch (SDORuntimeException&)
+ {
+ dataFactory->addType("http://tempuri.org", "RootType", false, false, false);
+ dataFactory->addType("http://tempuri.org", "Wrapper", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://tempuri.org", "RootType",
+ "Wrapper",
+ "http://tempuri.org", "Wrapper",
+ false, false, true);
+ dataFactory->addType("http://tempuri.org", "Part", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://tempuri.org", "RootType",
+ "Part",
+ "http://tempuri.org", "Part",
+ false, false, true);
+ }
+ }
+
+ WSServiceWrapper::~WSServiceWrapper()
+ {
+ logentry();
+ }
+
+ ///
+ /// This method will be called when a web service call needs to be made.
+ ///
+ void WSServiceWrapper::invoke(Operation& operation)
+ {
+ logentry();
+
+ const string& operationName = operation.getName();
+
+ loginfo("Service: %s, operation: %s", getService()->getType()->getName().c_str() , operationName.c_str());
+
+ for (unsigned int i=0; i<operation.getNParms(); i++)
+ {
+ loginfo("Parameter: %p, type: %u", operation.getParameterValue(i),(int) operation.getParameterType(i));
+ }
+
+ // Create the Axis2 client that will handle the Web Service invocation
+ Service* service = getService();
+ CompositeReference* compositeReference = (CompositeReference*)service->getComponent();
+
+ Axis2Client client(compositeReference);
+ client.invoke(operation);
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
+
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.h
new file mode 100644
index 0000000000..f7aebbb575
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.h
@@ -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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_ws_wsservicewrapper_h
+#define tuscany_sca_extension_ws_wsservicewrapper_h
+
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/Service.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace ws
+ {
+
+ class WSServiceWrapper : public ServiceWrapper
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param target The service wrapper represents a Web service.
+ */
+ WSServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor
+ */
+ virtual ~WSServiceWrapper();
+
+ /**
+ * All business method calls on the target service are performed through
+ * this invoke method.
+ * @param operation The details of the method, paramaters and return value for the
+ * business method to be called on the target service.
+ */
+ virtual void invoke(Operation& operation);
+ };
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_ws_wsservicewrapper_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/export.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/export.h
new file mode 100644
index 0000000000..d0e708f1a1
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/export.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_ws_reference_export_h
+#define tuscany_sca_ws_reference_export_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef TUSCANY_SCA_WS_REFERENCE_EXPORTS
+#define SCA_WS_REFERENCE_API __declspec(dllexport)
+#else
+#define SCA_WS_REFERENCE_API __declspec(dllimport)
+#endif
+
+#else
+#define SCA_WS_REFERENCE_API
+#endif
+
+#endif // tuscany_sca_ws_reference_export_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.cpp
new file mode 100644
index 0000000000..26d8dffc45
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.cpp
@@ -0,0 +1,144 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/ws/model/WSServiceBinding.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/ws/WSServiceWrapper.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ // Constructor
+ WSServiceBinding::WSServiceBinding(Service* service, const string& uri, const string& endpoint, const string& version)
+ : ServiceBinding(service, uri), endpoint(endpoint), soapVersion(version)
+ {
+ logentry();
+
+ parseEndpoint();
+
+ serviceWrapper = new WSServiceWrapper(service);
+ }
+
+ void WSServiceBinding::parseEndpoint()
+ {
+ logentry();
+
+ // Endpoint is of the form: <wsdl-namepace-uri>#wsdl.endpoint(<service-name>/<endpoint-name>)
+ string::size_type hash = endpoint.find("#");
+ if (hash != string::npos)
+ {
+ // Found a hash
+
+ // Namepace is the part before the #
+ wsdlNamespaceURL = endpoint.substr(0, hash);
+
+
+ if ( (hash+1) < endpoint.length())
+ {
+ // Check the next part is wsdl.endpoint(
+ int ending = hash+15;
+ string check = endpoint.substr(hash+1, 14);
+ if (check.compare("wsdl.endpoint(") == 0)
+ {
+ // Find the matching )
+ int endBracket = endpoint.find(")",ending);
+ if (endBracket-1 > ending+1)
+ {
+ string serviceAndEndpoint = endpoint.substr(ending, endBracket-ending);
+ // Look for a '/'
+ string::size_type slash = serviceAndEndpoint.find("/");
+ if (slash != string::npos)
+ {
+ serviceName = serviceAndEndpoint.substr(0, slash);
+
+ if ( (slash+1) < serviceAndEndpoint.length())
+ {
+ endpointName = serviceAndEndpoint.substr(slash+1);
+ }
+ else
+ {
+ endpointName = "";
+ }
+
+ }
+ else
+ {
+ // No '/' so all of it is the service name
+ serviceName = serviceAndEndpoint;
+ endpointName = "";
+
+ }
+ }
+ else
+ {
+ // Nothing between the ()
+ serviceName = "";
+ endpointName = "";
+ }
+ }
+ else
+ {
+ // not the correct characters after the #, ignore the rest
+ serviceName = "";
+ endpointName = "";
+ }
+
+ }
+ else
+ {
+ // Nothing after the hash
+ serviceName = "";
+ endpointName = "";
+ }
+ }
+ else
+ {
+ // No hash at all
+ wsdlNamespaceURL = endpoint;
+ serviceName = "";
+ endpointName = "";
+ }
+ }
+
+ // Destructor
+ WSServiceBinding::~WSServiceBinding()
+ {
+ logentry();
+ }
+
+ ServiceWrapper* WSServiceBinding::getServiceWrapper()
+ {
+ logentry();
+
+ return serviceWrapper;
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.h
new file mode 100644
index 0000000000..3c8c5eb12d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.h
@@ -0,0 +1,137 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_ws_model_wsservicebinding_h
+#define tuscany_sca_extension_ws_model_wsservicebinding_h
+
+#include <string>
+
+#include "tuscany/sca/ws/export.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/model/Service.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+ /**
+ * Information about a web service binding for service or a reference.
+ */
+ class WSServiceBinding : public tuscany::sca::model::ServiceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ * @param endpoint The definition of the endpoint to which the service
+ * or reference is to be bound. This is of the form
+ * "namespace"#endpoint("service"/"endpoint")
+ */
+ SCA_WS_REFERENCE_API WSServiceBinding(tuscany::sca::model::Service* service, const std::string& uri, const std::string& endpoint, const std::string& version);
+
+ /**
+ * Destructor.
+ */
+ SCA_WS_REFERENCE_API virtual ~WSServiceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#WebServiceBinding"; };
+
+ /**
+ * Create a wrapper for the service configured by this
+ * binding.
+ */
+ SCA_WS_REFERENCE_API virtual ServiceWrapper* getServiceWrapper();
+
+ /**
+ * Return the part of the endpoint definition describing the wsdl
+ * namespace.
+ * @return The wsdl namespace.
+ */
+ std::string getWSDLNamespaceURL() const { return wsdlNamespaceURL; };
+
+ /**
+ * Return the service part of the endpoint definition.
+ * @return The service to use.
+ */
+ std::string getServiceName() const { return serviceName; };
+
+ /**
+ * Return the endpoint name part of the endpoint definition.
+ * @return The endpoint name to use.
+ */
+ std::string getEndpointName() const { return endpointName; };
+
+ /**
+ * Return the SOAP version.
+ * @return The SOAP version to use.
+ */
+ std::string getSOAPVersion() const { return soapVersion; };
+
+ private:
+
+ /**
+ * Parse the endpoint specification.
+ */
+ void parseEndpoint();
+
+ /**
+ * The full endpoint string.
+ */
+ std::string endpoint;
+
+ /**
+ * Namespace from the endpoint.
+ */
+ std::string wsdlNamespaceURL;
+
+ /**
+ * Service name from the endpoint.
+ */
+ std::string serviceName;
+
+ /**
+ * WSDL Endpoint name.
+ */
+ std::string endpointName;
+
+ /**
+ * SOAP version.
+ */
+ std::string soapVersion;
+
+ /**
+ * The wrapper for the service configured by this binding.
+ */
+ ServiceWrapper* serviceWrapper;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_ws_model_wsservicebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/deploy.bat
new file mode 100644
index 0000000000..6d8c426da2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/reference/deploy.bat
@@ -0,0 +1,68 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set wsextdir=%extdir%\ws
+set refextdir=%wsextdir%\reference
+set srcdir=%rootdir%\runtime\extensions\ws\reference
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+call %srcdir%\..\deploy.bat %rootdir%
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %wsextdir% mkdir %wsextdir%
+if not exist %refextdir% mkdir %refextdir%
+if not exist %refextdir%\module mkdir %refextdir%\module
+if not exist %refextdir%\bin mkdir %refextdir%\bin
+if not exist %refextdir%\lib mkdir %refextdir%\lib
+
+set libname=tuscany_sca_ws_reference
+
+del %refextdir%\bin\%libname%.*
+del %refextdir%\lib\%libname%.*
+
+copy %inpath%\%libname%.lib %refextdir%\lib
+copy %inpath%\%libname%.dll %refextdir%\bin
+copy %inpath%\%libname%.dll %refextdir%\module
+
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %refextdir%\bin
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %refextdir%\module
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/Makefile.am
new file mode 100644
index 0000000000..18e9ba89b9
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/Makefile.am
@@ -0,0 +1,18 @@
+# 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.
+
+SUBDIRS = axis2c
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/Makefile.am
new file mode 100644
index 0000000000..feadf9e317
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/Makefile.am
@@ -0,0 +1,18 @@
+# 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.
+
+SUBDIRS = src \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/Makefile.am b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/Makefile.am
new file mode 100644
index 0000000000..95924779da
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/Makefile.am
@@ -0,0 +1,96 @@
+# 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.
+
+libdir=$(prefix)/extensions/ws/service/lib
+lib_LTLIBRARIES = \
+libtuscany_sca_ws_service.la \
+libtuscany_sca_ws_dispatcher.la
+
+noinst_HEADERS = \
+tuscany/sca/ws/*.h \
+tuscany/sca/ws/model/*.h
+
+libtuscany_sca_ws_service_la_SOURCES = \
+tuscany/sca/ws/WSReferenceBindingExtension.cpp \
+tuscany/sca/ws/model/WSReferenceBinding.cpp \
+tuscany/sca/ws/WSServiceProxy.cpp \
+tuscany/sca/ws/Axis2Service.cpp \
+tuscany/sca/ws/Axis2Utils.cpp
+
+libtuscany_sca_ws_service_la_LIBADD = \
+ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -ltuscany_sdo_axiom \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca \
+ -L$(AXIS2C_HOME)/lib \
+ -laxis2_util \
+ -laxis2_axiom \
+ -laxis2_wsdl \
+ -laxis2_engine \
+ -laxis2_parser \
+ -laxis2_minizip \
+ -lpthread \
+ -lwoden \
+ -laxis2_http_sender \
+ -laxis2_http_receiver
+
+rootdir=$(prefix)/extensions/ws/service
+root_DATA = axis2.xml
+root_SCRIPTS = deploy.sh
+
+libtuscany_sca_ws_dispatcher_la_SOURCES = \
+tuscany/sca/ws/Axis2Dispatcher.cpp \
+tuscany/sca/ws/Axis2DispatcherModule.cpp
+
+libtuscany_sca_ws_dispatcher_la_LIBADD = \
+ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -ltuscany_sdo_axiom \
+ -L$(top_builddir)/runtime/core/src -ltuscany_sca \
+ -L$(AXIS2C_HOME)/lib \
+ -laxis2_util \
+ -laxis2_axiom \
+ -laxis2_wsdl \
+ -laxis2_engine \
+ -laxis2_parser \
+ -laxis2_minizip \
+ -lpthread \
+ -lwoden \
+ -laxis2_http_sender \
+ -laxis2_http_receiver
+
+servicedir=$(rootdir)/services/tuscany
+service_DATA = services.xml
+
+modulesdir=$(rootdir)/modules/tuscany
+modules_DATA = module.xml
+
+EXTRA_DIST = axis2.xml services.xml module.xml deploy.sh
+
+install-data-hook:
+ cd $(servicedir); ln -s -f ../../lib/libtuscany_sca_ws_service.so libtuscany_sca_ws_service.so
+ cd $(modulesdir); ln -s -f ../../lib/libtuscany_sca_ws_dispatcher.so libtuscany_sca_ws_dispatcher.so
+
+INCLUDES = -I$(top_builddir)/runtime/core/src \
+ -I${TUSCANY_SDOCPP}/include \
+ -I${AXIS2C_HOME}/include
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+moduledir=$(prefix)/extensions/ws/service/module
+extension = libtuscany_sca_ws_service$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension) \ No newline at end of file
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/axis2.xml b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/axis2.xml
new file mode 100644
index 0000000000..641085466e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/axis2.xml
@@ -0,0 +1,181 @@
+<!--
+ 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.
+-->
+<axisconfig name="Axis2/C">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="false">false</parameter>
+ <parameter name="hotupdate" locked="false">false</parameter>
+ <parameter name="enableMTOM" locked="false">false</parameter>
+ <parameter name="enableREST" locked="false">true</parameter>
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+ <parameter name="seralizeLocation" locked="false">.</parameter>
+ <hostConfiguration>
+ <ip>127.0.0.1</ip>
+ <port>5555</port>
+ </hostConfiguration>
+
+
+ <!--if you want to extract the service archive file and work with that please uncomment this-->
+ <!--else , it wont extract archive file or does not take into consideration if someone drop-->
+ <!--exploded directory into /service directory-->
+ <!--<parameter name="extractServiceArchive" locked="false">true</parameter>-->
+
+
+ <!-- The way of adding listener to the system-->
+ <!-- <listener class="org.apache.axis2.ObserverIMPL">-->
+ <!-- <parameter name="RSS_URL" locked="false">http://127.0.0.1/rss</parameter>-->
+ <!-- </listener>-->
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!-- This is the Deafult Message Receiver for the Request Response style Operations -->
+ <!--messageReceiver mep="INOUT" class="axis2_receivers"/-->
+
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http" class="axis2_http_receiver">
+ <parameter name="port" locked="false">6060</parameter>
+ </transportReceiver>
+
+ <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+ <transportReceiver name="mail" class="org.apache.axis2.transport.mail.SimpleMailListener">
+ <parameter name="transport.mail.pop3.host" locked="false">127.0.0.1</parameter>
+ <parameter name="transport.mail.pop3.user" locked="false">axis2</parameter>
+ <parameter name="transport.mail.pop3.password" locked="false">axis2</parameter>
+ <parameter name="transport.mail.pop3.port" locked="false">110</parameter>
+ <parameter name="transport.mail.replyToAddress" locked="false">axis2@127.0.0.1</parameter>
+ </transportReceiver> -->
+
+ <!--
+ <transportReceiver name="tcp" class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ </transportReceiver>
+ -->
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <!--
+ <transportSender name="tcp" class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local" class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ -->
+ <transportSender name="http" class="axis2_http_sender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <!--parameter name="Transfer-Encoding">chunked</parameter-->
+ <!--parameter name="PROXY" proxy_host="127.0.0.1" proxy_port="8080" locked="true"/-->
+ </transportSender>
+ <!--
+ <transportSender name="https" class="axis2_http_sender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ </transportSender>
+ -->
+ <!-- Uncomment this one with the appropriate papameters to enable the SMTP transport Receiver
+ <transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
+ <parameter name="transport.mail.smtp.host" locked="false">127.0.0.1</parameter>
+ <parameter name="transport.mail.smtp.user" locked="false">axis2</parameter>
+ <parameter name="transport.mail.smtp.password" locked="false">axis2</parameter>
+ <parameter name="transport.mail.smtp.port" locked="false">25</parameter>
+ </transportSender>
+ -->
+
+ <!-- ================================================= -->
+ <!-- Global Modules -->
+ <!-- ================================================= -->
+ <!-- Comment this to disable Addressing -->
+ <module ref="addressing"/>
+
+ <module ref="tuscany"/>
+
+ <!--Configuring module , providing paramters for modules whether they refer or not-->
+ <!--<moduleConfig name="addressing">-->
+ <!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
+ <!--</moduleConfig>-->
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="inflow">
+ <!-- System pre defined phases -->
+ <phase name="TransportIn"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch">
+ <handler name="AddressingBasedDispatcher"
+ class="axis2_engine">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="RequestURIBasedDispatcher"
+ class="axis2_engine">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="SOAPActionBasedDispatcher"
+ class="axis2_engine">
+ <order phase="Dispatch"/>
+ </handler>
+ <handler name="SOAPMessageBodyBasedDispatcher"
+ class="axis2_engine">
+ <order phase="Dispatch"/>
+ </handler>
+ </phase>
+ <phase name="PostDispatch">
+ <handler name="DispatchPostConditionsEvaluator"
+ class="axis2_engine">
+ <order phase="PostDispatch"/>
+ </handler>
+ <handler name="InstanceDispatcher"
+ class="axis2_engine">
+ <order phase="PostDispatch"/>
+ </handler>
+ <handler name="SOAPProcessingModelChecker"
+ class="axis2_engine">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <!--phase name="userphase1"/-->
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <!--phase name="RMPhase"/-->
+ <!--phase name="userphase1"/-->
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <!--phase name="PolicyDetermination"/-->
+ <!--phase name="MessageOut"/-->
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <!-- user can add his own phases to this area -->
+ <!--phase name="userphase1"/-->
+ <!--phase name="RMPhase"/-->
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <!--phase name="RMPhase"/-->
+ <!--phase name="userphase1"/-->
+ <!--phase name="PolicyDetermination"/-->
+ <phase name="MessageOut"/>
+ </phaseOrder>
+</axisconfig>
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/deploy.bat
new file mode 100644
index 0000000000..6493e1cec9
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/deploy.bat
@@ -0,0 +1,39 @@
+@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.
+
+
+rem Will deploy the Tuscany SCA WS service Axis2C service and module
+rem to the correct places within the AXIS2C_HOME directory
+setlocal
+set currentPath=%~d0%~p0
+
+if "%AXIS2C_HOME%" == "" (
+echo "AXIS2C_HOME not set"
+goto end
+)
+echo Deploying to Axis2C installed at %AXIS2C_HOME%
+
+if not exist %AXIS2C_HOME%\services\tuscany mkdir %AXIS2C_HOME%\services\tuscany
+if not exist %AXIS2C_HOME%\modules\tuscany mkdir %AXIS2C_HOME%\modules\tuscany
+
+copy %currentPath%\services\tuscany\* %AXIS2C_HOME%\services\tuscany
+copy %currentPath%\modules\tuscany\* %AXIS2C_HOME%\modules\tuscany
+copy %currentPath%\axis2.xml %AXIS2C_HOME%\axis2.xml
+
+:end
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/deploy.sh b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/deploy.sh
new file mode 100755
index 0000000000..ffe571b0ee
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/deploy.sh
@@ -0,0 +1,47 @@
+#!/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$AXIS2C_HOME = x ]; then
+echo "AXIS2C_HOME not set"
+exit;
+fi
+echo "Deploying to Axis2C installed at $AXIS2C_HOME"
+
+if ! [ -d $AXIS2C_HOME/services/tuscany ]; then
+ mkdir $AXIS2C_HOME/services/tuscany
+fi
+
+if ! [ -d $AXIS2C_HOME/modules/tuscany ]; then
+ mkdir $AXIS2C_HOME/modules/tuscany
+fi
+
+cp $APFULLDIR/services/tuscany/services.xml $AXIS2C_HOME/services/tuscany
+
+if ! [ -f $AXIS2C_HOME/services/tuscany/libtuscany_sca_ws_service.so ]; then
+ ln -s $APFULLDIR/services/tuscany/libtuscany_sca_ws_service.so $AXIS2C_HOME/services/tuscany/libtuscany_sca_ws_service.so
+fi
+
+cp $APFULLDIR/modules/tuscany/module.xml $AXIS2C_HOME/modules/tuscany
+if ! [ -f $AXIS2C_HOME/modules/tuscany/libtuscany_sca_ws_dispatcher.so ]; then
+ ln -s $APFULLDIR/modules/tuscany/libtuscany_sca_ws_dispatcher.so $AXIS2C_HOME/modules/tuscany/libtuscany_sca_ws_dispatcher.so
+fi
+
+cp $APFULLDIR/axis2.xml $AXIS2C_HOME/axis2.xml
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/module.xml b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/module.xml
new file mode 100644
index 0000000000..97d4d43a86
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/module.xml
@@ -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.
+-->
+<module name="tuscany" class="tuscany_sca_ws_dispatcher">
+ <inflow>
+ <handler name="TuscanyDispatcher" class="tuscany_sca_ws_dispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+ </inflow>
+</module>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/services.xml b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/services.xml
new file mode 100644
index 0000000000..335d4d96be
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/services.xml
@@ -0,0 +1,25 @@
+<?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.
+-->
+<serviceGroup>
+<service name="TuscanyService">
+ <parameter name="ServiceClass" locked="xsd:false">tuscany_sca_ws_service</parameter>
+ <operation name="execute"/>
+</service>
+</serviceGroup>
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp
new file mode 100644
index 0000000000..b6d2ac9225
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp
@@ -0,0 +1,177 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#pragma warning(disable: 4091)
+#endif
+
+#include <axis2_handler_desc.h>
+#include <axis2_qname.h>
+#include <axis2_relates_to.h>
+#include <axis2_svc.h>
+#include <axis2_const.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_addr.h>
+#include <axis2_utils.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_body.h>
+
+#include "tuscany/sca/util/Logging.h"
+
+extern "C"
+{
+
+axis2_status_t AXIS2_CALL
+Axis2Dispatcher_invoke (
+ axis2_handler_t * handler,
+ const axis2_env_t *env,
+ struct axis2_msg_ctx *msg_ctx);
+
+axis2_svc_t *AXIS2_CALL
+Axis2Dispatcher_find_svc(
+ axis2_msg_ctx_t *msg_ctx,
+ const axis2_env_t *env);
+
+axis2_op_t *AXIS2_CALL
+Axis2Dispatcher_find_op(
+ axis2_msg_ctx_t *msg_ctx,
+ const axis2_env_t *env,
+ axis2_svc_t *svc);
+
+
+AXIS2_EXPORT axis2_handler_t* AXIS2_CALL
+Axis2Dispatcher_create(const axis2_env_t *env,
+ axis2_qname_t *qname)
+{
+ axis2_handler_t *handler = NULL;
+
+ handler = axis2_handler_create(env);
+ if (!handler)
+ {
+ return NULL;
+ }
+
+ /* handler init is handled by conf loading, so no need to do it here */
+
+ /* set the base struct's invoke op */
+ if (handler->ops)
+ handler->ops->invoke = Axis2Dispatcher_invoke;
+
+ return handler;
+}
+
+axis2_svc_t *AXIS2_CALL
+Axis2Dispatcher_find_svc(
+ axis2_msg_ctx_t *msg_ctx,
+ const axis2_env_t *env)
+{
+ axis2_svc_t *svc = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ conf_ctx = AXIS2_MSG_CTX_GET_CONF_CTX(msg_ctx, env);
+ if (conf_ctx)
+ {
+ axis2_conf_t *conf = NULL;
+ conf = AXIS2_CONF_CTX_GET_CONF(conf_ctx, env);
+ if (conf)
+ {
+ axis2_char_t* service_name = "TuscanyService";
+ svc = AXIS2_CONF_GET_SVC(conf, env, service_name);
+ if (svc)
+ {
+ loginfo("Service found using target endpoint address");
+ }
+ }
+ }
+
+ return svc;
+}
+
+axis2_op_t *AXIS2_CALL
+Axis2Dispatcher_find_op(
+ axis2_msg_ctx_t *msg_ctx,
+ const axis2_env_t *env,
+ axis2_svc_t *svc)
+{
+ axis2_op_t *op = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ axis2_qname_t *op_qname = NULL;
+ axis2_char_t* execute_op_name = "execute";
+ op_qname = axis2_qname_create(env, execute_op_name, NULL, NULL);
+
+ op = AXIS2_SVC_GET_OP_WITH_NAME(svc, env, AXIS2_QNAME_GET_LOCALPART(op_qname, env));
+
+ AXIS2_QNAME_FREE(op_qname, env);
+ if (op)
+ {
+ loginfo("TuscanyService execute operation found");
+ }
+ return op;
+}
+
+axis2_status_t AXIS2_CALL
+Axis2Dispatcher_invoke(
+ axis2_handler_t * handler,
+ const axis2_env_t *env,
+ struct axis2_msg_ctx *msg_ctx)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ if (!(AXIS2_MSG_CTX_GET_SERVER_SIDE(msg_ctx, env)))
+ return AXIS2_SUCCESS;
+
+ msg_ctx->ops->find_svc = Axis2Dispatcher_find_svc;
+ msg_ctx->ops->find_op = Axis2Dispatcher_find_op;
+
+ axis2_svc_t *axis_service = NULL;
+ axis2_op_t *op = NULL;
+
+ axis_service = AXIS2_MSG_CTX_GET_SVC(msg_ctx, env);
+
+ if (!axis_service)
+ {
+ axis_service = AXIS2_MSG_CTX_FIND_SVC(msg_ctx, env);
+ if (axis_service)
+ {
+ AXIS2_MSG_CTX_SET_SVC(msg_ctx, env, axis_service);
+ /*TODO Set the Service Group Context to the message Context*/
+ }
+ }
+ op = AXIS2_MSG_CTX_GET_OP(msg_ctx, env);
+ if (!op)
+ {
+ op = AXIS2_MSG_CTX_FIND_OP(msg_ctx, env, axis_service);
+
+ if (op)
+ {
+ AXIS2_MSG_CTX_SET_OP(msg_ctx, env, op);
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+}
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp
new file mode 100644
index 0000000000..0dc8f3358a
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#pragma warning(disable: 4091)
+#endif
+
+#include <axis2_module.h>
+#include <axis2_addr_mod.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_disp.h>
+
+extern "C"
+{
+
+axis2_status_t AXIS2_CALL
+Axis2DispatcherModule_shutdown(axis2_module_t *module,
+ const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+Axis2DispatcherModule_init(
+ axis2_module_t *module,
+ const axis2_env_t *env,
+ axis2_conf_ctx_t *conf_ctx,
+ axis2_module_desc_t *module_desc);
+
+axis2_status_t AXIS2_CALL
+Axis2DispatcherModule_fill_handler_create_func_map(axis2_module_t *module,
+ const axis2_env_t *env);
+
+AXIS2_EXTERN axis2_handler_t* AXIS2_CALL
+Axis2Dispatcher_create(const axis2_env_t *env,
+ axis2_qname_t *qname);
+
+axis2_module_t *
+Axis2DispatcherModule_create(const axis2_env_t *env)
+{
+ axis2_module_t *module = NULL;
+ module = (axis2_module_t*)AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_module_t));
+
+
+ module->ops = (axis2_module_ops_t*)AXIS2_MALLOC(
+ env->allocator, sizeof(axis2_module_ops_t));
+
+ module->ops->shutdown = Axis2DispatcherModule_shutdown;
+ module->ops->init = Axis2DispatcherModule_init;
+ module->ops->fill_handler_create_func_map =
+ Axis2DispatcherModule_fill_handler_create_func_map;
+
+ return module;
+}
+
+axis2_status_t AXIS2_CALL
+Axis2DispatcherModule_init(
+ axis2_module_t *module,
+ const axis2_env_t *env,
+ axis2_conf_ctx_t *conf_ctx,
+ axis2_module_desc_t *module_desc)
+{
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+Axis2DispatcherModule_shutdown(axis2_module_t *module,
+ const axis2_env_t *env)
+{
+ if(module->ops)
+ {
+ AXIS2_FREE(env->allocator, module->ops);
+ module->ops = NULL;
+ }
+
+ if(module->handler_create_func_map)
+ {
+ axis2_hash_free(module->handler_create_func_map, env);
+ module->handler_create_func_map = NULL;
+ }
+
+ if(module)
+ {
+ AXIS2_FREE(env->allocator, module);
+ module = NULL;
+ }
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+Axis2DispatcherModule_fill_handler_create_func_map(axis2_module_t *module,
+ const axis2_env_t *env)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ module->handler_create_func_map = axis2_hash_make(env);
+ axis2_hash_set(module->handler_create_func_map, "TuscanyDispatcher",
+ (axis2_ssize_t)AXIS2_HASH_KEY_STRING, (const void *)Axis2Dispatcher_create);
+
+ return AXIS2_SUCCESS;
+}
+
+/**
+ * Following block distinguish the exposed part of the dll.
+ */
+
+AXIS2_EXPORT int
+axis2_get_instance(axis2_module_t **inst,
+ const axis2_env_t *env)
+{
+ *inst = Axis2DispatcherModule_create(env);
+ if(!(*inst))
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int
+axis2_remove_instance(axis2_module_t *inst,
+ const axis2_env_t *env)
+{
+ axis2_status_t status = AXIS2_FAILURE;
+ if (inst)
+ {
+ status = Axis2DispatcherModule_shutdown(inst, env);
+ }
+ return status;
+}
+
+}
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
new file mode 100644
index 0000000000..13c87c8c87
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
@@ -0,0 +1,543 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#pragma warning(disable: 4091)
+#endif
+
+#include <sstream>
+
+#include <axis2_svc_skeleton.h>
+#include <axis2_array_list.h>
+#include <axis2_log_default.h>
+#include <axis2_error_default.h>
+#include <axiom.h>
+
+#include <sdo_axiom.h>
+
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+#include "WSServiceProxy.h"
+#include "model/WSReferenceBinding.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/CompositeService.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/WSDLDefinition.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+#include "tuscany/sca/model/WSDLInterface.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/util/Utils.h"
+#include "Axis2Utils.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace commonj::sdo_axiom;
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ int AXIS2_CALL
+ Axis2Service_free(axis2_svc_skeleton_t *svc_skeleton,
+ const axis2_env_t *env);
+
+ axiom_node_t* AXIS2_CALL
+ Axis2Service_invoke(axis2_svc_skeleton_t *svc_skeleton,
+ const axis2_env_t *env,
+ axiom_node_t *node,
+ axis2_msg_ctx_t *msg_ctx);
+
+ int AXIS2_CALL
+ Axis2Service_init(axis2_svc_skeleton_t *svc_skeleton,
+ const axis2_env_t *env);
+
+ axis2_svc_skeleton_t*
+ axis2_Axis2Service_create(axis2_env_t *env)
+ {
+ axis2_svc_skeleton_t *svc_skeleton = NULL;
+ svc_skeleton = (axis2_svc_skeleton_t *) AXIS2_MALLOC((env)->allocator,
+ sizeof(axis2_svc_skeleton_t));
+
+
+ svc_skeleton->ops = (axis2_svc_skeleton_ops_t *) AXIS2_MALLOC(
+ (env)->allocator, sizeof(axis2_svc_skeleton_ops_t));
+
+ svc_skeleton->func_array = NULL;
+
+ svc_skeleton->ops->free = Axis2Service_free;
+ svc_skeleton->ops->init = Axis2Service_init;
+ svc_skeleton->ops->invoke = Axis2Service_invoke;
+ /*svc_skeleton->ops->on_fault = Axis2Service_on_fault;*/
+
+ return svc_skeleton;
+ }
+
+ int AXIS2_CALL
+ Axis2Service_init(axis2_svc_skeleton_t *svc_skeleton,
+ const axis2_env_t *env)
+ {
+ // This method never seems to be called - an old Axis2C artifact?
+
+ svc_skeleton->func_array = axis2_array_list_create(env, 0);
+ return AXIS2_SUCCESS;
+ }
+
+ int AXIS2_CALL
+ Axis2Service_free(axis2_svc_skeleton_t *svc_skeleton,
+ const axis2_env_t *env)
+ {
+ if(svc_skeleton->ops)
+ {
+ AXIS2_FREE((env)->allocator, svc_skeleton->ops);
+ svc_skeleton->ops = NULL;
+ }
+
+ if(svc_skeleton)
+ {
+ AXIS2_FREE((env)->allocator, svc_skeleton);
+ svc_skeleton = NULL;
+ }
+ return AXIS2_SUCCESS;
+ }
+
+
+ /**
+ * Initialize the SCA runtime
+ */
+ CompositeService* initializeSCARuntime(const char*home, const char* root,
+ const char* path, const char* baseURI, const char *component, const char* service)
+ {
+ logentry();
+ loginfo("Home: %s", home);
+ loginfo("Root: %s", root);
+ loginfo("Path: %s", path);
+ loginfo("Base URI: %s", baseURI);
+ loginfo("Component: %s", component);
+ loginfo("Service: %s", service);
+
+ try
+ {
+ SCARuntime* runtime = SCARuntime::initializeSharedRuntime(home, root, path, baseURI);
+
+ string componentName;
+ if (strlen(component))
+ {
+ componentName = component;
+ }
+ else
+ {
+ componentName = runtime->getDefaultComponentName();
+ }
+ string serviceName = service;
+
+ loginfo("Resolving composite: %s, service: %s", componentName.c_str(), serviceName.c_str());
+ Component* compositeComponent = runtime->getSystem()->findComponent(componentName);
+ if (compositeComponent == NULL)
+ {
+ string msg = "Component not found " + componentName;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ runtime->setDefaultComponent(compositeComponent);
+
+ Composite* composite = (Composite*)compositeComponent->getType();
+ CompositeService* compositeService = (CompositeService*)composite->findComponent(serviceName);
+ if (compositeService == NULL)
+ {
+ string msg = "Composite service not found " + serviceName;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ return compositeService;
+ }
+ catch(TuscanyRuntimeException &ex)
+ {
+ ostringstream msg;
+ msg << ex;
+ logerror("Failed to initialize SCA runtime: %s", msg.str().c_str());
+ throw;
+ }
+ }
+
+
+ /*
+ * This method invokes the target service method
+ */
+ axiom_node_t* AXIS2_CALL
+ Axis2Service_invoke(axis2_svc_skeleton_t *svc_skeleton,
+ const axis2_env_t *env,
+ axiom_node_t *node,
+ axis2_msg_ctx_t *msg_ctx)
+ {
+ logentry();
+
+ try
+ {
+ if (node)
+ {
+ if (AXIOM_NODE_GET_NODE_TYPE(node, env) == AXIOM_ELEMENT)
+ {
+ axiom_element_t *element = NULL;
+ element = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env);
+ if (element)
+ {
+ string op_name = "";
+
+ axis2_bool_t rest = AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env);
+ if (rest)
+ {
+ axis2_endpoint_ref_t *endpoint_ref = AXIS2_MSG_CTX_GET_FROM(msg_ctx, env);
+ if (endpoint_ref)
+ {
+ const axis2_char_t *addr = AXIS2_ENDPOINT_REF_GET_ADDRESS(endpoint_ref, env);
+ if (addr)
+ {
+ // REST request, the op name is the last segment of the path
+ string raddress = addr;
+ string path;
+ string query;
+ Utils::tokeniseString("?", raddress, path, query);
+ string uri;
+ Utils::rTokeniseString("/", path, uri, op_name);
+ }
+ }
+ }
+ else
+ {
+ // SOAP request
+ // Get the operation name from the root element name, this is correct for DocLit Wrapped style
+ op_name = AXIOM_ELEMENT_GET_LOCALNAME(element, env);
+ }
+
+ if (op_name != "")
+ {
+ CompositeService* compositeService;
+
+ // Get the Tuscany home, system root, path and composite service name from the Axis2
+ // service parameters
+ char* homeParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyHome");
+ if (homeParam == NULL)
+ homeParam = "";
+
+ char* rootParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyRoot");
+ if (rootParam == NULL)
+ rootParam = "";
+
+ char* pathParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyPath");
+ if (pathParam == NULL)
+ pathParam = "";
+
+ char* baseURIParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyBaseURI");
+ if (baseURIParam == NULL)
+ baseURIParam = "";
+
+ char* serviceParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyService");
+ if (serviceParam != NULL)
+ {
+ loginfo("System root: %s, service name: %s, operation name: %s", rootParam, serviceParam, op_name.c_str());
+
+ // Service is of the form "component name"/"composite service name"
+ string component, service;
+ Utils::rTokeniseString("/", serviceParam, component, service);
+
+ compositeService = initializeSCARuntime(homeParam, rootParam, pathParam, baseURIParam, component.c_str(), service.c_str());
+ }
+ else {
+
+ // Use the default home, system root and component, the service is
+ // derived from the target address
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ endpoint_ref = AXIS2_MSG_CTX_GET_FROM(msg_ctx, env);
+ string address = AXIS2_ENDPOINT_REF_GET_ADDRESS(endpoint_ref, env);
+
+ axis2_bool_t isrest = AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env);
+ string path;
+ if (isrest)
+ {
+ string op;
+ Utils::rTokeniseString("/", address, path, op);
+ }
+ else
+ {
+ path = address;
+ }
+
+ string path2;
+ string service;
+ Utils::rTokeniseString("/", path, path2, service);
+
+ string path3;
+ string component;
+ Utils::rTokeniseString("/", path2, path3, component);
+ if (component == "services")
+ {
+ component = "";
+ }
+
+ loginfo("System root: %s, component name: %s, service name: %s, operation name: %s",
+ rootParam, component.c_str(), service.c_str(), op_name.c_str());
+
+ compositeService = initializeSCARuntime(homeParam, rootParam, pathParam, baseURIParam, component.c_str(), service.c_str());
+ }
+
+ if(!compositeService)
+ {
+ throwException(SystemConfigurationException,
+ "Failed to initialize SCA runtime, could not initialize CompositeService");
+ }
+
+ DataFactoryPtr dataFactory = compositeService->getComposite()->getDataFactory();
+ if (dataFactory == 0)
+ {
+ throwException(SystemConfigurationException,
+ "Failed to initialize SCA runtime, could not get DataFactory");
+ }
+
+ // Get the WS binding and the WSDL operation
+ Composite* composite = compositeService->getComposite();
+ Reference* reference = compositeService->getReference();
+ WSReferenceBinding* binding = (WSReferenceBinding*)reference->getBinding();
+ WSDLOperation wsdlOperation;
+
+ // First use the WSDL definition specified in the binding
+ string wsdlNamespace = binding->getWSDLNamespaceURL();
+ if (wsdlNamespace != "")
+ {
+ WSDLDefinition* wsdlDefinition = composite->findWSDLDefinition(wsdlNamespace);
+ if (wsdlDefinition == 0)
+ {
+ string msg = "WSDL not found for: " + wsdlNamespace;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ // Find the target operation in the WSDL port type.
+ try {
+ wsdlOperation = wsdlDefinition->findOperation(
+ binding->getServiceName(),
+ binding->getEndpointName(),
+ op_name.c_str());
+ }
+ catch(SystemConfigurationException&)
+ {
+ throw;
+ }
+
+ }
+ else
+ {
+ // Then use the WSDL definition specified in the WSDL interface, if any
+ Interface* iface = reference->getType()->getInterface();
+ if (iface != NULL &&
+ iface->getInterfaceTypeQName() == WSDLInterface::typeQName)
+ {
+ WSDLInterface* wsdlInterface = (WSDLInterface*)iface;
+ wsdlNamespace = wsdlInterface->getNamespaceURI();
+
+ if (wsdlNamespace != "")
+ {
+
+ WSDLDefinition* wsdl = composite->findWSDLDefinition(wsdlNamespace);
+ if (wsdl == 0)
+ {
+ string msg = "WSDL not found for: " + wsdlNamespace;
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+
+ try
+ {
+ wsdlOperation = wsdl->findOperation(wsdlInterface->getName(), op_name.c_str());
+ }
+ catch(SystemConfigurationException&)
+ {
+ throw;
+ }
+ }
+ }
+ }
+
+ // No WSDL definition was specified in the binding or interface
+ // Create a default document literal wrapped WSDL operation
+ if (wsdlNamespace == "")
+ {
+ wsdlNamespace = compositeService->getName();
+ wsdlOperation = WSDLOperation();
+ wsdlOperation.setOperationName(op_name.c_str());
+ wsdlOperation.setSoapAction(wsdlNamespace+ "#" +op_name);
+ wsdlOperation.setEndpoint("");
+ wsdlOperation.setSoapVersion(WSDLOperation::SOAP11);
+ wsdlOperation.setDocumentStyle(true);
+ wsdlOperation.setWrappedStyle(true);
+ wsdlOperation.setEncoded(false);
+ wsdlOperation.setInputType(string("http://tempuri.org") + "#" + op_name);
+ wsdlOperation.setOutputType(string("http://tempuri.org") + "#" + op_name + "Response");
+ }
+ else if (!wsdlOperation.isDocumentStyle() || !wsdlOperation.isWrappedStyle())
+ {
+ throwException(ServiceInvocationException,
+ "Only wrapped document style WSDL operations are currentlysupported");
+ }
+
+ // Convert the input AXIOM node to an SDO DataObject
+ axiom_node_t* body = AXIOM_NODE_GET_PARENT(node, env);
+ char* str = NULL;
+ str = AXIOM_NODE_TO_STRING(body, env);
+ if (str)
+ {
+ loginfo("Received request Axis2 OM: %s", str);
+ }
+
+ // Convert the SOAP body to an SDO DataObject
+ DataObjectPtr inputBodyDataObject = NULL;
+ DataObjectPtr inputDataObject = NULL;
+
+ AxiomHelper* axiomHelper = AxiomHelper::getHelper();
+
+ try
+ {
+ inputBodyDataObject = axiomHelper->toSdo(body, dataFactory);
+ if(!inputBodyDataObject)
+ {
+ string msg = "Could not convert request Axis2 OM to SDO";
+ throwException(ServiceInvocationException, msg.c_str());
+ }
+ else
+ {
+ ostringstream os;
+ os << inputBodyDataObject;
+ loginfo("Converted Axis2 OM node to SDO: %s", os.str().c_str());
+ }
+
+ // Get the first body part representing the doc-lit-wrapped wrapper element
+ PropertyList bpl = inputBodyDataObject->getInstanceProperties();
+ if (bpl.size()!=0)
+ {
+ if (bpl[0].isMany())
+ {
+ DataObjectList& parts = inputBodyDataObject->getList((unsigned int)0);
+ inputDataObject = parts[0];
+ }
+ else
+ {
+ inputDataObject = inputBodyDataObject->getDataObject(bpl[0]);
+ }
+ }
+ if (inputDataObject == NULL)
+ {
+ string msg = "Could not convert Axis2 body part to SDO";
+ throwException(ServiceInvocationException, msg.c_str());
+ }
+ }
+ catch(SDORuntimeException &ex)
+ {
+ throwException(ServiceDataException, ex);
+ }
+
+ // Dispatch to the WS proxy
+ WSServiceProxy* proxy = (WSServiceProxy*)binding->getServiceProxy();
+
+ DataObjectPtr outputDataObject = proxy->invoke(wsdlOperation, inputDataObject);
+
+ if(!outputDataObject)
+ {
+ return 0;
+ }
+
+ try
+ {
+ // Convert the output DataObject to an Axiom node
+ axiom_node_t* outputNode = axiomHelper->toAxiomNode(outputDataObject,
+ wsdlOperation.getOutputTypeUri().c_str(), wsdlOperation.getOutputTypeName().c_str());
+
+ AxiomHelper::releaseHelper(axiomHelper);
+
+ str = AXIOM_NODE_TO_STRING(outputNode, env);
+ if (str)
+ {
+ loginfo("Sending response Axis2 OM : %s", str);
+ }
+
+ return outputNode;
+ }
+ catch(SDORuntimeException &ex)
+ {
+ throwException(ServiceDataException, ex);
+ }
+ }
+ }
+ }
+ }
+
+ string msg = "Invalid parameters in Axis2 request OM";
+ throwException(ServiceInvocationException, msg.c_str());
+
+ }
+ catch(TuscanyRuntimeException& ex)
+ {
+ ostringstream msg;
+ msg << ex;
+ logerror("Failed to process Web service invocation: %s", msg.str().c_str());
+ }
+ return 0;
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
+extern "C"
+{
+
+ /**
+ * Following block distinguish the exposed part of the dll.
+ */
+
+ AXIS2_EXPORT int axis2_get_instance(axis2_svc_skeleton **inst,
+ axis2_env_t *env)
+ {
+ *inst = tuscany::sca::ws::axis2_Axis2Service_create(env);
+ if(!(*inst))
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+ }
+
+ AXIS2_EXPORT int axis2_remove_instance(axis2_svc_skeleton_t *inst,
+ axis2_env_t *env)
+ {
+ axis2_status_t status = AXIS2_FAILURE;
+ if (inst)
+ {
+ status = AXIS2_SVC_SKELETON_FREE(inst, env);
+ }
+ return status;
+ }
+}
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp
new file mode 100644
index 0000000000..09c3862590
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#pragma warning(disable: 4091)
+#endif
+
+#include <axis2_svc_ctx.h>
+#include <axis2_defines.h>
+
+#include "tuscany/sca/util/Logging.h"
+#include "Axis2Utils.h"
+
+using namespace tuscany::sca;
+using namespace tuscany::sca::ws;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ char* Axis2Utils::getAxisServiceParameterValue(const axis2_env_t *env, axis2_msg_ctx_t *msg_ctx, char* parameterName)
+ {
+ logentry();
+
+ struct axis2_svc *svc = NULL;
+ struct axis2_op_ctx *op_ctx = NULL;
+ struct axis2_svc_ctx *svc_ctx = NULL;
+ axis2_param_t *param = NULL;
+ char* paramValue = NULL;
+
+ op_ctx = AXIS2_MSG_CTX_GET_OP_CTX(msg_ctx, env);
+ svc_ctx = AXIS2_OP_CTX_GET_PARENT(op_ctx, env);
+ svc = AXIS2_SVC_CTX_GET_SVC(svc_ctx, env);
+ if(NULL == svc)
+ {
+ return NULL;
+ }
+
+ param = AXIS2_SVC_GET_PARAM(svc, env, parameterName);
+ if(!param)
+ {
+ logwarning("Axis parameter %s cannot be found", parameterName);
+ }
+ else
+ {
+ paramValue = (char*) AXIS2_PARAM_GET_VALUE(param, env);
+ }
+
+ return paramValue;
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h
new file mode 100644
index 0000000000..4e8b069010
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_ws_axis2utils_h
+#define tuscany_sca_extension_ws_axis2utils_h
+
+#include <axis2_env.h>
+#include <axis2_msg_ctx.h>
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ class Axis2Utils
+ {
+ public:
+ static char* getAxisServiceParameterValue(const axis2_env_t *env, axis2_msg_ctx_t *msg_ctx, char* parameterName);
+ };
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_ws_axis2utils_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp
new file mode 100644
index 0000000000..24a7552bc4
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#include "WSReferenceBindingExtension.h"
+#include "model/WSReferenceBinding.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+using namespace commonj::sdo;
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_ws_service_initialize()
+ {
+ tuscany::sca::ws::WSReferenceBindingExtension::initialize();
+ }
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+ // ===================================================================
+ // Constructor for the WSReferenceBinding class.
+ // ===================================================================
+ WSReferenceBindingExtension::WSReferenceBindingExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the WSReferenceBindingExtension class.
+ // ===================================================================
+ WSReferenceBindingExtension::~WSReferenceBindingExtension()
+ {
+ logentry();
+ }
+
+ const string WSReferenceBindingExtension::extensionName("ws");
+ const string WSReferenceBindingExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#WebServiceBinding");
+
+ // ===================================================================
+ // loadModelElement - load the info from binding.ws
+ // ===================================================================
+ ReferenceBinding* WSReferenceBindingExtension::getReferenceBinding(Composite *composite, Reference* reference, DataObjectPtr scdlBinding)
+ {
+ logentry();
+
+ string uri = scdlBinding->getCString("uri");
+
+ string endpoint;
+ try
+ {
+ endpoint = scdlBinding->getCString("endpoint");
+ }
+ catch (SDORuntimeException&)
+ {
+ endpoint = "";
+ }
+
+ string version;
+ try
+ {
+ commonj::sdo::DataObjectList& soap = scdlBinding->getList("soapbinding");
+ if (soap.size()!=0)
+ {
+ version = soap.getCString(0);
+ }
+ else
+ {
+ version = "";
+ }
+ }
+ catch (SDORuntimeException&)
+ {
+ version = "";
+ }
+
+ WSReferenceBinding* serviceBinding = new WSReferenceBinding(reference, uri, endpoint, version);
+
+ return serviceBinding;
+ }
+
+ void WSReferenceBindingExtension::initialize()
+ {
+ logentry();
+ SCARuntime::getCurrentRuntime()->registerReferenceBindingExtension(new WSReferenceBindingExtension());
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h
new file mode 100644
index 0000000000..712e7d2646
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_ws_wsreferencebindingextension_h
+#define tuscany_sca_extension_ws_wsreferencebindingextension_h
+
+#include "tuscany/sca/extension/ReferenceBindingExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ class WSReferenceBindingExtension : public ReferenceBindingExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ WSReferenceBindingExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~WSReferenceBindingExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#binding.ws")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ReferenceBinding* getReferenceBinding(
+ tuscany::sca::model::Composite* composite,
+ tuscany::sca::model::Reference *reference, commonj::sdo::DataObjectPtr scdlBinding);
+
+ static void initialize();
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_ws_wsreferencebindingextension_h
+
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp
new file mode 100644
index 0000000000..8dd27ec60d
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp
@@ -0,0 +1,572 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include <sstream>
+
+#include "commonj/sdo/SDO.h"
+
+#include "WSServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/model/WSDLDefinition.h"
+#include "tuscany/sca/model/WSDLInterface.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+#include "model/WSReferenceBinding.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ WSServiceProxy::WSServiceProxy(Reference* reference)
+ : ServiceProxy(reference)
+ {
+ logentry();
+
+ // Get the target service wrapper
+ WSReferenceBinding* referenceBinding = (WSReferenceBinding*)reference->getBinding();
+ serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
+
+ // Define the SOAP Body type and element to allow a SOAP body to
+ // be loaded in a DataObject
+ DataFactoryPtr dataFactory = reference->getComponent()->getComposite()->getDataFactory();
+ try {
+ const Type& bodyType = dataFactory->getType("http://www.w3.org/2003/05/soap-envelope", "Body");
+ } catch (SDORuntimeException&)
+ {
+
+ // Define the SOAP 1.2 Body type
+ dataFactory->addType("http://www.w3.org/2003/05/soap-envelope", "RootType", false, false, false);
+ dataFactory->addType("http://www.w3.org/2003/05/soap-envelope", "Body", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://www.w3.org/2003/05/soap-envelope", "RootType",
+ "Body",
+ "http://www.w3.org/2003/05/soap-envelope", "Body",
+ false, false, true);
+
+ // Define the SOAP 1.1 Body type
+ dataFactory->addType("http://schemas.xmlsoap.org/soap/envelope/", "RootType", false, false, false);
+ dataFactory->addType("http://schemas.xmlsoap.org/soap/envelope/", "Body", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://schemas.xmlsoap.org/soap/envelope/", "RootType",
+ "Body",
+ "http://schemas.xmlsoap.org/soap/envelope/", "Body",
+ false, false, true);
+ }
+
+ try {
+ const Type& tempType = dataFactory->getType("http://tempuri.org", "RootType");
+ } catch (SDORuntimeException&)
+ {
+ dataFactory->addType("http://tempuri.org", "RootType", false, false, false);
+ dataFactory->addType("http://tempuri.org", "Wrapper", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://tempuri.org", "RootType",
+ "Wrapper",
+ "http://tempuri.org", "Wrapper",
+ false, false, true);
+ dataFactory->addType("http://tempuri.org", "Part", false, true, false);
+ dataFactory->addPropertyToType(
+ "http://tempuri.org", "RootType",
+ "Part",
+ "http://tempuri.org", "Part",
+ false, false, true);
+ }
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ WSServiceProxy::~WSServiceProxy()
+ {
+ logentry();
+ }
+
+ ///
+ /// This method will be called to process an operation invocation.
+ ///
+ DataObjectPtr WSServiceProxy::invoke(const WSDLOperation& wsdlOperation, DataObjectPtr inputDataObject)
+ {
+ logentry();
+
+ Reference* reference = getReference();
+ Component* component = reference->getComponent();
+ Composite* composite = component ->getComposite();
+
+ WSReferenceBinding* referenceBinding = (WSReferenceBinding*)reference->getBinding();
+ DataFactoryPtr dataFactoryPtr = reference->getComponent()->getComposite()->getDataFactory();
+
+ const char* outputTypeURI = wsdlOperation.getOutputTypeUri().c_str();
+ const char* outputTypeName = wsdlOperation.getOutputTypeName().c_str();
+
+ loginfo("WSDLOperation inputType: %s#%s",
+ wsdlOperation.getInputTypeUri().c_str(),
+ wsdlOperation.getInputTypeName().c_str());
+ loginfo("WSDLOperation outputType: %s#%s",
+ outputTypeURI,
+ outputTypeName);
+
+ try
+ {
+
+ // Create new Operation object and set parameters and return value
+ Operation operation(wsdlOperation.getOperationName().c_str());
+
+ // Go through the input data object to set the operation parameters
+ PropertyList pl = inputDataObject->getInstanceProperties();
+
+ for(unsigned int i=0; i<pl.size(); i++)
+ {
+ const char* name = pl[i].getName();
+
+ switch (pl[i].getTypeEnum())
+ {
+ case Type::BooleanType:
+ {
+ bool* boolData = new bool;
+ *boolData = inputDataObject->getBoolean(pl[i]);
+ operation.addParameter(boolData);
+ }
+ break;
+ case Type::ByteType:
+ {
+ char* byteData = new char;
+ *byteData = inputDataObject->getByte(pl[i]);
+ operation.addParameter(byteData);
+ }
+ break;
+ case Type::BytesType:
+ {
+ int len = inputDataObject->getLength(pl[i]);
+ char** bytesData = new char*;
+ *bytesData = new char[len+1];
+ int bytesWritten = inputDataObject->getBytes(pl[i], *bytesData, len);
+ // Ensure the bytes end with the null char. Not sure if this is neccessary
+ if(bytesWritten <= len)
+ {
+ (*bytesData)[bytesWritten] = 0;
+ }
+ else
+ {
+ (*bytesData)[len] = 0;
+ }
+ operation.addParameter(bytesData);
+ }
+ break;
+ case Type::CharacterType:
+ {
+ // This code should work but won't be used as there is no mapping from an XSD type to the SDO CharacterType
+ wchar_t* charData = new wchar_t;
+ *charData = inputDataObject->getCharacter(pl[i]);
+ operation.addParameter(charData);
+ }
+ break;
+ case Type::DoubleType:
+ {
+ long double* doubleData = new long double;
+ *doubleData = inputDataObject->getDouble(pl[i]);
+ operation.addParameter(doubleData);
+ }
+ break;
+ case Type::FloatType:
+ {
+ float* floatData = new float;
+ *floatData = inputDataObject->getFloat(pl[i]);
+ operation.addParameter(floatData);
+ }
+ break;
+ case Type::IntegerType:
+ {
+ long* intData = new long;
+ *intData = inputDataObject->getInteger(pl[i]);
+ operation.addParameter(intData);
+ }
+ break;
+ case Type::ShortType:
+ {
+ short* shortData = new short;
+ *shortData = inputDataObject->getShort(pl[i]);
+ operation.addParameter(shortData);
+ }
+ break;
+ case Type::StringType:
+ {
+ string* stringData;
+ if(inputDataObject->isSet(pl[i]))
+ {
+ stringData = new string(inputDataObject->getCString(pl[i]));
+ }
+ else
+ {
+ // The data is not set, so pass an empty string as the parameter
+ stringData = new string();
+ }
+ operation.addParameter(stringData);
+ }
+ break;
+ case Type::DataObjectType:
+ {
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = inputDataObject->getDataObject(pl[i]);
+ if(!*dataObjectData)
+ {
+ loginfo("Null DataObject parameter named %s", name);
+ }
+ else
+ {
+ (*dataObjectData)->detach();
+ }
+ operation.addParameter(dataObjectData);
+ }
+ break;
+ case Type::OpenDataObjectType:
+ {
+ /*
+ * This code deals with xsd:any element parameters
+ * Get each element as a DataObject and add in to the parameter list
+ */
+
+ DataObjectList& dataObjectList = inputDataObject->getList(pl[i]);
+
+ for(unsigned int j=0; j<dataObjectList.size(); j++)
+ {
+ DataObjectPtr dob = dataObjectList[j];
+ if(!dob)
+ {
+
+ // Add a null DataObject ptr
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = NULL;
+ loginfo("Null OpenDataObject parameter named %s[%d]", name, j);
+ operation.addParameter(dataObjectData);
+ }
+ else
+ {
+
+ SequencePtr sequence = dob->getSequence();
+ if (sequence->size()!=0)
+ {
+ // Add a text element
+ if (sequence->isText(0))
+ {
+ string* stringData = new string(sequence->getCStringValue(0));
+ operation.addParameter(stringData);
+ }
+ else
+ {
+ // Add a complex element DataObject
+ DataObjectPtr* dataObjectData = new DataObjectPtr;
+ *dataObjectData = sequence->getDataObjectValue(0);
+ if(!*dataObjectData)
+ {
+ loginfo("Null DataObject parameter named %s", name);
+ }
+ else
+ {
+ (*dataObjectData)->detach();
+ }
+ operation.addParameter(dataObjectData);
+ }
+ }
+ else
+ {
+ // Empty content, add an empty string
+ loginfo("Empty OpenDataObject parameter named %s[%d]", name, j);
+ string* stringData = new string("");
+ operation.addParameter(stringData);
+ }
+ }
+ }
+ }
+ break;
+ default:
+ {
+ ostringstream msg;
+ msg << "Unsupported param type: " << pl[i].getTypeEnum();
+ throwException(SystemConfigurationException, msg.str().c_str());
+ }
+ }
+ }
+
+ // Call into the target service wrapper
+ serviceWrapper->invoke(operation);
+
+ // Set the data in the outputDataObject to be returned
+ DataObjectPtr outputDataObject;
+ try
+ {
+ // Create the output wrapper
+ const Type& rootType = dataFactoryPtr->getType(outputTypeURI, "RootType");
+ const Property& prop = rootType.getProperty(outputTypeName);
+ const Type& outputType = prop.getType();
+ outputDataObject = dataFactoryPtr->create(outputType);
+ }
+ catch (SDORuntimeException&)
+ {
+ try
+ {
+ // Create the output wrapper
+ const Type& outputType = dataFactoryPtr->getType(outputTypeURI, outputTypeName);
+ outputDataObject = dataFactoryPtr->create(outputType);
+ }
+ catch (SDORuntimeException&)
+ {
+ // The output wrapper type is not known, create an open DataObject
+ //outputDataObject = dataFactoryPtr->create("http://tempuri.org", "Wrapper");
+ outputDataObject = dataFactoryPtr->create(Type::SDOTypeNamespaceURI, "OpenDataObject");
+ }
+ }
+
+ setOutputData(operation, outputDataObject, dataFactoryPtr);
+
+ return outputDataObject;
+
+ }
+ catch(SDORuntimeException& ex)
+ {
+ throwException(ServiceInvocationException, ex);
+ }
+ catch(TuscanyRuntimeException&)
+ {
+ throw;
+ }
+ }
+
+
+ void WSServiceProxy::setOutputData(Operation& operation, DataObjectPtr outputDataObject, DataFactoryPtr dataFactoryPtr)
+ {
+ logentry();
+
+ // Go through data object to set the return value
+ PropertyList pl = outputDataObject->getType().getProperties();
+
+ if(pl.size() == 0)
+ {
+ if(outputDataObject->getType().isOpenType() && outputDataObject->getType().isDataObjectType())
+ {
+ /*
+ * This code deals with returning xsd:any elements
+ */
+ DataObjectList& l = outputDataObject->getList("return");
+ Operation::ParameterType resultType = operation.getReturnType();
+ switch(resultType)
+ {
+ case Operation::BOOL:
+ {
+ l.append(*(bool*)operation.getReturnValue());
+ break;
+ }
+ case Operation::SHORT:
+ {
+ l.append(*(short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::INT:
+ {
+ l.append(*(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONG:
+ {
+ l.append(*(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::USHORT:
+ {
+ l.append(*(short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::UINT:
+ {
+ l.append(*(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::ULONG:
+ {
+ l.append(*(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ l.append(*(float*)operation.getReturnValue());
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ l.append(*(long double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ l.append(*(long double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ l.append(*(char**)operation.getReturnValue());
+ break;
+ }
+ case Operation::STRING:
+ {
+ l.append((*(string*)operation.getReturnValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ l.append(*(DataObjectPtr*)operation.getReturnValue());
+ break;
+ }
+ default:
+ {
+ // One way operation, no return value
+ break;
+ }
+ }
+ }
+ else
+ {
+ loginfo("No return values defined");
+ }
+ }
+ else {
+
+ // Should only be one return value.. This goes through all return values
+ for(unsigned int i=0; i<pl.size(); i++)
+ {
+ const char* name = pl[i].getName();
+
+ Operation::ParameterType resultType = operation.getReturnType();
+ switch(resultType)
+ {
+ case Operation::BOOL:
+ {
+ outputDataObject->setBoolean(pl[i], *(bool*)operation.getReturnValue());
+ break;
+ }
+ case Operation::SHORT:
+ {
+ outputDataObject->setShort(pl[i], *(short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::INT:
+ {
+ outputDataObject->setInteger(pl[i], *(int*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONG:
+ {
+ outputDataObject->setInteger(pl[i], *(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::USHORT:
+ {
+ outputDataObject->setInteger(pl[i], *(unsigned short*)operation.getReturnValue());
+ break;
+ }
+ case Operation::UINT:
+ {
+ outputDataObject->setInteger(pl[i], *(unsigned int*)operation.getReturnValue());
+ break;
+ }
+ case Operation::ULONG:
+ {
+ outputDataObject->setInteger(pl[i], *(unsigned long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ outputDataObject->setFloat(pl[i], *(float*)operation.getReturnValue());
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ outputDataObject->setDouble(pl[i], *(double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ outputDataObject->setDouble(pl[i], *(long double*)operation.getReturnValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ if(*(char**)operation.getReturnValue() != NULL)
+ {
+ outputDataObject->setCString(pl[i], *(char**)operation.getReturnValue());
+ }
+ else
+ {
+ loginfo("Null return value, leaving property %s unset", pl[i].getName());
+ }
+ break;
+ }
+ case Operation::STRING:
+ {
+ outputDataObject->setCString(pl[i], (*(string*)operation.getReturnValue()).c_str());
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+
+ if(*(DataObjectPtr*)operation.getReturnValue() != NULL)
+ {
+ outputDataObject->setDataObject(pl[i], *(DataObjectPtr*)operation.getReturnValue());
+ }
+ else
+ {
+ loginfo("Null return value, leaving property %s unset", pl[i].getName());
+ }
+
+ break;
+ }
+ default:
+ {
+ // One way operation, no return value
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h
new file mode 100644
index 0000000000..4d57514688
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_ws_wsserviceproxy_h
+#define tuscany_sca_extension_ws_wsserviceproxy_h
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+#include "model/WSReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ /**
+ * Holds a proxy for a given component and reference.
+ * The proxy which is held inside a ServiceProxy will be specific to the programming
+ * interface expected by the client. In this particular case the client is an Axis2
+ * Web service skeleton.
+ */
+ class WSServiceProxy : public ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a reference. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The reference on the source component.
+ * @param target The wrapper of the service which is wired to this reference.
+ */
+ WSServiceProxy(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Create a new service proxy for a service. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The service on the target component.
+ * @param target The wrapper of the target service.
+ */
+ WSServiceProxy(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~WSServiceProxy();
+
+ /**
+ * Invoke the specified operation
+ */
+ commonj::sdo::DataObjectPtr invoke(const tuscany::sca::model::WSDLOperation& wsdlOperation,
+ commonj::sdo::DataObjectPtr inputDataObject);
+
+ private:
+
+ void setOutputData(Operation& operation,
+ commonj::sdo::DataObjectPtr outputDataObject, commonj::sdo::DataFactoryPtr dataFactoryPtr);
+
+ /**
+ * The target service wrapper
+ */
+ ServiceWrapper* serviceWrapper;
+
+ };
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_ws_wsserviceproxy_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/export.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/export.h
new file mode 100644
index 0000000000..e52adf4db0
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/export.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_ws_service_export_h
+#define tuscany_sca_ws_service_export_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef TUSCANY_SCA_WS_SERVICE_EXPORTS
+#define SCA_WS_SERVICE_API __declspec(dllexport)
+#else
+#define SCA_WS_SERVICE_API __declspec(dllimport)
+#endif
+
+#else
+#define SCA_WS_SERVICE_API
+#endif
+
+#endif // tuscany_sca_ws_service_export_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp
new file mode 100644
index 0000000000..220caf2d0c
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp
@@ -0,0 +1,151 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/ws/model/WSReferenceBinding.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/ws/WSServiceProxy.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ // Constructor
+ WSReferenceBinding::WSReferenceBinding(Reference* reference, const string& uri, const string& endpoint, const string&version)
+ : ReferenceBinding(reference, uri), endpoint(endpoint), soapVersion(version)
+ {
+ logentry();
+
+ parseEndpoint();
+ }
+
+ void WSReferenceBinding::parseEndpoint()
+ {
+ logentry();
+
+ // Endpoint is of the form: <wsdl-namepace-uri>#wsdl.endpoint(<service-name>/<endpoint-name>)
+ string::size_type hash = endpoint.find("#");
+ if (hash != string::npos)
+ {
+ // Found a hash
+
+ // Namepace is the part before the #
+ wsdlNamespaceURL = endpoint.substr(0, hash);
+
+
+ if ( (hash+1) < endpoint.length())
+ {
+ // Check the next part is wsdl.endpoint(
+ int ending = hash+15;
+ string check = endpoint.substr(hash+1, 14);
+ if (check.compare("wsdl.endpoint(") == 0)
+ {
+ // Find the matching )
+ int endBracket = endpoint.find(")",ending);
+ if (endBracket-1 > ending+1)
+ {
+ string serviceAndEndpoint = endpoint.substr(ending, endBracket-ending);
+ // Look for a '/'
+ string::size_type slash = serviceAndEndpoint.find("/");
+ if (slash != string::npos)
+ {
+ serviceName = serviceAndEndpoint.substr(0, slash);
+
+ if ( (slash+1) < serviceAndEndpoint.length())
+ {
+ endpointName = serviceAndEndpoint.substr(slash+1);
+ }
+ else
+ {
+ endpointName = "";
+ }
+
+ }
+ else
+ {
+ // No '/' so all of it is the service name
+ serviceName = serviceAndEndpoint;
+ endpointName = "";
+
+ }
+ }
+ else
+ {
+ // Nothing between the ()
+ serviceName = "";
+ endpointName = "";
+ }
+ }
+ else
+ {
+ // not the correct characters after the #, ignore the rest
+ serviceName = "";
+ endpointName = "";
+ }
+
+ }
+ else
+ {
+ // Nothing after the hash
+ serviceName = "";
+ endpointName = "";
+ }
+ }
+ else
+ {
+ // No hash at all
+ wsdlNamespaceURL = endpoint;
+ serviceName = "";
+ endpointName = "";
+ }
+ }
+
+ // Destructor
+ WSReferenceBinding::~WSReferenceBinding()
+ {
+ logentry();
+ }
+
+ void WSReferenceBinding::configure(ServiceBinding *binding)
+ {
+ logentry();
+
+ targetServiceBinding = binding;
+
+ serviceProxy = new WSServiceProxy(getReference());
+ }
+
+ ServiceProxy* WSReferenceBinding::getServiceProxy()
+ {
+ logentry();
+
+ return serviceProxy;
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h
new file mode 100644
index 0000000000..b565e6c30e
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_extension_ws_model_wsreferencebinding_h
+#define tuscany_sca_extension_ws_model_wsreferencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/ws/export.h"
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+ /**
+ * Information about a web service binding for service or a reference.
+ */
+ class WSReferenceBinding : public tuscany::sca::model::ReferenceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ * @param endpoint The definition of the endpoint to which the entrypoint
+ * or external service is to be bound. This is of the form
+ * "namespace"#endpoint("service"/"endpoint")
+ */
+ SCA_WS_SERVICE_API WSReferenceBinding(tuscany::sca::model::Reference* reference,
+ const std::string&uri, const std::string& endpoint, const std::string& version);
+
+ /**
+ * Destructor.
+ */
+ SCA_WS_SERVICE_API virtual ~WSReferenceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#WebServiceBinding"; };
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ SCA_WS_SERVICE_API virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding);
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ SCA_WS_SERVICE_API virtual ServiceProxy* getServiceProxy();
+
+ /**
+ * Return the part of the endpoint definition describing the wsdl
+ * namespace.
+ * @return The wsdl namespace.
+ */
+ std::string getWSDLNamespaceURL() const { return wsdlNamespaceURL; };
+
+ /**
+ * Return the service part of the endpoint definition.
+ * @return The service to use.
+ */
+ std::string getServiceName() const { return serviceName; };
+
+ /**
+ * Return the endpoint name part of the endpoint definition.
+ * @return The endpoint name to use.
+ */
+ std::string getEndpointName() const { return endpointName; };
+
+ /**
+ * Return the SOAP version.
+ * @return The SOAP version to use.
+ */
+ std::string getSOAPVersion() const { return soapVersion; };
+
+ /**
+ * Returns the target service binding.
+ */
+ tuscany::sca::model::ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; };
+
+ private:
+
+ /**
+ * Parse the endpoint specification.
+ */
+ void parseEndpoint();
+
+ /**
+ * The full endpoint string.
+ */
+ std::string endpoint;
+
+ /**
+ * Namespace from the endpoint.
+ */
+ std::string wsdlNamespaceURL;
+
+ /**
+ * Service name from the endpoint.
+ */
+ std::string serviceName;
+
+ /**
+ * Endpoint name from the endpoint.
+ */
+ std::string endpointName;
+
+ /**
+ * SOAP version.
+ */
+ std::string soapVersion;
+
+ /**
+ * The proxy representing the reference to the client
+ * component.
+ */
+ ServiceProxy* serviceProxy;
+
+ /**
+ * The service binding of the target
+ */
+ tuscany::sca::model::ServiceBinding* targetServiceBinding;
+ };
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_ws_model_wsreferencebinding_h
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/deploy.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/deploy.bat
new file mode 100644
index 0000000000..ac4b50190b
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/deploy.bat
@@ -0,0 +1,76 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set wsextdir=%extdir%\ws
+set svcextdir=%wsextdir%\service
+set svcsdir=%svcextdir%\services
+set srcdir=%rootdir%\runtime\extensions\ws\service\axis2c\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %wsextdir% mkdir %wsextdir%
+if not exist %svcextdir% mkdir %svcextdir%
+if not exist %svcextdir%\module mkdir %svcextdir%\module
+if not exist %svcextdir%\bin mkdir %svcextdir%\bin
+if not exist %svcextdir%\lib mkdir %svcextdir%\lib
+
+set libname=tuscany_sca_ws_service
+
+del %svcextdir%\bin\%libname%.*
+del %svcextdir%\lib\%libname%.*
+
+copy %inpath%\%libname%.lib %svcextdir%\lib
+copy %inpath%\%libname%.dll %svcextdir%\bin
+copy %inpath%\%libname%.dll %svcextdir%\module
+
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %svcextdir%\bin
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %svcextdir%\module
+
+if not exist %svcsdir% mkdir %svcsdir%
+if not exist %svcsdir%\tuscany mkdir %svcsdir%\tuscany
+
+copy %srcdir%\axis2.xml %svcextdir%
+copy %srcdir%\deploy.bat %svcextdir%
+copy %srcdir%\services.xml %svcsdir%\tuscany
+copy %inpath%\%libname%.dll %svcsdir%\tuscany
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %svcsdir%\tuscany
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/deploymodule.bat b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/deploymodule.bat
new file mode 100644
index 0000000000..246728b6b2
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/service/deploymodule.bat
@@ -0,0 +1,69 @@
+@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 . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set wsextdir=%extdir%\ws
+set svcextdir=%wsextdir%\service
+set modsdir=%svcextdir%\modules
+set srcdir=%rootdir%\runtime\extensions\ws\service\axis2c\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %wsextdir% mkdir %wsextdir%
+
+set libname=tuscany_sca_ws_dispatcher
+
+del %svcextdir%\bin\%libname%.*
+del %svcextdir%\lib\%libname%.*
+
+copy %inpath%\%libname%.lib %svcextdir%\lib
+copy %inpath%\%libname%.dll %svcextdir%\bin
+
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %svcextdir%\bin
+
+
+if not exist %modsdir% mkdir %modsdir%
+if not exist %modsdir%\tuscany mkdir %modsdir%\tuscany
+
+copy %srcdir%\module.xml %modsdir%\tuscany
+copy %inpath%\%libname%.dll %modsdir%\tuscany
+if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %modsdir%\tuscany
+
+goto end
+:usage
+echo Usage: deploy <sca-root> <build-output>
+:end
+
+endlocal
diff --git a/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/xsd/sca-binding-webservice.xsd b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/xsd/sca-binding-webservice.xsd
new file mode 100644
index 0000000000..2c1c2abbcc
--- /dev/null
+++ b/tags/native-sca-1.0.incubating-M3/runtime/extensions/ws/xsd/sca-binding-webservice.xsd
@@ -0,0 +1,55 @@
+<?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.
+-->
+
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ elementFormDefault="qualified">
+
+ <element name="binding.ws" type="sca:WebServiceBinding" substitutionGroup="sca:binding"/>
+ <complexType name="WebServiceBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="soapbinding" type="sca:SOAPBinding" minOccurs="0" maxOccurs="unbounded"/>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="endpoint" type="anyURI" use="optional" />
+ <attribute name="location" type="anyURI" use="optional" />
+ <attribute name="conformanceURIs" type="sca:ConformanceURIList" use="optional" />
+ <attribute name="interfaceMapping" type="string" use="optional" />
+ <anyAttribute namespace="##any" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="SOAPBinding">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="optional" />
+ <attribute name="version" type="string" use="optional" />
+ <anyAttribute namespace="##any" processContents="lax" />
+ </complexType>
+
+ <simpleType name="ConformanceURIList">
+ <list itemType="anyURI"/>
+ </simpleType>
+</schema>