From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/runtime/Makefile.am | 1 + .../sca/runtime/core/Makefile.am | 1 + .../sca/runtime/core/deploy.bat | 72 + .../sca/runtime/core/src/Makefile.am | 57 + .../core/src/tuscany/sca/core/Operation.cpp | 372 ++++ .../runtime/core/src/tuscany/sca/core/Operation.h | 198 +++ .../core/src/tuscany/sca/core/SCARuntime.cpp | 487 ++++++ .../runtime/core/src/tuscany/sca/core/SCARuntime.h | 262 +++ .../core/src/tuscany/sca/core/ServiceProxy.cpp | 51 + .../core/src/tuscany/sca/core/ServiceProxy.h | 81 + .../core/src/tuscany/sca/core/ServiceWrapper.cpp | 52 + .../core/src/tuscany/sca/core/ServiceWrapper.h | 79 + .../core/src/tuscany/sca/core/TuscanyRuntime.cpp | 111 ++ .../core/src/tuscany/sca/core/TuscanyRuntime.h | 95 + .../sca/runtime/core/src/tuscany/sca/export.h | 41 + .../sca/extension/ImplementationExtension.cpp | 48 + .../sca/extension/ImplementationExtension.h | 80 + .../tuscany/sca/extension/InterfaceExtension.cpp | 48 + .../src/tuscany/sca/extension/InterfaceExtension.h | 77 + .../sca/extension/ReferenceBindingExtension.cpp | 47 + .../sca/extension/ReferenceBindingExtension.h | 81 + .../sca/extension/ServiceBindingExtension.cpp | 47 + .../sca/extension/ServiceBindingExtension.h | 80 + .../runtime/core/src/tuscany/sca/model/Binding.cpp | 46 + .../runtime/core/src/tuscany/sca/model/Binding.h | 83 + .../core/src/tuscany/sca/model/Component.cpp | 146 ++ .../runtime/core/src/tuscany/sca/model/Component.h | 184 ++ .../core/src/tuscany/sca/model/ComponentType.cpp | 261 +++ .../core/src/tuscany/sca/model/ComponentType.h | 181 ++ .../core/src/tuscany/sca/model/Composite.cpp | 198 +++ .../runtime/core/src/tuscany/sca/model/Composite.h | 199 +++ .../src/tuscany/sca/model/CompositeReference.cpp | 67 + .../src/tuscany/sca/model/CompositeReference.h | 82 + .../src/tuscany/sca/model/CompositeService.cpp | 69 + .../core/src/tuscany/sca/model/CompositeService.h | 86 + .../core/src/tuscany/sca/model/Contract.cpp | 47 + .../runtime/core/src/tuscany/sca/model/Contract.h | 88 + .../core/src/tuscany/sca/model/Interface.cpp | 47 + .../runtime/core/src/tuscany/sca/model/Interface.h | 91 + .../core/src/tuscany/sca/model/ModelLoader.cpp | 1815 ++++++++++++++++++++ .../core/src/tuscany/sca/model/ModelLoader.h | 129 ++ .../core/src/tuscany/sca/model/Reference.cpp | 72 + .../runtime/core/src/tuscany/sca/model/Reference.h | 129 ++ .../src/tuscany/sca/model/ReferenceBinding.cpp | 47 + .../core/src/tuscany/sca/model/ReferenceBinding.h | 95 + .../core/src/tuscany/sca/model/ReferenceType.cpp | 82 + .../core/src/tuscany/sca/model/ReferenceType.h | 139 ++ .../runtime/core/src/tuscany/sca/model/Service.cpp | 56 + .../runtime/core/src/tuscany/sca/model/Service.h | 103 ++ .../core/src/tuscany/sca/model/ServiceBinding.cpp | 47 + .../core/src/tuscany/sca/model/ServiceBinding.h | 89 + .../core/src/tuscany/sca/model/ServiceType.cpp | 58 + .../core/src/tuscany/sca/model/ServiceType.h | 109 ++ .../core/src/tuscany/sca/model/WSDLDefinition.cpp | 448 +++++ .../core/src/tuscany/sca/model/WSDLDefinition.h | 143 ++ .../core/src/tuscany/sca/model/WSDLInterface.cpp | 102 ++ .../core/src/tuscany/sca/model/WSDLInterface.h | 100 ++ .../core/src/tuscany/sca/model/WSDLOperation.cpp | 58 + .../core/src/tuscany/sca/model/WSDLOperation.h | 147 ++ .../runtime/core/src/tuscany/sca/model/Wire.cpp | 48 + .../sca/runtime/core/src/tuscany/sca/model/Wire.h | 95 + .../core/src/tuscany/sca/util/DefaultLogWriter.cpp | 45 + .../core/src/tuscany/sca/util/DefaultLogWriter.h | 48 + .../core/src/tuscany/sca/util/Exceptions.cpp | 213 +++ .../runtime/core/src/tuscany/sca/util/Exceptions.h | 190 ++ .../sca/runtime/core/src/tuscany/sca/util/File.cpp | 224 +++ .../sca/runtime/core/src/tuscany/sca/util/File.h | 135 ++ .../core/src/tuscany/sca/util/FileLogWriter.cpp | 51 + .../core/src/tuscany/sca/util/FileLogWriter.h | 55 + .../runtime/core/src/tuscany/sca/util/Library.cpp | 160 ++ .../runtime/core/src/tuscany/sca/util/Library.h | 99 ++ .../core/src/tuscany/sca/util/LogWriter.cpp | 34 + .../runtime/core/src/tuscany/sca/util/LogWriter.h | 49 + .../runtime/core/src/tuscany/sca/util/Logger.cpp | 109 ++ .../sca/runtime/core/src/tuscany/sca/util/Logger.h | 91 + .../runtime/core/src/tuscany/sca/util/Logging.h | 67 + .../runtime/core/src/tuscany/sca/util/Utils.cpp | 562 ++++++ .../sca/runtime/core/src/tuscany/sca/util/Utils.h | 69 + .../sca/runtime/core/test/Makefile.am | 2 + .../sca/runtime/extensions/Makefile.am | 27 + .../sca/runtime/extensions/cpp/Makefile.am | 7 + .../sca/runtime/extensions/cpp/deploy.bat | 74 + .../sca/runtime/extensions/cpp/src/Makefile.am | 31 + .../cpp/src/osoa/sca/ComponentContext.cpp | 139 ++ .../extensions/cpp/src/osoa/sca/ComponentContext.h | 114 ++ .../cpp/src/osoa/sca/CompositeContext.cpp | 113 ++ .../extensions/cpp/src/osoa/sca/CompositeContext.h | 98 ++ .../cpp/src/osoa/sca/ServiceRuntimeException.h | 101 ++ .../runtime/extensions/cpp/src/osoa/sca/export.h | 42 + .../sca/runtime/extensions/cpp/src/osoa/sca/sca.h | 31 + .../cpp/src/tuscany/sca/cpp/CPPExtension.cpp | 74 + .../cpp/src/tuscany/sca/cpp/CPPExtension.h | 57 + .../tuscany/sca/cpp/CPPImplementationExtension.cpp | 105 ++ .../tuscany/sca/cpp/CPPImplementationExtension.h | 72 + .../src/tuscany/sca/cpp/CPPInterfaceExtension.cpp | 74 + .../src/tuscany/sca/cpp/CPPInterfaceExtension.h | 72 + .../cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp | 193 +++ .../cpp/src/tuscany/sca/cpp/CPPServiceProxy.h | 116 ++ .../cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp | 198 +++ .../cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h | 162 ++ .../src/tuscany/sca/cpp/ComponentContextImpl.cpp | 163 ++ .../cpp/src/tuscany/sca/cpp/ComponentContextImpl.h | 123 ++ .../src/tuscany/sca/cpp/CompositeContextImpl.cpp | 106 ++ .../cpp/src/tuscany/sca/cpp/CompositeContextImpl.h | 93 + .../tuscany/sca/cpp/model/CPPImplementation.cpp | 82 + .../src/tuscany/sca/cpp/model/CPPImplementation.h | 150 ++ .../cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp | 62 + .../cpp/src/tuscany/sca/cpp/model/CPPInterface.h | 121 ++ .../tuscany/sca/cpp/model/CPPReferenceBinding.cpp | 59 + .../tuscany/sca/cpp/model/CPPReferenceBinding.h | 99 ++ .../tuscany/sca/cpp/model/CPPServiceBinding.cpp | 52 + .../src/tuscany/sca/cpp/model/CPPServiceBinding.h | 81 + .../extensions/cpp/xsd/sca-implementation-cpp.xsd | 49 + .../extensions/cpp/xsd/sca-interface-cpp.xsd | 43 + .../sca/runtime/extensions/php/Makefile.am | 7 + .../sca/runtime/extensions/php/src/Makefile.am | 28 + .../php/src/osoa/sca/ServiceRuntimeException.h | 115 ++ .../runtime/extensions/php/src/osoa/sca/export.h | 42 + .../php/src/tuscany/sca/php/PHPExtension.cpp | 73 + .../php/src/tuscany/sca/php/PHPExtension.h | 57 + .../tuscany/sca/php/PHPImplementationExtension.cpp | 78 + .../tuscany/sca/php/PHPImplementationExtension.h | 72 + .../php/src/tuscany/sca/php/PHPServiceWrapper.cpp | 405 +++++ .../php/src/tuscany/sca/php/PHPServiceWrapper.h | 110 ++ .../tuscany/sca/php/model/PHPImplementation.cpp | 87 + .../src/tuscany/sca/php/model/PHPImplementation.h | 98 ++ .../tuscany/sca/php/model/PHPServiceBinding.cpp | 58 + .../src/tuscany/sca/php/model/PHPServiceBinding.h | 81 + .../extensions/php/xsd/sca-implementation-php.xsd | 39 + .../sca/runtime/extensions/python/Makefile.am | 7 + .../sca/runtime/extensions/python/deploy.bat | 84 + .../sca/runtime/extensions/python/src/Makefile.am | 41 + .../src/tuscany/sca/python/PythonExtension.cpp | 75 + .../src/tuscany/sca/python/PythonExtension.h | 57 + .../sca/python/PythonImplementationExtension.cpp | 91 + .../sca/python/PythonImplementationExtension.h | 73 + .../sca/python/PythonInterfaceExtension.cpp | 122 ++ .../tuscany/sca/python/PythonInterfaceExtension.h | 72 + .../src/tuscany/sca/python/PythonServiceProxy.cpp | 99 ++ .../src/tuscany/sca/python/PythonServiceProxy.h | 86 + .../sca/python/PythonServiceRuntimeException.h | 100 ++ .../tuscany/sca/python/PythonServiceWrapper.cpp | 950 ++++++++++ .../src/tuscany/sca/python/PythonServiceWrapper.h | 143 ++ .../python/src/tuscany/sca/python/export.h | 41 + .../sca/python/model/PythonImplementation.cpp | 87 + .../sca/python/model/PythonImplementation.h | 129 ++ .../tuscany/sca/python/model/PythonInterface.cpp | 52 + .../src/tuscany/sca/python/model/PythonInterface.h | 84 + .../sca/python/model/PythonReferenceBinding.cpp | 59 + .../sca/python/model/PythonReferenceBinding.h | 95 + .../sca/python/model/PythonServiceBinding.cpp | 58 + .../sca/python/model/PythonServiceBinding.h | 82 + .../python/src/tuscany/sca/python/sca_module.cpp | 380 ++++ .../python/src/tuscany/sca/python/sca_proxy.py | 56 + .../python/src/tuscany/sca/python/sca_setup.py | 60 + .../python/xsd/sca-implementation-python.xsd | 49 + .../extensions/python/xsd/sca-interface-python.xsd | 62 + .../sca/runtime/extensions/ruby/Makefile.am | 7 + .../sca/runtime/extensions/ruby/deploy.bat | 71 + .../sca/runtime/extensions/ruby/src/Makefile.am | 31 + .../extensions/ruby/src/tuscany/sca/ruby/Ruby.h | 39 + .../src/tuscany/sca/ruby/RubyCompositeContext.cpp | 77 + .../ruby/src/tuscany/sca/ruby/RubyExtension.cpp | 72 + .../ruby/src/tuscany/sca/ruby/RubyExtension.h | 58 + .../sca/ruby/RubyImplementationExtension.cpp | 79 + .../tuscany/sca/ruby/RubyImplementationExtension.h | 72 + .../ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp | 374 ++++ .../ruby/src/tuscany/sca/ruby/RubyServiceProxy.h | 117 ++ .../src/tuscany/sca/ruby/RubyServiceWrapper.cpp | 724 ++++++++ .../ruby/src/tuscany/sca/ruby/RubyServiceWrapper.h | 96 ++ .../extensions/ruby/src/tuscany/sca/ruby/export.h | 38 + .../tuscany/sca/ruby/model/RubyImplementation.cpp | 154 ++ .../tuscany/sca/ruby/model/RubyImplementation.h | 140 ++ .../sca/ruby/model/RubyReferenceBinding.cpp | 59 + .../tuscany/sca/ruby/model/RubyReferenceBinding.h | 96 ++ .../tuscany/sca/ruby/model/RubyServiceBinding.cpp | 52 + .../tuscany/sca/ruby/model/RubyServiceBinding.h | 78 + .../ruby/xsd/sca-implementation-ruby.xsd | 39 + .../sca/runtime/extensions/sca/Makefile.am | 6 + .../runtime/extensions/sca/reference/Makefile.am | 1 + .../extensions/sca/reference/axis2c/Makefile.am | 1 + .../sca/reference/axis2c/src/Makefile.am | 21 + .../sca/binding/SCAServiceBindingExtension.cpp | 97 ++ .../sca/binding/SCAServiceBindingExtension.h | 74 + .../sca/binding/model/SCAServiceBinding.cpp | 46 + .../tuscany/sca/binding/model/SCAServiceBinding.h | 72 + .../sca/runtime/extensions/sca/service/Makefile.am | 1 + .../extensions/sca/service/axis2c/Makefile.am | 1 + .../extensions/sca/service/axis2c/src/Makefile.am | 21 + .../sca/binding/SCAReferenceBindingExtension.cpp | 97 ++ .../sca/binding/SCAReferenceBindingExtension.h | 74 + .../sca/binding/model/SCAReferenceBinding.cpp | 47 + .../sca/binding/model/SCAReferenceBinding.h | 71 + .../runtime/extensions/sca/xsd/sca-binding-sca.xsd | 37 + .../sca/runtime/extensions/ws/Makefile.am | 6 + .../sca/runtime/extensions/ws/deploy.bat | 45 + .../runtime/extensions/ws/reference/Makefile.am | 1 + .../extensions/ws/reference/axis2c/Makefile.am | 1 + .../extensions/ws/reference/axis2c/src/Makefile.am | 32 + .../axis2c/src/tuscany/sca/ws/Axis2Client.cpp | 704 ++++++++ .../axis2c/src/tuscany/sca/ws/Axis2Client.h | 67 + .../tuscany/sca/ws/WSServiceBindingExtension.cpp | 108 ++ .../src/tuscany/sca/ws/WSServiceBindingExtension.h | 75 + .../axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp | 110 ++ .../axis2c/src/tuscany/sca/ws/WSServiceWrapper.h | 67 + .../src/tuscany/sca/ws/model/WSServiceBinding.cpp | 134 ++ .../src/tuscany/sca/ws/model/WSServiceBinding.h | 137 ++ .../sca/runtime/extensions/ws/reference/deploy.bat | 65 + .../sca/runtime/extensions/ws/service/Makefile.am | 1 + .../extensions/ws/service/axis2c/Makefile.am | 1 + .../extensions/ws/service/axis2c/src/Makefile.am | 71 + .../extensions/ws/service/axis2c/src/axis2.xml | 181 ++ .../extensions/ws/service/axis2c/src/deploy.cmd | 39 + .../extensions/ws/service/axis2c/src/deploy.sh | 47 + .../extensions/ws/service/axis2c/src/module.xml | 25 + .../extensions/ws/service/axis2c/src/services.xml | 25 + .../axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp | 176 ++ .../src/tuscany/sca/ws/Axis2DispatcherModule.cpp | 149 ++ .../axis2c/src/tuscany/sca/ws/Axis2Service.cpp | 506 ++++++ .../axis2c/src/tuscany/sca/ws/Axis2Utils.cpp | 72 + .../service/axis2c/src/tuscany/sca/ws/Axis2Utils.h | 46 + .../tuscany/sca/ws/WSReferenceBindingExtension.cpp | 108 ++ .../tuscany/sca/ws/WSReferenceBindingExtension.h | 74 + .../axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp | 578 +++++++ .../axis2c/src/tuscany/sca/ws/WSServiceProxy.h | 96 ++ .../tuscany/sca/ws/model/WSReferenceBinding.cpp | 139 ++ .../src/tuscany/sca/ws/model/WSReferenceBinding.h | 153 ++ .../sca/runtime/extensions/ws/service/deploy.bat | 73 + .../runtime/extensions/ws/service/deploymodule.bat | 69 + .../extensions/ws/xsd/sca-binding-webservice.xsd | 55 + 230 files changed, 25860 insertions(+) create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/deploy.bat create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/Operation.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/Operation.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/export.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Binding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Binding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Component.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Component.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ComponentType.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ComponentType.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Composite.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Composite.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeReference.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeReference.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeService.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeService.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Contract.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Contract.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Interface.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Interface.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Reference.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Reference.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceType.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceType.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Service.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Service.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceType.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceType.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLDefinition.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLDefinition.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLInterface.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLInterface.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLOperation.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLOperation.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Wire.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Wire.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Exceptions.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Exceptions.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/File.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/File.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Library.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Library.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/LogWriter.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logger.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logger.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logging.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Utils.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Utils.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/test/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/deploy.bat create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/export.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/sca.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/osoa/sca/ServiceRuntimeException.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/osoa/sca/export.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/xsd/sca-implementation-php.xsd create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/deploy.bat create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceRuntimeException.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/export.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_setup.py create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/xsd/sca-implementation-python.xsd create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/xsd/sca-interface-python.xsd create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/deploy.bat create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/Ruby.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/export.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/xsd/sca-implementation-ruby.xsd create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/model/SCAServiceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/model/SCAServiceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/model/SCAReferenceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/model/SCAReferenceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/xsd/sca-binding-sca.xsd create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/deploy.bat create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/deploy.bat create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/axis2.xml create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/deploy.cmd create mode 100755 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/deploy.sh create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/module.xml create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/services.xml create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/deploy.bat create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/deploymodule.bat create mode 100644 tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/xsd/sca-binding-webservice.xsd (limited to 'tags/cpp-1.0-incubating-M2-RC1/sca/runtime') diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/Makefile.am new file mode 100644 index 0000000000..9eebb44c40 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = core extensions diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/Makefile.am new file mode 100644 index 0000000000..af437a64d6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/deploy.bat b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/deploy.bat new file mode 100644 index 0000000000..178ffb7b39 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 +:end + +endlocal diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/Makefile.am new file mode 100644 index 0000000000..00a26b8683 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/Makefile.am @@ -0,0 +1,57 @@ +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/Operation.cpp \ +tuscany/sca/core/SCARuntime.cpp \ +tuscany/sca/core/ServiceProxy.cpp \ +tuscany/sca/core/ServiceWrapper.cpp \ +tuscany/sca/core/TuscanyRuntime.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/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/Exceptions.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/Utils.cpp + +libtuscany_sca_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include + +AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG + \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/Operation.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/Operation.cpp new file mode 100644 index 0000000000..aa030a1ce7 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/Operation.cpp @@ -0,0 +1,372 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/Operation.h" +#include + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/core/SCARuntime.h" + + +namespace tuscany +{ + namespace sca + { + // =========== + // Constructor + // =========== + Operation::Operation(const char* operationName) + { + LOGENTRY(1,"Operation::constructor"); + + if (operationName != 0) + { + name = operationName; + } + + LOGEXIT(1,"Operation::constructor"); + } + + // ========== + // Destructor + // ========== + Operation::~Operation() + { + LOGENTRY(1,"Operation::destructor"); + clean(); + LOGEXIT(1,"Operation::destructor"); + } + + // ========== + // Copy Constructor + // ========== + Operation::Operation(const Operation& op) + { + LOGENTRY(1,"Operation::copy contructor"); + copy(op); + LOGEXIT(1,"Operation::copy contructor"); + } + + // ========== + // operator= + // ========== + Operation& Operation::operator=(const Operation& op) + { + LOGENTRY(1,"Operation::operator="); + if (&op != this) + { + copy(op); + } + LOGEXIT(1,"Operation::operator="); + return *this; + } + + // ========== + // Clean + // ========== + void Operation::clean() + { + LOGENTRY(1,"Operation::clean"); + 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(); + } + + LOGEXIT(1,"Operation::clean"); + } + + // ========== + // Copy + // ========== + void Operation::copy(const Operation& op) + { + LOGENTRY(1,"Operation::copy"); + 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; + } + + LOGEXIT(1,"Operation::copy"); + } + + // ============================================== + // getParameter: return parameter at position pos + // ============================================== + void* Operation::getParameterValue(unsigned int pos) const + { + if (pos < parameters.size()) + { + return parameters[pos].getValue(); + } + + return 0; + } + + // ============================================== + // getParameter: return of parameter + // ============================================== + const Operation::Parameter& Operation::getParameter(unsigned int pos) const + { + if (pos < parameters.size()) + { + return parameters[pos]; + } + + throw "index out of range"; + } + + + // ============================================== + // getParameterType: return type of parameter + // ============================================== + Operation::ParameterType Operation::getParameterType(unsigned int pos) const + { + if (pos < parameters.size()) + { + return parameters[pos].getType(); + } + + return VOID_TYPE; + } + + // =========================================== + // addParameter: set parameter at position pos + // =========================================== + void Operation::addParameter(const void *parm) + { + LOGINFO(4, "Operation::addParameter(void*)"); + parameters.insert(parameters.end(), Parameter((void*)parm, VOID_TYPE)); + } + + void Operation::addParameter(const bool *parm) + { + LOGINFO(4, "Operation::addParameter(bool)"); + parameters.insert(parameters.end(), Parameter((void*)parm, BOOL)); + } + + void Operation::addParameter(const short *parm) + { + LOGINFO(4, "Operation::addParameter(short)"); + parameters.insert(parameters.end(), Parameter((void*)parm, SHORT)); + } + + void Operation::addParameter(const int *parm) + { + LOGINFO(4, "Operation::addParameter(int)"); + parameters.insert(parameters.end(), Parameter((void*)parm, INT)); + } + + void Operation::addParameter(const long *parm) + { + LOGINFO(4, "Operation::addParameter(long)"); + parameters.insert(parameters.end(), Parameter((void*)parm, LONG)); + } + + void Operation::addParameter(const unsigned short *parm) + { + LOGINFO(4, "Operation::addParameter(unsigned short)"); + parameters.insert(parameters.end(), Parameter((void*)parm, USHORT)); + } + + void Operation::addParameter(const unsigned int *parm) + { + LOGINFO(4, "Operation::addParameter(unsigned int)"); + parameters.insert(parameters.end(), Parameter((void*)parm, UINT)); + } + + void Operation::addParameter(const unsigned long *parm) + { + LOGINFO(4, "Operation::addParameter(unsigned long)"); + parameters.insert(parameters.end(), Parameter((void*)parm, ULONG)); + } + + void Operation::addParameter(const float *parm) + { + LOGINFO(4, "Operation::addParameter(float)"); + parameters.insert(parameters.end(), Parameter((void*)parm, FLOAT)); + } + + void Operation::addParameter(const double *parm) + { + LOGINFO(4, "Operation::addParameter(double)"); + parameters.insert(parameters.end(), Parameter((void*)parm, DOUBLE)); + } + + void Operation::addParameter(const long double *parm) + { + LOGINFO(4, "Operation::addParameter(long double)"); + parameters.insert(parameters.end(), Parameter((void*)parm, LONGDOUBLE)); + } + + void Operation::addParameter(const char* *parm) + { + LOGINFO(4, "Operation::addParameter(char*)"); + parameters.insert(parameters.end(), Parameter((void*)parm, CHARS)); + } + + void Operation::addParameter(const char *parm) + { + LOGINFO(4, "Operation::addParameter(char)"); + parameters.insert(parameters.end(), Parameter((void*)parm, CHAR)); + } + + void Operation::addParameter(const string *parm) + { + LOGINFO(4, "Operation::addParameter(string)"); + parameters.insert(parameters.end(), Parameter((void*)parm, STRING)); + } + + void Operation::addParameter(const DataObjectPtr *parm) + { + LOGINFO(4, "Operation::addParameter(DataObjectPtr)"); + parameters.insert(parameters.end(), Parameter((void*)new DataObjectPtr(*parm), DATAOBJECT)); + } + + Operation::Parameter::Parameter(void* val, Operation::ParameterType typ) + : value(val), type(typ) + { + } + + // =========================================== + // setReturnValue + // =========================================== + void Operation::setReturnValue(const void *parm) + { + LOGINFO(4, "Operation::setReturnValue(void*)"); + returnValue = Parameter((void*)parm, VOID_TYPE); + } + + void Operation::setReturnValue(const bool *parm) + { + LOGINFO(4, "Operation::setReturnValue(bool*)"); + returnValue = Parameter((void*)parm, BOOL); + } + + void Operation::setReturnValue(const short *parm) + { + LOGINFO(4, "Operation::setReturnValue(short*)"); + returnValue = Parameter((void*)parm, SHORT); + } + + void Operation::setReturnValue(const int *parm) + { + LOGINFO(4, "Operation::setReturnValue(int)"); + returnValue = Parameter((void*)parm, INT); + } + + void Operation::setReturnValue(const long *parm) + { + LOGINFO(4, "Operation::setReturnValue(long*)"); + returnValue = Parameter((void*)parm, LONG); + } + + void Operation::setReturnValue(const unsigned short *parm) + { + LOGINFO(4, "Operation::setReturnValue(unsigned short*)"); + returnValue = Parameter((void*)parm, USHORT); + } + + void Operation::setReturnValue(const unsigned int *parm) + { + LOGINFO(4, "Operation::setReturnValue(unsigned int)"); + returnValue = Parameter((void*)parm, UINT); + } + + void Operation::setReturnValue(const unsigned long *parm) + { + LOGINFO(4, "Operation::setReturnValue(unsigned long*)"); + returnValue = Parameter((void*)parm, ULONG); + } + + void Operation::setReturnValue(const float *parm) + { + LOGINFO(4, "Operation::setReturnValue(float*)"); + returnValue = Parameter((void*)parm, FLOAT); + } + + void Operation::setReturnValue(const double *parm) + { + LOGINFO(4, "Operation::setReturnValue(double*)"); + returnValue = Parameter((void*)parm, DOUBLE); + } + + void Operation::setReturnValue(const long double *parm) + { + LOGINFO(4, "Operation::setReturnValue(long double*)"); + returnValue = Parameter((void*)parm, LONGDOUBLE); + } + + void Operation::setReturnValue(const char *parm) + { + LOGINFO(4, "Operation::setReturnValue(char)"); + returnValue = Parameter((void*)parm, CHAR); + } + + void Operation::setReturnValue(const char* *parm) + { + LOGINFO(4, "Operation::setReturnValue(char*)"); + returnValue = Parameter((void*)parm, CHARS); + } + + void Operation::setReturnValue(const string *parm) + { + LOGINFO(4, "Operation::setReturnValue(string*)"); + returnValue = Parameter((void*)parm, STRING); + } + + void Operation::setReturnValue(const DataObjectPtr *parm) + { + LOGINFO(4, "Operation::setReturnValue(DataObjectPtr*)"); + returnValue = Parameter((void*)new DataObjectPtr(*parm), DATAOBJECT); + } + + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/Operation.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/Operation.h new file mode 100644 index 0000000000..84338ae9e8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/Operation.h @@ -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$ */ + +#ifndef tuscany_sca_core_operation_h +#define tuscany_sca_core_operation_h +#include "tuscany/sca/export.h" +#include "commonj/sdo/SDO.h" +using commonj::sdo::DataObjectPtr; +#include +using std::string; +#include +using std::vector; + +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 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); + SCA_API void* getValue() const {return value;} + SCA_API ParameterType getType() const {return type;} + + private: + 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 string *retVal); + SCA_API void setReturnValue(const DataObjectPtr *retVal); + + /** + * Set a parameter on the operation. + * @param pos The position of the parameter in the parameter list. + * @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 string *parm); + SCA_API void addParameter(const 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 type 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 ParameterType getParameterType(unsigned int pos) const; + + /** + * 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 void* getParameterValue(unsigned int pos) const; + + SCA_API ParameterType getReturnType() const {return returnValue.getType();} + SCA_API void* getReturnValue() const {return returnValue.getValue();} + + private: + /** + * Operation name (method name). + */ + string name; + + /** + * Array of parameters. + */ + typedef std::vector 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp new file mode 100644 index 0000000000..49ec646bb1 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp @@ -0,0 +1,487 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/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/util/Exceptions.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/Component.h" + +#if defined(WIN32) || defined (_WINDOWS) +#include +#endif + +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"; + + // ========================================================== + // Initialize static class member to not pointing at anything + // ========================================================== + SCARuntime* SCARuntime::instance = 0; + string SCARuntime::systemRoot = ""; + string SCARuntime::systemPath = ""; + string SCARuntime::defaultComponentName = ""; + + + // ========================================================== + // Set the system configuration root + // ========================================================== + void SCARuntime::setSystemRoot(const string& root) + { + LOGENTRY(1, "SCARuntime::setSystemRoot"); + systemRoot = root; + LOGINFO_1(3, "SCARuntime::setSystemRoot - set to %s", root.c_str()); + LOGEXIT(1, "SCARuntime::setSystemRoot"); + } + + // ========================================================== + // Set the system configuration root + // ========================================================== + void SCARuntime::setSystemPath(const string& path) + { + LOGENTRY(1, "SCARuntime::setSystemPath"); + systemPath = path; + LOGINFO_1(3, "SCARuntime::setSystemPath - set to %s", path.c_str()); + LOGEXIT(1, "SCARuntime::setSystemPath"); + } + + // ========================================================== + // Set the default component name + // ========================================================== + void SCARuntime::setDefaultComponentName(const string& componentName) + { + LOGENTRY(1, "SCARuntime::setDefaultComponentName"); + defaultComponentName = componentName; + LOGINFO_1(3, "SCARuntime::setDefaultComponentName - set to %s", componentName.c_str()); + LOGEXIT(1, "SCARuntime::setDefaultComponentName"); + } + + // =================================================================== + // Constructor for the SCARuntime class. This will be a singleton that + // holds all the information about the current runtime. + // =================================================================== + SCARuntime::SCARuntime() : system(0), defaultComponent(0) + { + LOGENTRY(1, "SCARuntime::constructor"); + + // Locate the SCA install root + char* root = 0; + root = getenv(TUSCANY_SCACPP); + if (root == 0) + { + string msg = TUSCANY_SCACPP; + msg += " environment variable not set"; + throw SystemConfigurationException(msg.c_str()); + } + else + { + SCARoot = root; + } + + LOGEXIT(1, "SCARuntime::constructor"); + } + + // =================================================================== + // Destructor for the SCARuntime class. + // =================================================================== + SCARuntime::~SCARuntime() + { + LOGENTRY(1, "SCARuntime::destructor"); + + if (system) + { + delete system; + } + + LOGEXIT(1, "SCARuntime::destructor"); + } + + // ============================================================= + // Get the instance of the runtime, creates it if does not exist + // static method + // ============================================================= + SCARuntime* SCARuntime::getInstance() + { + LOGENTRY(1, "SCARuntime::getInstance"); + + if (instance == NULL) + { + instance = new SCARuntime(); + + // load extensions + instance->loadExtensions(); + + 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"; + throw SystemConfigurationException(msg.c_str()); + } + + systemRoot = systemRootEnv; + } + if (systemPath == "") + { + + // Get system path from environment variable TUSCANY_SCACPP_PATH + char* systemPathEnv = getenv(TUSCANY_SCACPP_PATH); + if (systemPathEnv == 0) + { + // Make the path optional for now +// string msg = TUSCANY_SCACPP_PATH; +// msg += " environment variable not set"; +// throw SystemConfigurationException(msg.c_str()); + } + else + { + systemPath = systemPathEnv; + } + } + } + + LOGEXIT(1, "SCARuntime::getInstance"); + + return instance; + + } + + + // ============================================================= + // Release the instance of the runtime. + // ============================================================= + void SCARuntime::releaseInstance() + { + LOGENTRY(1, "SCARuntime::releaseInstance"); + + if (instance) + { + delete instance; + instance = 0; + systemRoot = ""; + systemPath = ""; + defaultComponentName = ""; + } + + LOGEXIT(1, "SCARuntime::releaseInstance"); + } + + // ====================================== + // Load up all the details of the runtime + // ====================================== + void SCARuntime::load() + { + LOGENTRY(1, "SCARuntime::load"); + + LOGINFO_1(2,"configuration root: %s", systemRoot.c_str()); + LOGINFO_1(2,"configuration path: %s", systemPath.c_str()); + + // Load the system composite + ModelLoader loader(system); + loader.load(systemRoot, systemPath); + + LOGEXIT(1, "SCARuntime::load"); + } + + + // ====================================== + // Load up extensions to the runtime + // ====================================== + void SCARuntime::loadExtensions() + { + LOGENTRY(1, "SCARuntime::loadExtensions"); + + string extensionsRoot = SCARoot + "/extensions"; + +#if defined(WIN32) || defined (_WINDOWS) + string pattern = "*.dll"; +#else + string pattern = "*.so"; +#endif + + Files files(extensionsRoot, pattern, true); + for (unsigned int i=0; i < files.size(); i++) + { + try + { + Library lib = Library( files[i].getDirectory() + "/" + files[i].getFileName()); + extensionsList.push_back(lib); + TUSCANY_IMPLEMENTATION_EXTENSION_INITIALIZE extension = + (TUSCANY_IMPLEMENTATION_EXTENSION_INITIALIZE)lib.getSymbol("tuscany_sca_extension_initialize"); + if (extension) + { + extension(); + } + } + catch (TuscanyRuntimeException& ex) + { + LOGERROR_3(0, "SCARuntime::loadExtensions failed to load extension library: %s: %s: %s", + files[i].getFileName().c_str(), ex.getEClassName(), ex.getMessageText()); + } + } + + LOGEXIT(1, "SCARuntime::loadExtensions"); + } + + + // ====================================== + // register an interfaceExtension + // ====================================== + void SCARuntime::registerInterfaceExtension(InterfaceExtension* extension) + { + LOGENTRY(1, "SCARuntime::registerInterfaceExtension"); + if (extension) + { + interfaceExtensions[extension->getExtensionTypeQName()] = extension; + } + LOGEXIT(1, "SCARuntime::registerInterfaceExtension"); + } + + // ====================================== + // find an InterfaceExtension + // ====================================== + InterfaceExtension* SCARuntime::getInterfaceExtension(const string& extensionTypeQName) + { + return interfaceExtensions[extensionTypeQName]; + } + + // ====================================== + // register an implementationExtension + // ====================================== + void SCARuntime::registerImplementationExtension(ImplementationExtension* extension) + { + LOGENTRY(1, "SCARuntime::registerImplementationExtension"); + if (extension) + { + implementationExtensions[extension->getExtensionTypeQName()] = extension; + } + LOGEXIT(1, "SCARuntime::registerImplementationExtension"); + } + + // ====================================== + // find an implementationExtension + // ====================================== + ImplementationExtension* SCARuntime::getImplementationExtension(const string& extensionTypeQName) + { + return implementationExtensions[extensionTypeQName]; + } + + // ====================================== + // register a referenceBindingExtension + // ====================================== + void SCARuntime::registerReferenceBindingExtension(ReferenceBindingExtension* extension) + { + LOGENTRY(1, "SCARuntime::registerReferenceBindingExtension"); + if (extension) + { + referenceBindingExtensions[extension->getExtensionTypeQName()] = extension; + } + LOGEXIT(1, "SCARuntime::registerReferenceBindingExtension"); + } + + // ====================================== + // find a referenceBindingExtension + // ====================================== + ReferenceBindingExtension* SCARuntime::getReferenceBindingExtension(const string& extensionTypeQName) + { + return referenceBindingExtensions[extensionTypeQName]; + } + + // ====================================== + // register a serviceBindingExtension + // ====================================== + void SCARuntime::registerServiceBindingExtension(ServiceBindingExtension* extension) + { + LOGENTRY(1, "SCARuntime::registerServiceBindingExtension"); + if (extension) + { + serviceBindingExtensions[extension->getExtensionTypeQName()] = extension; + } + LOGEXIT(1, "SCARuntime::registerServiceBindingExtension"); + } + + // ====================================== + // find a serviceBindingExtension + // ====================================== + ServiceBindingExtension* SCARuntime::getServiceBindingExtension(const string& extensionTypeQName) + { + return serviceBindingExtensions[extensionTypeQName]; + } + + + // =================================== + // Return the top of the runtime model + // =================================== + Composite* SCARuntime::getSystem() + { + if (!system) + { + system = new Composite("tuscany/sca/system", ""); + load(); + } + return system; + } + + + // =================================================== + // setCurrentComponent: push component for this thread + // =================================================== + void SCARuntime::setCurrentComponent(Component* component) + { + +#if defined(WIN32) || defined (_WINDOWS) + DWORD currentThreadId = GetCurrentThreadId(); +#else + pthread_t currentThreadId = pthread_self(); +#endif + COMPONENTS_MAP::iterator iter = components.find(currentThreadId); + if (iter == components.end()) + { + components[currentThreadId] = COMPONENT_STACK(); + iter = components.find(currentThreadId); + } + + COMPONENT_STACK& compStack = iter->second; + compStack.push(component); + } + + + // ==================================================== + // unsetCurrentComponent: pop component for this thread + // ==================================================== + Component* SCARuntime::unsetCurrentComponent() + { +#if defined(WIN32) || defined (_WINDOWS) + DWORD currentThreadId = GetCurrentThreadId(); +#else + pthread_t currentThreadId = pthread_self(); +#endif + + COMPONENTS_MAP::iterator iter = components.find(currentThreadId); + if (iter != components.end()) + { + COMPONENT_STACK& compStack = iter->second; + if (compStack.size() > 0) + { + Component* component = compStack.top(); + compStack.pop(); + return component; + } + } + + return 0; + } + + // ============================================================= + // getCurrentComponent: return current component for this thread + // ============================================================= + Component* SCARuntime::getCurrentComponent() + { +#if defined(WIN32) || defined (_WINDOWS) + DWORD currentThreadId = GetCurrentThreadId(); +#else + pthread_t currentThreadId = pthread_self(); +#endif + + COMPONENTS_MAP::iterator iter = components.find(currentThreadId); + if (iter == components.end()) + { + components[currentThreadId] = COMPONENT_STACK(); + iter = components.find(currentThreadId); + } + + COMPONENT_STACK& compStack = iter->second; + if (compStack.size() > 0) + { + return compStack.top(); + } + else + { + return 0; + } + + } + + // =========================================== + // getCurrentCompositeComponent: return the current composite component + // =========================================== + Component* SCARuntime::getDefaultComponent() + { + + // ---------------------- + // Get the default Component + // ---------------------- + if (!defaultComponent) + { + // ------------------------------------------- + // Get the default component name from the environment + // ------------------------------------------- + if (defaultComponentName == "") + { + const char* defComp = getenv(TUSCANY_SCACPP_COMPONENT); + if (!defComp) + { + defComp = getenv(TUSCANY_SCACPP_DEFAULT_COMPONENT); + } + if (!defComp) + { + string message = TUSCANY_SCACPP_COMPONENT; + message += " environment variable not set"; + throw SystemConfigurationException(message.c_str()); + } + defaultComponentName = defComp; + } + + defaultComponent = getSystem()->findComponent(defaultComponentName); + if (!defaultComponent) + { + string message = "Component \'" + defaultComponentName + "\' not found"; + throw SystemConfigurationException(message.c_str()); + } + } + return defaultComponent; + } + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h new file mode 100644 index 0000000000..ef78296480 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h @@ -0,0 +1,262 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 + +#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" + +#if defined(WIN32) || defined (_WINDOWS) +#include +#else +#include +#endif + +#include +#include +#include +#include +using namespace std; + +using namespace tuscany::sca::model; + + +namespace tuscany +{ + namespace sca + { + + /** + * A singleton which represents the executing SCA runtime. + */ + class SCARuntime { + public: + + /** + * Get the single instance. + * @return The single instance of the runtime. + */ + SCA_API static SCARuntime* getInstance(); + + /** + * Release the single instance. + */ + SCA_API static void releaseInstance(); + + /** + * 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. + */ + SCA_API void load(); + + /** + * Set the system root + * @param root The path to the system configuration. + */ + static void setSystemRoot(const string& root); + + /** + * Set the search path for composites. + * @param path The search path for composites. + */ + static void setSystemPath(const string& path); + + /** + * Set the default Component for the system + * @param componentName The name of the default component. + */ + static void setDefaultComponentName(const string& componentName); + + /** + * Set the current component for the current thread. + * @param component The current component. + */ + SCA_API void setCurrentComponent(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 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 Composite* getSystem(); + + /** + * The directory in which the Tuscany runtime has been installed. + */ + SCA_API const string& getInstallRoot() {return SCARoot;} + + /** + * Return the current component for this thread. + * @return The current component for this thread. + */ + SCA_API Component* getCurrentComponent(); + + /** + * Get the default component set for this runtime. + * @return The default composite. + */ + SCA_API Component* getDefaultComponent(); + + /** + * Register an implementation extension + */ + SCA_API void registerImplementationExtension(ImplementationExtension* extension); + + /** + * Returns the implementation extension associated with + * the specified qname + */ + SCA_API ImplementationExtension* getImplementationExtension(const 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 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 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 string& typeQname); + + private: + /** + * Default constructor is private to prevent more than one instance. + */ + SCARuntime(); + + virtual ~SCARuntime(); + + /** + * The single instance of this class. + */ + static SCARuntime* instance; + + /** + * Pointer to the top of the runtime model. + */ + Composite* system; + + /** + * The installed path of the Tuscany runtime. + */ + string SCARoot; + + /** + * The path to the system configuration + */ + static string systemRoot; + + /** + * The search path for composites. + */ + static string systemPath; + + /** + * The default CompositeComponent. + */ + static string defaultComponentName; + + /** + * The default component set for this runtime. + */ + Component* defaultComponent; + + + typedef stack COMPONENT_STACK; +#if defined(WIN32) || defined (_WINDOWS) + typedef map COMPONENTS_MAP; +#else + typedef map COMPONENTS_MAP; +#endif + + /** + * A map of threads to components. + */ + COMPONENTS_MAP components; + + typedef map IMPLEMENTATION_EXTENSIONS_MAP; + IMPLEMENTATION_EXTENSIONS_MAP implementationExtensions; + + typedef map REFERENCE_BINDING_EXTENSIONS_MAP; + REFERENCE_BINDING_EXTENSIONS_MAP referenceBindingExtensions; + + typedef map SERVICE_BINDING_EXTENSIONS_MAP; + SERVICE_BINDING_EXTENSIONS_MAP serviceBindingExtensions; + + typedef map INTERFACE_EXTENSIONS_MAP; + INTERFACE_EXTENSIONS_MAP interfaceExtensions; + + // Runtime Extensions + void loadExtensions(); + + typedef list 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp new file mode 100644 index 0000000000..f835b53267 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.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/core/ServiceProxy.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Exceptions.h" + +namespace tuscany +{ + namespace sca + { + // ============================ + // Constructor: Create a proxy + // ============================ + ServiceProxy::ServiceProxy(Reference* reference) + : reference(reference) + { + LOGENTRY(1,"ServiceProxy::constructor"); + LOGEXIT(1,"ServiceProxy::constructor"); + + } + + // ========== + // Destructor + // ========== + ServiceProxy::~ServiceProxy() + { + LOGENTRY(1,"ServiceProxy::destructor"); + LOGEXIT(1,"ServiceProxy::destructor"); + } + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h new file mode 100644 index 0000000000..69af373062 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.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_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" +#include "tuscany/sca/core/ServiceWrapper.h" + +#include +using std::vector; + +using namespace tuscany::sca::model; + + +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(Reference* reference); + + /** + * Destructor. + */ + virtual ~ServiceProxy(); + + /** + * Returns the reference represented by this proxy. + * @return The Reference represented by this proxy. + */ + Reference* getReference() const { return reference; }; + + private: + + /** + * The reference represented by this proxy. + */ + Reference* reference; + + }; + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_core_serviceproxy_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp new file mode 100644 index 0000000000..51ee4f02b7 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +namespace tuscany +{ + namespace sca + { + + // =========== + // Constructor + // =========== + ServiceWrapper::ServiceWrapper(Service* service) + : service(service) + { + LOGENTRY(1,"ServiceWrapper::constructor"); + + LOGEXIT(1,"ServiceWrapper::constructor"); + + } + + // ========== + // Destructor + // ========== + ServiceWrapper::~ServiceWrapper() + { + LOGENTRY(1,"ServiceWrapper::destructor"); + LOGEXIT(1,"ServiceWrapper::destructor"); + } + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h new file mode 100644 index 0000000000..816e1d06f4 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.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_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" + +using namespace tuscany::sca::model; + + +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(Service* service); + + /** + * Destructor. + */ + virtual ~ServiceWrapper(); + + /** + * Get the service represented by this wrapper. + * @return The service represented by this wrapper. + */ + 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. + */ + Service* service; + + }; + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_core_servicewrapper_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp new file mode 100644 index 0000000000..5e6cd4a197 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/TuscanyRuntime.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/Exceptions.h" +#include "tuscany/sca/core/SCARuntime.h" + +namespace tuscany +{ + namespace sca + { + + // ========================================================== + // Set the system configuration root path + // ========================================================== + void TuscanyRuntime::setSystemRoot(const string& root) + { + LOGENTRY(1, "TuscanyRuntime::setSystemRoot"); + systemRoot = root; + LOGINFO_1(3, "TuscanyRuntime::setSystemRoot - set to %s", root.c_str()); + LOGEXIT(1, "TuscanyRuntime::setSystemRoot"); + } + + // ========================================================== + // Set the search path for composites + // ========================================================== + void TuscanyRuntime::setSystemPath(const string& path) + { + LOGENTRY(1, "TuscanyRuntime::setSystemPath"); + systemPath = path; + LOGINFO_1(3, "TuscanyRuntime::setSystemPath - set to %s", path.c_str()); + LOGEXIT(1, "TuscanyRuntime::setSystemPath"); + } + + // ========================================================== + // Set the default component name + // ========================================================== + void TuscanyRuntime::setDefaultComponentName(const string& componentName) + { + LOGENTRY(1, "TuscanyRuntime::setDefaultComponentName"); + defaultComponentName = componentName; + LOGINFO_1(3, "TuscanyRuntime::setDefaultComponentName - set to %s", componentName.c_str()); + LOGEXIT(1, "TuscanyRuntime::setDefaultComponentName"); + } + + // =================================================================== + // Constructor for the TuscanyRuntime class. + // =================================================================== + TuscanyRuntime::TuscanyRuntime(const string& componentName, const string& root, const string& path) + { + LOGENTRY(1, "TuscanyRuntime::constructor"); + setSystemRoot(root); + setSystemPath(path); + setDefaultComponentName(componentName); + LOGEXIT(1, "TuscanyRuntime::constructor"); + } + + // =================================================================== + // Destructor for the TuscanyRuntime class. + // =================================================================== + TuscanyRuntime::~TuscanyRuntime() + { + LOGENTRY(1, "TuscanyRuntime::destructor");; + LOGEXIT(1, "TuscanyRuntime::destructor"); + } + + // =================================================================== + // Start the runtime. + // =================================================================== + void TuscanyRuntime::start() + { + LOGENTRY(1, "TuscanyRuntime::start"); + SCARuntime::setSystemRoot(systemRoot); + SCARuntime::setSystemPath(systemPath); + SCARuntime::setDefaultComponentName(defaultComponentName); + SCARuntime::getInstance(); + LOGEXIT(1, "TuscanyRuntime::start"); + } + + // =================================================================== + // Stop the runtime. + // =================================================================== + void TuscanyRuntime::stop() + { + LOGENTRY(1, "TuscanyRuntime::stop"); + SCARuntime::releaseInstance(); + LOGEXIT(1, "TuscanyRuntime::stop"); + } + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h new file mode 100644 index 0000000000..f1ac59f357 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.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_core_tuscanyruntime_h +#define tuscany_sca_core_tuscanyruntime_h + +#include "tuscany/sca/export.h" +#include +using std::string; + +namespace tuscany +{ + namespace sca + { + + /** + * A singleton which represents the executing SCA runtime. + */ + class SCA_API TuscanyRuntime + { + public: + /** + * Default constructor + */ + TuscanyRuntime(const string& defaultComponentName = "", + const string& root = "", const string& path = ""); + + /** + * Destructor + */ + virtual ~TuscanyRuntime(); + + + /** + * Set the system root configuration path + * @param root The path to the system configuration. + */ + void setSystemRoot(const string& root); + + /** + * Set the system composite search path + * @param root The search path for composites. + */ + void setSystemPath(const string& path); + + /** + * Set the default component for the system + * @param componentName The name of the default component. + */ + void setDefaultComponentName(const string& componentName); + + /** + * start the runtime + */ + void start(); + + /** + * stop the runtime + */ + void stop(); + + + private: + string systemRoot; + string systemPath; + string defaultComponentName; + }; + + + } // End namespace sca +} // End namespace tuscany + + + + +#endif // tuscany_sca_core_tuscanyruntime_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/export.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/export.h new file mode 100644 index 0000000000..79b02fe4cf --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 +#include +#include +#define SCA_API +#endif + +#endif // tuscany_sca_export_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp new file mode 100644 index 0000000000..21eab40c72 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.cpp @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $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(1, "ImplementationExtension::constructor"); + LOGEXIT(1, "ImplementationExtension::constructor"); + } + + // =================================================================== + // Destructor for the ImplementationExtension class. + // =================================================================== + ImplementationExtension::~ImplementationExtension() + { + LOGENTRY(1, "ImplementationExtension::destructor");; + LOGEXIT(1, "ImplementationExtension::destructor"); + } + + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h new file mode 100644 index 0000000000..4744a5b14c --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.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_extension_implementationextension_h +#define tuscany_sca_extension_implementationextension_h + +#include "tuscany/sca/export.h" +#include +using std::string; + +#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 "commonj/sdo/SDO.h" + +using namespace tuscany::sca::model; + +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 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 string& getExtensionTypeQName() = 0; + + /** + * Get an implementation from a DataObject representing + * an SCDL implementation element + */ + virtual ComponentType* getImplementation(Composite* composite, commonj::sdo::DataObjectPtr scdlImplementation) = 0; + + }; + + + } // End namespace sca +} // End namespace tuscany + + +#endif // tuscany_sca_extension_implementationextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.cpp new file mode 100644 index 0000000000..f0cb0b1b2d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.cpp @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $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(1, "InterfaceExtension::constructor"); + LOGEXIT(1, "InterfaceExtension::constructor"); + } + + // =================================================================== + // Destructor for the InterfaceExtension class. + // =================================================================== + InterfaceExtension::~InterfaceExtension() + { + LOGENTRY(1, "InterfaceExtension::destructor");; + LOGEXIT(1, "InterfaceExtension::destructor"); + } + + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h new file mode 100644 index 0000000000..545eb92caa --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.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_interfaceextension_h +#define tuscany_sca_extension_interfaceextension_h + +#include "tuscany/sca/export.h" +#include +using std::string; + +#include "tuscany/sca/model/Interface.h" +#include "tuscany/sca/model/Composite.h" +#include "commonj/sdo/SDO.h" + +using namespace tuscany::sca::model; + +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 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 string& getExtensionTypeQName() = 0; + + /** + * Get an interface from a DataObject representing an + * SCDL interface + */ + virtual Interface* getInterface(Composite *composite, commonj::sdo::DataObjectPtr scdlInterface) = 0; + + }; + + + } // End namespace sca +} // End namespace tuscany + + +#endif // tuscany_sca_extension_interfaceextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.cpp new file mode 100644 index 0000000000..9797cb33a9 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.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/ReferenceBindingExtension.h" +#include "tuscany/sca/util/Logging.h" +namespace tuscany +{ + namespace sca + { + // =================================================================== + // Constructor for the ReferenceBindingExtension class. + // =================================================================== + ReferenceBindingExtension::ReferenceBindingExtension() + { + LOGENTRY(1, "ReferenceBindingExtension::constructor"); + LOGEXIT(1, "ReferenceBindingExtension::constructor"); + } + + // =================================================================== + // Destructor for the ReferenceBindingExtension class. + // =================================================================== + ReferenceBindingExtension::~ReferenceBindingExtension() + { + LOGENTRY(1, "ReferenceBindingExtension::destructor");; + LOGEXIT(1, "ReferenceBindingExtension::destructor"); + } + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ReferenceBindingExtension.h new file mode 100644 index 0000000000..1af89e6c5a --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 "tuscany/sca/export.h" + +#include +using std::string; + +#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" + +#include "commonj/sdo/SDO.h" + +using namespace tuscany::sca::model; + +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 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 string& getExtensionTypeQName() = 0; + + /** + * Get a reference binding from a DataObject representing + * an SCDL binding element + */ + virtual ReferenceBinding* getReferenceBinding(Composite* composite, Reference* reference, commonj::sdo::DataObjectPtr scdlBinding) = 0; + + }; + + + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_referencebindingextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.cpp new file mode 100644 index 0000000000..9ffb4d10d1 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.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/ServiceBindingExtension.h" +#include "tuscany/sca/util/Logging.h" +namespace tuscany +{ + namespace sca + { + // =================================================================== + // Constructor for the ServiceBindingExtension class. + // =================================================================== + ServiceBindingExtension::ServiceBindingExtension() + { + LOGENTRY(1, "ServiceBindingExtension::constructor"); + LOGEXIT(1, "ServiceBindingExtension::constructor"); + } + + // =================================================================== + // Destructor for the ServiceBindingExtension class. + // =================================================================== + ServiceBindingExtension::~ServiceBindingExtension() + { + LOGENTRY(1, "ServiceBindingExtension::destructor");; + LOGEXIT(1, "ServiceBindingExtension::destructor"); + } + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.h new file mode 100644 index 0000000000..9d65a7441a --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/extension/ServiceBindingExtension.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_extension_servicebindingextension_h +#define tuscany_sca_extension_servicebindingextension_h + +#include "tuscany/sca/export.h" +#include +using std::string; + +#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" + +#include "commonj/sdo/SDO.h" + +using namespace tuscany::sca::model; + +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 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 string& getExtensionTypeQName() = 0; + + /** + * Get a reference binding from a DataObject representing + * an SCDL binding element + */ + virtual ServiceBinding* getServiceBinding(Composite* composite, Service* service, commonj::sdo::DataObjectPtr scdlBinding) = 0; + + }; + + + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_servicebindingextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Binding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Binding.cpp new file mode 100644 index 0000000000..af7aa2ff6f --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Binding.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/util/Logging.h" +#include "tuscany/sca/model/Binding.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + Binding::Binding(const string& uri) : uri(uri) + { + } + + // Destructor + Binding::~Binding() + { + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Binding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Binding.h new file mode 100644 index 0000000000..b68529020d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 +using std::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 string& uri); + + /** + * Destructor. + */ + SCA_API virtual ~Binding(); + + /** + * Returns the binding type + * @return The binding type. + */ + SCA_API virtual string getType() = 0; + + /** + * Returns the binding URI. + * @return The binding URI. + */ + SCA_API const string& getURI() const { return uri; }; + + private: + + /** + * The binding URI. + */ + string uri; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_binding_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Component.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Component.cpp new file mode 100644 index 0000000000..905d8c3555 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Component.cpp @@ -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$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/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 commonj::sdo; +#include +using namespace std; +namespace tuscany +{ + namespace sca + { + namespace model + { + // Constructor + Component::Component(Composite* composite, const std::string& componentName, ComponentType *componentType) + : name(componentName), composite(composite), type(componentType) + { + LOGENTRY(1, "Component::constructor"); + LOGINFO_1(3, "Component::constructor: Component name: %s", name.c_str()); + + // Initialize the component from its component type + componentType->initializeComponent(this); + + LOGEXIT(1, "Component::constructor"); + } + + Component::~Component() + { + } + + void Component::addService(Service* service) + { + services[service->getType()->getName()] = service; + } + + Service* Component::findService(const string& serviceName) + { + // 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) + { + references[reference->getType()->getName()] = reference; + } + + Reference* Component::findReference(const std::string& referenceName) + { + return references[referenceName]; + } + + DataObjectPtr Component::getProperties() + { + if (!properties) + { + properties = type->getPropertyDataFactory()->create("org/osoa/sca", "Properties"); + } + return properties; + } + + void Component::setProperty(const string& name, DataObjectPtr value) + { + //cout << "setting property: " << name.c_str() << " to: " << value <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 (SDOPropertyNotFoundException&) + { + // Configuration error: property is not defined + string message = "Undefined property: " + name; + throw SystemConfigurationException(message.c_str()); + } + + //cout << "properties set: " << props << endl; + + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Component.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Component.h new file mode 100644 index 0000000000..dc34b03a57 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Component.h @@ -0,0 +1,184 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "tuscany/sca/export.h" +#include +using std::string; + +#include + +#include "commonj/sdo/SDO.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 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 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 string& referenceName); + + /** + * Returns all the services defined on this component. + * @return All the services defined on this component. + */ + typedef std::map 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 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 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 DataObjectPtr getProperties(); + + private: + + /** + * Name of the component. + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ComponentType.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ComponentType.cpp new file mode 100644 index 0000000000..a69364d7c4 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ComponentType.cpp @@ -0,0 +1,261 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/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" + +#include + +using namespace commonj::sdo; +using namespace std; + +namespace tuscany +{ + namespace sca + { + namespace model + { + + // Constructor + ComponentType::ComponentType(Composite* composite, const string& name) + : composite(composite), name(name) + { + LOGENTRY(1, "ComponentType::constructor"); + LOGEXIT(1, "ComponentType::constructor"); + } + + // Destructor + ComponentType::~ComponentType() + { + } + + void ComponentType::addServiceType(ServiceType* serviceType) + { + serviceTypes[serviceType->getName()] = serviceType; + } + + ServiceType* ComponentType::findServiceType(const string& serviceName) + { + // 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) + { + referenceTypes[referenceType->getName()] = referenceType; + } + + ReferenceType* ComponentType::findReferenceType(const string& referenceName) + { + return referenceTypes[referenceName]; + } + + void ComponentType::addPropertyType(const string& name, + const string& type, + bool many, + DataObjectPtr* defaultValue) + { + // 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&) + { + // cout << "setting default failed" <addType("org/osoa/sca", "Properties", false, false, false, false); + } + return propertyFactory; + } + + void ComponentType::initializeComponent(Component* component) + { + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ComponentType.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ComponentType.h new file mode 100644 index 0000000000..18e78ffedf --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ComponentType.h @@ -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$ */ + +#ifndef tuscany_sca_model_componenttype_h +#define tuscany_sca_model_componenttype_h + +#include +using std::string; + +#include + +#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 string& name); + + /** + * Destructor. + */ + SCA_API virtual ~ComponentType(); + + /** + * Returns the name of the component type + */ + SCA_API const 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 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 string& referenceName); + + /** + * Returns the service types defined on this component. + * @return The service types defined on this component. + */ + typedef std::map 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 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 string& name, + const string& type, + bool many, + commonj::sdo::DataObjectPtr* defaultValue); + + /** + * 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 + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Composite.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Composite.cpp new file mode 100644 index 0000000000..7b7fbcbdda --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Composite.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 "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/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" + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + Composite::Composite(const string& name, const string& root) + : ComponentType(0, name), root(root) + { + LOGENTRY(1, "Composite::constructor"); + LOGEXIT(1, "Composite::constructor"); + } + + // Destructor + Composite::~Composite() + { + } + + void Composite::addComponent(Component* component) + { + LOGENTRY(1, "Composite::addComponent"); + components[component->getName()] = component; + LOGEXIT(1, "Composite::addComponent"); + } + + Component* Composite::findComponent(const std::string& name) + { + LOGENTRY(1, "Composite::findComponent"); + Component* component = components[name]; + LOGEXIT(1, "Composite::findComponent"); + return component; + } + + Service* Composite::findComponentService(const std::string& name) + { + LOGENTRY(1, "Composite::findComponentService"); + + 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); + } + LOGEXIT(1, "Composite::findComponentService"); + return service; + } + + void Composite::addWire(const std::string& source, const std::string& target) + { + LOGENTRY(1, "Composite::addWire"); + Wire* wire=new Wire(source, target); + wires.push_back(wire); + LOGEXIT(1, "Composite::addWire"); + } + + void Composite::addInclude(Composite* composite) + { + LOGENTRY(1, "Composite::addInclude"); + includes.push_back(composite); + + for (COMPONENT_MAP::iterator iter = composite->components.begin(); + iter != composite->components.end(); + iter++) + { + components[iter->first] = iter->second; + } + LOGEXIT(1, "Composite::addInclude"); + } + + void Composite::resolveWires() + { + LOGENTRY(1, "Composite::resolveWires"); + + for (WIRES::iterator iter = wires.begin(); + iter != wires.end(); + iter++) + { + Wire* wire = *iter; + + // Locate the target + Service* service = findComponentService(wire->getTarget()); + if (!service) + { + LOGERROR_1(0, "Composite::resolveWires: Wire target %s not found", wire->getTarget().c_str()); + } + else + { + Component* component = findComponent(wire->getSourceComponent()); + if (component) + { + Reference* reference = component->findReference(wire->getSourceReference()); + if (reference) + { + + // Configure the binding on the reference from the binding on the target + // service + reference->getBinding()->configure(service->getBinding()); + } + else + { + LOGERROR_1(0, "Composite::resolveWires: Wire source reference %s not found", wire->getSourceReference().c_str()); + } + } + else + { + LOGERROR_1(0, "Composite::resolveWires: Wire source %s not found", wire->getSourceComponent().c_str()); + } + } + } + + LOGEXIT(1, "Composite::resolveWires"); + } + + void Composite::addWSDLDefinition(commonj::sdo::DataObjectPtr wsdlModel) + { + LOGENTRY(1, "Composite::addWSDLDefinition"); + WSDLDefinition* wsdlDefinition = new WSDLDefinition(wsdlModel); + wsdlDefinitions[wsdlDefinition->getNamespace()] = wsdlDefinition; + LOGEXIT(1, "Composite::addWSDLDefinition"); + + } + + WSDLDefinition* Composite::findWSDLDefinition(const std::string& wsdlNamespace ) + { + return wsdlDefinitions[wsdlNamespace]; + + } + + commonj::sdo::XSDHelperPtr Composite::getXSDHelper() + { + if (xsdHelper == 0) + { + xsdHelper = commonj::sdo::HelperProvider::getXSDHelper(); + } + + return xsdHelper; + } + + commonj::sdo::XMLHelperPtr Composite::getXMLHelper() + { + if (xmlHelper == 0) + { + xmlHelper = commonj::sdo::HelperProvider::getXMLHelper(getXSDHelper()->getDataFactory()); + } + + return xmlHelper; + } + + commonj::sdo::DataFactoryPtr Composite::getDataFactory() + { + return getXSDHelper()->getDataFactory(); + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Composite.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Composite.h new file mode 100644 index 0000000000..3e9fdfa832 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Composite.h @@ -0,0 +1,199 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "tuscany/sca/export.h" +#include +using std::string; + +#include +using std::map; +#include +using std::vector; + +#include "commonj/sdo/SDO.h" + +#include "tuscany/sca/model/ComponentType.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + class Component; + class ComponentType; + 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 string& name, const 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 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/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 string& source, const 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 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 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 string& wsdlNamespace); + + /** + * 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. + */ + 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 map COMPONENT_MAP; + COMPONENT_MAP components; + + /** + * Vector of all the composites included in this composite. + */ + typedef vector INCLUDES; + INCLUDES includes; + + /** + * Vector of all the wires in this composite. + */ + typedef vector WIRES; + WIRES wires; + + /** + * Map by namespace of all the wsdl definitions in this composite. + */ + typedef map WSDL_MAP; + WSDL_MAP wsdlDefinitions; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_composite_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeReference.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeReference.cpp new file mode 100644 index 0000000000..e3ef4b05f4 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeReference.cpp @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +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(1, "CompositeReference::constructor"); + LOGINFO_1(2, "CompositeReference::constructor: CompositeReference 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); + + LOGEXIT(1, "CompositeReference::constructor"); + } + + // Destructor + CompositeReference::~CompositeReference() + { + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeReference.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeReference.h new file mode 100644 index 0000000000..aa2ed12e7f --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeReference.h @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 + +#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 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; }; + + private: + + /** + * The service exposed by this composite reference. + */ + Service* service; + + }; + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_compositereferencetype_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeService.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeService.cpp new file mode 100644 index 0000000000..691091449e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeService.cpp @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +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(1, "CompositeService::constructor"); + LOGINFO_1(2, "CompositeService::constructor: CompositeService 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); + + LOGEXIT(1, "CompositeService::constructor"); + } + + // Destructor + CompositeService::~CompositeService() + { + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeService.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeService.h new file mode 100644 index 0000000000..c0c185676a --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/CompositeService.h @@ -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$ */ + +#ifndef tuscany_sca_model_compositeservicetype_h +#define tuscany_sca_model_compositeservicetype_h + +#include +using std::string; +#include +using std::vector; + +#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 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Contract.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Contract.cpp new file mode 100644 index 0000000000..c9d8f017c7 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Contract.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/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) + { + } + + // Destructor + Contract::~Contract() + { + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Contract.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Contract.h new file mode 100644 index 0000000000..da533f4887 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Contract.h @@ -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$ */ + +#ifndef tuscany_sca_model_contract_h +#define tuscany_sca_model_contract_h + +#include +using std::string; + +#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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Interface.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Interface.cpp new file mode 100644 index 0000000000..bbc6c79bc6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Interface.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/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) + { + } + + Interface::~Interface() + { + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Interface.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Interface.h new file mode 100644 index 0000000000..f02476745e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Interface.h @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 + +using namespace std; + +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 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp new file mode 100644 index 0000000000..fe83807af4 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp @@ -0,0 +1,1815 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/export.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/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 "commonj/sdo/TypeDefinitions.h" +#include "tuscany/sca/util/File.h" + + +using namespace commonj::sdo; + + +#if defined(WIN32) || defined (_WINDOWS) +#define PATH_SEPARATOR ";" +#else +#define PATH_SEPARATOR ":" +#endif + +namespace tuscany +{ + namespace sca + { + + namespace model + { + // =========== + // Constructor + // =========== + ModelLoader::ModelLoader(Composite* system) : system(system) + { + LOGENTRY(1, "ModelLoader::constructor"); + + runtime = SCARuntime::getInstance(); + + LOGEXIT(1, "ModelLoader::constructor"); + } + + // ========== + // Destructor + // ========== + ModelLoader::~ModelLoader() + { + } + + // ========================================================= + // 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(1, "ModelLoader::load"); + LOGINFO_1(2,"system root: %s", systemRoot.c_str()); + LOGINFO_1(2,"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(); + + LOGEXIT(1, "ModelLoader::load"); + } + + // ======================================================================== + // 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) + { + // Get all the composite files on the system root path + // These composites are included in the system composite + LOGENTRY(1, "ModelLoader::loadSystem"); + for (string path = systemRoot; path != ""; ) + { + string dir; + Utils::tokeniseString(PATH_SEPARATOR, path, dir, path); + if (dir != "") + { + LOGINFO_1(2, "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 + } + } + } + } + LOGEXIT(1, "ModelLoader::loadSystem"); + } + + // ===================================================================== + // 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) + { + // Get all the composite files on the composite search path + LOGENTRY(1, "ModelLoader::loadComposites"); + for (string path = searchPath; path != ""; ) + { + string dir; + Utils::tokeniseString(PATH_SEPARATOR, path, dir, path); + if (dir != "") + { + LOGINFO_1(2, "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); + } + + LOGEXIT(1, "ModelLoader::loadComposites"); + } + + // ==================================================================== + // 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(1, "ModelLoader::loadCompositeFile"); + LOGINFO_1(2, "composite filename: %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_1(0, "ModelLoader::loadCompositeFile: 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_1(0, "ModelLoader::loadCompositeFile: Exception caught: %s", ex.getMessageText()); + } + + LOGEXIT(1, "ModelLoader::loadCompositeFile"); + return composite; + } + + // =========== + // mapCompositePass1 + // =========== + Composite* ModelLoader::mapCompositePass1(const File& file, DataObjectPtr root) + { + LOGENTRY(1, "ModelLoader::mapCompositePass1"); + + const string& compositeRootDir = file.getDirectory(); + const string compositeName = root->getCString("name"); + LOGINFO_2(2, "ModelLoader::mapCompositePass1: Loading composite: %s, root Dir: %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 (int i = 0; i < compositeServiceList.size(); i++) + { + addCompositeService(composite, compositeServiceList[i]); + } + + // ----------------- + // Composite references + // ----------------- + DataObjectList& compositeReferenceList = root->getList("reference"); + for (int cri = 0; cri < compositeReferenceList.size(); cri++) + { + addCompositeReference(composite, compositeReferenceList[cri]); + } + + // ----- + // Wires + // ----- + DataObjectList& wireList = root->getList("wire"); + for (int l = 0; l < wireList.size(); l++) + { + string source = wireList[l]->getCString("source"); + string target = wireList[l]->getCString("target"); + composite->addWire(source, target); + } + + LOGEXIT(1, "ModelLoader::mapCompositePass1"); + return composite; + } + + // =========== + // mapCompositePass2 + // =========== + Composite* ModelLoader::mapCompositePass2(const string& compositeName, DataObjectPtr root) + { + LOGENTRY(1, "ModelLoader::mapCompositePass2"); + + LOGINFO_1(2, "ModelLoader::mapCompositePass2: Loading composite: %s", compositeName.c_str()); + + Composite* composite = compositeModels[compositeName]; + + // ---------------------------- + // Add components to the composite + // ---------------------------- + DataObjectList& componentList = root->getList("component"); + int i; + for (i=0; i < componentList.size(); i++) + { + addComponent(composite, componentList[i]); + } + + // Resolve all the wires inside the composite + composite->resolveWires(); + + LOGEXIT(1, "ModelLoader::mapCompositePass2"); + return composite; + } + + // ================================= + // addComponent: + // ================================= + void ModelLoader::addComponent(Composite* composite, DataObjectPtr componentDO) + { + // ------------------- + // Get the component implementation + // ------------------- + DataObjectPtr impl = componentDO->getDataObject("implementation"); + if (!impl) + { + string message = "No implementation for component: "; + message = message + componentDO->getCString("name"); + throw 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"); + throw 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 + LOGINFO_1(0, "ModelLoader::addComponent: 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_2(0, "ModelLoader::addComponent (%s): Exception caught: %s", + typeFileName.c_str(), ex.getMessageText()); + throw SystemConfigurationException(ex.getMessageText()); + } + } + } + else + { + LOGERROR_1(0, "ModelLoader::addComponent: Unsupported implementation type: %s", implTypeQname.c_str()); + + string message = "Implementation type not supported: "; + message = message + implTypeQname; + throw SystemConfigurationException(message.c_str()); + } + } + + // First check that references exist, some component types + // will create all used references automatically + DataObjectList& refs = componentDO->getList("reference"); + for (int i=0; igetCString("name"); + if (!componentType->findReferenceType(refName)) + { + // Configuration error: reference is not defined + string message = "Undefined reference: " + refName; + throw SystemConfigurationException(message.c_str()); + } + } + + // Create the component + Component* component = new Component(composite, componentDO->getCString("name"), componentType); + composite->addComponent(component); + + // ---------- + // Properties + // ---------- + DataObjectList& props = componentDO->getList("property"); + for (int pi=0; pigetCString("name"); + DataObjectPtr propValue = props[pi]->getDataObject("value"); + + component->setProperty(propName, propValue); + } + + // ---------- + // References + // ---------- + for (int ri=0; rigetCString("name"); + if (!component->findReference(refName)) + { + // Configuration error: reference is not defined + string message = "Undefined reference: " + refName; + throw 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) + { + DataObjectList& serviceTypes = componentTypeDO->getList("service"); + for (int i=0; igetCString("name"), iface, NULL); + componentType->addServiceType(serviceType); + } + } + + // =================================================== + // addReferenceTypes: add the references to the component type + // =================================================== + void ModelLoader::addReferenceTypes(Composite* composite, ComponentType* componentType, DataObjectPtr componentTypeDO) + { + DataObjectList& refs = componentTypeDO->getList("reference"); + for (int i=0; iisSet("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) + { + // ----------------- + // get the interface + // ----------------- + DataObjectPtr iface = obj->getDataObject("interface"); + if (!iface) + { + string message = "No interface for: "; + message = message + obj->getCString("name"); + throw 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_1(1, "ModelLoader::getInterface: Unsupported interface type: %s", typeQname.c_str()); + return 0; + } + } + + } + + // ============================================== + // addProperties: add properties to the component type + // ============================================== + void ModelLoader::addPropertyTypes(ComponentType* componentType, DataObjectPtr componentTypeDO) + { + DataObjectList& props = componentTypeDO->getList("property"); + for (int i=0; igetCString("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) + { + + //Utils::printDO(compositeServiceDO); + 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->addComponent(compositeService); + + DataObjectList& refs = compositeServiceDO->getList("reference"); + for (int i=0; iaddWire(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"); + throw SystemConfigurationException(message.c_str()); + } + DataObjectPtr binding = bindings[0]; + + // Utils::printDO(binding); + + // 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_1(0, "ModelLoader::addCompositeService: Unsupported binding type: %s", bindingTypeQname.c_str()); + + string message = "Binding type not supported: "; + message = message + bindingTypeQname; + throw SystemConfigurationException(message.c_str()); + } + } + + + // ========================================================= + // addCompositeReference: add a CompositeReference to the composite + // ========================================================= + void ModelLoader::addCompositeReference(Composite* composite, DataObjectPtr compositeReferenceDO) + { + 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->addComponent(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"); + throw SystemConfigurationException(message.c_str()); + } + DataObjectPtr binding = bindings[0]; + + //Utils::printDO(binding); + + // 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_1(0, "ModelLoader::addCompositeReference: Unsupported binding type: %s", bindingTypeQname.c_str()); + + string message = "Binding type not supported: "; + message = message + bindingTypeQname; + throw 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(1, "ModelLoader::loadTypeMetadata"); + + // 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_1(0, "ModelLoader::loadTypeMetadata: Unable to load file: %s", filename.c_str()); + } + else + { + LOGINFO_2(2, "ModelLoader::loadTypeMetadata: Loading composite config for: %s, root Dir: %s", composite->getName().c_str(), compositeRootDir.c_str()); + + if(compositeConfigFile->getRootDataObject()->isSet("xsd")) + { + DataObjectList& xsds = compositeConfigFile->getRootDataObject()->getList("xsd/file"); + + for (int i=0; iisSet("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 (int j=0; jisSet("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()); + } + } + + LOGEXIT(1, "ModelLoader::loadTypeMetadata"); + } + + + /// + /// Use the types from an xsd or wsdl file + /// + void ModelLoader::loadXMLSchema(Composite* composite, const char *fileName) + { + LOGENTRY(1, "ModelLoader::loadXMLSchema"); + + // Load a xsd file -> set the types in the data factory associated with + // the composite + try { + composite->getXSDHelper()->defineFile(fileName); + //Utils::printTypes((*compositeIter)->getXSDHelper()->getDataFactory()); + + } catch (SDOTypeNotFoundException ex) + { + LOGERROR_1(0, "ModelLoader: Exception caught: %s", ex.getMessageText()); + throw ex; + } + LOGEXIT(1, "ModelLoader::loadXMLSchema"); + } + + /// + /// Load the web services definition from a wsdl + /// + void ModelLoader::loadWSDLDefinition(Composite* composite, const char *fileName) + { + LOGENTRY(1, "ModelLoader::loadWSDLDefinition"); + + 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_1(0, "ModelLoader: Unable to load or parse WSDL %s", fileName); + } + + } catch (SDOTypeNotFoundException ex) + { + LOGERROR_1(0, "ModelLoader: SDOTypeNotFoundException caught: %s", ex.getMessageText()); + throw ex; + } + catch (SDONullPointerException ex) + { + LOGERROR_1(0, "ModelLoader: SDONullPointerException caught: %s", ex.getMessageText()); + throw ex; + } + LOGEXIT(1, "ModelLoader::loadWSDLDefinition"); + + } + + ////////////////////////////////////////////////////////////////////////////// + // Methods used to load the model into memory + ////////////////////////////////////////////////////////////////////////////// + + /// + /// Get an XSDHelper that has the appropriate XSDs already loaded + /// + const XSDHelperPtr ModelLoader::getXSDHelper() + { + if (myXSDHelper == 0) + { + + // Create an xsd helper + myXSDHelper = HelperProvider::getXSDHelper(); + + try { + + // Load the Assembly model schema + string root = SCARuntime::getInstance()->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 (SDOTypeNotFoundException ex) + { + LOGERROR_1(0, "ModelLoader: Exception caught: %s", ex.getMessageText()); + throw ex; + } + } + + //cout << myXSDHelper->getDataFactory(); + + return myXSDHelper; + } + + + /// + /// Get an XMLHelper to load files + /// + const XMLHelperPtr ModelLoader::getXMLHelper() + { + if (myXMLHelper == 0) { + + // Create an xml helper + myXMLHelper = HelperProvider::getXMLHelper(getXSDHelper()->getDataFactory()); + + } + + return myXMLHelper; + } + + void ModelLoader::initializeWSDLModel(XSDHelperPtr xsdHelper) + { + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h new file mode 100644 index 0000000000..d0374e61d6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "tuscany/sca/export.h" +#include "commonj/sdo/SDO.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" + +#include +using std::map; + +using commonj::sdo::DataObjectPtr; +using commonj::sdo::XSDHelperPtr; +using namespace tuscany::sca; + + +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(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 string& systemRoot, const string& systemPath); + + private: + void loadSystem(const string& systemRoot); + + void loadComposites(const string& searchPath); + Composite* loadCompositeFile(const File& file); + Composite* mapCompositePass1(const File& file, DataObjectPtr rootDO); + Composite* mapCompositePass2(const string& compositeName, DataObjectPtr rootDO); + + void addComponent(Composite* composite, DataObjectPtr componentDO); + void addCompositeService(Composite* composite, DataObjectPtr compositeServiceDO); + void addCompositeReference(Composite* composite, DataObjectPtr referenceServiceDO); + + void addServiceTypes(Composite* composite, ComponentType* componentType, DataObjectPtr componentTypeDO); + void addReferenceTypes(Composite* composite, ComponentType* componentType, DataObjectPtr componentTypeDO); + void addPropertyTypes(ComponentType* componentType, DataObjectPtr componentTypeDO); + + void loadTypeMetadata(const string &compositeRootDir, Composite* composite); + + void loadXMLSchema(Composite* composite, const char *fileName); + void loadWSDLDefinition(Composite* composite, const char *fileName); + void initializeWSDLModel(XSDHelperPtr xsdHelper); + + Interface* getInterface(Composite* composite, 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 map COMPOSITE_MODELS; + COMPOSITE_MODELS compositeModels; + + typedef map COMPOSITE_DATAOBJECTS; + COMPOSITE_DATAOBJECTS compositeDataObjects; + + typedef map COMPOSITE_FILES; + COMPOSITE_FILES compositeFiles; + + }; + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_modelloader_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Reference.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Reference.cpp new file mode 100644 index 0000000000..98084c6261 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Reference.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/util/Logging.h" +#include "tuscany/sca/util/Exceptions.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/model/ReferenceType.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + + // Constructor + Reference::Reference(Component* component, ReferenceType* referenceType) + : component(component), type(referenceType), binding(0) + { + } + + // Destructor + Reference::~Reference() + { + } + + void Reference::setBinding(ReferenceBinding* binding) + { + this->binding = binding; + } + + ReferenceBinding* Reference::getBinding() const + { + return binding; + } + + void Reference::addTarget(Service* target) + { + if (type->getMultiplicity() == ReferenceType::ONE_ONE || type->getMultiplicity() == ReferenceType::ZERO_ONE) + { + if (targets.size() > 0) + { + // throw exception + string message = "Duplicate wire for reference: " + type->getName(); + throw SystemConfigurationException(message.c_str()); + } + } + + targets.push_back(target); + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Reference.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Reference.h new file mode 100644 index 0000000000..b58ca54b4a --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Reference.h @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 +using std::string; +#include +using std::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 vector 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp new file mode 100644 index 0000000000..e18f8f3461 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.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/util/Logging.h" +#include "tuscany/sca/model/ReferenceBinding.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + ReferenceBinding::ReferenceBinding(Reference *reference, const string& uri) : + Binding(uri), reference(reference) + { + } + + // Destructor + ReferenceBinding::~ReferenceBinding() + { + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h new file mode 100644 index 0000000000..259d088a26 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.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_model_referencebinding_h +#define tuscany_sca_model_referencebinding_h +#include +using std::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 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; + + /** + * 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceType.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceType.cpp new file mode 100644 index 0000000000..cc9b40ca5b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceType.cpp @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/Exceptions.h" +#include "tuscany/sca/model/ReferenceType.h" + +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) + { + } + + ReferenceType::~ReferenceType() + { + } + + ReferenceType::Multiplicity ReferenceType::getMultiplicityFromString(const string& multip) + { + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceType.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceType.h new file mode 100644 index 0000000000..a9d6adc0eb --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ReferenceType.h @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 +using std::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 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 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 string& multip); + + private: + + /** + * The component type on which this reference is defined. + */ + ComponentType *componentType; + + /** + * The name of the reference type. + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Service.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Service.cpp new file mode 100644 index 0000000000..83a2858248 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Service.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$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/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) + { + } + + // Destructor + Service::~Service() + { + } + + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Service.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Service.h new file mode 100644 index 0000000000..bd632b7a3b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Service.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_model_service_h +#define tuscany_sca_model_service_h + +#include +using std::string; + +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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp new file mode 100644 index 0000000000..b8f1aabb2c --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.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/util/Logging.h" +#include "tuscany/sca/model/ServiceBinding.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + ServiceBinding::ServiceBinding(Service* service, const string& uri) : + Binding(uri), service(service) + { + } + + // Destructor + ServiceBinding::~ServiceBinding() + { + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.h new file mode 100644 index 0000000000..feaa989505 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 +using std::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 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceType.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceType.cpp new file mode 100644 index 0000000000..40ecca2ceb --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceType.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/model/ServiceType.h" + +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) + { + } + + // Destructor + ServiceType::~ServiceType() + { + } + + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceType.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceType.h new file mode 100644 index 0000000000..7b6dd4b97f --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/ServiceType.h @@ -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$ */ + +#ifndef tuscany_sca_model_servicetype_h +#define tuscany_sca_model_servicetype_h + +#include +using std::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 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 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. + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLDefinition.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLDefinition.cpp new file mode 100644 index 0000000000..ac7bf0306b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLDefinition.cpp @@ -0,0 +1,448 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/util/Exceptions.h" + +using namespace tuscany::sca; + +using namespace commonj::sdo; + +namespace tuscany +{ + namespace sca + { + namespace model + { + + + // Constructor + WSDLDefinition::WSDLDefinition(DataObjectPtr wsdlModel) + : wsdlModel(wsdlModel) + { + LOGENTRY(1, "WSDLDefinition::constructor"); + + // Trace + //Utils::printDO(wsdlModel); + + LOGEXIT(1, "WSDLDefinition::constructor"); + } + + WSDLDefinition::~WSDLDefinition() + { + } + + + /// + /// The namespace of the service and other definitions defined in this wsdl definition + string WSDLDefinition::getNamespace() + { + return wsdlModel->getCString("targetNamespace"); + } + + /// + /// Find the operation defined in this wsdl + /// + const WSDLOperation& WSDLDefinition::findOperation(const string& serviceName, + const string& portName, + const string& operationName) + { + string message; + + string operationKey = serviceName+"#"+portName+"#"+operationName; + OperationMap::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"; + throw SystemConfigurationException(message.c_str()); + } + else + { + + + // Found the service + DataObjectList& portList = service->getList("port"); + for (int j=0; jgetCString("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"; + throw 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 (int i=0; igetCString("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"; + throw SystemConfigurationException(message.c_str()); + } + + //Utils::printDO(wsPortType); + + // Found the portType, find the operation + DataObjectList& operationList = wsPortType->getList("operation"); + for (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"; + throw 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"; + throw 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"; + throw SystemConfigurationException(message.c_str()); + } + } + // cannot find the port + message = "Unable to find port "; + message = message + portName; + message = message + " in the WSDL definition"; + throw SystemConfigurationException(message.c_str()); + } + + } + + /// + /// Find the operation defined in this wsdl + /// + const WSDLOperation& WSDLDefinition::findOperation(const string& portTypeName, + const string& operationName) + { + string operationKey = portTypeName+"#"+operationName; + OperationMap::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"; + throw SystemConfigurationException(message.c_str()); + } + + //Utils::printDO(wsPortType); + + // Found the portType, find the operation + DataObjectList& operationList = wsPortType->getList("operation"); + for (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"; + throw 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"; + throw 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"; + throw SystemConfigurationException(message.c_str()); + + } + + /// + /// Find a service + /// + DataObjectPtr WSDLDefinition::findService(const string& serviceName) + { + DataObjectPtr service = 0; + + + // Find the binding + DataObjectList& serviceList = wsdlModel->getList("service"); + for (int i=0; igetCString("name")); + + if (name.compare(serviceName) == 0) + { + return serviceList[i]; + } + } + + return service; + } + + + /// + /// Find a named binding + /// + DataObjectPtr WSDLDefinition::findBinding(const string& bindingName) + { + DataObjectPtr binding = 0; + string uri; + string name; + + + //Utils::tokeniseQName(bindingName, uri, name); + Utils::rTokeniseString(":", bindingName, uri, name); + + + // Find the binding + DataObjectList& bindingList = wsdlModel->getList("binding"); + for (int i=0; igetCString("name")); + + if (nameBinding.compare(name) == 0) + { + return bindingList[i]; + } + } + + return binding; + } + + /// + /// Find a named portType + /// + DataObjectPtr WSDLDefinition::findPortType(const string& portTypeName) + { + DataObjectPtr portType = 0; + string uri; + string name; + + + // Utils::tokeniseQName(portTypeName, uri, name); + Utils::rTokeniseString(":", portTypeName, uri, name); + + + // Find the binding + DataObjectList& portTypeList = wsdlModel->getList("portType"); + for (int i=0; igetCString("name")); + + if (namePortType.compare(name) == 0) + { + return portTypeList[i]; + } + } + + return portType; + } + + /// + /// Find a named message + /// + DataObjectPtr WSDLDefinition::findMessage(const string& messageName) + { + DataObjectPtr message = 0; + string uri; + string name; + + + // Utils::tokeniseQName(messageName, uri, name); + Utils::rTokeniseString(":", messageName, uri, name); + + + // Find the binding + DataObjectList& messageList = wsdlModel->getList("message"); + for (int i=0; igetCString("name")); + + if (nameMessage.compare(name) == 0) + { + return messageList[i]; + } + } + + return message; + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLDefinition.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLDefinition.h new file mode 100644 index 0000000000..1f07294dcb --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLDefinition.h @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "tuscany/sca/model/WSDLOperation.h" + +#include "tuscany/sca/export.h" +#include +using std::string; + +#include "commonj/sdo/SDO.h" +using commonj::sdo::DataObjectPtr; + +#include +using std::map; + +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(DataObjectPtr wsdlModel); + + /** + * Destructor. + */ + SCA_API virtual ~WSDLDefinition(); + + + /** + * Returns the target namespace of the WSDL definitions. + * @return The target namespace. + */ + SCA_API string getNamespace(void); + + /** + * 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 string& serviceName, + const string& portName, + const 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 string& portTypeName, + const 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. + */ + DataObjectPtr findService(const 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. + */ + DataObjectPtr findBinding(const 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. + */ + DataObjectPtr findPortType(const 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. + */ + DataObjectPtr findMessage(const string& messageName); + + + /** + * The data object representation of the WSDL document. + */ + DataObjectPtr wsdlModel; + + typedef map OperationMap; + OperationMap operationMap; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_wsdldefinition_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLInterface.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLInterface.cpp new file mode 100644 index 0000000000..1b7aed525c --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLInterface.cpp @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + + +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) + { + parse(qname); + } + + void WSDLInterface::parse(const string& qname) + { + // PortType is of the form: #wsdl.interface() + 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() + { + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLInterface.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLInterface.h new file mode 100644 index 0000000000..e59453e3f2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLInterface.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_wsdlinterface_h +#define tuscany_sca_model_wsdlinterface_h + +#include "tuscany/sca/model/Interface.h" + +#include +using std::string; + +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 string& qname, bool remotable, bool conversational); + + /** + * Destructor. + */ + virtual ~WSDLInterface(); + + /** + * Returns the WSDL namespace + */ + string getNamespaceURI() const { return namespaceURI; } + + /** + * Returns the interface name + */ + 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 string& getInterfaceTypeQName() { return typeQName; }; + + /** + * The QName of the schema type for this interface type. + */ + SCA_API static const string typeQName; + + private: + + /** + * Parse the WSDL qname + */ + void parse(const string& qname); + + /** + * WSDL namespace. + */ + string namespaceURI; + + /** + * Name of the WSDL interface. + */ + string name; + + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_wsdlinterface_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLOperation.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLOperation.cpp new file mode 100644 index 0000000000..264286caf3 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLOperation.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/model/WSDLOperation.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + + + // Constructor + WSDLOperation::WSDLOperation() + { + LOGENTRY(1, "WSDLOperation::constructor"); + LOGEXIT(1, "WSDLOperation::constructor"); + } + + WSDLOperation::~WSDLOperation() + { + } + + + void WSDLOperation::setInputType(const string& inputType) + { + Utils::tokeniseQName(inputType, inputTypeUri, inputTypeName); + } + + void WSDLOperation::setOutputType(const string& outputType) + { + Utils::tokeniseQName(outputType, outputTypeUri, outputTypeName); + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLOperation.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/WSDLOperation.h new file mode 100644 index 0000000000..371c67a6da --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 "tuscany/sca/export.h" +#include +using std::string; + + +#include "commonj/sdo/SDO.h" +using commonj::sdo::DataObjectPtr; + +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 string& getOperationName() const {return operationName;} + SCA_API void setOperationName(const string& opName) {operationName = opName;} + + /** + * The soap action string for this operation. + * @return The soap action. + */ + SCA_API const string& getSoapAction() const {return soapAction;} + SCA_API void setSoapAction(const string& soapAct) {soapAction = soapAct;} + + /** + * Return the endpoint address for the target web service. + * @return The endpoint address. + */ + SCA_API const string& getEndpoint() const {return endpoint;} + SCA_API void setEndpoint(const 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 string& inputType); + SCA_API const string& getInputTypeUri() const {return inputTypeUri;} + SCA_API const string& getInputTypeName() const {return inputTypeName;} + SCA_API void setOutputType(const string& outputType); + SCA_API const string& getOutputTypeUri() const {return outputTypeUri;} + SCA_API const string& getOutputTypeName() const {return outputTypeName;} + + private: + /** + * The name of the operation for use when serializing an + * outgoing message. + */ + string operationName; + + /** + * The soap action string for this operation. + */ + string soapAction; + + /** + * The endpoint address of the target web service. + */ + string endpoint; + + bool documentStyle; + bool wrappedStyle; + bool encoded; + soapVersion soapVer; + + string inputTypeUri; + string inputTypeName; + + string outputTypeUri; + string outputTypeName; + + DataObjectPtr inputMessage; + DataObjectPtr outputMessage; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_wsdloperation_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Wire.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Wire.cpp new file mode 100644 index 0000000000..77caae53a2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Wire.cpp @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/model/Wire.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + + // Constructor + Wire::Wire(const std::string& source, const std::string& targ) + { + Utils::tokeniseUri(source, sourceComponent, sourceReference); + target = targ; + } + + Wire::~Wire() + { + } + + } // End namespace model + + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Wire.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Wire.h new file mode 100644 index 0000000000..707ac5da0e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/model/Wire.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_model_wire_h +#define tuscany_sca_model_wire_h + +#include +using std::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 string& source, const 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 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 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 string& getTarget() { return target; } + + private: + /** + * The source component of the wire. + */ + string sourceComponent; + + /** + * The source reference of the wire. + */ + string sourceReference; + + /** + * The target uri of the wire. + */ + string target; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_wire_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp new file mode 100644 index 0000000000..7b0b535523 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp @@ -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. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/DefaultLogWriter.h" +#include +using namespace std; + +namespace tuscany +{ + namespace sca + { + DefaultLogWriter::~DefaultLogWriter() + { + } + + void DefaultLogWriter::log(int level, const char* msg) + { + for (int i=0; i < level; i++) + { + cout << " "; + } + cout << msg < + + +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); + + // 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; + + + }; // 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) + { + } + private: + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_exceptions_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/File.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/File.cpp new file mode 100644 index 0000000000..20066a09e0 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/File.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$ $Date$ */ + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "tuscany/sca/util/File.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/Exceptions.h" +#include + +#include +#include +using namespace std; + +#if defined(WIN32) || defined (_WINDOWS) +#include +#else +#include +#include +#include +#endif + +namespace tuscany +{ + namespace sca + { + File::File(const string& dir, const string& file) + : directory(dir), fileName(file) + { + } + File::~File() + { + } + + + Files::Files(const string& rootDir, const string& pattern, bool subdirectories) + : rootDirectory(rootDir) + { + findFiles(rootDirectory, pattern, subdirectories); + } + + Files::~Files() + { + } + + unsigned int Files::size() + { + return files.size(); + } + + const File& Files::operator[] (unsigned int index) + { + if (size() <= index) + { + throw SystemConfigurationException("Files::operator[] index out of bounds"); + } + + FILES::iterator iter = files.begin(); + for (unsigned int i=0; id_name; + struct stat statbuf; + if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + continue; + if (stat(entryName.c_str(), &statbuf) != 0) + { + perror("stat"); + } + else + { + if (S_ISDIR(statbuf.st_mode)) + { + if (subdirectories) + { + findFiles(entryName, pattern, subdirectories); + } + } + else if (S_ISREG(statbuf.st_mode)) + { + 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())) ))) + { + // Add the file to our list + files.push_back(File(rootDir, filename)); + } + } + } + } + closedir(root); +#endif + } + + + } // End namespace sca +} // End namespace tuscany + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/File.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/File.h new file mode 100644 index 0000000000..a0aef07cf3 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/File.h @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 +using std::string; +#include +using std::vector; + +namespace tuscany +{ + namespace sca + { + /** + * 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 string& directory, const string& fileName); + + /** + * Destructor. + */ + virtual ~File(); + + /** + * Return the directory in which this file is located. + * @return Name of the directory. + */ + const string& getDirectory() const {return directory;} + + /** + * Name of the file. + * @return Name of the file. + */ + const string& getFileName() const {return fileName;} + private: + /** + * Name of the directory. + */ + string directory; + + /** + * Name of the file. + */ + string fileName; + }; + + /** + * 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. + */ + Files(const string& rootDirectory, const string& pattern, bool subdirectories = 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. + */ + void findFiles(const string& rootDirectory, const string& pattern, bool subdirectories); + + /** + * The top level directory to search. + */ + string rootDirectory; + + typedef vector FILES; + + /** + * Vector of File. + */ + FILES files; + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_file_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp new file mode 100644 index 0000000000..109d398e1a --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.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/FileLogWriter.h" +#include +using namespace std; + +namespace tuscany +{ + namespace sca + { + FileLogWriter::FileLogWriter(const char* logfile) + { + logFile.open(logfile, ios_base::app); + } + + FileLogWriter::~FileLogWriter() + { + logFile.close(); + } + + void FileLogWriter::log(int level, const char* msg) + { + for (int i=0; i < level; i++) + { + logFile << " "; + } + logFile << msg < +#include +using std::ofstream; + +namespace tuscany +{ + namespace sca + { + /** + * 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* msg); + private: + ofstream logFile; + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_defaultlogwriter_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Library.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Library.cpp new file mode 100644 index 0000000000..a9ff01b293 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Library.cpp @@ -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$ */ + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "tuscany/sca/util/Library.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/Exceptions.h" +#include "tuscany/sca/util/Logging.h" + +namespace tuscany +{ + namespace sca + { + Library::Library() + : hDLL(NULL) + { + } + + Library::Library(const string& libraryName) + : name(libraryName), hDLL(NULL) + { + LOGINFO_1(3, "Library::construcor : %s", name.c_str()); + load(); + } + + Library::Library(const Library& lib) + : name(lib.name), hDLL(NULL) + { + LOGINFO_1(3, "Library::copy constructor : %s", name.c_str()); + if (lib.hDLL) + { + load(); + } + } + + Library& Library::operator=(const Library& lib) + { + LOGINFO_1(3, "Library::operator= : %s", name.c_str()); + if (&lib != this) + { + unload(); + name = lib.name; + load(); + } + return *this; + } + + Library::~Library() + { + LOGINFO_1(3, "Library::destructor: %s", name.c_str()); + unload(); + } + + + void Library::load() + { + LOGINFO_1(3, "Library::load : %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"; + } + hDLL = LoadLibrary(dllName.c_str()); + if (hDLL == NULL) + { + msg = "Unable to load library: " + dllName; + } +#else + int l = name.length(); + string soName; + if (l>=3 && name.substr(l-3, 3)==".so") + { + soName = name; + } + else + { + int s = name.rfind("/"); + if (s == name.length()) + { + soName = name + ".so"; + } + else + { + s++; + soName = name.substr(0, s) + "lib" + name.substr(s, name.length()-s) + ".so"; + } + } + hDLL = dlopen(soName.c_str(), RTLD_NOW); + if (hDLL == NULL) + { + msg = "Unable to load library: " + soName + ": " + dlerror(); + } +#endif + if (hDLL == NULL) + { + LOGERROR(1, msg.c_str()); + throw SystemConfigurationException(msg.c_str()); + } + } + + void Library::unload() + { + if (hDLL != NULL) + { + LOGINFO_1(3, "Library::unload : %s", name.c_str()); +#if defined(WIN32) || defined (_WINDOWS) + FreeLibrary(hDLL); +#else + dlclose(hDLL); +#endif + hDLL = NULL; + } + } + + void* Library::getSymbol(const string& symbol) + { + LOGINFO_1(3, "Library::getSymbol : %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 sca +} // End namespace tuscany + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Library.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Library.h new file mode 100644 index 0000000000..48b2ad4430 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Library.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_util_library_h +#define tuscany_sca_util_library_h +#include "tuscany/sca/export.h" + +#if defined(WIN32) || defined (_WINDOWS) +#include +#else +#include +#include +#endif + +#include +using std::string; + +namespace tuscany +{ + namespace sca + { + /** + * 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 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 string& symbol); + private: + /** + * Name of the library. + */ + 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 sca +} // End namespace tuscany + +#endif // tuscany_sca_util_library_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp new file mode 100644 index 0000000000..7613e14c4a --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp @@ -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. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/LogWriter.h" + +namespace tuscany +{ + namespace sca + { + LogWriter::~LogWriter() + { + } + + } // End namespace sca +} // End namespace tuscany + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/LogWriter.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/LogWriter.h new file mode 100644 index 0000000000..430ce1a785 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/LogWriter.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. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_util_logwriter_h +#define tuscany_sca_util_logwriter_h + +#include "tuscany/sca/export.h" + +namespace tuscany +{ + namespace sca + { + /** + * 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 msg The message to log. + */ + virtual void log(int level, const char* msg) = 0; + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_logwriter_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logger.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logger.cpp new file mode 100644 index 0000000000..cdaa3e562b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logger.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$ */ + +#include +#include + +#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 + { + 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) + { + logWriter->log(level, msg); + } + } + + void Logger::logArgs(int level, const char* msg, ...) + { + if (level <= loggingLevel) + { + va_list variableArguments; + va_start(variableArguments, msg); + char messageBuffer[1024]; + vsprintf(messageBuffer, msg, variableArguments); + logWriter->log(level, messageBuffer); + va_end(variableArguments); + } + } + + } // End namespace sca +} // End namespace tuscany + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logger.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logger.h new file mode 100644 index 0000000000..b0b09adc50 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logger.h @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 + { + /** + * 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, ...); + + /** + * 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(); + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_logger_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logging.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logging.h new file mode 100644 index 0000000000..047c653229 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Logging.h @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +#define LOGENTRY(level, methodName) \ +if (tuscany::sca::Logger::loggingLevel >= level) \ +tuscany::sca::Logger::log(level, "Entering: " methodName); + +#define LOGEXIT(level, methodName) \ +if (tuscany::sca::Logger::loggingLevel >= level) \ +tuscany::sca::Logger::log(level, "Exiting: " methodName); + +#define LOGINFO(level, message) \ +if (tuscany::sca::Logger::loggingLevel >= level) \ +tuscany::sca::Logger::log(level, message); + +#define LOGINFO_1(level, message, arg1) \ +if (tuscany::sca::Logger::loggingLevel >= level) \ +tuscany::sca::Logger::logArgs(level, message, arg1); + +#define LOGINFO_2(level, message, arg1, arg2) \ +if (tuscany::sca::Logger::loggingLevel >= level) \ +tuscany::sca::Logger::logArgs(level, message, arg1, arg2); + +#define LOGINFO_3(level, message, arg1, arg2, arg3) \ +if (tuscany::sca::Logger::loggingLevel >= level) \ +tuscany::sca::Logger::logArgs(level, message, arg1, arg2, arg3); + +#define LOGERROR(level, message) \ +if (tuscany::sca::Logger::loggingLevel >= level) \ +tuscany::sca::Logger::log(level, message); + +#define LOGERROR_1(level, message, arg1) \ +if (tuscany::sca::Logger::loggingLevel >= level) \ +tuscany::sca::Logger::logArgs(level, message, arg1); + +#define LOGERROR_2(level, message, arg1, arg2) \ +if (tuscany::sca::Logger::loggingLevel >= level) \ +tuscany::sca::Logger::logArgs(level, message, arg1, arg2); + +#define LOGERROR_3(level, message, arg1, arg2, arg3) \ +if (tuscany::sca::Logger::loggingLevel >= level) \ +tuscany::sca::Logger::logArgs(level, message, arg1, arg2, arg3); + +#endif // tuscany_sca_util_logging_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Utils.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Utils.cpp new file mode 100644 index 0000000000..447f498eff --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/src/tuscany/sca/util/Utils.cpp @@ -0,0 +1,562 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/Utils.h" + +using namespace std; +using namespace commonj::sdo; +namespace tuscany +{ + namespace sca + { + 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) + { + token1 = str.substr(0, sep); + if ( (sep+1) < str.length()) + { + token2 = str.substr(sep+1); + } + 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) + { + token1 = str.substr(0, sep); + if ( (sep+1) < str.length()) + { + token2 = str.substr(sep+1); + } + 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 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 (int j = 0; j 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 (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 (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 (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 (int j = 0; j getCString(pl[i]) <getDataObject(pl[i]), inc); + inc--; + } + } + else + { + tabs(inc); + cout<< "Property Value: not set" <getType().isOpenType() && dataObject->getType().isDataObjectType()) + { + SequencePtr sequence = dataObject->getSequence(); + if (sequence != NULL) + { + for (int i = 0; i < sequence->size(); i++) + { + if (sequence->isText(i)) + { + tabs(inc); + cout<< "Text Value: " << sequence->getCStringValue(i) <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 (int j = 0; j getCString(p) <getDataObject(p), inc); + inc--; + } + } + else + { + tabs(inc); + cout<< "Property Value: not set" <getTypes(); + for (int i = 0; i < tl.size(); i++) + { + cout << "Type: " << tl[i].getURI()<< "#" << tl[i].getName() << endl; + PropertyList pl = tl[i].getProperties(); + for (int j = 0; j < pl.size(); j++) + { + cout << "\tProperty: " << pl[j].getName() + << " type: " < +using std::string; +#include "commonj/sdo/SDO.h" + +#include "tuscany/sca/export.h" + +namespace tuscany +{ + namespace sca + { + /** + * Utility methods to parse strings and provide debugging information. + */ + class SCA_API Utils { + + public: + static void tokeniseUri(const string& uri, string& token1, string& token2); + static void tokeniseQName(const string& sdoname, string& uri, string& name); + static void tokeniseString( + const string& separator, + const string& str, + string& token1, + string& token2); + + static void rTokeniseString( + const string& separator, + const string& str, + string& token1, + string& token2); + + static void breakpoint(); + + 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, string& diff); + static const bool compareProperties(commonj::sdo::DataObjectPtr dataObject1, const commonj::sdo::Property& prop1, commonj::sdo::DataObjectPtr dataObject2, const commonj::sdo::Property& prop2, string& diff); + + private: + static void tabs(int increment=0); + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_utils_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/test/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/test/Makefile.am new file mode 100644 index 0000000000..1d38fb8abb --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/core/test/Makefile.am @@ -0,0 +1,2 @@ +SUBDIRS = + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/Makefile.am new file mode 100644 index 0000000000..e0e5104032 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/Makefile.am @@ -0,0 +1,27 @@ +if WANT_ALL + CPP_EXTENSION = cpp + PYTHON_EXTENSION = python + RUBY_EXTENSION = ruby + PHP_EXTENSION = php + WSBINDING_EXTENSION = ws + SCABINDING_EXTENSION = sca +endif +if WANT_CPP + CPP_EXTENSION = cpp +endif +if WANT_PYTHON + PYTHON_EXTENSION = python +endif +if WANT_RUBY + RUBY_EXTENSION = ruby +endif +if WANT_PHP + PHP_EXTENSION = php +endif +if WANT_WSBINDING + WSBINDING_EXTENSION = ws +endif +if WANT_SCABINDING + SCABINDING_EXTENSION = sca +endif +SUBDIRS = ${CPP_EXTENSION} ${WSBINDING_EXTENSION} ${SCABINDING_EXTENSION} ${PYTHON_EXTENSION} ${RUBY_EXTENSION} ${PHP_EXTENSION} diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/Makefile.am new file mode 100644 index 0000000000..1c3113603b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = src + +datadir=$(prefix)/extensions/cpp + +nobase_data_DATA = xsd/*.xsd + +EXTRA_DIST = xsd \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/deploy.bat b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/deploy.bat new file mode 100644 index 0000000000..e87f3b4dd6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/deploy.bat @@ -0,0 +1,74 @@ +@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%\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 + +if exist %inpath%\tuscany_sca_cpp.pdb copy %inpath%\tuscany_sca_cpp.pdb %cppextdir%\bin + +goto end +:usage +echo Usage: deploy +:end + +endlocal diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/Makefile.am new file mode 100644 index 0000000000..3891e14051 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/Makefile.am @@ -0,0 +1,31 @@ +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/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 + \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp new file mode 100644 index 0000000000..bd0a6c39db --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/ComponentContext.h" +#include "tuscany/sca/util/Logging.h" +#include "osoa/sca/ServiceRuntimeException.h" +#include "tuscany/sca/cpp/ComponentContextImpl.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "commonj/sdo/SDO.h" +using commonj::sdo::DataFactoryPtr; + +using namespace tuscany::sca; +using namespace tuscany::sca::cpp; + +namespace osoa +{ + namespace sca + { + + // ======================================================= + // getCurrent: create a context from the current component + // ======================================================= + ComponentContext ComponentContext::getCurrent() + { + LOGENTRY(1, "ComponentContext::getCurrent"); + Component* component = tuscany::sca::SCARuntime::getInstance()->getCurrentComponent(); + if (!component) + { + throw ComponentContextException("No current component"); + } + ComponentContext* cci = new ComponentContextImpl(component); + LOGEXIT(1, "ComponentContext::constructor"); + return ComponentContext(cci); + } + + // =========== + // Constructor + // =========== + ComponentContext::ComponentContext(ComponentContext* implementation) + : impl(implementation) + { + LOGENTRY(1, "ComponentContext::constructor"); + LOGEXIT(1, "ComponentContext::constructor"); + } + + // ========== + // Destructor + // ========== + ComponentContext::~ComponentContext() + { + LOGENTRY(1, "ComponentContext::destructor"); + delete impl; + LOGEXIT(1, "ComponentContext::destructor"); + } + + // =================================== + // Copy constructor: create a new impl + // =================================== + ComponentContext::ComponentContext(const ComponentContext& ctx) + { + Component* component = ((ComponentContextImpl*)impl)->getComponent(); + impl = new ComponentContextImpl(component); + } + + // ============================= + // operator= : create a new impl + // ============================= + ComponentContext& ComponentContext::operator=(const ComponentContext& ctx) + { + if (this != &ctx) + { + Component* component = ((ComponentContextImpl*)impl)->getComponent(); + impl = new ComponentContextImpl(component); + } + return *this; + } + + // ========== + // getService + // ========== + void* ComponentContext::getService(const std::string& referenceName) + { + LOGENTRY(1, "ComponentContext::getService"); + void* service = impl->getService(referenceName); + LOGEXIT(1, "ComponentContext::getService"); + return service; + } + + // =========== + // getServices + // =========== + std::list ComponentContext::getServices(const std::string& referenceName) + { + return impl->getServices(referenceName); + } + + // ============ + // getProperties + // ============= + DataObjectPtr ComponentContext::getProperties() + { + LOGENTRY(1, "ComponentContext::getProperties"); + DataObjectPtr properties = impl->getProperties(); + LOGEXIT(1, "ComponentContext::getProperties"); + return properties; + } + + // ============ + // getDataFactory + // ============= + DataFactoryPtr ComponentContext::getDataFactory() + { + LOGENTRY(1, "ComponentContext::getDataFactory"); + DataFactoryPtr dataFactory = impl->getDataFactory(); + LOGEXIT(1, "ComponentContext::getDataFactory"); + return dataFactory; + } + + + } // End namespace sca +} // End namespace osoa diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h new file mode 100644 index 0000000000..fae62062b2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.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 osoa_sca_componentcontext_h +#define osoa_sca_componentcontext_h + +#include "osoa/sca/export.h" +#include "commonj/sdo/SDO.h" +#include +#include +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 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp new file mode 100644 index 0000000000..43e5e6806e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/CompositeContext.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/cpp/CompositeContextImpl.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "commonj/sdo/SDO.h" + +using commonj::sdo::DataFactoryPtr; +using namespace tuscany::sca; +using namespace tuscany::sca::cpp; + + +namespace osoa +{ + namespace sca + { + // =========== + // Constructor + // =========== + CompositeContext::CompositeContext(CompositeContext* implementation) + : impl(implementation) + { + } + + // =================================== + // Copy constructor: create a new impl + // =================================== + CompositeContext::CompositeContext(const CompositeContext& ctx) + { + impl = new CompositeContextImpl( + tuscany::sca::SCARuntime::getInstance()->getDefaultComponent()); + } + + // ============================= + // operator= : create a new impl + // ============================= + CompositeContext& CompositeContext::operator=(const CompositeContext& ctx) + { + if (this != &ctx) + { + impl = new CompositeContextImpl( + tuscany::sca::SCARuntime::getInstance()->getDefaultComponent()); + } + return *this; + } + + // ========== + // Destructor + // ========== + CompositeContext::~CompositeContext() + { + LOGENTRY(1, "CompositeContext::destructor"); + delete impl; + LOGEXIT(1, "CompositeContext::destructor"); + } + + // ==================================================== + // getCurrent: create a context from the current composite + // ==================================================== + CompositeContext CompositeContext::getCurrent() + { + LOGENTRY(1, "CompositeContext::getCurrent"); + CompositeContext* cci = new CompositeContextImpl( + tuscany::sca::SCARuntime::getInstance()->getDefaultComponent()); + LOGEXIT(1, "CompositeContext::getCurrent"); + return CompositeContext(cci); + } + + // ============= + // locateService + // ============= + void* CompositeContext::locateService(const std::string& serviceName) + { + LOGENTRY(1, "CompositeContext::locateService"); + void* sp = impl->locateService(serviceName); + LOGEXIT(1, "CompositeContext::locateService"); + return sp; + } + + // ============= + // getDataFactory + // ============= + DataFactoryPtr CompositeContext::getDataFactory() + { + LOGENTRY(1, "CompositeContext::getDataFactory"); + DataFactoryPtr df = impl->getDataFactory(); + LOGEXIT(1, "CompositeContext::getDataFactory"); + return df; + } + + + } // End namespace sca +} // End namespace osoa diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h new file mode 100644 index 0000000000..ac13ed875e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "osoa/sca/export.h" +#include "commonj/sdo/SDO.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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h new file mode 100644 index 0000000000..7bf8800242 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.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 osoa_sca_serviceruntimeexception_h +#define osoa_sca_serviceruntimeexception_h + +#include "osoa/sca/export.h" + +#include "tuscany/sca/util/Exceptions.h" +using tuscany::sca::TuscanyRuntimeException; +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 TuscanyRuntimeException + { + public: + ServiceRuntimeException( + const char *name="ServiceRuntimeException", + severity_level sev=Severe, + const char* msg_text="") + : TuscanyRuntimeException(name, sev, msg_text) + { + } + }; // 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/export.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/export.h new file mode 100644 index 0000000000..8a69913be4 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 +#include +#include +#define SCA_CPP_API +#endif + +#endif // osoa_sca_export_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/sca.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/osoa/sca/sca.h new file mode 100644 index 0000000000..6cce9453d7 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp new file mode 100644 index 0000000000..b418a52425 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.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/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_extension_initialize() + { + tuscany::sca::cpp::CPPExtension::initialize(); + } +} + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + // =================================================================== + // Constructor for the CPPExtension class. + // =================================================================== + CPPExtension::CPPExtension() + { + LOGENTRY(1, "CPPExtension::constructor"); + LOGEXIT(1, "CPPExtension::constructor"); + } + + // =================================================================== + // Destructor for the CPPExtension class. + // =================================================================== + CPPExtension::~CPPExtension() + { + LOGENTRY(1, "CPPExtension::destructor");; + LOGEXIT(1, "CPPExtension::destructor"); + } + + void CPPExtension::initialize() + { + LOGENTRY(1, "CPPExtension::initialize");; + SCARuntime::getInstance()->registerImplementationExtension(new CPPImplementationExtension()); + SCARuntime::getInstance()->registerInterfaceExtension(new CPPInterfaceExtension()); + LOGEXIT(1, "CPPExtension::initialize");; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h new file mode 100644 index 0000000000..d6c872629d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp new file mode 100644 index 0000000000..5ddf4b1113 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp @@ -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$ */ + +#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" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + // =================================================================== + // Constructor for the CPPImplementationExtension class. + // =================================================================== + CPPImplementationExtension::CPPImplementationExtension() + { + LOGENTRY(1, "CPPImplementationExtension::constructor"); + LOGEXIT(1, "CPPImplementationExtension::constructor"); + } + + // =================================================================== + // Destructor for the CPPImplementationExtension class. + // =================================================================== + CPPImplementationExtension::~CPPImplementationExtension() + { + LOGENTRY(1, "CPPImplementationExtension::destructor");; + LOGEXIT(1, "CPPImplementationExtension::destructor"); + } + + 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) + { + string implType = scdlImplementation->getType().getName(); + if (implType == "CPPImplementation") + { + 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; + } + else + { + return NULL; + } + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h new file mode 100644 index 0000000000..8548a208e9 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h @@ -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$ */ + +#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 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 string& getExtensionTypeQName() {return typeQName;} + + virtual ComponentType* getImplementation(Composite* composite, DataObjectPtr scdlImplementation); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppimplementationextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp new file mode 100644 index 0000000000..d470949746 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.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/cpp/CPPInterfaceExtension.h" +#include "tuscany/sca/cpp/model/CPPInterface.h" +#include "tuscany/sca/util/Logging.h" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + // =================================================================== + // Constructor for the CPPInterfaceExtension class. + // =================================================================== + CPPInterfaceExtension::CPPInterfaceExtension() + { + LOGENTRY(1, "CPPInterfaceExtension::constructor"); + LOGEXIT(1, "CPPInterfaceExtension::constructor"); + } + + // =================================================================== + // Destructor for the CPPInterfaceExtension class. + // =================================================================== + CPPInterfaceExtension::~CPPInterfaceExtension() + { + LOGENTRY(1, "CPPInterfaceExtension::destructor");; + LOGEXIT(1, "CPPInterfaceExtension::destructor"); + } + + 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) + { + // Determine the type + string ifType = scdlInterface->getType().getName(); + if (ifType == "CPPInterface") + { + string header = scdlInterface->getCString("header"); + string className = scdlInterface->getCString("class"); + bool remotable = scdlInterface->getBoolean("remotable"); + + return new CPPInterface(header, className, remotable, false); + } + return 0; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h new file mode 100644 index 0000000000..62c3b9854b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h @@ -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$ */ + +#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 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 string& getExtensionTypeQName() {return typeQName;} + + virtual tuscany::sca::model::Interface* getInterface(Composite* composite, DataObjectPtr scdlInterface); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppinterfaceextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp new file mode 100644 index 0000000000..56511fc9e6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/CPPServiceProxy.h" +#include "tuscany/sca/util/Logging.h" +#include "osoa/sca/ServiceRuntimeException.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 osoa::sca; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // ============================ + // Constructor: Create a proxy + // ============================ + CPPServiceProxy::CPPServiceProxy(Reference* reference) + : ServiceProxy(reference) + { + LOGENTRY(1,"CPPServiceProxy::constructor"); + + // ---------------------- + // 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); + + LOGEXIT(1,"CPPServiceProxy::constructor"); + } + + // ============================ + // Constructor: Create a proxy + // ============================ + CPPServiceProxy::CPPServiceProxy(Service* service) + : ServiceProxy(0) + { + LOGENTRY(1,"CPPServiceProxy::constructor"); + + // ---------------------- + // 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); + + LOGEXIT(1,"CPPServiceProxy::constructor"); + } + + void CPPServiceProxy::createProxy(Component* component, const string& name, ServiceWrapper* serviceWrapper) + { + LOGENTRY(1,"CPPServiceProxy::createProxy"); + + ComponentType* componentType = component->getType(); + if (!componentType) + { + string msg = "Component " + component->getName() + " has no implementation defined"; + throw 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_2(1, "CPPServiceProxy::createProxy: Unable to locate %s in library %s", + proxyFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Unable to locate " + proxyFactoryName + " in library " + fullLibraryName; + throw ServiceNotFoundException(msg.c_str()); + } + + // ----------------------------------- + // Now create an instance of the proxy + // ----------------------------------- + void* proxy = proxyFactory(serviceWrapper); + if (!proxy) + { + LOGERROR_2(1, "CPPServiceProxy::createProxy: Factory method %s in library %s returned null", + proxyFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Factory method " + proxyFactoryName + " in library " + fullLibraryName + " returned null"; + throw ServiceNotFoundException(msg.c_str()); + } + else + { + proxies.push_back(proxy); + } + + // ------------------------- + // Get the destructor method + // ------------------------- + destructor = (PROXYDESTRUCTOR)proxyLibrary.getSymbol(proxyDestructorName); + + LOGEXIT(1,"CPPServiceProxy::createProxy"); + } + + // ========== + // Destructor + // ========== + CPPServiceProxy::~CPPServiceProxy() + { + LOGENTRY(1,"CPPServiceProxy::destructor"); + + // Delete the proxies + if (destructor != NULL && proxies.size() != 0) + { + destructor(*proxies.begin()); + } + LOGEXIT(1,"CPPServiceProxy::destructor"); + } + + CPPServiceProxy::PROXIES CPPServiceProxy::getProxies() + { + return proxies; + } + + void* CPPServiceProxy::getProxy() + { + if (proxies.size() != 0) + { + return *proxies.begin(); + } + else + { + return NULL; + } + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h new file mode 100644 index 0000000000..77a20d08b8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +using namespace tuscany::sca::model; + + +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(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(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 PROXIES; + virtual PROXIES getProxies(); + + private: + + /** + * Create the proxy + */ + void createProxy(Component* component, const 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. + */ + Library proxyLibrary; + + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppserviceproxy_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp new file mode 100644 index 0000000000..3d7df2d44d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 "tuscany/sca/cpp/CPPServiceWrapper.h" + +#include "osoa/sca/ServiceRuntimeException.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 osoa::sca; + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // =================== + // Static data members + // =================== + void* CPPServiceWrapper::staticImpl = 0; + + // =========== + // Constructor + // =========== + CPPServiceWrapper::CPPServiceWrapper(Service* service) + : ServiceWrapper(service) + { + LOGENTRY(1,"CPPServiceWrapper::constructor"); + + component = service->getComponent(); + interf = service->getType()->getInterface(); + implementation = (CPPImplementation*)component->getType(); + + LOGEXIT(1,"CPPServiceWrapper::constructor"); + + } + + // ========== + // Destructor + // ========== + CPPServiceWrapper::~CPPServiceWrapper() + { + LOGENTRY(1,"CPPServiceWrapper::destructor"); + LOGEXIT(1,"CPPServiceWrapper::destructor"); + } + + + // ====================================================================== + // getImplementation: get an implementation for this scope + // ====================================================================== + void* CPPServiceWrapper::getImplementation() + { + 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() + { + if (implementation->getScope() == CPPImplementation::STATELESS) + { + deleteImplementation(); + } + } + + // ====================================================================== + // invoke: wrapper call to service with setting the component context + // ====================================================================== + void CPPServiceWrapper::invoke(Operation& operation) + { + LOGENTRY(1,"CPPServiceWrapper::invoke"); + + SCARuntime* runtime = SCARuntime::getInstance(); + runtime->setCurrentComponent(component); + + try + { + invokeService(operation); + } + catch (...) + { + runtime->unsetCurrentComponent(); + throw; + } + runtime->unsetCurrentComponent(); + LOGEXIT(1,"CPPServiceWrapper::invoke"); + + } + + void CPPServiceWrapper::setLibrary(Library* lib) + { + wrapperLibrary = lib; + } + + // ====================================================================== + // getServiceWrapper: create a wrapper for the target ComponentService + // ====================================================================== + CPPServiceWrapper* CPPServiceWrapper::getServiceWrapper(Service* service) + { + 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"; + throw 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_2(1, "CPPServiceWrapper::getServiceWrapper: Unable to locate %s in library %s", + wrapperFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Unable to locate " + wrapperFactoryName + " in library " + fullLibraryName; + throw ServiceNotFoundException(msg.c_str()); + } + + // ------------------------------------- + // Now create an instance of the wrapper + // ------------------------------------- + serviceWrapper = wrapperFactory(service); + if (!serviceWrapper) + { + LOGERROR_2(1, "CPPServiceWrapper::getServiceWrapper: Factory method %s in library %s returned null", + wrapperFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Factory method " + wrapperFactoryName + " in library " + fullLibraryName + " returned null"; + throw ServiceNotFoundException(msg.c_str()); + } + serviceWrapper->setLibrary(wrapperLib); + + return serviceWrapper; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h new file mode 100644 index 0000000000..eeeb9cdb82 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +using namespace tuscany::sca::model; + + +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(Service* service); + + /** + * Constructor. + * @param target The component service to which this wrapper refers. + */ + CPPServiceWrapper(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. + */ + 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. + */ + Component* component; + + /** + * A pointer to the interface which the service exposes. + */ + Interface* interf; + + /** + * The component implementation + */ + CPPImplementation* implementation; + + /** + * Pointer to the loaded library which contains the component + * implementation. + */ + Library* wrapperLibrary; + + /** + * Set the loaded library which contains the component + * implementation. + * @param lib The library. + */ + void setLibrary(Library* lib); + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppservicewrapper_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp new file mode 100644 index 0000000000..76d6bbc5f6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp @@ -0,0 +1,163 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "osoa/sca/ServiceRuntimeException.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" + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // =========== + // Constructor + // =========== + ComponentContextImpl::ComponentContextImpl(Component* comp) + : ComponentContext(0), component(comp) + { + LOGENTRY(1, "ComponentContextImpl::constructor"); + LOGEXIT(1, "ComponentContextImpl::constructor"); + } + + // ========== + // Destructor + // ========== + ComponentContextImpl::~ComponentContextImpl() + { + } + + + // ========================================================================== + // getServices: return a list of Proxies for services wired to this reference + // ========================================================================== + std::list ComponentContextImpl::getServices(const std::string& referenceName) + { + LOGENTRY(1, "ComponentContextImpl::getServices"); + + // -------------------------------------------------------------- + // locate reference in the current component and determine target + // -------------------------------------------------------------- + Reference* reference = component->findReference(referenceName); + if (!reference) + { + string message = "Reference not defined: "; + message = message + referenceName; + throw 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"; + throw ServiceNotFoundException(message.c_str()); + } + + return serviceProxy->getProxies(); + + } // End getServices() + + + // =================================================================== + // getService: return a Proxy for the services wired to this reference + // =================================================================== + void* ComponentContextImpl::getService(const std::string& referenceName) + { + LOGENTRY(1, "ComponentContextImpl::getService"); + + // -------------------------------------------------------------- + // locate reference in the current component and determine target + // -------------------------------------------------------------- + Reference* reference = component->findReference(referenceName); + if (!reference) + { + string message = "Reference not defined: "; + message = message + referenceName; + throw 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; + throw 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"; + throw ServiceNotFoundException(message.c_str()); + } + + void* service = serviceProxy->getProxy(); + return service; + + } // End getService() + + // ============================================== + // getProperties: return the component properties + // ============================================== + DataObjectPtr ComponentContextImpl::getProperties() + { + LOGENTRY(1, "ComponentContextImpl::getProperties"); + DataObjectPtr properties = component->getProperties(); + + LOGEXIT(1, "ComponentContextImpl::getProperties"); + return properties; + } + + // ============================================== + // getDataFactory: return the data factory for the composite in which + // this component resides + // ============================================== + commonj::sdo::DataFactoryPtr ComponentContextImpl::getDataFactory() + { + LOGENTRY(1, "ComponentContextImpl::getProperties"); + commonj::sdo::DataFactoryPtr dataFactory = component->getComposite()->getDataFactory(); + + LOGEXIT(1, "ComponentContextImpl::getDataFactory"); + return dataFactory; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h new file mode 100644 index 0000000000..6d9b76feeb --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.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_cpp_componentcontextimpl_h +#define tuscany_sca_cpp_componentcontextimpl_h + +#include +using std::vector; + +#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" + +using namespace osoa::sca; + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + /** + * Contains the actual implementation of a ComponentContext interface. + */ + class ComponentContextImpl : public ComponentContext + { + + public: + /** + * Constructor that takes a Component which represents the runtime + * model for this context. + */ + ComponentContextImpl(Component* component); + + /** + * Default constructor. + */ + virtual ~ComponentContextImpl(); + + /** + * See ComponentContext. + */ + virtual void* getService(const std::string& referenceName); + + /** + * See ComponentContext. + */ + virtual std::list getServices(const std::string& referenceName); + + /** + * See ComponentContext. + */ + virtual DataObjectPtr getProperties(); + + /** + * See ComponentContext. + */ + virtual commonj::sdo::DataFactoryPtr getDataFactory(); + + /** + * Returns the contained Component. + * @return The Component to which this context refers. + */ + virtual Component* getComponent() {return component;} + + private: + ComponentContextImpl(const ComponentContextImpl&); + ComponentContextImpl& operator=(const ComponentContextImpl&); + + /** + * Pointer to the runtime model Component to which this + * context refers. + */ + 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( + Reference* serviceReference, + 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(Service* target); + + }; + + } // End namespaca cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_componentcontextimpl_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp new file mode 100644 index 0000000000..009e0ed765 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "osoa/sca/ServiceRuntimeException.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" +#include "commonj/sdo/SDO.h" + +using namespace tuscany::sca::model; +using namespace osoa::sca; +using namespace commonj::sdo; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // =========== + // Constructor + // =========== + CompositeContextImpl::CompositeContextImpl(Component* component) + : CompositeContext(0), component(component), composite((Composite*)component->getType()) + { + } + + // ========== + // Destructor + // ========== + CompositeContextImpl::~CompositeContextImpl() + { + } + + // =========================================================================== + // locateService: return a proxy connected to a wrapper for the target service + // =========================================================================== + void* CompositeContextImpl::locateService(const std::string& serviceName) + { + LOGENTRY(1, "CompositeContextImpl::locateService"); + + // ---------------------------- + // Locate the component service + // ---------------------------- + Service* service = composite->findComponentService(serviceName); + string msg; + if (!service) + { + msg = "Service not found: "; + msg = msg + serviceName; + throw 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); + LOGEXIT(1, "CompositeContextImpl::locateService"); + return serviceProxy->getProxy(); + + } + + // ============================================== + // getDataFactory: return the data factory for the current composite + // ============================================== + DataFactoryPtr CompositeContextImpl::getDataFactory() + { + LOGENTRY(1, "CompositeContextImpl::getDataFactory"); + DataFactoryPtr dataFactory = composite->getDataFactory(); + + LOGEXIT(1, "CompositeContextImpl::getDataFactory"); + return dataFactory; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h new file mode 100644 index 0000000000..c11af16848 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.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_cpp_compositecontextimpl_h +#define tuscany_sca_cpp_compositecontextimpl_h + +#include +using std::vector; + +#include "osoa/sca/CompositeContext.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/cpp/CPPServiceProxy.h" + +using namespace osoa::sca; + +namespace tuscany +{ + namespace sca + { + + namespace cpp + { + + /** + * Contains the actual implementation of a CompositeContext interface. + */ + class CompositeContextImpl : public CompositeContext + { + + public: + /** + * Constructor that takes a Composite which represents the runtime + * model for this context. + */ + CompositeContextImpl(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. + */ + Composite* composite; + + /** + * Pointer to the runtime model Component object to which this + * context refers. + */ + Component* component; + + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_compositecontextimpl_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp new file mode 100644 index 0000000000..4fb7c7cfd5 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +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 (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 (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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h new file mode 100644 index 0000000000..20636df884 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h @@ -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$ */ + +#ifndef tuscany_sca_cpp_model_cppimplementation_h +#define tuscany_sca_cpp_model_cppimplementation_h +#include "tuscany/sca/model/ComponentType.h" + +#include +using std::map; +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Holds information about an SCA implementation written in C++ + */ + class CPPImplementation : public 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(Composite* composite, const string& library, const string& header, const string&headerPath, + const string& headerStub, const string& className, Scope scope); + + /** + * Destructor + */ + virtual ~CPPImplementation(); + + /** + * Initialize a component of this type. + * @param component The component to initialize. + */ + virtual void initializeComponent(Component* component); + + /** + * Returns the name of the shared library. + * @return The name of the shared library. + */ + const string& getLibrary() const { return library; } + + /** + * Get the name of the header file. + * @return Name of the header file. + */ + const string& getHeader() const { return header; } + + /** + * Get the header file name without the extension. + * @return The name of the header file without any extension. + */ + const string& getHeaderStub() const { return headerStub; } + + /** + * Get the header path. + * @return The pathe element of the header. + */ + const string& getHeaderPath() const { return headerPath; } + + /** + * Get the name of the class. + * @return The class name if specified. + */ + const string& getClass() const { return className; } + + /** + * Returns the implementation scope + */ + Scope getScope() { return scope; } + + private: + + /** + * Name of the shared library. + */ + string library; + + /** + * Name of the header file describing the interface. + */ + string header; + + /** + * Name of the header file without the extension. + */ + string headerStub; + + /** + * Path element of the header. + */ + 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. + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp new file mode 100644 index 0000000000..a728880e32 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.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/util/Utils.h" +#include "tuscany/sca/cpp/model/CPPInterface.h" + + +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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h new file mode 100644 index 0000000000..d50d2f9485 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "tuscany/sca/model/Interface.h" + +#include +using std::map; +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Holds information about an interface described using a C++ + * header file. + */ + class CPPInterface : public 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 string& header, + const 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 string& getHeader() { return header; } + + /** + * Return the name of the header file without the extension. + * @return Header file name without any extension. + */ + const string& getHeaderStub() { return headerStub; } + + /** + * Get the name of the class. + * @return The name of the class defining the interface. + */ + const 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 string& getInterfaceTypeQName() { return typeQName; }; + + private: + + /** + * Name of the header file containing the definition of the interface. + */ + string header; + + /** + * Name of the header file without the extension. + */ + string headerStub; + + /** + * Name of the class in the header file. + */ + string className; + + /** + * The QName of the schema type for this interface type. + */ + static const string typeQName; + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_model_cppinterface_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp new file mode 100644 index 0000000000..3c87560445 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.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/cpp/model/CPPReferenceBinding.h" +#include "tuscany/sca/cpp/CPPServiceProxy.h" + + +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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h new file mode 100644 index 0000000000..81ba88940d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.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_cpp_model_cppreferencebinding_h +#define tuscany_sca_cpp_model_cppreferencebinding_h + +#include "tuscany/sca/model/ReferenceBinding.h" + + +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Information about a CPP service binding for service or a reference. + */ + class CPPReferenceBinding : public 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(Reference* reference); + + /** + * Destructor. + */ + virtual ~CPPReferenceBinding(); + + /** + * Returns the type of binding. + */ + virtual 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(ServiceBinding* serviceBinding); + + /** + * Returns the target service binding. + */ + ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; }; + + private: + + /** + * The proxy representing the reference to the client + * component. + */ + ServiceProxy* serviceProxy; + + /** + * The service binding of the target + */ + ServiceBinding* targetServiceBinding; + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_model_cppreferencebinding_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp new file mode 100644 index 0000000000..641d9452f8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h new file mode 100644 index 0000000000..f7db3065b3 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 "tuscany/sca/model/ServiceBinding.h" +using namespace tuscany::sca::model; +#include +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Information about a CPP service binding for service or a reference. + */ + class CPPServiceBinding : public 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(Service* service); + + /** + * Destructor. + */ + virtual ~CPPServiceBinding(); + + /** + * Returns the type of binding. + */ + virtual 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd new file mode 100644 index 0000000000..7292f747b8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd new file mode 100644 index 0000000000..585bac0dc4 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/Makefile.am new file mode 100644 index 0000000000..30e7006028 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = src + +datadir=$(prefix)/extensions/php + +nobase_data_DATA = xsd/*.xsd + +EXTRA_DIST = xsd \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/Makefile.am new file mode 100644 index 0000000000..7be9269831 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/Makefile.am @@ -0,0 +1,28 @@ +libdir=$(prefix)/extensions/php/lib +lib_LTLIBRARIES = libtuscany_sca_php.la +includedir=$(prefix)/extensions/php/include +nobase_include_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/PHPServiceWrapper.cpp \ +tuscany/sca/php/model/PHPImplementation.cpp \ +tuscany/sca/php/model/PHPServiceBinding.cpp + +libtuscany_sca_php_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \ + -L$(top_builddir)/runtime/core/src -ltuscany_sca \ + -L${PHP_LIB} -lphp5 + +INCLUDES = -Imodel -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include \ + -I${PHP_INCLUDE} \ + -I${PHP_INCLUDE}/main \ + -I${PHP_INCLUDE}/Zend \ + -I${PHP_INCLUDE}/TSRM \ + -I${PHP_INCLUDE}/sapi/embed + +AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG + \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/osoa/sca/ServiceRuntimeException.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/osoa/sca/ServiceRuntimeException.h new file mode 100644 index 0000000000..d31679b994 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/osoa/sca/ServiceRuntimeException.h @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/util/Exceptions.h" +using tuscany::sca::TuscanyRuntimeException; +namespace osoa +{ + namespace sca + { + /** + * Top level exception to represent all the exceptions that may be + * thrown by an SCA runtime implementation. + */ + class SCA_PHP_API ServiceRuntimeException : public TuscanyRuntimeException + { + public: + ServiceRuntimeException( + const char *name="ServiceRuntimeException", + severity_level sev=Severe, + const char* msg_text="") + : TuscanyRuntimeException(name, sev, msg_text) + { + } + }; // End ServiceRuntimeException class definition + + + /** + * A remotable service is currently unavailable. It is possible that a retry + * may resolve this exception. + */ + class SCA_PHP_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_PHP_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_PHP_API ComponentContextException: public ServiceRuntimeException + { + public: + ComponentContextException(const char* msg) + : ServiceRuntimeException("ComponentContextException", Error, + msg) + { + } + private: + }; // End ComponentContextException class definition + + /** + * There is an error whilst trying to invoke a component. + */ + class SCA_PHP_API ComponentInvocationException: public ServiceRuntimeException + { + public: + ComponentInvocationException(const char* msg) + : ServiceRuntimeException("ComponentInvocationException", Error, + msg) + { + } + private: + }; // End ComponentInvocationException class definition + + + } // End namespace sca +} // End namespace osoa + +#endif // osoa_sca_serviceruntimeexception_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/osoa/sca/export.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/osoa/sca/export.h new file mode 100644 index 0000000000..99794a3352 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/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 +#include "tuscany/sca/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 +#include +#include +#define SCA_PHP_API +#endif + +#endif // osoa_sca_export_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp new file mode 100644 index 0000000000..f8768738e9 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.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/PHPExtension.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/php/PHPImplementationExtension.h" + + +extern "C" +{ + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void tuscany_sca_extension_initialize() + { + tuscany::sca::php::PHPExtension::initialize(); + } +} + +namespace tuscany +{ + namespace sca + { + namespace php + { + // =================================================================== + // Constructor for the PHPExtension class. + // =================================================================== + PHPExtension::PHPExtension() + { + LOGENTRY(1, "PHPExtension::constructor"); + LOGEXIT(1, "PHPExtension::constructor"); + } + + // =================================================================== + // Destructor for the PHPExtension class. + // =================================================================== + PHPExtension::~PHPExtension() + { + LOGENTRY(1, "PHPExtension::destructor");; + LOGEXIT(1, "PHPExtension::destructor"); + } + + void PHPExtension::initialize() + { + LOGENTRY(1, "PHPExtension::initialize");; + SCARuntime::getInstance()->registerImplementationExtension(new PHPImplementationExtension()); + //SCARuntime::getInstance()->registerInterfaceExtension(new PHPInterfaceExtension()); + LOGEXIT(1, "PHPExtension::initialize");; + } + + } // End namespace php + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.h new file mode 100644 index 0000000000..971ed93c86 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp new file mode 100644 index 0000000000..7f204b0ce9 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp @@ -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$ */ + +#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" + + +namespace tuscany +{ + namespace sca + { + namespace php + { + // =================================================================== + // Constructor for the PHPImplementationExtension class. + // =================================================================== + PHPImplementationExtension::PHPImplementationExtension() + { + LOGENTRY(1, "PHPImplementationExtension::constructor"); + LOGEXIT(1, "PHPImplementationExtension::constructor"); + } + + // =================================================================== + // Destructor for the PHPImplementationExtension class. + // =================================================================== + PHPImplementationExtension::~PHPImplementationExtension() + { + LOGENTRY(1, "PHPImplementationExtension::destructor");; + LOGEXIT(1, "PHPImplementationExtension::destructor"); + } + + 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) + { + string implType = scdlImplementation->getType().getName(); + if (implType == "PHPImplementation") + { + string module = scdlImplementation->getCString("module"); + string className = scdlImplementation->getCString("class"); + + PHPImplementation* phpImpl = new PHPImplementation(composite, module, className); + + return phpImpl; + } + else + { + return NULL; + } + } + + } // End namespace php + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h new file mode 100644 index 0000000000..9aa4aea969 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h @@ -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$ */ + +#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 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 string& getExtensionTypeQName() {return typeQName;} + + virtual ComponentType* getImplementation(Composite* composite, DataObjectPtr scdlImplementation); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace php + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_php_phpimplementationextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp new file mode 100644 index 0000000000..1b11e660c6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp @@ -0,0 +1,405 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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$ */ + + +// some strangeness in the build that causes +// WinSock.h and WinSock2.h to be included leading to redefinitions +#define _WINSOCKAPI_ + +#include "tuscany/sca/php/PHPServiceWrapper.h" + +#include "osoa/sca/ServiceRuntimeException.h" +#include "tuscany/sca/util/Logging.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 + +using namespace osoa::sca; + +namespace tuscany +{ + namespace sca + { + namespace php + { + // a global!! place to put the response + // as I can't get the PHP return value + // processing to work. Need to be + // removed when the proper PHP SAPI is used + // The variable is only valid between the PHP engine call and + // the results processing. It stores the last thing that + // the script echoed + string scriptResponse; + + // Global callbacks used by the PHP engine + + // Callback for log messages + void php_log_message(char *message) + { + LOGINFO_1(5, "PHP Log (%s)", message); + } + + // Callback for unbuffered writes (echo, print etc.) + int php_ub_write(const char *str, unsigned int str_length TSRMLS_DC) + { + LOGINFO_1(5, "PHP Write (%s)", str); + scriptResponse = str; + 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) + { + char buffer[2048]; + int len; + + len = snprintf(buffer, 2048, "Error on line %d: ", error_lineno); + vsnprintf(buffer + len, (2048 - len), format, args); + LOGINFO_1(5, "PHP Unformatted Error (%s)", buffer); + zend_bailout(); + } + + // Callback for flush (could be used to do something with the scriptResponse) + void php_flush(void *server_context) + { + LOGINFO(5, "Flush"); + } + + // =========== + // Constructor + // =========== + PHPServiceWrapper::PHPServiceWrapper(Service* service) + : ServiceWrapper(service) + { + LOGENTRY(1,"PHPServiceWrapper::constructor"); + + 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"; + throw ServiceNotFoundException(msg.c_str()); + } + + LOGINFO_1(3,"PHPServiceWrapper::getServiceWrapper module %s", impl->getModule().c_str()); + LOGINFO_1(3,"PHPServiceWrapper::getServiceWrapper class %s", impl->getClass().c_str()); + + LOGEXIT(1,"PHPServiceWrapper::constructor"); + + } + + // ========== + // Destructor + // ========== + PHPServiceWrapper::~PHPServiceWrapper() + { + LOGENTRY(1,"PHPServiceWrapper::destructor"); + LOGEXIT(1,"PHPServiceWrapper::destructor"); + } + + + // ====================================================================== + // invoke: wrapper call to service with setting the component context + // ====================================================================== + void PHPServiceWrapper::invoke(Operation& operation) + { + LOGENTRY(1,"PHPServiceWrapper::invoke"); + + SCARuntime* runtime = SCARuntime::getInstance(); + runtime->setCurrentComponent(component); + + try + { + LOGINFO_1(4, "PHPServiceWrapper::invoke called with operation name: %s", operation.getName().c_str()); + + // create a temporary script which + // - includes the named script + // - creates a class instance if required + // - calls the named method with the provided arguments + + // get the component type information + PHPImplementation* impl = (PHPImplementation*)component->getType(); + + // first create the temporay script and include the module + string script = "include '" + impl->getModule() + ".php';"; + + // if we have a class create an instance + string className = impl->getClass(); + if( &className != NULL && className.size() > 0) + { + script += "$anobject = new " + className + "();"; + } + + // construct the call to the function + script += "$response = "; + + if( &className != NULL && className.size() > 0) + { + script += " $anobject->"; + } + + script += operation.getName().c_str(); + script += "("; + + char tempString [32]; + + // add the parameters to the call + 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 + script += "true"; + } + else + { + script += "false"; + } + break; + } + case Operation::SHORT: + { + sprintf ( tempString, "%d", *(short*)parm.getValue() ); + script += tempString; + break; + } + case Operation::USHORT: + { + sprintf ( tempString, "%d", *(unsigned short*)parm.getValue() ); + script += tempString; + break; + } + case Operation::LONG: + { + sprintf ( tempString, "%d", *(long*)parm.getValue() ); + script += tempString; + break; + } + case Operation::ULONG: + { + sprintf ( tempString, "%d", *(unsigned long*)parm.getValue() ); + script += tempString; + break; + } + case Operation::FLOAT: + { + sprintf ( tempString, "%g", *(float*)parm.getValue() ); + script += tempString; + break; + } + case Operation::DOUBLE: + { + sprintf ( tempString, "%g", *(double*)parm.getValue() ); + script += tempString; + break; + } + case Operation::LONGDOUBLE: + { + sprintf ( tempString, "%g", *(long double*)parm.getValue() ); + script += tempString; + break; + } + case Operation::CHARS: + { + script += *(char**)parm.getValue(); + break; + } + case Operation::STRING: + { + script += (*(string*)parm.getValue()).c_str(); + break; + } + default: + { + throw new ComponentInvocationException("Operation parameter type not supported"); + } + } + + if ( ( i + 1 ) < operation.getNParms() ) + { + script += ", "; + } + } + + + // the closing bracket of the call + script += ");echo $response;return $response;"; + + // we now have the temporary script to make the call + LOGINFO_1(5, "Executing PHP script \n%s", script.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.flush = php_flush; + + //PHP_EMBED_START_BLOCK(/* argc */ 0, /* argv */ NULL) + void ***tsrm_ls; + int status = php_embed_init(0, NULL PTSRMLS_CC); + LOGINFO_1(5, "Engine startup status %d", status); + + zend_first_try { + // set error handler + zend_error_cb = php_error_cb; + + // call the dynamically created script + //zval retval; + zend_eval_string((char *) script.c_str(), + NULL,//&retval, + "PHP Component" TSRMLS_CC); + + // get the response + // This doesn't want to work for some reason + // so have chaced the last echo that the script + // returns in the global scriptResponse variable + // This is a bit of a rubbish way of doing things so + // needs replacing when proper SAPI is used + //convert_to_string(&retval); + //LOGINFO_1(5, "Script returned %s", Z_STRVAL(retval)); + //zval_dtor(&retval); + + //PHP_EMBED_END_BLOCK() + } zend_catch { + int exit_status = EG(exit_status); + LOGINFO_1(5, "In catch %d", exit_status); + } zend_end_try(); + + //clean up + php_embed_shutdown(TSRMLS_C); + LOGINFO(5, "Engine shutdown"); + + // get the response values + LOGINFO_1(5, "Script returned %s", scriptResponse.c_str()); + + switch(operation.getReturnType()) + { + case Operation::BOOL: + { + if(scriptResponse == "true") + { + *(bool*)operation.getReturnValue() = true; + } + break; + } + case Operation::SHORT: + { + *(short*)operation.getReturnValue() = (short) strtol(scriptResponse.c_str(), NULL,10); + break; + } + case Operation::LONG: + { + *(long*)operation.getReturnValue() = (long) strtol(scriptResponse.c_str(), NULL,10); + break; + } + case Operation::USHORT: + { + *(unsigned short*)operation.getReturnValue() = (unsigned short) strtoul(scriptResponse.c_str(), NULL,10); + break; + } + case Operation::ULONG: + { + *(unsigned long*)operation.getReturnValue() = (unsigned long) strtoul(scriptResponse.c_str(), NULL,10); + break; + } + case Operation::FLOAT: + { + *(float*)operation.getReturnValue() = (float) strtod(scriptResponse.c_str(), NULL); + break; + } + case Operation::DOUBLE: + { + *(double*)operation.getReturnValue() = (double) strtod(scriptResponse.c_str(), NULL); + break; + } + case Operation::LONGDOUBLE: + { + *(long double*)operation.getReturnValue() = (long double) strtod(scriptResponse.c_str(), NULL); + break; + } + case Operation::CHARS: + { + *(char**)operation.getReturnValue() = (char *)scriptResponse.c_str(); + break; + } + case Operation::STRING: + { + *(string*)operation.getReturnValue() = scriptResponse; + break; + } + default:; + } + } + catch (...) + { + runtime->unsetCurrentComponent(); + throw; + } + runtime->unsetCurrentComponent(); + LOGEXIT(1,"PHPServiceWrapper::invoke"); + + } + + // ====================================================================== + // getServiceWrapper: create a wrapper for the target ComponentService + // ====================================================================== + PHPServiceWrapper* PHPServiceWrapper::getServiceWrapper(Service* service) + { + LOGENTRY(1,"PHPServiceWrapper::getServiceWrapper"); + PHPServiceWrapper* serviceWrapper = 0; + + // --------------------------------- + // Create an instance of the wrapper + // --------------------------------- + serviceWrapper = new PHPServiceWrapper(service); + if (!serviceWrapper) + { + string msg = "Could not create new PHPServiceWrapper"; + LOGERROR(1, msg.c_str()); + throw ServiceNotFoundException(msg.c_str()); + } + + LOGEXIT(1,"PHPServiceWrapper::getServiceWrapper"); + return serviceWrapper; + } + + } // End namespace php + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h new file mode 100644 index 0000000000..ef83a026a6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "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" + +using namespace tuscany::sca::model; + + +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(Service* service); + + /** + * Constructor. + * @param target The component service to which this wrapper refers. + */ + PHPServiceWrapper(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: + + + /** + * The component to which this wrapper refers. + */ + Component* component; + + /** + * Set to true if the service is remotable. + */ + bool remotable; + + /** + * A pointer to the interface which the service exposes. + */ + Interface* interf; + + }; + + } // End namespace php + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_php_phpservicewrapper_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp new file mode 100644 index 0000000000..f8992ed498 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +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(1,"PHPImplementation::constructor"); + LOGEXIT(1,"PHPImplementation::constructor"); + } + + PHPImplementation::~PHPImplementation() + { + LOGENTRY(1,"PHPImplementation::destructor"); + LOGEXIT(1,"PHPImplementation::destructor"); + } + + void PHPImplementation::initializeComponent(Component* component) + { + LOGENTRY(1,"PHPImplementation::initializeComponent"); + 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++; + } + + // References not yet supported.. + + //// 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++; + //} + LOGEXIT(1,"PHPImplementation::initializeComponent"); + } + + } // End namespace php + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h new file mode 100644 index 0000000000..b89ba8c5c2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "tuscany/sca/model/ComponentType.h" + +#include +using std::map; +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace php + { + /** + * Holds information about an SCA implementation written in PHP + */ + class PHPImplementation : public 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(Composite* composite, const string& module, const string& className); + + /** + * Destructor + */ + virtual ~PHPImplementation(); + + /** + * Initialize a component of this type. + * @param component The component to initialize. + */ + virtual void initializeComponent(Component* component); + + /** + * Returns the name of the module. + * @return The name of the module. + */ + const string& getModule() const { return module; } + + /** + * Get the name of the class. + * @return The class name if specified. + */ + const string& getClass() const { return className; } + + private: + + /** + * Name of the module. + */ + 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. + */ + string className; + }; + + } // End namespace php + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_php_model_phpimplementation_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.cpp new file mode 100644 index 0000000000..fa162ce8f2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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" + +namespace tuscany +{ + namespace sca + { + namespace php + { + + // Constructor + PHPServiceBinding::PHPServiceBinding(Service* service) + : ServiceBinding(service, "") + { + LOGENTRY(1,"PHPServiceBinding::constructor"); + serviceWrapper = PHPServiceWrapper::getServiceWrapper(service); + LOGEXIT(1,"PHPServiceBinding::constructor"); + } + + // Destructor + PHPServiceBinding::~PHPServiceBinding() + { + LOGENTRY(1,"PHPServiceBinding::destructor"); + LOGEXIT(1,"PHPServiceBinding::destructor"); + } + + ServiceWrapper* PHPServiceBinding::getServiceWrapper() + { + LOGENTRY(1,"PHPServiceBinding::getServiceWrapper"); + LOGEXIT(1,"PHPServiceBinding::getServiceWrapper"); + return (ServiceWrapper*)serviceWrapper; + } + + } // End namespace php + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.h new file mode 100644 index 0000000000..6b1e694bd6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 "tuscany/sca/model/ServiceBinding.h" +using namespace tuscany::sca::model; +#include +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace php + { + /** + * Information about a PHP service binding for service or a reference. + */ + class PHPServiceBinding : public 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(Service* service); + + /** + * Destructor. + */ + virtual ~PHPServiceBinding(); + + /** + * Returns the type of binding. + */ + virtual 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/xsd/sca-implementation-php.xsd b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/xsd/sca-implementation-php.xsd new file mode 100644 index 0000000000..0f32f120e6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/php/xsd/sca-implementation-php.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/Makefile.am new file mode 100644 index 0000000000..c3acfab447 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = src + +datadir=$(prefix)/extensions/python + +nobase_data_DATA = xsd/*.xsd + +EXTRA_DIST = xsd \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/deploy.bat b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/deploy.bat new file mode 100644 index 0000000000..db007e892c --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/deploy.bat @@ -0,0 +1,84 @@ +@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%\include mkdir %pythonextdir%\include +if not exist %pythonextdir%\include\tuscany mkdir %pythonextdir%\include\tuscany +if not exist %pythonextdir%\include\tuscany\sca mkdir %pythonextdir%\include\tuscany\sca +if not exist %pythonextdir%\include\tuscany\sca\python mkdir %pythonextdir%\include\tuscany\sca\python +if not exist %pythonextdir%\include\tuscany\sca\python\model mkdir %pythonextdir%\include\tuscany\sca\python\model +if not exist %pythonextdir%\xsd mkdir %pythonextdir%\xsd + +del %pythonextdir%\bin\tuscany_sca_python.* +del %pythonextdir%\lib\*.lib + +copy %srcdir%\tuscany\sca\python\*.h %pythonextdir%\include\tuscany\sca\python +copy %srcdir%\tuscany\sca\python\model\*.h %pythonextdir%\include\tuscany\sca\python\model + +copy %srcdir%\..\xsd\*.* %pythonextdir%\xsd + +copy %inpath%\tuscany_sca_python.lib %pythonextdir%\lib +copy %inpath%\tuscany_sca_python.dll %pythonextdir%\bin + +if exist %inpath%\tuscany_sca_python.pdb copy %inpath%\tuscany_sca_python.pdb %pythonextdir%\bin + + +echo Building extension to Python +set origdir=%~d0%~p0 +set bindir=%pythonextdir%\bin +cd %srcdir%\tuscany\sca\python\ + +rem if %pythonextdir% is a relative path, it won't be found, so set %bindir% to a full path +if not exist %bindir% set bindir=%origdir%\%pythonextdir%\bin + +%PYTHON_HOME%\python sca_setup.py build +%PYTHON_HOME%\python sca_setup.py install --install-lib %bindir% +cd %origdir% + +goto end +:usage +echo Usage: deploy +:end + +endlocal diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/Makefile.am new file mode 100644 index 0000000000..a7c62400c1 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/Makefile.am @@ -0,0 +1,41 @@ +libdir=$(prefix)/extensions/python/lib +lib_LTLIBRARIES = libtuscany_sca_python.la + +install-exec-hook: + cd $(libdir); ln -s -f libtuscany_sca_python.so sca.so + +pydir=$(prefix)/extensions/python/lib +py_DATA = tuscany/sca/python/sca_proxy.py +EXTRA_DIST = tuscany/sca/python/sca_proxy.py + +includedir=$(prefix)/extensions/python/include +nobase_include_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 + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp new file mode 100644 index 0000000000..4744f628e0 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.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/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" + + +extern "C" +{ + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void tuscany_sca_extension_initialize() + { + tuscany::sca::python::PythonExtension::initialize(); + } +} + +namespace tuscany +{ + namespace sca + { + namespace python + { + // =================================================================== + // Constructor for the PythonExtension class. + // =================================================================== + PythonExtension::PythonExtension() + { + LOGENTRY(1, "PythonExtension::constructor"); + LOGEXIT(1, "PythonExtension::constructor"); + } + + // =================================================================== + // Destructor for the PythonExtension class. + // =================================================================== + PythonExtension::~PythonExtension() + { + LOGENTRY(1, "PythonExtension::destructor");; + LOGEXIT(1, "PythonExtension::destructor"); + } + + void PythonExtension::initialize() + { + LOGENTRY(1, "PythonExtension::initialize");; + SCARuntime::getInstance()->registerImplementationExtension(new PythonImplementationExtension()); + SCARuntime::getInstance()->registerInterfaceExtension(new PythonInterfaceExtension()); + LOGEXIT(1, "PythonExtension::initialize");; + } + + } // End namespace python + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.h new file mode 100644 index 0000000000..783f37a228 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.cpp new file mode 100644 index 0000000000..0623fb206c --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.cpp @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + + +namespace tuscany +{ + namespace sca + { + namespace python + { + // =================================================================== + // Constructor for the PythonImplementationExtension class. + // =================================================================== + PythonImplementationExtension::PythonImplementationExtension() + { + LOGENTRY(1, "PythonImplementationExtension::constructor"); + LOGEXIT(1, "PythonImplementationExtension::constructor"); + } + + // =================================================================== + // Destructor for the PythonImplementationExtension class. + // =================================================================== + PythonImplementationExtension::~PythonImplementationExtension() + { + LOGENTRY(1, "PythonImplementationExtension::destructor");; + LOGEXIT(1, "PythonImplementationExtension::destructor"); + } + + 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) + { + string implType = scdlImplementation->getType().getName(); + if (implType == "PythonImplementation") + { + 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; + } + else + { + return NULL; + } + } + + } // End namespace python + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.h new file mode 100644 index 0000000000..69414dce22 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonImplementationExtension.h @@ -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$ */ + + +#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 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 string& getExtensionTypeQName() {return typeQName;} + + virtual ComponentType* getImplementation(Composite* composite, DataObjectPtr scdlImplementation); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace python + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_python_pythonimplementationextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.cpp new file mode 100644 index 0000000000..2a4c94b7af --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.cpp @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +//#include "commonj/sdo/SDO.h" +//using commonj::sdo::DataObjectList; + +namespace tuscany +{ + namespace sca + { + namespace python + { + // =================================================================== + // Constructor for the PythonInterfaceExtension class. + // =================================================================== + PythonInterfaceExtension::PythonInterfaceExtension() + { + LOGENTRY(1, "PythonInterfaceExtension::constructor"); + LOGEXIT(1, "PythonInterfaceExtension::constructor"); + } + + // =================================================================== + // Destructor for the PythonInterfaceExtension class. + // =================================================================== + PythonInterfaceExtension::~PythonInterfaceExtension() + { + LOGENTRY(1, "PythonInterfaceExtension::destructor");; + LOGEXIT(1, "PythonInterfaceExtension::destructor"); + } + + 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) + { + // 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; igetCString("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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.h new file mode 100644 index 0000000000..3596857c0d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonInterfaceExtension.h @@ -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$ */ + +#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 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 string& getExtensionTypeQName() {return typeQName;} + + virtual tuscany::sca::model::Interface* getInterface(Composite* composite, DataObjectPtr scdlInterface); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace python + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_python_pythoninterfaceextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.cpp new file mode 100644 index 0000000000..ef482f32e8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.cpp @@ -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$ */ + +#include "tuscany/sca/python/PythonServiceProxy.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/python/PythonServiceRuntimeException.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/python/model/PythonImplementation.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(1,"PythonServiceProxy::constructor(Reference)"); + + // Get the service wrapper + PythonReferenceBinding* referenceBinding = (PythonReferenceBinding*)reference->getBinding(); + serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper(); + + LOGEXIT(1,"PythonServiceProxy::constructor(Reference)"); + } + + // ========================================== + // Constructor: Create a proxy from a service + // ========================================== + PythonServiceProxy::PythonServiceProxy(Service* service) + : ServiceProxy(NULL) + { + LOGENTRY(1,"PythonServiceProxy::constructor(Service)"); + + // Get the service wrapper + serviceWrapper = service->getBinding()->getServiceWrapper(); + + LOGEXIT(1,"PythonServiceProxy::constructor(Service)"); + } + + // ========== + // Destructor + // ========== + PythonServiceProxy::~PythonServiceProxy() + { + LOGENTRY(1,"PythonServiceProxy::destructor"); + LOGEXIT(1,"PythonServiceProxy::destructor"); + } + + // ===================================================== + // invokeService: invoke the service wired to this proxy + // ===================================================== + void PythonServiceProxy::invokeService(Operation& operation) + { + LOGENTRY(1,"PythonServiceProxy::invokeService"); + + // Invoke the service + serviceWrapper->invoke(operation); + + LOGEXIT(1,"PythonServiceProxy::invokeService"); + } + } // End namespace python + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.h new file mode 100644 index 0000000000..f16cb95609 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceProxy.h @@ -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$ */ + +#ifndef tuscany_sca_python_pythonserviceproxy_h +#define tuscany_sca_python_pythonserviceproxy_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" + +#include "export.h" + +using namespace tuscany::sca::model; + + +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(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(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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceRuntimeException.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceRuntimeException.h new file mode 100644 index 0000000000..aa8c88d06d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceRuntimeException.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_python_pythonserviceruntimeexception_h +#define tuscany_sca_python_pythonserviceruntimeexception_h + +#include "export.h" + +#include "tuscany/sca/util/Exceptions.h" +using tuscany::sca::TuscanyRuntimeException; +namespace tuscany +{ + namespace sca + { + namespace python + { + /** + * Exception to represent a failure in a Python call. + */ + class SCA_PYTHON_API PythonServiceRuntimeException : public TuscanyRuntimeException + { + public: + PythonServiceRuntimeException( + const char *name="PythonServiceRuntimeException", + severity_level sev=Severe, + const char* msg_text="") + : TuscanyRuntimeException(name, sev, msg_text) + { + } + }; // End PythonServiceRuntimeException class definition + + /** + * The target of a wire cannot be found, or the reference has not been + * configured. + */ + class SCA_PYTHON_API PythonServiceNotFoundException: public PythonServiceRuntimeException + { + public: + PythonServiceNotFoundException(const char* msg) + : PythonServiceRuntimeException("PythonServiceNotFoundException", Error, + msg) + { + } + private: + }; // End PythonServiceNotFoundException class definition + + + /** + * There is no current component (for example, if a non-SCA component + * tries to get the current ComponentContext). + */ + class SCA_PYTHON_API PythonComponentContextException: public PythonServiceRuntimeException + { + public: + PythonComponentContextException(const char* msg) + : PythonServiceRuntimeException("PythonComponentContextException", Error, + msg) + { + } + private: + }; // End PythonComponentContextException class definition + + /** + * There is no current component (for example, if a non-SCA component + * tries to get the current ComponentContext). + */ + class SCA_PYTHON_API PythonComponentInvocationException: public PythonServiceRuntimeException + { + public: + PythonComponentInvocationException(const char* msg) + : PythonServiceRuntimeException("ComponentInvocationException", Error, + msg) + { + } + private: + }; // End PythonComponentInvocationException class definition + + } // End namespace python + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_python_pythonserviceruntimeexception_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp new file mode 100644 index 0000000000..0223a5741d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp @@ -0,0 +1,950 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/PythonServiceRuntimeException.h" +#include "tuscany/sca/python/PythonServiceWrapper.h" + +#include "tuscany/sca/util/Logging.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" + +#include "commonj/sdo/SDO.h" +using namespace commonj::sdo; + +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_2(5, "PythonServiceWrapper::printPyObject %s: %s", name, PyString_AsString(pObjRepr)); + Py_DECREF(pObjRepr); + + PyObject* pObjDir = PyObject_Dir(pObj); + PyObject* pObjDirRepr = PyObject_Repr(pObjDir); + LOGINFO_2(5, "PythonServiceWrapper::printPyObject dir(%s): %s", name, PyString_AsString(pObjDirRepr)); + Py_DECREF(pObjDirRepr); + Py_DECREF(pObjDir); + } + + // =========== + // Constructor + // =========== + PythonServiceWrapper::PythonServiceWrapper(Service* service) + : ServiceWrapper(service) + { + LOGENTRY(1,"PythonServiceWrapper::constructor"); + + 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"; + throw PythonServiceNotFoundException(msg.c_str()); + } + + LOGINFO_1(3,"PythonServiceWrapper::constructor module %s", impl->getModule().c_str()); + LOGINFO_1(3,"PythonServiceWrapper::constructor path %s", impl->getModulePath().c_str()); + LOGINFO_1(3,"PythonServiceWrapper::constructor class %s", impl->getClass().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() + "/" + impl->getModulePath(); + + 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(); + LOGERROR(0, msg.c_str()); + throw PythonComponentContextException(msg.c_str()); + } + //else + //{ + // addReferences(pythonModule); + // addProperties(pythonModule); + //} + + printPyObject("pythonModule",pythonModule); + + LOGEXIT(1,"PythonServiceWrapper::constructor"); + + } + + // ========== + // Destructor + // ========== + PythonServiceWrapper::~PythonServiceWrapper() + { + LOGENTRY(1,"PythonServiceWrapper::destructor"); + Py_XDECREF(pythonClassInstance); + Py_XDECREF(pythonModule); + Py_Finalize(); + LOGEXIT(1,"PythonServiceWrapper::destructor"); + } + + // ====================================================================== + // newInstance: create a new class instance + // ====================================================================== + PyObject* PythonServiceWrapper::newInstance() + { + LOGENTRY(1,"PythonServiceWrapper::newInstance"); + 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"; + LOGERROR(0, msg.c_str()); + throw new PythonComponentInvocationException(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"; + LOGERROR(0, msg.c_str()); + throw new PythonComponentInvocationException(msg.c_str()); + } + Py_XDECREF(pClass); + } + } + LOGEXIT(1,"PythonServiceWrapper::newInstance"); + return pClassInstance; + } + + // ====================================================================== + // getInstance: get a class instance for this scope + // ====================================================================== + PyObject* PythonServiceWrapper::getInstance() + { + LOGENTRY(1,"PythonServiceWrapper::getInstance"); + + PythonImplementation::Scope scope = implementation->getScope(); + if (scope == PythonImplementation::COMPOSITE) + { + if (!pythonClassInstance) + { + pythonClassInstance = newInstance(); + } + return pythonClassInstance; + } + else // (scope == PythonImplementation::STATELESS) + { + return newInstance(); + } + LOGEXIT(1,"PythonServiceWrapper::getInstance"); + } + + // ====================================================================== + // releaseImplementation: release the implementation for this scope + // ====================================================================== + void PythonServiceWrapper::releaseInstance() + { + LOGENTRY(1,"PythonServiceWrapper::releaseInstance"); + + 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; + } + } + LOGEXIT(1,"PythonServiceWrapper::releaseInstance"); + } + + // ====================================================================== + // invoke: wrapper call to service with setting the component context + // ====================================================================== + void PythonServiceWrapper::invoke(Operation& operation) + { + LOGENTRY(1,"PythonServiceWrapper::invoke"); + + SCARuntime* runtime = SCARuntime::getInstance(); + runtime->setCurrentComponent(component); + + + // Load the references & properties into the module + addReferences(pythonModule); + addProperties(pythonModule); + + try + { + LOGINFO_1(4, "PythonServiceWrapper::invoke called with operation name: %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 - throw exception + string msg = "Python module or class instance has not been created"; + LOGERROR(0, msg.c_str()); + throw new PythonComponentInvocationException(msg.c_str()); + } + + if (pFunc && PyCallable_Check(pFunc)) + { + PyObject* pArgs = PyTuple_New(operation.getNParms()); + PyObject* pValue = NULL; + + 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; + } + default: throw new PythonComponentInvocationException("Operation parameter type not supported"); + } + + if (!pValue) + { + Py_DECREF(pArgs); + + if(PyErr_Occurred()) + { + PyErr_Print(); + } + + string msg = "Error converting parameter into Python type"; + LOGERROR(0, msg.c_str()); + throw new PythonComponentInvocationException(msg.c_str()); + + } + //printPyObject("Param value", pValue); + + /* pValue reference stolen here: */ + PyTuple_SetItem(pArgs, i, pValue); + } + + pValue = PyObject_CallObject(pFunc, pArgs); + //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_1(3, "PythonServiceWrapper::invoke Return value is int type: %d", PyInt_AsLong(pValue)); + *data = PyInt_AsLong(pValue); + } + else + { + LOGINFO_1(3, "PythonServiceWrapper::invoke Return value is long type: %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_1(3, "PythonServiceWrapper::invoke Return value is bool type: %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_1(3, "PythonServiceWrapper::invoke Return value is float type: %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_1(3, "PythonServiceWrapper::invoke Return value is string type: %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 + operation.setReturnValue(data); + } + } + } + else + { + PyObject* valueRepr = PyObject_Repr(pValue); + PyObject* valueType = PyObject_Type(pValue); + PyObject* valueTypeRepr = PyObject_Repr(valueType); + LOGINFO_2(3, "PythonServiceWrapper::invoke Return value is of unknown type (%s) and has repr: %s", PyString_AsString(valueTypeRepr), PyString_AsString(valueRepr)); + Py_DECREF(valueTypeRepr); + Py_DECREF(valueType); + Py_DECREF(valueRepr); + } + + Py_DECREF(pValue); + } + else + { + Py_DECREF(pFunc); + if(PyErr_Occurred()) + { + PyErr_Print(); + } + string msg = "Error whilst calling Python module"; + LOGERROR(0, msg.c_str()); + throw new PythonComponentInvocationException(msg.c_str()); + } + } + else + { + if (PyErr_Occurred()) + { + PyErr_Print(); + } + string msg = "Cannot find the operation named " + operation.getName() + " in the Python module"; + LOGERROR(0, msg.c_str()); + throw new PythonComponentInvocationException(msg.c_str()); + } + Py_XDECREF(pFunc); + + } + catch (...) + { + releaseInstance(); + runtime->unsetCurrentComponent(); + throw; + } + releaseInstance(); + runtime->unsetCurrentComponent(); + LOGEXIT(1,"PythonServiceWrapper::invoke"); + + } + + + // ========================================================================== + // Add any properties into the loaded implementation module as Python objects + // ========================================================================== + void PythonServiceWrapper::addProperties(PyObject* module) + { + // 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 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, "", propName); + property = PyString_FromString(serializedData.c_str()); + 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_3(3, "Successfully added property named %s with type %s and value %s to python module", propName.c_str(), pl[i].getType().getName(), propValue.c_str()); + } + else + { + LOGERROR_1(1, "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) + { + + // 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"; + LOGERROR(0, 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_1(3, "Successfully added sca_proxy_class instance as %s to pythonModule", referenceName.c_str()); + } + else + { + LOGERROR_1(1, "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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h new file mode 100644 index 0000000000..51b0f1dd64 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.h @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 + +#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" + +using namespace tuscany::sca::model; + +// undefine _DEBUG so Python does not need it's deebug dll +#ifdef _DEBUG +#undef _DEBUG +#define _SCA_PYTHON_DEBUG +#endif +#include +#ifdef _SCA_PYTHON_DEBUG +#define _DEBUG +#endif + + +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(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. + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/export.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/export.h new file mode 100644 index 0000000000..b608a50711 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 +#include +#include +#define SCA_PYTHON_API +#endif + +#endif // tuscany_sca_export_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.cpp new file mode 100644 index 0000000000..413d87173d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.cpp @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/Reference.h" +#include "tuscany/sca/util/Utils.h" + +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(1,"PythonImplementation::constructor"); + LOGEXIT(1,"PythonImplementation::constructor"); + } + + PythonImplementation::~PythonImplementation() + { + LOGENTRY(1,"PythonImplementation::destructor"); + LOGEXIT(1,"PythonImplementation::destructor"); + } + + void PythonImplementation::initializeComponent(Component* component) + { + LOGENTRY(1,"PythonImplementation::initializeComponent"); + 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++; + } + + LOGEXIT(1,"PythonImplementation::initializeComponent"); + } + + } // End namespace python + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.h new file mode 100644 index 0000000000..6d4cece5fd --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonImplementation.h @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "tuscany/sca/model/ComponentType.h" + +#include +using std::map; +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace python + { + /** + * Holds information about an SCA implementation written in Python + */ + class PythonImplementation : public 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(Composite* composite, const string& module, const string& modulePath, const string& className, Scope scope); + + /** + * Destructor + */ + virtual ~PythonImplementation(); + + /** + * Initialize a component of this type. + * @param component The component to initialize. + */ + virtual void initializeComponent(Component* component); + + /** + * Returns the name of the module. + * @return The name of the module. + */ + const string& getModule() const { return module; } + + /** + * Get the header path. + * @return The pathe element of the header. + */ + const string& getModulePath() const { return modulePath; } + + /** + * Get the name of the class. + * @return The class name if specified. + */ + const string& getClass() const { return className; } + + /** + * Returns the implementation scope + */ + Scope getScope() const { return scope; } + + private: + + /** + * Name of the module. + */ + string module; + + /** + * Path to the module. + */ + 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. + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.cpp new file mode 100644 index 0000000000..6836158e0d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.cpp @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + + +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(1, "PythonInterface::constructor"); + LOGEXIT(1, "PythonInterface::constructor"); + } + + PythonInterface::~PythonInterface() + { + } + + } // End namespace python + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.h new file mode 100644 index 0000000000..ed42a3920d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonInterface.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_python_model_pythoninterface_h +#define tuscany_sca_python_model_pythoninterface_h + +#include "tuscany/sca/python/export.h" +#include "tuscany/sca/model/Interface.h" + +#include +using std::map; +#include +using std::vector; +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace python + { + /** + * Holds information about an interface described using a C++ + * header file. + */ + class PythonInterface : public 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 string& getInterfaceTypeQName() { return typeQName; }; + + /** + * The QName of the schema type for this interface type. + */ + SCA_PYTHON_API static const string typeQName; + + }; + + } // End namespace python + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_python_model_pythoninterface_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.cpp new file mode 100644 index 0000000000..82f5811203 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.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/python/model/PythonReferenceBinding.h" +#include "tuscany/sca/python/PythonServiceProxy.h" + + +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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.h new file mode 100644 index 0000000000..b37d261416 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonReferenceBinding.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_python_model_pythonreferencebinding_h +#define tuscany_sca_python_model_pythonreferencebinding_h + +#include "tuscany/sca/model/ReferenceBinding.h" + + +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace python + { + /** + * Information about a Python service binding for service or a reference. + */ + class PythonReferenceBinding : public ReferenceBinding + { + public: + + /** + * Constructor. + */ + PythonReferenceBinding(Reference* reference); + + /** + * Destructor. + */ + virtual ~PythonReferenceBinding(); + + /** + * Returns the type of binding. + */ + virtual 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(ServiceBinding* serviceBinding); + + /** + * Returns the target service binding. + */ + ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; }; + + private: + + /** + * The proxy representing the reference to the client + * component. + */ + ServiceProxy* serviceProxy; + + /** + * The service binding of the target + */ + ServiceBinding* targetServiceBinding; + }; + + } // End namespace python + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_python_model_pythonreferencebinding_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.cpp new file mode 100644 index 0000000000..544682c18e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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" + +namespace tuscany +{ + namespace sca + { + namespace python + { + + // Constructor + PythonServiceBinding::PythonServiceBinding(Service* service) + : ServiceBinding(service, "") + { + LOGENTRY(1,"PythonServiceBinding::constructor"); + serviceWrapper = new PythonServiceWrapper(service); + LOGEXIT(1,"PythonServiceBinding::constructor"); + } + + // Destructor + PythonServiceBinding::~PythonServiceBinding() + { + LOGENTRY(1,"PythonServiceBinding::destructor"); + LOGEXIT(1,"PythonServiceBinding::destructor"); + } + + ServiceWrapper* PythonServiceBinding::getServiceWrapper() + { + LOGENTRY(1,"PythonServiceBinding::getServiceWrapper"); + LOGEXIT(1,"PythonServiceBinding::getServiceWrapper"); + return (ServiceWrapper*)serviceWrapper; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.h new file mode 100644 index 0000000000..f2d64b3edc --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/model/PythonServiceBinding.h @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "tuscany/sca/model/ServiceBinding.h" +using namespace tuscany::sca::model; +#include +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace python + { + /** + * Information about a Python service binding for service or a reference. + */ + class PythonServiceBinding : public 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(Service* service); + + /** + * Destructor. + */ + virtual ~PythonServiceBinding(); + + /** + * Returns the type of binding. + */ + virtual 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp new file mode 100644 index 0000000000..d3a92ba57b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp @@ -0,0 +1,380 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 + +#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 tuscany::sca; +using namespace tuscany::sca::model; + +#include "PythonServiceProxy.h" +using namespace tuscany::sca::python; + +#include "tuscany/sca/util/Logging.h" + +#include +#include +using namespace std; + +static PyObject* scaError; + +/** +* Prints out PyObject and dir(PyObject) +* for debugging purposes +*/ +static void printPyObject(char* prefix, char* name, PyObject* pObj) +{ + LOGINFO(4, "Entering printPyObject"); + PyObject* pObjRepr = PyObject_Repr(pObj); + LOGINFO_3(4, "%s printPyObject %s: %s", prefix, name, PyString_AsString(pObjRepr)); + Py_XDECREF(pObjRepr); + + if(pObj != NULL) + { + PyObject* pObjDir = PyObject_Dir(pObj); + PyObject* pObjDirRepr = PyObject_Repr(pObjDir); + LOGINFO_3(4, "%s printPyObject dir(%s): %s", prefix, name, PyString_AsString(pObjDirRepr)); + Py_DECREF(pObjDirRepr); + Py_DECREF(pObjDir); + } + LOGINFO(4, "Returning from printPyObject"); +} + +static PyObject* sca_locateservice(PyObject *self, PyObject *args) +{ + // 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(0, 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 PythonServiceProxy* getServiceProxy(PyObject *args) +{ + LOGENTRY(1, "sca_module getPythonServiceProxy"); + + PythonServiceProxy* serviceProxy = NULL; + SCARuntime* runtime = SCARuntime::getInstance(); + + // 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_1(3, "sca_invoke Service/Reference name is %s", name.c_str()); + } + else + { + string msg = "sca_invoke Service/Reference name has not been set"; + LOGERROR(1, 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 = "sca_invoke Could not find the reference named "+name; + LOGERROR(1, msg.c_str()); + PyErr_SetString(scaError, msg.c_str()); + + return NULL; + } + + ReferenceBinding* refBinding = ref->getBinding(); + serviceProxy = (PythonServiceProxy*) refBinding->getServiceProxy(); + } + else + { + Component* component = runtime->getDefaultComponent(); + Composite* composite = (Composite*)component->getType(); + Service* service = composite->findComponentService(name); + + if(!service) + { + string msg = "sca_invoke Could not find the service named "+name; + LOGERROR(1, msg.c_str()); + PyErr_SetString(scaError, msg.c_str()); + return NULL; + } + + serviceProxy = new PythonServiceProxy(service); + } + + return serviceProxy; +} + + +static PyObject* sca_invoke(PyObject *self, PyObject *args) +{ + LOGENTRY(1, "sca_invoke"); + + PythonServiceProxy* pythonServiceProxy = getServiceProxy(args); + if(!pythonServiceProxy) + { + return NULL; + } + + // 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_1(3, "sca_invoke Operation name is %s", operationName.c_str()); + } + else + { + string msg = "sca_invoke Operation name has not been set"; + LOGERROR(1, msg.c_str()); + PyErr_SetString(scaError, msg.c_str()); + return NULL; + } + + // Create the Operation object + Operation operation(operationName.c_str()); + + // Parameters are the fourth argument + PyObject* paramTuple = PyTuple_GetItem(args, 3); + + // Go through the supplied parameters + for(int i=0; i < PyTuple_Size(paramTuple); i++) + { + PyObject* param = PyTuple_GetItem(paramTuple, i); + + if(PyInt_Check(param)) + { + LOGINFO_2(3, "sca_invoke Param %d is int type: %d", i, PyInt_AsLong(param)); + long* intData = new long; + *intData = PyInt_AsLong(param); + operation.addParameter(intData); + } + else if(PyBool_Check(param)) + { + LOGINFO_2(3, "sca_invoke Param %d is bool type: %d", i, (param == Py_True)); + bool* boolData = new bool; + *boolData = (param == Py_True); + operation.addParameter(boolData); + } + else if(PyLong_Check(param)) + { + LOGINFO_2(3, "sca_invoke Param %d is long type: %l", i, PyLong_AsLong(param)); + long* longData = new long; + *longData = PyLong_AsLong(param); + operation.addParameter(longData); + } + else if(PyFloat_Check(param)) + { + LOGINFO_2(3, "sca_invoke Param %d is float type: %f", i, PyFloat_AsDouble(param)); + double* doubleData = new double; + *doubleData = PyFloat_AsDouble(param); + operation.addParameter(doubleData); + } + else if(PyString_Check(param)) + { + LOGINFO_2(3, "sca_invoke %d is string type: %s", i, PyString_AsString(param)); + const char** stringData = new const char*; + *stringData = PyString_AsString(param); + operation.addParameter(stringData); + } + 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(1, 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(...) + { + string msg = "sca_invoke Exception thrown whilst invoking the service"; + LOGERROR(1, 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; + } + default: + { + Py_INCREF(Py_None); + returnValue = Py_None; + } + + } + + LOGEXIT(1, "sca_invoke"); + return returnValue; +} +static PyMethodDef ModuleMethods[] = +{ + {"locateservice", sca_locateservice, METH_VARARGS, "Locates an SCA service & returns an sca_proxy_class instance"}, + {"invoke", sca_invoke, METH_VARARGS, "Invoke an operation on an SCA service or reference"}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +PyMODINIT_FUNC initsca(void) +{ + LOGENTRY(1, "initsca"); + + // 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); + + LOGEXIT(1, "initsca"); +} diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py new file mode 100644 index 0000000000..1846bf994d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_proxy.py @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# +# +# +# This Python code is 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): + return sca.invoke(self.sca_proxy_name, self.sca_proxy_is_reference, operationName, args) + + return invokeFunction + + def __getattr__(self, operationName): + return self.invoke(operationName) + + def __str__(self): + return '' + + def __repr__(self): + return '' + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_setup.py b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_setup.py new file mode 100644 index 0000000000..9363d5533f --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/src/tuscany/sca/python/sca_setup.py @@ -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. +# +# +# +# +# This Python code builds and/or installs the sca and +# sca_proxy extension modules +# +# Build/install with the following comands: +# python scaSetup.py build +# python scaSetup.py install +# +# + +from distutils.core import setup, Extension, os + +TUSCANY_SCACPP = os.environ.get("TUSCANY_SCACPP") +print 'Using TUSCANY_SCACPP at ' + TUSCANY_SCACPP + +TUSCANY_SDOCPP = os.environ.get("TUSCANY_SDOCPP") +print 'Using TUSCANY_SDOCPP at ' + TUSCANY_SDOCPP + +macros = [] +if os.name == 'nt': + macros = [ ('WIN32',None) ] + +module1 = Extension('sca', + define_macros = macros, + sources = ['sca_module.cpp'], + include_dirs = [ TUSCANY_SCACPP + '/include', + TUSCANY_SCACPP + '/extensions/python/include', + TUSCANY_SDOCPP + '/include'], + libraries = ['tuscany_sca', + 'tuscany_sdo', + 'tuscany_sca_python'], + library_dirs = [ TUSCANY_SCACPP + '/lib', + TUSCANY_SCACPP + '/extensions/python/lib', + TUSCANY_SDOCPP + '/lib']) + +setup (name = 'sca', + version = '1.0', + description = 'The Tuscany SCA package', + url='http://incubator.apache.org/tuscany/', + ext_modules = [module1], + py_modules = ['sca_proxy']) diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/xsd/sca-implementation-python.xsd b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/xsd/sca-implementation-python.xsd new file mode 100644 index 0000000000..e1c7247992 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/xsd/sca-implementation-python.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/xsd/sca-interface-python.xsd b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/xsd/sca-interface-python.xsd new file mode 100644 index 0000000000..dd9075c7fb --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/python/xsd/sca-interface-python.xsd @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/Makefile.am new file mode 100644 index 0000000000..6605dacf9a --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/Makefile.am @@ -0,0 +1,7 @@ +SUBDIRS = src + +datadir=$(prefix)/extensions/ruby + +nobase_data_DATA = xsd/*.xsd + +EXTRA_DIST = xsd \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/deploy.bat b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/deploy.bat new file mode 100644 index 0000000000..176ac4640d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/deploy.bat @@ -0,0 +1,71 @@ +@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%\bin mkdir %rubyextdir%\bin +if not exist %rubyextdir%\lib mkdir %rubyextdir%\lib +if not exist %rubyextdir%\include mkdir %rubyextdir%\include +if not exist %rubyextdir%\include\tuscany mkdir %rubyextdir%\include\tuscany +if not exist %rubyextdir%\include\tuscany\sca mkdir %rubyextdir%\include\tuscany\sca +if not exist %rubyextdir%\include\tuscany\sca\ruby mkdir %rubyextdir%\include\tuscany\sca\ruby +if not exist %rubyextdir%\include\tuscany\sca\ruby\model mkdir %rubyextdir%\include\tuscany\sca\ruby\model +if not exist %rubyextdir%\xsd mkdir %rubyextdir%\xsd + +del %rubyextdir%\bin\tuscany_sca_ruby.* +del %rubyextdir%\lib\*.lib + +copy %srcdir%\tuscany\sca\ruby\*.h %rubyextdir%\include\tuscany\sca\ruby +copy %srcdir%\tuscany\sca\ruby\model\*.h %rubyextdir%\include\tuscany\sca\ruby\model + +copy %srcdir%\..\xsd\*.* %rubyextdir%\xsd + +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 +:end + +endlocal diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/Makefile.am new file mode 100644 index 0000000000..066f3aa284 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/Makefile.am @@ -0,0 +1,31 @@ +libdir=$(prefix)/extensions/ruby/lib +lib_LTLIBRARIES = libtuscany_sca_ruby.la + +install-exec-hook: + cd $(libdir); ln -s -f libtuscany_sca_ruby.so tuscany_sca_ruby.so + +includedir=$(prefix)/extensions/ruby/include +nobase_include_HEADERS = \ +tuscany/sca/ruby/*.h \ +tuscany/sca/ruby/model/*.h + +libtuscany_sca_ruby_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_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \ + -L$(top_builddir)/runtime/core/src -ltuscany_sca \ + -L${RUBY_LIB} -lruby + +INCLUDES = -Imodel -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include \ + -I${RUBY_INCLUDE} + +AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG + \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/Ruby.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/Ruby.h new file mode 100644 index 0000000000..a6b8ee8ffa --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 + +#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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp new file mode 100644 index 0000000000..148bccc025 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.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/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" + +using namespace tuscany::sca::ruby; + +extern "C" +{ + + // Implement the Sca::locateService module function + SCA_RUBY_API VALUE tuscany_sca_ruby_locateService(VALUE module, VALUE value) + { + + // Get the default component + Component* defaultComponent = tuscany::sca::SCARuntime::getInstance()->getDefaultComponent(); + Composite* composite = (Composite*)defaultComponent->getType(); + + // Locate the service + const char* serviceName = rb_string_value_cstr(&value); + 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 + RubyServiceProxy* serviceProxy = new RubyServiceProxy(service); + + // Return the Ruby proxy value object + return serviceProxy->getProxyValue(); + } + + // Initialize the Ruby extension + SCA_RUBY_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_RUBY_API void Init_libtuscany_sca_ruby() + { + Init_tuscany_sca_ruby(); + } +} diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp new file mode 100644 index 0000000000..7153ef4fb1 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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" + + +extern "C" +{ + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void tuscany_sca_extension_initialize() + { + tuscany::sca::ruby::RubyExtension::initialize(); + } +} + +namespace tuscany +{ + namespace sca + { + namespace ruby + { + // =================================================================== + // Constructor for the RubyExtension class. + // =================================================================== + RubyExtension::RubyExtension() + { + LOGENTRY(1, "RubyExtension::constructor"); + LOGEXIT(1, "RubyExtension::constructor"); + } + + // =================================================================== + // Destructor for the RubyExtension class. + // =================================================================== + RubyExtension::~RubyExtension() + { + LOGENTRY(1, "RubyExtension::destructor");; + LOGEXIT(1, "RubyExtension::destructor"); + } + + void RubyExtension::initialize() + { + LOGENTRY(1, "RubyExtension::initialize");; + SCARuntime::getInstance()->registerImplementationExtension(new RubyImplementationExtension()); + LOGEXIT(1, "RubyExtension::initialize");; + } + + } // End namespace ruby + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.h new file mode 100644 index 0000000000..232431ca1e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.cpp new file mode 100644 index 0000000000..2bc5f9d0d9 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.cpp @@ -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$ */ + +#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" + + +namespace tuscany +{ + namespace sca + { + namespace ruby + { + // =================================================================== + // Constructor for the RubyImplementationExtension class. + // =================================================================== + RubyImplementationExtension::RubyImplementationExtension() + { + LOGENTRY(1, "RubyImplementationExtension::constructor"); + LOGEXIT(1, "RubyImplementationExtension::constructor"); + } + + // =================================================================== + // Destructor for the RubyImplementationExtension class. + // =================================================================== + RubyImplementationExtension::~RubyImplementationExtension() + { + LOGENTRY(1, "RubyImplementationExtension::destructor");; + LOGEXIT(1, "RubyImplementationExtension::destructor"); + } + + 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) + { + string implType = scdlImplementation->getType().getName(); + if (implType == "RubyImplementation") + { + 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; + } + else + { + return NULL; + } + } + + } // End namespace ruby + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.h new file mode 100644 index 0000000000..a1c5f26a3e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyImplementationExtension.h @@ -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$ */ + +#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 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 string& getExtensionTypeQName() {return typeQName;} + + virtual ComponentType* getImplementation(Composite* composite, DataObjectPtr scdlImplementation); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace ruby + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_ruby_rubyimplementationextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp new file mode 100644 index 0000000000..228f1f8940 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.cpp @@ -0,0 +1,374 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/RubyServiceProxy.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/util/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" + +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(1,"RubyServiceProxy::constructor"); + + // ---------------------- + // 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(); + + LOGEXIT(1,"RubyServiceProxy::constructor"); + } + + // ============================ + // Constructor: Create a proxy + // ============================ + RubyServiceProxy::RubyServiceProxy(Service* service) + : ServiceProxy(0) + { + LOGENTRY(1,"RubyServiceProxy::constructor"); + + // ---------------------- + // Get the component + // ---------------------- + component = service->getComponent(); + string name = service->getType()->getName(); + + // Get the service wrapper + serviceWrapper = service->getBinding()->getServiceWrapper(); + + // Create the Ruby proxy + createProxy(); + + LOGEXIT(1,"RubyServiceProxy::constructor"); + } + + // ========== + // Destructor + // ========== + RubyServiceProxy::~RubyServiceProxy() + { + LOGENTRY(1,"RubyServiceProxy::destructor"); + LOGEXIT(1,"RubyServiceProxy::destructor"); + } + + void RubyServiceProxy::createProxy() + { + // 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) + { + // 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)); + + 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) + { + operation.addParameter(&dob); + } + 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()); + VALUE vstr[1]; + vstr[0] = rb_str_new2(str); + + value = rb_class_new_instance(1, vstr, RubyImplementation::getXMLDocumentClass()); + break; + } + default: + { + //throw new ComponentInvocationException("Operation parameter type not supported"); + string msg = "Operation parameter type not supported" + resultType; + rb_raise(rb_eRuntimeError, msg.c_str()); + return Qnil; + } + } + + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.h new file mode 100644 index 0000000000..f4692733f1 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceProxy.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_ruby_rubyserviceproxy_h +#define tuscany_sca_ruby_rubyserviceproxy_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" + +using namespace tuscany::sca::model; + +#include "tuscany/sca/ruby/Ruby.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(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(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 + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp new file mode 100644 index 0000000000..a0eb97142d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp @@ -0,0 +1,724 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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/RubyServiceWrapper.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/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" +#include "commonj/sdo/SDO.h" + +using commonj::sdo::PropertyList; + +namespace tuscany +{ + namespace sca + { + namespace ruby + { + + // =========== + // Constructor + // =========== + RubyServiceWrapper::RubyServiceWrapper(Service* service) + : ServiceWrapper(service) + { + LOGENTRY(1,"RubyServiceWrapper::constructor"); + + component = service->getComponent(); + implementation = (RubyImplementation*)component->getType(); + interf = service->getType()->getInterface(); + + LOGEXIT(1,"RubyServiceWrapper::constructor"); + + } + + // ========== + // Destructor + // ========== + RubyServiceWrapper::~RubyServiceWrapper() + { + LOGENTRY(1,"RubyServiceWrapper::destructor"); + LOGEXIT(1,"RubyServiceWrapper::destructor"); + } + + // ====================================================================== + // invoke: wrapper call to service with setting the component context + // ====================================================================== + void RubyServiceWrapper::invoke(Operation& operation) + { + LOGENTRY(1,"RubyServiceWrapper::invoke"); + + SCARuntime* runtime = SCARuntime::getInstance(); + 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()); + VALUE vstr[1]; + vstr[0] = rb_str_new2(str); + + value = rb_class_new_instance(1, vstr, RubyImplementation::getXMLDocumentClass()); + break; + } + default: + { + //throw new ComponentInvocationException("Operation parameter type not supported"); + string msg = "Operation parameter type not supported" + parmType; + throw msg.c_str(); + } + } + + args[i] = value; + } + } + + + // Invoke the specified method + VALUE result; + if (n == 0) + { + result = rb_funcall(instance, method, 0); + } + else + { + result = rb_funcall2(instance, method, n, args); + } + + // 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)); + + Composite* composite = component->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) + { + operation.setReturnValue(&dob); + } + else + { + string msg = "Document could not be converted to a DataObject"; + throw msg.c_str(); + } + } + else + { + string msg = "Ruby type not supported: " + resultType; + throw msg.c_str(); + } + break; + } + default: + { + string msg = "Ruby type not supported: " + resultType; + throw msg.c_str(); + } + } + + } + catch (...) + { + runtime->unsetCurrentComponent(); + throw; + } + runtime->unsetCurrentComponent(); + LOGEXIT(1,"RubyServiceWrapper::invoke"); + + } + + } // End namespace ruby + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.h new file mode 100644 index 0000000000..849bbdd33e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.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_ruby_rubyservicewrapper_h +#define tuscany_sca_ruby_rubyservicewrapper_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" +#include "tuscany/sca/ruby/export.h" + +#include "tuscany/sca/ruby/Ruby.h" + +using namespace tuscany::sca::model; + +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(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. + */ + Component* component; + + /** + * A pointer to the interface which the service exposes. + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/export.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/export.h new file mode 100644 index 0000000000..21f09dddfc --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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_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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.cpp new file mode 100644 index 0000000000..877b98e7b4 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.cpp @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +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() + { + } + + void RubyImplementation::loadClass() + { + // 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; + } + + // Load the specified Ruby script + if (script != "") + { + // Convert any windows slashes \ in the root path to unix slashes / + // otherwise the ruby interpreter throws an error + 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 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.h new file mode 100644 index 0000000000..32b5801f42 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyImplementation.h @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "tuscany/sca/model/ComponentType.h" + +#include +using std::map; +#include +using std::string; + +#include "tuscany/sca/ruby/Ruby.h" + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace ruby + { + /** + * Holds information about an SCA implementation written in Ruby + */ + class RubyImplementation : public 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(Composite* composite, const string& module, const string& className, const string& script); + + /** + * Destructor + */ + virtual ~RubyImplementation(); + + /** + * Initialize a component of this type. + * @param component The component to initialize. + */ + virtual void initializeComponent(Component* component); + + /** + * Returns the name of the Ruby module. + * @return The name of the Ruby module. + */ + const string& getModule() const { return module; } + + /** + * Returns the name of Ruby class. + * @return Name of the Ruby class. + */ + const string& getClass() const { return className; } + + /** + * Returns the path of the Ruby script. + * @return The path of the Ruby script. + */ + const string& getScript() const { return script; } + + /** + * Returns the Ruby implementation class + */ + VALUE getImplementationClass() const { return implementationClass; } + + /** + * Returns the Ruby REXML::Document class + */ + static VALUE getXMLDocumentClass() { return xmlDocumentClass; } + + private: + + /** + * Load the Ruby implementation class + */ + void loadClass(); + + /** + * Name of the Ruby module. + */ + string module; + + /** + * Name of the Ruby class. + */ + string className; + + /** + * Path of the Ruby script. + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.cpp new file mode 100644 index 0000000000..0e813983f2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.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/ruby/model/RubyReferenceBinding.h" +#include "tuscany/sca/ruby/RubyServiceProxy.h" + + +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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.h new file mode 100644 index 0000000000..cab1c22c48 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyReferenceBinding.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_ruby_model_rubyreferencebinding_h +#define tuscany_sca_ruby_model_rubyreferencebinding_h + +#include "tuscany/sca/model/ReferenceBinding.h" + + +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace ruby + { + /** + * Information about a Ruby service binding for service or a reference. + */ + class RubyReferenceBinding : public ReferenceBinding + { + public: + + /** + * Constructor. + */ + RubyReferenceBinding(Reference* reference); + + /** + * Destructor. + */ + virtual ~RubyReferenceBinding(); + + /** + * Returns the type of binding. + */ + virtual 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(ServiceBinding* serviceBinding); + + /** + * Returns the target service binding. + */ + ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; }; + + private: + + /** + * The proxy representing the reference to the client + * component. + */ + ServiceProxy* serviceProxy; + + /** + * The service binding of the target + */ + ServiceBinding* targetServiceBinding; + }; + + } // End namespace ruby + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_ruby_model_rubyreferencebinding_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.cpp new file mode 100644 index 0000000000..376a4db0f7 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.cpp @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.h new file mode 100644 index 0000000000..24c0275bb9 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/model/RubyServiceBinding.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_ruby_model_rubyservicebinding_h +#define tuscany_sca_ruby_model_rubyservicebinding_h + +#include "tuscany/sca/model/ServiceBinding.h" +using namespace tuscany::sca::model; +#include +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace ruby + { + /** + * Information about a Ruby service binding for service or a reference. + */ + class RubyServiceBinding : public ServiceBinding + { + public: + + /** + * Constructor. + */ + RubyServiceBinding(Service* service); + + /** + * Destructor. + */ + virtual ~RubyServiceBinding(); + + /** + * Returns the type of binding. + */ + virtual 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/xsd/sca-implementation-ruby.xsd b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/xsd/sca-implementation-ruby.xsd new file mode 100644 index 0000000000..f6598590d1 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ruby/xsd/sca-implementation-ruby.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/Makefile.am new file mode 100644 index 0000000000..9e104f739f --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/Makefile.am @@ -0,0 +1,6 @@ +SUBDIRS = reference service +datadir=$(prefix)/extensions/sca + +nobase_data_DATA = xsd/*.xsd + +EXTRA_DIST = xsd diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/Makefile.am new file mode 100644 index 0000000000..f3ba006041 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = axis2c diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/Makefile.am new file mode 100644 index 0000000000..af437a64d6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/Makefile.am new file mode 100644 index 0000000000..ea296e2ca8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/Makefile.am @@ -0,0 +1,21 @@ +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 \ + -L$(top_builddir)/runtime/extensions/ws/reference/axis2c/src -ltuscany_sca_ws_reference + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include \ + -I$(top_builddir)/runtime/extensions/ws/reference/axis2c/src + +AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp new file mode 100644 index 0000000000..b12702bf43 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "model/SCAServiceBinding.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/core/SCARuntime.h" + +extern "C" +{ + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void tuscany_sca_extension_initialize() + { + tuscany::sca::binding::SCAServiceBindingExtension::initialize(); + } +} + + +namespace tuscany +{ + namespace sca + { + namespace binding + { + // =================================================================== + // Constructor for the SCAServiceBinding class. + // =================================================================== + SCAServiceBindingExtension::SCAServiceBindingExtension() + { + LOGENTRY(1, "SCAServiceBindingExtension::constructor"); + LOGEXIT(1, "SCAServiceBindingExtension::constructor"); + } + + // =================================================================== + // Destructor for the SCAServiceBindingExtension class. + // =================================================================== + SCAServiceBindingExtension::~SCAServiceBindingExtension() + { + LOGENTRY(1, "SCAServiceBindingExtension::destructor");; + LOGEXIT(1, "SCAServiceBindingExtension::destructor"); + } + + 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) + { + string bindingType = scdlBinding->getType().getName(); + if (bindingType == "SCABinding") + { + string uri = scdlBinding->getCString("uri"); + + SCAServiceBinding* serviceBinding = new SCAServiceBinding(service, uri); + + return serviceBinding; + } + else + { + return NULL; + } + } + + void SCAServiceBindingExtension::initialize() + { + LOGENTRY(1, "SCAServiceBindingExtension::initialize");; + SCARuntime::getInstance()->registerServiceBindingExtension(new SCAServiceBindingExtension()); + LOGEXIT(1, "SCAServiceBindingExtension::initialize");; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.h new file mode 100644 index 0000000000..4cd05bee16 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.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_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 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 string& getExtensionTypeQName() {return typeQName;} + + virtual ServiceBinding* getServiceBinding(Composite* composite, Service* service, DataObjectPtr scdlBinding); + + static void initialize(); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace binding + } // End namespace sca +} // End namespace tuscany + +#endif //tuscany_sca_extension_binding_scaservicebindingextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/model/SCAServiceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/model/SCAServiceBinding.cpp new file mode 100644 index 0000000000..a6b052f04f --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/model/SCAServiceBinding.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/util/Logging.h" +#include "tuscany/sca/binding/model/SCAServiceBinding.h" +#include "tuscany/sca/core/ServiceWrapper.h" + +namespace tuscany +{ + namespace sca + { + namespace binding + { + + // Constructor + SCAServiceBinding::SCAServiceBinding(Service* service, const string& uri) + : WSServiceBinding(service, uri, "", "") + { + } + + // Destructor + SCAServiceBinding::~SCAServiceBinding() + { + } + + } // End namespace binding + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/model/SCAServiceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/model/SCAServiceBinding.h new file mode 100644 index 0000000000..90eb222b7b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/model/SCAServiceBinding.h @@ -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$ */ + +#ifndef tuscany_sca_extension_binding_model_scaservicebinding_h +#define tuscany_sca_extension_binding_model_scaservicebinding_h + +#include "tuscany/sca/model/ServiceBinding.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/ws/model/WSServiceBinding.h" + +#include +using std::string; + +using namespace tuscany::sca::model; +using namespace tuscany::sca::ws; + +namespace tuscany +{ + namespace sca + { + namespace binding + { + /** + * Information about an SCA service binding for service or a reference. + */ + class SCAServiceBinding : public WSServiceBinding + { + public: + + /** + * Constructor. + * @param uri The uri of the binding. + */ + SCAServiceBinding(model::Service* service, const string& uri); + + /** + * Destructor. + */ + virtual ~SCAServiceBinding(); + + /** + * Returns the type of binding. + */ + virtual string getType() { return "http://www.osoa.org/xmlns/sca/1.0#SCABinding"; }; + + private: + + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_ws_model_wsservicebinding_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/Makefile.am new file mode 100644 index 0000000000..f3ba006041 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = axis2c diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/Makefile.am new file mode 100644 index 0000000000..f963effea2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/Makefile.am new file mode 100644 index 0000000000..4339ff624e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/Makefile.am @@ -0,0 +1,21 @@ +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 \ + -L$(top_builddir)/runtime/extensions/ws/service/axis2c/src -ltuscany_sca_ws_service + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include \ + -I$(top_builddir)/runtime/extensions/ws/service/axis2c/src + +AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp new file mode 100644 index 0000000000..7fb9b4af64 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + + +extern "C" +{ + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void tuscany_sca_extension_initialize() + { + tuscany::sca::binding::SCAReferenceBindingExtension::initialize(); + } +} + +namespace tuscany +{ + namespace sca + { + namespace binding + { + // =================================================================== + // Constructor for the SCAReferenceBinding class. + // =================================================================== + SCAReferenceBindingExtension::SCAReferenceBindingExtension() + { + LOGENTRY(1, "SCAReferenceBindingExtension::constructor"); + LOGEXIT(1, "SCAReferenceBindingExtension::constructor"); + } + + // =================================================================== + // Destructor for the SCAReferenceBindingExtension class. + // =================================================================== + SCAReferenceBindingExtension::~SCAReferenceBindingExtension() + { + LOGENTRY(1, "SCAReferenceBindingExtension::destructor");; + LOGEXIT(1, "SCAReferenceBindingExtension::destructor"); + } + + 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) + { + string bindingType = scdlBinding->getType().getName(); + if (bindingType == "SCABinding") + { + string uri = scdlBinding->getCString("uri"); + + SCAReferenceBinding* serviceBinding = new SCAReferenceBinding(reference, uri); + + return serviceBinding; + } + else + { + return NULL; + } + } + + void SCAReferenceBindingExtension::initialize() + { + LOGENTRY(1, "SCAReferenceBindingExtension::initialize");; + SCARuntime::getInstance()->registerReferenceBindingExtension(new SCAReferenceBindingExtension()); + LOGEXIT(1, "SCAReferenceBindingExtension::initialize");; + } + + } // End namespace binding + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.h new file mode 100644 index 0000000000..9f5ddd55eb --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.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_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 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 string& getExtensionTypeQName() {return typeQName;} + + virtual ReferenceBinding* getReferenceBinding(Composite* composite, Reference *reference, DataObjectPtr scdlBinding); + + static void initialize(); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace binding + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_binding_scareferencebindingextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/model/SCAReferenceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/model/SCAReferenceBinding.cpp new file mode 100644 index 0000000000..6e7b4eaccc --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/model/SCAReferenceBinding.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/util/Logging.h" +#include "tuscany/sca/binding/model/SCAReferenceBinding.h" +#include "tuscany/sca/ws/model/WSReferenceBinding.h" +#include "tuscany/sca/core/ServiceProxy.h" + +namespace tuscany +{ + namespace sca + { + namespace binding + { + + // Constructor + SCAReferenceBinding::SCAReferenceBinding(Reference* reference, const string& uri) + : WSReferenceBinding(reference, uri, "", "") + { + } + + // Destructor + SCAReferenceBinding::~SCAReferenceBinding() + { + } + + } // End namespace binding + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/model/SCAReferenceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/model/SCAReferenceBinding.h new file mode 100644 index 0000000000..445a00be82 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/model/SCAReferenceBinding.h @@ -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$ */ + +#ifndef tuscany_sca_extension_binding_model_scareferencebinding_h +#define tuscany_sca_extension_binding_model_scareferencebinding_h + +#include "tuscany/sca/model/ReferenceBinding.h" +#include "tuscany/sca/ws/model/WSReferenceBinding.h" + +using namespace tuscany::sca::model; +using namespace tuscany::sca::ws; + +#include +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace binding + { + /** + * Information about a web service binding for service or a reference. + */ + class SCAReferenceBinding : public WSReferenceBinding + { + public: + + /** + * Constructor. + * @param uri The uri of the binding. + */ + SCAReferenceBinding(Reference* reference, const string&uri); + + /** + * Destructor. + */ + virtual ~SCAReferenceBinding(); + + /** + * Returns the type of binding. + */ + virtual string getType() { return "http://www.osoa.org/xmlns/sca/1.0#SCABinding"; }; + + private: + + }; + + } // End namespace binding + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_binding_model_scareferencebinding_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/xsd/sca-binding-sca.xsd b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/xsd/sca-binding-sca.xsd new file mode 100644 index 0000000000..1051c3910c --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/sca/xsd/sca-binding-sca.xsd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/Makefile.am new file mode 100644 index 0000000000..ca91c69428 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/Makefile.am @@ -0,0 +1,6 @@ +SUBDIRS = reference service +datadir=$(prefix)/extensions/ws + +nobase_data_DATA = xsd/*.xsd + +EXTRA_DIST = xsd diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/deploy.bat b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/deploy.bat new file mode 100644 index 0000000000..567875624f --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 +:end + +endlocal diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/Makefile.am new file mode 100644 index 0000000000..f3ba006041 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = axis2c diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/Makefile.am new file mode 100644 index 0000000000..af437a64d6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/Makefile.am new file mode 100644 index 0000000000..e5a9433333 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/Makefile.am @@ -0,0 +1,32 @@ +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 + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp new file mode 100644 index 0000000000..8174e23f3d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp @@ -0,0 +1,704 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 + +#include +#include +#include +#include +#include + +#include +#include "Axis2Client.h" + +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/util/Logging.h" +#include "model/WSServiceBinding.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/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" + +#include + +using namespace tuscany::sca::ws; + + +using namespace commonj::sdo; +using namespace commonj::sdo_axiom; + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + Axis2Client::Axis2Client(CompositeReference* compositeReference) + : compositeReference(compositeReference) + { + } + + Axis2Client::~Axis2Client() + { + } + + void Axis2Client::invoke(tuscany::sca::Operation& operation) + { + LOGENTRY(1, "Axis2Client::invoke"); + + // Initialize Axis2 stuff + axis2_allocator_t *allocator = axis2_allocator_init (NULL); + axis2_log_t *log = axis2_log_create(allocator, NULL, "tuscany_client.log"); + axis2_error_t *error = axis2_error_create(allocator); + axis2_env_t *env = axis2_env_create_with_error_log(allocator, error, log); + env->log->level = 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) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "WSDL description %s not found\n", wsdlNamespace.c_str()); + string msg = "WSDL not found for " + wsdlNamespace; + throw 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 &ex) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "SystemConfigurationException has been caught: %s\n", ex.getMessageText()); + 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) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "WSDL description %s not found\n", wsdlNamespace.c_str()); + string msg = "WSDL not found for " + wsdlNamespace; + throw SystemConfigurationException(msg.c_str()); + } + + try + { + wsdlOperation = wsdl->findOperation(wsdlInterface->getName(), operationName); + } + catch(SystemConfigurationException &ex) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "SystemConfigurationException has been caught: %s\n", ex.getMessageText()); + 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(wsdlNamespace + "#" + operationName); + wsdlOperation.setOutputType(wsdlNamespace + "#" + operationName + "Response"); + } + + // Get the target endpoint address + // The URI specified in the binding overrides the address specified in + // the WSDL + axis2_char_t* address; + if (binding->getURI() != "") + { + address = (axis2_char_t*)binding->getURI().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(); + axis2_char_t* serviceName = (axis2_char_t*)binding->getServiceName().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); + + /* Create service client */ + + axis2_char_t* client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + { + throw SystemConfigurationException("Environment error: AXIS2C_HOME not set"); + } + axis2_svc_client_t* svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "invoke FAILED: Error code:" + " %d :: %s", env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + + throw SystemConfigurationException("Axis2Client: axis2_svc_client_create failed"); + } + + /* Set service client options */ + AXIS2_SVC_CLIENT_SET_OPTIONS(svc_client, env, options); + + /* 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); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invoke failed: Error code:" + " %d :: %s", env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + throw SystemConfigurationException("Axis2Client: Invoke failed"); + } + + LOGINFO(2, "Warning: Have not freed Axis2C service client memory due to Jira AXIS2C-209"); + // Uncommenting this code causes crash when invoking a composite with both Axis2C ws.binding + // service and reference. See Jiras TUSCANY-536 and AXIS2C-209 + //if (svc_client) + //{ + // AXIS2_SVC_CLIENT_FREE(svc_client, env); + // svc_client = NULL; + //} + + LOGEXIT(1, "Axis2Client::invoke"); + } + + axiom_node_t* Axis2Client::createPayload(Operation& operation, + const WSDLOperation& wsdlOperation, + axis2_env_t* env) + { + LOGENTRY(1, "Axis2Client::createPayload"); + axiom_node_t* request_node = NULL; + + // map the operation request to the wsdl + if (wsdlOperation.isDocumentStyle()) + { + // Document style + // only support single part messages - WS-I compliant + + // 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 output wrapper + const Type& inputType = dataFactory->getType(wsdlOperation.getInputTypeUri().c_str(), + wsdlOperation.getInputTypeName().c_str()); + inputDataObject = dataFactory->create(inputType); + } + catch (SDORuntimeException e) + { + // The input wrapper type is not known, create an open DataObject + 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 (int i=0; igetList(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: throw "unsupported parameter type"; + } + } + } + } + else { + + // Each parameter in the operation should be a property on the request dataobject + for (int i=0; isetBoolean(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: throw "unsupported parameter type"; + } + } + } + + // 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); + } + else + { + // RPC + } + + char* str = AXIOM_NODE_TO_STRING(request_node, env); + LOGINFO_1(3, "Sending this OM node in XML : %s \n", str); + + LOGEXIT(1, "Axis2Client::createPayload"); + return request_node; + } + + void Axis2Client::setReturn(axiom_node_t* ret_node, + Operation& operation, + const WSDLOperation& wsdlOperation, + axis2_env_t* env) + { + LOGENTRY(1, "Axis2Client::setReturn"); + + if (wsdlOperation.isDocumentStyle()) + { + // Document style + 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) + { + AXIS2_LOG_INFO((env)->log, "Axis2Client invoke has response OM: %s\n", str); + } + + // Convert the SOAP body to an SDO DataObject + AxiomHelper* axiomHelper = AxiomHelper::getHelper(); + DataObjectPtr outputBodyDataObject = axiomHelper->toSdo(body, dataFactory); + AxiomHelper::releaseHelper(axiomHelper); + + if(!outputBodyDataObject) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service invoke: Could not convert received Axiom node to SDO"); + /** TODO: return a SOAP fault here */ + return; + } + + // 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) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Client invoke: Could not convert body part to SDO"); + return; + } + + 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; + } + //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[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 = outputDataObject->getDataObject(pl[i]); + if(!dataObjectData) + { + LOGINFO(4, "SDO DataObject return value was null"); + } + operation.setReturnValue(&dataObjectData); + } + break; + case Type::OpenDataObjectType: + { + /* + * This code deals with xsd:any element parameters + */ + + DataObjectList& dataObjectList = outputDataObject->getList(pl[i]); + + for(int j=0; jgetSequence(); + 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 dob = sequence->getDataObjectValue(0); + if(!dob) + { + LOGINFO(4, "SDO DataObject return value was null"); + } + operation.setReturnValue(&dob); + } + } + else + { + // Empty content, add an empty string + LOGINFO(4, "SDO OpenDataObject return value was empy"); + string *stringData = new string(""); + operation.setReturnValue(stringData); + } + } + } + } + break; + case Type::DateType: + LOGERROR(0, "SDO DateType return values are not yet supported"); + break; + case Type::LongType: + LOGERROR(0, "SDO LongType (int64_t) return values are not yet supported"); + break; + case Type::UriType: + LOGERROR(0, "SDO UriType return values are not yet supported"); + break; + case Type::BigDecimalType: + LOGERROR(0, "SDO BigDecimalType return values are not yet supported"); + break; + case Type::BigIntegerType: + LOGERROR(0, "SDO BigIntegerType return values are not yet supported"); + break; + default: + LOGERROR(0, "Unknown SDO type has been found in return value. Unknown types are not yet supported"); + break; + } + } + else + { + // RPC + } + LOGEXIT(1, "Axis2Client::setReturn"); + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.h new file mode 100644 index 0000000000..5ec302f0c8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.h @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 + +#include "tuscany/sca/core/Operation.h" +#include "tuscany/sca/model/CompositeReference.h" +#include "tuscany/sca/model/WSDLOperation.h" + +using namespace tuscany::sca::model; + + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + class Axis2Client + { + public: + Axis2Client(CompositeReference* externalService); + virtual ~Axis2Client(); + + virtual void invoke(Operation& operation); + + private: + CompositeReference* compositeReference; + + axiom_node_t* createPayload(Operation& operation, + const WSDLOperation& wsdlOp, + axis2_env_t* env); + + void setReturn(axiom_node_t* returnNode, + Operation& operation, + const 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp new file mode 100644 index 0000000000..c260445b60 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp @@ -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$ */ + +#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" + +extern "C" +{ + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void tuscany_sca_extension_initialize() + { + tuscany::sca::ws::WSServiceBindingExtension::initialize(); + } +} + + +namespace tuscany +{ + namespace sca + { + namespace ws + { + // =================================================================== + // Constructor for the WSServiceBinding class. + // =================================================================== + WSServiceBindingExtension::WSServiceBindingExtension() + { + LOGENTRY(1, "WSServiceBindingExtension::constructor"); + LOGEXIT(1, "WSServiceBindingExtension::constructor"); + } + + // =================================================================== + // Destructor for the WSServiceBindingExtension class. + // =================================================================== + WSServiceBindingExtension::~WSServiceBindingExtension() + { + LOGENTRY(1, "WSServiceBindingExtension::destructor");; + LOGEXIT(1, "WSServiceBindingExtension::destructor"); + } + + 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) + { + string bindingType = scdlBinding->getType().getName(); + if (bindingType == "WebServiceBinding") + { + string uri = scdlBinding->getCString("uri"); + string endpoint = scdlBinding->getCString("endpoint"); + commonj::sdo::DataObjectList& soap = scdlBinding->getList("soapbinding"); + string version; + if (soap.size()!=0) + { + version = soap.getCString(0); + } + else + { + version = ""; + } + + WSServiceBinding* serviceBinding = new WSServiceBinding(service, uri, endpoint, version); + + return serviceBinding; + } + else + { + return NULL; + } + } + + void WSServiceBindingExtension::initialize() + { + LOGENTRY(1, "WSServiceBindingExtension::initialize");; + SCARuntime::getInstance()->registerServiceBindingExtension(new WSServiceBindingExtension()); + LOGEXIT(1, "WSServiceBindingExtension::initialize");; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.h new file mode 100644 index 0000000000..db2c0c791f --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.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_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 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 string& getExtensionTypeQName() {return typeQName;} + + virtual ServiceBinding* getServiceBinding(Composite* composite, Service* service, DataObjectPtr scdlBinding); + + static void initialize(); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif //tuscany_sca_extension_ws_wsservicebindingextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp new file mode 100644 index 0000000000..5839aa8722 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 "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" + +#include "commonj/sdo/SDO.h" +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) + { + // 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 e) + { + 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); + } + } + + WSServiceWrapper::~WSServiceWrapper() + { + } + + /// + /// This method will be called when a web service call needs to be made. + /// + void WSServiceWrapper::invoke(Operation& operation) + { + LOGENTRY(1, "WSServiceWrapper::invoke"); + + const string& operationName = operation.getName(); + + LOGINFO_2(2,"Service: %s, Operation: %s", getService()->getType()->getName().c_str() , operationName.c_str()); + + for (unsigned int i=0; igetComponent(); + + Axis2Client client(compositeReference); + client.invoke(operation); + + LOGEXIT(1, "WSServiceWrapper::invoke"); + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.h new file mode 100644 index 0000000000..93607db4a2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.h @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +using namespace tuscany::sca::model; + + +namespace tuscany +{ + namespace sca + { + + namespace ws + { + + class WSServiceWrapper : public ServiceWrapper + { + public: + + /** + * Constructor. + * @param target The service wrapper represents a Web service. + */ + WSServiceWrapper(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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.cpp new file mode 100644 index 0000000000..8980ec489b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.cpp @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +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) + { + parseEndpoint(); + + serviceWrapper = new WSServiceWrapper(service); + } + + void WSServiceBinding::parseEndpoint() + { + // Endpoint is of the form: #wsdl.endpoint(/) + 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() + { + } + + ServiceWrapper* WSServiceBinding::getServiceWrapper() + { + return serviceWrapper; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/model/WSServiceBinding.h new file mode 100644 index 0000000000..15691ce6eb --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 "tuscany/sca/model/ServiceBinding.h" +#include "tuscany/sca/model/Service.h" + +#include +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace ws + { + /** + * Information about a web service binding for service or a reference. + */ + class WSServiceBinding : public 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") + */ + WSServiceBinding(model::Service* service, const string& uri, const string& endpoint, const string& version); + + /** + * Destructor. + */ + virtual ~WSServiceBinding(); + + /** + * Returns the type of binding. + */ + virtual string getType() { return "http://www.osoa.org/xmlns/sca/1.0#WebServiceBinding"; }; + + /** + * Create a wrapper for the service configured by this + * binding. + */ + virtual ServiceWrapper* getServiceWrapper(); + + /** + * Return the part of the endpoint definition describing the wsdl + * namespace. + * @return The wsdl namespace. + */ + string getWSDLNamespaceURL() const { return wsdlNamespaceURL; }; + + /** + * Return the service part of the endpoint definition. + * @return The service to use. + */ + string getServiceName() const { return serviceName; }; + + /** + * Return the endpoint name part of the endpoint definition. + * @return The endpoint name to use. + */ + string getEndpointName() const { return endpointName; }; + + /** + * Return the SOAP version. + * @return The SOAP version to use. + */ + string getSOAPVersion() const { return soapVersion; }; + + private: + + /** + * Parse the endpoint specification. + */ + void parseEndpoint(); + + /** + * The full endpoint string. + */ + string endpoint; + + /** + * Namespace from the endpoint. + */ + string wsdlNamespaceURL; + + /** + * Service name from the endpoint. + */ + string serviceName; + + /** + * WSDL Endpoint name. + */ + string endpointName; + + /** + * SOAP version. + */ + 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/deploy.bat b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/deploy.bat new file mode 100644 index 0000000000..2bba10425c --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/reference/deploy.bat @@ -0,0 +1,65 @@ +@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%\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 + +if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %refextdir%\bin + +goto end +:usage +echo Usage: deploy +:end + +endlocal diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/Makefile.am new file mode 100644 index 0000000000..f3ba006041 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = axis2c diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/Makefile.am new file mode 100644 index 0000000000..f963effea2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/Makefile.am new file mode 100644 index 0000000000..30b0635f6b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/Makefile.am @@ -0,0 +1,71 @@ +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 + +moduledir=$(rootdir)/modules/tuscany +module_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 $(moduledir); 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 diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/axis2.xml b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/axis2.xml new file mode 100644 index 0000000000..641085466e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/axis2.xml @@ -0,0 +1,181 @@ + + + + + + false + false + false + true + + admin + axis2 + + . + + 127.0.0.1 + 5555 + + + + + + + + + + + + + + + + + + + + + + + + + 6060 + + + + + + + + + + + + HTTP/1.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/deploy.cmd b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/deploy.cmd new file mode 100644 index 0000000000..6493e1cec9 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/deploy.cmd @@ -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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/deploy.sh b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/deploy.sh new file mode 100755 index 0000000000..ffe571b0ee --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/module.xml b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/module.xml new file mode 100644 index 0000000000..97d4d43a86 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/module.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/services.xml b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/services.xml new file mode 100644 index 0000000000..335d4d96be --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/services.xml @@ -0,0 +1,25 @@ + + + + + tuscany_sca_ws_service + + + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp new file mode 100644 index 0000000000..fe3eb52064 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp @@ -0,0 +1,176 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, + "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) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, + "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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp new file mode 100644 index 0000000000..0dc8f3358a --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 +#include +#include +#include + +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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp new file mode 100644 index 0000000000..046a6e221b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp @@ -0,0 +1,506 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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 +#include +#include +#include +#include +#include + +#include +using commonj::sdo::DataObjectPtr; +using commonj::sdo::DataFactoryPtr; +using commonj::sdo::DataObjectList; +using commonj::sdo::PropertyList; +using commonj::sdo_axiom::AxiomHelper; + +#include "tuscany/sca/util/Exceptions.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/TuscanyRuntime.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/util/Utils.h" +#include "Axis2Utils.h" + +using namespace tuscany::sca; +using namespace tuscany::sca::ws; +using namespace tuscany::sca::model; + +int AXIS2_CALL +Axis2Service_free(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env); + +/* + * This method invokes the right 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); + +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->func_array) + { + AXIS2_ARRAY_LIST_FREE(svc_skeleton->func_array, env); + svc_skeleton->func_array = NULL; + }*/ + + 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 Tuscany runtime + */ + +static string systemRoot = ""; +static string componentName = ""; +static string serviceName = ""; +static TuscanyRuntime* tuscanyRuntime = NULL; +static CompositeService* compositeService = NULL; + +void initTuscanyRuntime(const axis2_env_t *env, const char* root, const char *component, const char* service) +{ + AXIS2_LOG_INFO((env)->log, "Axis2Service init, root: %s, component: %s, service: %s\n", root, component, service); + try + { + + bool newInitParams = false; + + if(systemRoot != root) + { + systemRoot = root; + newInitParams = true; + } + + if(componentName != component) + { + componentName = component; + newInitParams = true; + } + + if(serviceName != service) + { + serviceName = service; + newInitParams = true; + } + + if(tuscanyRuntime == NULL) + { + AXIS2_LOG_INFO((env)->log, "Creating new Tuscany runtime\n"); + tuscanyRuntime = new TuscanyRuntime(componentName, systemRoot); + tuscanyRuntime->start(); + } + else if(tuscanyRuntime != NULL && newInitParams) + { + AXIS2_LOG_INFO((env)->log, "Restarting Tuscany runtime\n"); + tuscanyRuntime->stop(); + tuscanyRuntime->setDefaultComponentName(componentName); + tuscanyRuntime->setSystemRoot(systemRoot); + tuscanyRuntime->start(); + } + + if(compositeService == NULL) + { + Composite* composite = (Composite*)SCARuntime::getInstance()->getDefaultComponent()->getType(); + compositeService = (CompositeService*)composite->findComponent(serviceName); + } + else + { + if(newInitParams) + { + Composite* composite = SCARuntime::getInstance()->getDefaultComponent()->getComposite(); + compositeService = (CompositeService*)composite->findComponent(serviceName); + } + } + } + catch(TuscanyRuntimeException &ex) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText()); + } +} + + +/* + * 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) +{ + 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 *address = AXIS2_ENDPOINT_REF_GET_ADDRESS(endpoint_ref, env); + if (address) + { + axis2_char_t **url_tokens = axis2_parse_request_url_for_svc_and_op(env, address); + if (url_tokens) + { + if (url_tokens[1]) + { + op_name = url_tokens[1]; + } + if (NULL != url_tokens[1]) + AXIS2_FREE(env->allocator, url_tokens[1]); + if (NULL != url_tokens[0]) + AXIS2_FREE(env->allocator, url_tokens[0]); + AXIS2_FREE(env->allocator, url_tokens); + } + } + } + } + else + { + // This gets 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 != "") + { + // Get the Tuscany system root and composite service name from the Axis2 + // service parameters + char* rootParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanySystemRoot"); + if (rootParam == NULL) + rootParam = ""; + + char* serviceParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyService"); + if (serviceParam != NULL) + { + AXIS2_LOG_INFO((env)->log, "Axis2Service invoke called with 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); + + initTuscanyRuntime(env, rootParam, component.c_str(), service.c_str()); + } + else { + + // Use the default 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); + axis2_char_t *address = NULL; + address = (axis2_char_t*) AXIS2_ENDPOINT_REF_GET_ADDRESS(endpoint_ref, env); + axis2_char_t **url_tokens = NULL; + url_tokens = axis2_parse_request_url_for_svc_and_op(env, address); + string service(url_tokens[0]); + + AXIS2_LOG_INFO((env)->log, "Axis2Service invoke called with system root: %s, service name: %s, operation name: %s", rootParam, service.c_str(), op_name.c_str()); + + initTuscanyRuntime(env, rootParam, "", service.c_str()); + } + + if(!compositeService) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: Tuscany initialisation failed"); + return 0; + } + + DataFactoryPtr dataFactory = compositeService->getComposite()->getDataFactory(); + if (dataFactory == 0) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: CompositeService has no SCA implementation"); + return 0; + } + + // Get the WS binding and the WSDL operation + Composite* composite = compositeService->getComposite(); + Reference* reference = compositeService->getReference(); + WSReferenceBinding* binding = (WSReferenceBinding*)reference->getBinding(); + WSDLOperation wsdlOperation; + + 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) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "WSDL description %s not found\n", wsdlNamespace.c_str()); + string msg = "WSDL not found for " + wsdlNamespace; + throw 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 &ex) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "SystemConfigurationException has been caught: %s\n", ex.getMessageText()); + throw; + } + + } + else + { + 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) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "WSDL description %s not found\n", wsdlNamespace.c_str()); + string msg = "WSDL not found for " + wsdlNamespace; + throw SystemConfigurationException(msg.c_str()); + } + + try + { + wsdlOperation = wsdl->findOperation(wsdlInterface->getName(), op_name.c_str()); + } + catch(SystemConfigurationException &ex) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "SystemConfigurationException has been caught: %s\n", ex.getMessageText()); + throw; + } + } + } + } + + if (wsdlNamespace == "") + { + // 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(wsdlNamespace + "#" + op_name); + wsdlOperation.setOutputType(wsdlNamespace + "#" + op_name + "Response"); + } + + // 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) + { + AXIS2_LOG_INFO((env)->log, "Axis2Service invoke has request OM: %s\n", str); + } + + // Convert the SOAP body to an SDO DataObject + AxiomHelper* axiomHelper = AxiomHelper::getHelper(); + DataObjectPtr inputBodyDataObject = NULL; + + try + { + inputBodyDataObject = axiomHelper->toSdo(body, dataFactory); + } + catch(SDORuntimeException &ex) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: SDORuntimeException thrown: %s", ex.getMessageText()); + } + + if(!inputBodyDataObject) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: Could not convert received Axiom node to SDO"); + /** TODO: return a SOAP fault here */ + return 0; + } + + // Get the first body part representing the doc-lit-wrapped wrapper element + DataObjectPtr inputDataObject = NULL; + 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) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: Could not convert body part to SDO"); + return 0; + } + + // Dispatch to the WS proxy + WSServiceProxy* proxy = (WSServiceProxy*)binding->getServiceProxy(); + + DataObjectPtr outputDataObject = proxy->invoke(wsdlOperation, inputDataObject); + + if(!outputDataObject) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: Failure whilst invoking CompositeService"); + + /** TODO: return a SOAP fault here */ + return 0; + } + + // 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) + { + AXIS2_LOG_INFO((env)->log, "Axis2Service invoke has response OM : %s\n", str); + } + + + //LOGEXIT(1, "Axis2Service_invoke"); + return outputNode; + } + } + } + } + + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: invalid OM parameters in request"); + //LOGERROR(0, "Axis2Service service ERROR: invalid OM parameters in request\n"); + + /** TODO: return a SOAP fault here */ + return 0; +} + + +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 = 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp new file mode 100644 index 0000000000..c2ed487d3f --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.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$ */ + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#pragma warning(disable: 4091) +#endif +#include "Axis2Utils.h" + +#include +#include + +#include "tuscany/sca/util/Logging.h" + +using namespace tuscany::sca; +using namespace tuscany::sca::ws; + + +/* Static utility method to retrieve service parameters from the service.xml file + * Get an odd linking error if this method (or the header's it requires) are in + * a different class. + */ +char* Axis2Utils::getAxisServiceParameterValue(const axis2_env_t *env, axis2_msg_ctx_t *msg_ctx, char* parameterName) +{ + 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; + + LOGENTRY(1, "Axis2Utils::getAxisServiceParameterValue"); + + 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) + { + LOGERROR_1(0,"Axis parameter %s cannot be found", parameterName); + } + else + { + paramValue = (char*) AXIS2_PARAM_GET_VALUE(param, env); + } + + LOGEXIT(1, "Axis2Utils::getAxisServiceParameterValue"); + return paramValue; +} + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h new file mode 100644 index 0000000000..4e8b069010 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 +#include + + +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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp new file mode 100644 index 0000000000..2cf5e5d8e1 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp @@ -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$ */ + + +#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" + + +extern "C" +{ + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void tuscany_sca_extension_initialize() + { + tuscany::sca::ws::WSReferenceBindingExtension::initialize(); + } +} + +namespace tuscany +{ + namespace sca + { + namespace ws + { + // =================================================================== + // Constructor for the WSReferenceBinding class. + // =================================================================== + WSReferenceBindingExtension::WSReferenceBindingExtension() + { + LOGENTRY(1, "WSReferenceBindingExtension::constructor"); + LOGEXIT(1, "WSReferenceBindingExtension::constructor"); + } + + // =================================================================== + // Destructor for the WSReferenceBindingExtension class. + // =================================================================== + WSReferenceBindingExtension::~WSReferenceBindingExtension() + { + LOGENTRY(1, "WSReferenceBindingExtension::destructor");; + LOGEXIT(1, "WSReferenceBindingExtension::destructor"); + } + + 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) + { + string bindingType = scdlBinding->getType().getName(); + if (bindingType == "WebServiceBinding") + { + string uri = scdlBinding->getCString("uri"); + string endpoint = scdlBinding->getCString("endpoint"); + commonj::sdo::DataObjectList& soap = scdlBinding->getList("soapbinding"); + string version; + if (soap.size()!=0) + { + version = soap.getCString(0); + } + else + { + version = ""; + } + + WSReferenceBinding* serviceBinding = new WSReferenceBinding(reference, uri, endpoint, version); + + return serviceBinding; + } + else + { + return NULL; + } + } + + void WSReferenceBindingExtension::initialize() + { + LOGENTRY(1, "WSReferenceBindingExtension::initialize");; + SCARuntime::getInstance()->registerReferenceBindingExtension(new WSReferenceBindingExtension()); + LOGEXIT(1, "WSReferenceBindingExtension::initialize");; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h new file mode 100644 index 0000000000..c7972fe15a --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.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_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 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 string& getExtensionTypeQName() {return typeQName;} + + virtual ReferenceBinding* getReferenceBinding(Composite* composite, Reference *reference, DataObjectPtr scdlBinding); + + static void initialize(); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_ws_wsreferencebindingextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp new file mode 100644 index 0000000000..8aca358793 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.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 "WSServiceProxy.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/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" + +#include "commonj/sdo/SDO.h" +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(1,"WSServiceProxy::constructor"); + + // 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 e) + { + + // 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); + } + + LOGEXIT(1,"WSServiceProxy::constructor"); + } + + // ========== + // Destructor + // ========== + WSServiceProxy::~WSServiceProxy() + { + LOGENTRY(1,"WSServiceProxy::destructor"); + LOGEXIT(1,"WSServiceProxy::destructor"); + } + + /// + /// This method will be called to process an operation invocation. + /// + DataObjectPtr WSServiceProxy::invoke(const WSDLOperation& wsdlOperation, DataObjectPtr inputDataObject) + { + LOGENTRY(1,"WSServiceProxy::invoke"); + + Reference* reference = getReference(); + Component* component = reference->getComponent(); + Composite* composite = component ->getComposite(); + + WSReferenceBinding* referenceBinding = (WSReferenceBinding*)reference->getBinding(); + DataFactoryPtr dataFactoryPtr = reference->getComponent()->getComposite()->getDataFactory(); + + bool documentStyle = wsdlOperation.isDocumentStyle(); + bool wrappedStyle = wsdlOperation.isWrappedStyle(); + + const char* outputTypeURI = wsdlOperation.getOutputTypeUri().c_str(); + const char* outputTypeName = wsdlOperation.getOutputTypeName().c_str(); + + LOGINFO_2(4, "WSServiceProxy has got WSDLOperation with inputType: %s#%s", + wsdlOperation.getInputTypeUri().c_str(), + wsdlOperation.getInputTypeName().c_str()); + LOGINFO_2(4, "WSServiceProxy has got WSDLOperation with outputType: %s#%s", + outputTypeURI, + outputTypeName); + LOGINFO_2(4, "WSServiceProxy has got WSDLOperation with documentStyle=%d and wrapped=%d", + documentStyle, + wrappedStyle); + + if (documentStyle) + { + if (wrappedStyle) + { + + // 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(int i=0; igetBoolean(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[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]); + //printf("inputDataObject has FloatType named %s with value %f\n", name, *floatData); + 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 = inputDataObject->getDataObject(pl[i]); + if(!dataObjectData) + { + LOGINFO_1(4, "SDO DataObject parameter named %s was null", name); + } + 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 + */ + + printf("inputDataObject has OpenDataObjectType named %s\n", name); + DataObjectList& dataObjectList = inputDataObject->getList(pl[i]); + + for(int j=0; jgetSequence(); + 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 dob = sequence->getDataObjectValue(0); + if(!dob) + { + LOGINFO_1(4, "SDO DataObject parameter named %s was null", name); + } + operation.addParameter(&dob); + } + } + else + { + // Empty content, add an empty string + LOGINFO_2(4, "SDO OpenDataObject parameter named %s[%d] was empty", name, j); + string* stringData = new string(""); + operation.addParameter(stringData); + } + } + } + } + break; + case Type::DateType: + LOGERROR_1(0, "SDO DateType parameters are not yet supported (%s)", name); + return NULL; + case Type::LongType: + LOGERROR_1(0, "SDO LongType (int64_t) parameters are not yet supported (%s)", name); + return NULL; + break; + case Type::UriType: + LOGERROR_1(0, "SDO UriType parameters are not yet supported (%s)", name); + return NULL; + break; + case Type::BigDecimalType: + LOGERROR_1(0, "SDO BigDecimalType parameters are not yet supported (%s)", name); + return NULL; + break; + case Type::BigIntegerType: + LOGERROR_1(0, "SDO BigIntegerType parameters are not yet supported (%s)", name); + return NULL; + break; + default: + LOGERROR_1(0, "Unknown SDO type parameter named %s has been found. Unknown types are not yet supported", name); + return NULL; + } + } + + try + { + + // 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& outputType = dataFactoryPtr->getType(outputTypeURI, outputTypeName); + outputDataObject = dataFactoryPtr->create(outputType); + } + catch (SDORuntimeException e) + { + // The output wrapper type is not known, create an open DataObject + outputDataObject = dataFactoryPtr->create(Type::SDOTypeNamespaceURI, "OpenDataObject"); + } + + setOutputData(operation, outputDataObject, dataFactoryPtr); + + LOGEXIT(1,"WSServiceProxy::invoke"); + + return outputDataObject; + + } + catch(SDORuntimeException &ex) + { + // TODO: Return more error information than just a null DataObject + LOGERROR_2(0, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText()); + return NULL; + } + catch(TuscanyRuntimeException &ex) + { + // TODO: Return more error information than just a null DataObject + LOGERROR_2(0, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText()); + return NULL; + } + } + else + { + LOGERROR(0, "CompositeServices with non-wrapped document style WSDL Operations are not yet supported"); + LOGEXIT(1,"WSServiceProxy::invoke"); + return NULL; + } + } + else + { + // RPC style + LOGERROR(0, "CompositeServices with RPC style WSDL Operations are not yet supported"); + return NULL; + } + } + + + void WSServiceProxy::setOutputData(Operation& operation, DataObjectPtr outputDataObject, DataFactoryPtr dataFactoryPtr) + { + // 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: + { + string msg = "Unsupported parameter type"; + msg += resultType; + throw msg.c_str(); + } + } + } + else + { + LOGINFO(4, "No return values are defined"); + } + } + else { + + // Should only be one return value.. This goes through all return values + for(int i=0; isetBoolean(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_1(4, "Return value is NULL, so 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_1(4, "Return value is NULL, so leaving property %s unset", pl[i].getName()); + } + + break; + } + default: + { + string msg = "Unsupported parameter type"; + msg += resultType; + throw msg.c_str(); + } + } + } + } + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h new file mode 100644 index 0000000000..82ab4385f2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.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_extension_ws_wsserviceproxy_h +#define tuscany_sca_extension_ws_wsserviceproxy_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" +#include "commonj/sdo/SDO.h" + +using namespace tuscany::sca::model; + +using commonj::sdo::DataObjectPtr; +using commonj::sdo::DataFactoryPtr; + +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(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(Service* service); + + /** + * Destructor. + */ + virtual ~WSServiceProxy(); + + /** + * Invoke the specified operation + */ + DataObjectPtr invoke(const WSDLOperation& wsdlOperation, DataObjectPtr inputDataObject); + + private: + + void setOutputData(Operation& operation, DataObjectPtr outputDataObject, 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/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp new file mode 100644 index 0000000000..23ecc133e8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT 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" + +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) + { + parseEndpoint(); + } + + void WSReferenceBinding::parseEndpoint() + { + // Endpoint is of the form: #wsdl.endpoint(/) + 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() + { + } + + void WSReferenceBinding::configure(ServiceBinding *binding) + { + targetServiceBinding = binding; + + serviceProxy = new WSServiceProxy(getReference()); + } + + ServiceProxy* WSReferenceBinding::getServiceProxy() + { + return serviceProxy; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h new file mode 100644 index 0000000000..90e28e326b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 "tuscany/sca/model/ReferenceBinding.h" + +using namespace tuscany::sca::model; + +#include +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace ws + { + /** + * Information about a web service binding for service or a reference. + */ + class WSReferenceBinding : public 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") + */ + WSReferenceBinding(Reference* reference, const string&uri, const string& endpoint, const string& version); + + /** + * Destructor. + */ + virtual ~WSReferenceBinding(); + + /** + * Returns the type of binding. + */ + virtual string getType() { return "http://www.osoa.org/xmlns/sca/1.0#WebServiceBinding"; }; + + /** + * Configure this binding from a service binding. + */ + virtual void configure(ServiceBinding* serviceBinding); + + /** + * Create a proxy representing the reference to the + * client component. + */ + virtual ServiceProxy* getServiceProxy(); + + /** + * Return the part of the endpoint definition describing the wsdl + * namespace. + * @return The wsdl namespace. + */ + string getWSDLNamespaceURL() const { return wsdlNamespaceURL; }; + + /** + * Return the service part of the endpoint definition. + * @return The service to use. + */ + string getServiceName() const { return serviceName; }; + + /** + * Return the endpoint name part of the endpoint definition. + * @return The endpoint name to use. + */ + string getEndpointName() const { return endpointName; }; + + /** + * Return the SOAP version. + * @return The SOAP version to use. + */ + string getSOAPVersion() const { return soapVersion; }; + + /** + * Returns the target service binding. + */ + ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; }; + + private: + + /** + * Parse the endpoint specification. + */ + void parseEndpoint(); + + /** + * The full endpoint string. + */ + string endpoint; + + /** + * Namespace from the endpoint. + */ + string wsdlNamespaceURL; + + /** + * Service name from the endpoint. + */ + string serviceName; + + /** + * Endpoint name from the endpoint. + */ + string endpointName; + + /** + * SOAP version. + */ + string soapVersion; + + /** + * The proxy representing the reference to the client + * component. + */ + ServiceProxy* serviceProxy; + + /** + * The service binding of the target + */ + ServiceBinding* targetServiceBinding; + }; + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_ws_model_wsreferencebinding_h diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/deploy.bat b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/deploy.bat new file mode 100644 index 0000000000..0722342b03 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/deploy.bat @@ -0,0 +1,73 @@ +@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%\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 + +if exist %inpath%\%libname%.pdb copy %inpath%\%libname%.pdb %svcextdir%\bin + +if not exist %svcsdir% mkdir %svcsdir% +if not exist %svcsdir%\tuscany mkdir %svcsdir%\tuscany + +copy %srcdir%\axis2.xml %svcextdir% +copy %srcdir%\deploy.cmd %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 +:end + +endlocal diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/deploymodule.bat b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/service/deploymodule.bat new file mode 100644 index 0000000000..246728b6b2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/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 +:end + +endlocal diff --git a/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/xsd/sca-binding-webservice.xsd b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/xsd/sca-binding-webservice.xsd new file mode 100644 index 0000000000..2c1c2abbcc --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC1/sca/runtime/extensions/ws/xsd/sca-binding-webservice.xsd @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3