summaryrefslogtreecommitdiffstats
path: root/sca-cpp/tags/cpp-sca-20060405/runtime/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/tags/cpp-sca-20060405/runtime/core/src')
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.cdtbuild43
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.cdtproject15
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.project19
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs9
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/Makefile.am103
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.cpp132
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.h105
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.cpp270
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.h120
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.cpp93
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.h80
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.cpp102
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.h71
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/SCA.cpp21
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.cpp105
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.h84
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp208
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.h236
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/export.h39
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/sca.h29
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp202
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h156
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp102
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h81
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/Operation.cpp88
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/Operation.h115
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp215
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCAEntryPoint.h126
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCARuntime.cpp288
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCARuntime.h166
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp121
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceProxy.h89
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp55
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceWrapper.h73
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Binding.cpp44
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Binding.h85
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPImplementation.cpp54
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPImplementation.h125
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPInterface.cpp67
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPInterface.h143
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Component.cpp303
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Component.h202
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/EntryPoint.cpp96
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/EntryPoint.h138
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ExternalService.cpp55
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ExternalService.h97
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Implementation.cpp44
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Implementation.h66
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Interface.cpp44
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Interface.h65
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ModelLoader.cpp1555
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ModelLoader.h104
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Module.cpp235
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Module.h235
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Service.cpp47
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Service.h81
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ServiceReference.cpp89
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ServiceReference.h136
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Subsystem.cpp122
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Subsystem.h131
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/System.cpp118
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/System.h89
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WSBinding.cpp127
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WSBinding.h106
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wire.cpp46
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wire.h91
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WireTarget.cpp49
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WireTarget.h106
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wsdl.cpp345
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wsdl.h132
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WsdlOperation.cpp57
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WsdlOperation.h117
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp43
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h46
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Exceptions.h48
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.cpp216
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.h133
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp49
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.h53
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.cpp119
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.h97
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.cpp32
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.h47
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.cpp107
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.h89
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logging.h72
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.cpp212
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.h61
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/SDOStub.cpp448
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/SDOStub.h143
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.cpp116
-rw-r--r--sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.h48
92 files changed, 11686 insertions, 0 deletions
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.cdtbuild b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.cdtbuild
new file mode 100644
index 0000000000..60990b3bc1
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.cdtbuild
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?fileVersion 3.0.0?>
+
+<ManagedProjectBuildInfo>
+<project id="tuscany_sca.cdt.managedbuild.target.gnu.so.396678379" name="Shared Library (Gnu)" projectType="cdt.managedbuild.target.gnu.so">
+<configuration artifactExtension="so" artifactName="tuscany_sca" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.so.debug.1559343291" name="Debug" parent="cdt.managedbuild.config.gnu.so.debug">
+<toolChain id="cdt.managedbuild.toolchain.gnu.so.debug.609825338" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.so.debug">
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.compiler.so.debug.77943252" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.debug"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug.1766408370" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug">
+<option id="gnu.cpp.compiler.option.preprocessor.def.2024197080" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+<listOptionValue builtIn="false" value="_DEBUG"/>
+</option>
+<option id="gnu.cpp.compiler.option.include.paths.1737038239" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${project_loc}"/>
+<listOptionValue builtIn="false" value="${TUSCANY_SDOCPP}/include"/>
+<listOptionValue builtIn="false" value="${AXISCPP_DEPLOY}/include"/>
+</option>
+</tool>
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.linker.so.debug.716034031" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.debug"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.so.debug.10617576" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.debug"/>
+<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.so.debug.12565873" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.debug"/>
+<macros/>
+</toolChain>
+</configuration>
+<configuration artifactExtension="so" artifactName="tuscany_sca" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.so.release.1621584437" name="Release" parent="cdt.managedbuild.config.gnu.so.release">
+<toolChain id="cdt.managedbuild.toolchain.gnu.so.release.848211885" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.so.release">
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.compiler.so.release.1423119436" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.release"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.so.release.1296381577" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.release">
+<option id="gnu.cpp.compiler.option.include.paths.366400225" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${project_loc}"/>
+<listOptionValue builtIn="false" value="${TUSCANY_SDOCPP}/include"/>
+<listOptionValue builtIn="false" value="${AXISCPP_DEPLOY}/include"/>
+</option>
+</tool>
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.linker.so.release.1135017546" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.release"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.so.release.468695598" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.release"/>
+<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.so.release.153520855" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.release"/>
+<macros/>
+</toolChain>
+</configuration>
+<macros/>
+</project>
+</ManagedProjectBuildInfo>
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.cdtproject b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.cdtproject
new file mode 100644
index 0000000000..48a12e6664
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.cdtproject
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse-cdt version="2.0"?>
+
+<cdtproject id="org.eclipse.cdt.managedbuilder.core.managedMake">
+<extension id="org.eclipse.cdt.managedbuilder.core.ManagedBuildManager" point="org.eclipse.cdt.core.ScannerInfoProvider"/>
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>
+<data>
+<item id="org.eclipse.cdt.core.pathentry">
+<pathentry kind="src" path=""/>
+<pathentry kind="out" path=""/>
+<pathentry kind="con" path="org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"/>
+</item>
+</data>
+</cdtproject>
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.project b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.project
new file mode 100644
index 0000000000..86fb4b8663
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.project
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>tuscany_sca</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ </natures>
+</projectDescription>
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs
new file mode 100644
index 0000000000..0e5a987932
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs
@@ -0,0 +1,9 @@
+#Thu Feb 16 12:50:21 GMT 2006
+eclipse.preferences.version=1
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.so.debug.1559343291=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.so.release.1621584437=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.so.debug.1559343291=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.so.release.1621584437=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/project=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.so.debug.1559343291=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable delimiter\="" name\="TUSCANY_SDOCPP" operation\="replace" value\="/home/tuscany/workspace/sdo"/>\n</environment>\n
+environment/project/cdt.managedbuild.config.gnu.so.release.1621584437=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable delimiter\="" name\="TUSCANY_SDOCPP" operation\="replace" value\="/home/tuscany/workspace/sdo"/>\n</environment>\n
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/Makefile.am b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/Makefile.am
new file mode 100644
index 0000000000..a09444250c
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/Makefile.am
@@ -0,0 +1,103 @@
+lib_LTLIBRARIES = libtuscany_sca.la
+
+nobase_include_HEADERS = \
+osoa/sca/ComponentContext.h \
+osoa/sca/ComponentContextImpl.h \
+osoa/sca/export.h \
+osoa/sca/ModuleContext.h \
+osoa/sca/ModuleContextImpl.h \
+osoa/sca/sca.h \
+osoa/sca/ServiceList.h \
+osoa/sca/ServiceRuntimeException.h \
+tuscany/sca/core/ComponentServiceWrapper.h \
+tuscany/sca/core/ExternalServiceWrapper.h \
+tuscany/sca/core/Operation.h \
+tuscany/sca/core/SCAEntryPoint.h \
+tuscany/sca/core/SCARuntime.h \
+tuscany/sca/core/ServiceProxy.h \
+tuscany/sca/core/ServiceWrapper.h \
+tuscany/sca/model/Binding.h \
+tuscany/sca/model/Component.h \
+tuscany/sca/model/CPPImplementation.h \
+tuscany/sca/model/CPPInterface.h \
+tuscany/sca/model/EntryPoint.h \
+tuscany/sca/model/ExternalService.h \
+tuscany/sca/model/Implementation.h \
+tuscany/sca/model/Interface.h \
+tuscany/sca/model/ModelLoader.h \
+tuscany/sca/model/Module.h \
+tuscany/sca/model/Service.h \
+tuscany/sca/model/ServiceReference.h \
+tuscany/sca/model/Subsystem.h \
+tuscany/sca/model/System.h \
+tuscany/sca/model/Wire.h \
+tuscany/sca/model/WireTarget.h \
+tuscany/sca/model/WSBinding.h \
+tuscany/sca/model/Wsdl.h \
+tuscany/sca/model/WsdlOperation.h \
+tuscany/sca/util/DefaultLogWriter.h \
+tuscany/sca/util/Exceptions.h \
+tuscany/sca/util/File.h \
+tuscany/sca/util/FileLogWriter.h \
+tuscany/sca/util/Library.h \
+tuscany/sca/util/Logger.h \
+tuscany/sca/util/Logging.h \
+tuscany/sca/util/LogWriter.h \
+tuscany/sca/util/Utils.h \
+tuscany/sca/ws/SDOStub.h \
+tuscany/sca/ws/WSServiceWrapper.h
+
+
+libtuscany_sca_la_SOURCES = \
+osoa/sca/ComponentContext.cpp \
+osoa/sca/ComponentContextImpl.cpp \
+osoa/sca/ModuleContext.cpp \
+osoa/sca/ModuleContextImpl.cpp \
+osoa/sca/SCA.cpp \
+osoa/sca/ServiceList.cpp \
+osoa/sca/ServiceRuntimeException.cpp \
+tuscany/sca/util/DefaultLogWriter.cpp \
+tuscany/sca/util/File.cpp \
+tuscany/sca/util/FileLogWriter.cpp \
+tuscany/sca/util/Library.cpp \
+tuscany/sca/util/Logger.cpp \
+tuscany/sca/util/LogWriter.cpp \
+tuscany/sca/util/Utils.cpp \
+tuscany/sca/model/Binding.cpp \
+tuscany/sca/model/Component.cpp \
+tuscany/sca/model/CPPImplementation.cpp \
+tuscany/sca/model/CPPInterface.cpp \
+tuscany/sca/model/EntryPoint.cpp \
+tuscany/sca/model/ExternalService.cpp \
+tuscany/sca/model/Implementation.cpp \
+tuscany/sca/model/Interface.cpp \
+tuscany/sca/model/ModelLoader.cpp \
+tuscany/sca/model/Module.cpp \
+tuscany/sca/model/Service.cpp \
+tuscany/sca/model/ServiceReference.cpp \
+tuscany/sca/model/Subsystem.cpp \
+tuscany/sca/model/System.cpp \
+tuscany/sca/model/Wire.cpp \
+tuscany/sca/model/WireTarget.cpp \
+tuscany/sca/model/WSBinding.cpp \
+tuscany/sca/model/Wsdl.cpp \
+tuscany/sca/model/WsdlOperation.cpp \
+tuscany/sca/core/ComponentServiceWrapper.cpp \
+tuscany/sca/core/ExternalServiceWrapper.cpp \
+tuscany/sca/core/Operation.cpp \
+tuscany/sca/core/SCAEntryPoint.cpp \
+tuscany/sca/core/SCARuntime.cpp \
+tuscany/sca/core/ServiceProxy.cpp \
+tuscany/sca/core/ServiceWrapper.cpp \
+tuscany/sca/ws/SDOStub.cpp \
+tuscany/sca/ws/WSServiceWrapper.cpp
+
+libtuscany_sca_la_LIBADD = -lstdc++ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
+ -L${AXISCPP_DEPLOY}/lib -laxis_client
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
+
+INCLUDES = -I$(top_builddir)/runtime/core/src \
+ -I${TUSCANY_SDOCPP}/include \
+ -I${AXISCPP_DEPLOY}/include
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.cpp
new file mode 100644
index 0000000000..73c3ed2e36
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.cpp
@@ -0,0 +1,132 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ComponentContext.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "osoa/sca/ComponentContextImpl.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace tuscany::sca;
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ // =======================================================
+ // getCurrent: create a context from the current component
+ // =======================================================
+ ComponentContext ComponentContext::getCurrent()
+ {
+ LOGENTRY(1, "ComponentContext::getCurrent");
+ Component* component = SCARuntime::getInstance()->getCurrentComponent();
+ if (!component)
+ {
+ throw ComponentContextException("No current component");
+ }
+ ComponentContextImpl* cci = new ComponentContextImpl(component);
+ LOGEXIT(1, "ComponentContext::constructor");
+ return ComponentContext(cci);
+ }
+
+ // ===========
+ // Constructor
+ // ===========
+ ComponentContext::ComponentContext(ComponentContextImpl* 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)
+ {
+ impl = new ComponentContextImpl(impl->getComponent());
+ }
+
+ // =============================
+ // operator= : create a new impl
+ // =============================
+ ComponentContext& ComponentContext::operator=(const ComponentContext& ctx)
+ {
+ if (this != &ctx)
+ {
+ impl = new ComponentContextImpl(impl->getComponent());
+ }
+ return *this;
+ }
+
+ // ==========
+ // getService
+ // ==========
+ void* ComponentContext::getService(const char* referenceName)
+ {
+ LOGENTRY(1, "ComponentContext::getService");
+ void* service = impl->getService(referenceName);
+ LOGEXIT(1, "ComponentContext::getService");
+ return service;
+ }
+
+ // ===========
+ // getServices
+ // ===========
+ ServiceList ComponentContext::getServices(const char* 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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.h
new file mode 100644
index 0000000000..10d334a936
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.h
@@ -0,0 +1,105 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_componentcontext_h
+#define osoa_sca_componentcontext_h
+
+#include "osoa/sca/export.h"
+#include "osoa/sca/ServiceList.h"
+#include "commonj/sdo/SDO.h"
+namespace osoa
+{
+ namespace sca
+ {
+ class ComponentContextImpl;
+
+ /**
+ * An SCA component implementation uses the ComponentContext class to
+ * retrieve information about the configured SCA component.
+ */
+ class SCA_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.
+ */
+ void* getService(const char* 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.
+ */
+ ServiceList getServices(const char* referenceName);
+
+ /**
+ * Get the configured properties for the component.
+ * @return A data object representing all the properties that
+ * are configured for this component.
+ */
+ 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.
+ */
+ commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Destructor
+ */
+ virtual ~ComponentContext();
+
+
+ ComponentContext(const ComponentContext&);
+ ComponentContext& operator=(const ComponentContext&);
+
+ private:
+ /**
+ * Constructor to create an interface class from the contained
+ * implementation.
+ * @param implementation the actual implementation class
+ */
+ ComponentContext(ComponentContextImpl* implementation);
+
+ /**
+ * Pointer to the class which provides the actual implementation.
+ */
+ ComponentContextImpl* impl;
+
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_componentcontext_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.cpp
new file mode 100644
index 0000000000..436e44d5e1
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.cpp
@@ -0,0 +1,270 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "osoa/sca/ComponentContextImpl.h"
+#include "tuscany/sca/model/WireTarget.h"
+#include "tuscany/sca/core/ComponentServiceWrapper.h"
+#include "tuscany/sca/core/ExternalServiceWrapper.h"
+#include "tuscany/sca/model/CPPImplementation.h"
+#include "tuscany/sca/model/Module.h"
+
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+namespace osoa
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ ComponentContextImpl::ComponentContextImpl(Component* comp)
+ : component(comp)
+ {
+ LOGENTRY(1, "ComponentContextImpl::constructor");
+ LOGEXIT(1, "ComponentContextImpl::constructor");
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ComponentContextImpl::~ComponentContextImpl()
+ {
+ // --------------------------------------------
+ // Delete the proxies served up by this context
+ // --------------------------------------------
+ for (PROXIES::iterator iter = proxies.begin(); iter != proxies.end(); iter++)
+ {
+ delete (ServiceProxy*)*iter;
+ }
+ }
+
+
+ // ==========================================================================
+ // getServices: return a list of Proxies for services wired to this reference
+ // ==========================================================================
+ ServiceList ComponentContextImpl::getServices(const char* referenceName)
+ {
+ LOGENTRY(1, "ComponentContextImpl::getServices");
+
+ string message;
+
+ // --------------------------------------------------------------
+ // locate reference in the current component and determine target
+ // --------------------------------------------------------------
+ ServiceReference* serviceReference = component->findReference(referenceName);
+ if (!serviceReference)
+ {
+ message = "Reference not defined: ";
+ message = message + referenceName;
+ throw ServiceNotFoundException(message.c_str());
+ }
+
+ // Get the target services from the ServiceReference
+ const ServiceReference::TARGETS& targets = serviceReference->getTargets();
+
+ // --------------------
+ // Validate the request
+ // --------------------
+ switch (serviceReference->getMultiplicity())
+ {
+ case ServiceReference::ONE_MANY:
+ case ServiceReference::ONE_ONE:
+ {
+ if (targets.size() == 0)
+ {
+ message = "Reference ";
+ message = message + referenceName + " not wired";
+ throw ServiceNotFoundException(message.c_str());
+ }
+ }
+ default:
+ {
+ }
+ } // end switch
+
+ // ------------------------------
+ // Create a proxy for each target
+ // ------------------------------
+ ServiceList services(targets.size());
+ for (ServiceReference::TARGETS::const_iterator iter = targets.begin();
+ iter!=targets.end();
+ iter++)
+ {
+ services.addService(getServiceProxy(serviceReference, *iter));
+ }
+
+ return services;
+
+ } // End getServices()
+
+
+ // ===================================================================
+ // getService: return a Proxy for the services wired to this reference
+ // ===================================================================
+ void* ComponentContextImpl::getService(const char* referenceName)
+ {
+ LOGENTRY(1, "ComponentContextImpl::getService");
+
+ string message;
+
+ // --------------------------------------------------------------
+ // locate reference in the current component and determine target
+ // --------------------------------------------------------------
+ ServiceReference* serviceReference = component->findReference(referenceName);
+ if (!serviceReference)
+ {
+ message = "Reference not defined: ";
+ message = message + referenceName;
+ throw ServiceNotFoundException(message.c_str());
+ }
+
+ // Get the target service from the ServiceReference
+ const ServiceReference::TARGETS& targets = serviceReference->getTargets();
+
+ // --------------------
+ // Validate the request
+ // --------------------
+ switch (serviceReference->getMultiplicity())
+ {
+ case ServiceReference::ZERO_MANY:
+ case ServiceReference::ONE_MANY:
+ {
+ message = "getService() called for reference with multiplicity >1 :";
+ message = message + referenceName;
+ throw ServiceNotFoundException(message.c_str());
+ }
+ case ServiceReference::ONE_ONE:
+ {
+ if (targets.size() == 0)
+ {
+ message = "Reference ";
+ message = message + referenceName + " not wired";
+ throw ServiceNotFoundException(message.c_str());
+ }
+ }
+ default:
+ {
+ }
+ } // end switch
+
+ // Return the proxy
+ return getServiceProxy(serviceReference, *targets.begin());
+
+ } // End getService()
+
+
+ // ==================================================================
+ // getServiceProxy: Create and return an instance of the ServiceProxy
+ // ==================================================================
+ void* ComponentContextImpl::getServiceProxy(
+ ServiceReference* serviceReference,
+ WireTarget* target)
+ {
+ // -----------------------------------
+ // Get a ServiceWrapper for the target
+ // -----------------------------------
+ ServiceWrapper* serviceWrapper = getServiceWrapper(target);
+
+ // ------------------------------
+ // Get a Proxy for this reference
+ // ------------------------------
+ try
+ {
+ ServiceProxy* serviceProxy = new ServiceProxy(component, serviceReference->getName(), serviceWrapper);
+ void* service = serviceProxy->getProxy();
+ // service MUST be set here or an exception will have been thrown
+ proxies.push_back(serviceProxy);
+ return service;
+ }
+ catch (ServiceRuntimeException&)
+ {
+ delete serviceWrapper;
+ throw ;
+ }
+ }
+
+
+ // ======================================================================
+ // getServiceWrapper: Create and return an instance of the ServiceWrapper
+ // ======================================================================
+ ServiceWrapper* ComponentContextImpl::getServiceWrapper(WireTarget* target)
+ {
+ // -------------------------
+ // Determine type of Service
+ // -------------------------
+ switch (target->getServiceType())
+ {
+ case WireTarget::ExternalServiceType:
+ {
+ // ----------------
+ // External Service
+ // ----------------
+ return ExternalServiceWrapper::createServiceWrapper((ExternalService*)target);
+ }
+
+ case WireTarget::ComponentServiceType:
+ {
+ // -----------------
+ // Component Service
+ // -----------------
+ return ComponentServiceWrapper::createServiceWrapper((Service*)target);
+ }
+
+ default:
+ {
+ string message = "Undefined wire target type for : ";
+ message = message + target->getName();
+ throw ServiceNotFoundException(message.c_str());
+ }
+ } // end switch
+ }
+
+
+
+ // ==============================================
+ // 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 module in which
+ // this component resides
+ // ==============================================
+ DataFactoryPtr ComponentContextImpl::getDataFactory()
+ {
+ LOGENTRY(1, "ComponentContextImpl::getProperties");
+ DataFactoryPtr dataFactory = component->getModule()->getDataFactory();
+
+ LOGEXIT(1, "ComponentContextImpl::getDataFactory");
+ return dataFactory;
+ }
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.h
new file mode 100644
index 0000000000..bd3a0d106a
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.h
@@ -0,0 +1,120 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_componentcontextimpl_h
+#define osoa_sca_componentcontextimpl_h
+
+#include "osoa/sca/ServiceList.h"
+
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/model/Service.h"
+
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+namespace osoa
+{
+ namespace sca
+ {
+ /**
+ * Contains the actual implementation of a ComponentContext interface.
+ */
+ class ComponentContextImpl
+ {
+
+ public:
+ /**
+ * Constructor that takes a Component which represents the runtime
+ * model for this context.
+ */
+ ComponentContextImpl(Component* component);
+
+ /**
+ * Default constructor.
+ */
+ virtual ~ComponentContextImpl();
+
+ /**
+ * See ComponentContext.
+ */
+ void* getService(const char* referenceName);
+
+ /**
+ * See ComponentContext.
+ */
+ ServiceList getServices(const char* referenceName);
+
+ /**
+ * See ComponentContext.
+ */
+ DataObjectPtr getProperties();
+
+ /**
+ * See ComponentContext.
+ */
+ commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Returns the contained Component.
+ * @return The Component to which this context refers.
+ */
+ 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(
+ ServiceReference* serviceReference,
+ WireTarget* 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(WireTarget* target);
+
+
+ typedef vector<ServiceProxy*> PROXIES;
+ /**
+ * A vector of the proxies created by this ComponentContext. The
+ * proxies will be destroyed when the ComponentContext is destroyed.
+ */
+ PROXIES proxies;
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_componentcontextimpl_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.cpp
new file mode 100644
index 0000000000..93e36b297f
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.cpp
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ModuleContext.h"
+#include "tuscany/sca/util/Logging.h"
+#include "osoa/sca/ModuleContextImpl.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace tuscany::sca;
+
+namespace osoa
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ ModuleContext::ModuleContext(ModuleContextImpl* implementation)
+ : impl(implementation)
+ {
+ }
+
+ // ===================================
+ // Copy constructor: create a new impl
+ // ===================================
+ ModuleContext::ModuleContext(const ModuleContext& ctx)
+ {
+ impl = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule());
+ }
+
+ // =============================
+ // operator= : create a new impl
+ // =============================
+ ModuleContext& ModuleContext::operator=(const ModuleContext& ctx)
+ {
+ if (this != &ctx)
+ {
+ impl = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule());
+ }
+ return *this;
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ModuleContext::~ModuleContext()
+ {
+ LOGENTRY(1, "ModuleContext::destructor");
+ delete impl;
+ LOGEXIT(1, "ModuleContext::destructor");
+ }
+
+ // ====================================================
+ // getCurrent: create a context from the current module
+ // ====================================================
+ ModuleContext ModuleContext::getCurrent()
+ {
+ LOGENTRY(1, "ModuleContext::getCurrent");
+ ModuleContextImpl* mci = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule());
+ LOGEXIT(1, "ModuleContext::getCurrent");
+ return ModuleContext(mci);
+ }
+
+ // =============
+ // locateService
+ // =============
+ void* ModuleContext::locateService(const char* serviceName)
+ {
+ LOGENTRY(1, "ModuleContext::locateService");
+ void* sp = impl->locateService(serviceName);
+ LOGEXIT(1, "ModuleContext::locateService");
+ return sp;
+ }
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.h
new file mode 100644
index 0000000000..7aacb00123
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.h
@@ -0,0 +1,80 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_modulecontext_h
+#define osoa_sca_modulecontext_h
+
+#include "osoa/sca/export.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+ class ModuleContextImpl;
+
+ /**
+ * An SCA component implementation, or a non-SCA client, uses the
+ * ModuleContext class to retrieve information about the configured
+ * SCA module.
+ */
+ class SCA_API ModuleContext
+ {
+
+ public:
+ /**
+ * Return a new ModuleContext for the current Component.
+ */
+ static ModuleContext 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.
+ */
+ void* locateService(const char* serviceName);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ModuleContext();
+
+ ModuleContext(const ModuleContext&);
+ ModuleContext& operator=(const ModuleContext&);
+
+ private:
+ /**
+ * Constructor to create an interface class from the contained
+ * implementation.
+ * @param implementation The actual implementation class.
+ */
+ ModuleContext(ModuleContextImpl* implementation);
+
+ /**
+ * Pointer to the class which provides the actual implementation.
+ */
+ ModuleContextImpl* impl;
+
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_modulecontext_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.cpp
new file mode 100644
index 0000000000..4d96ee336d
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.cpp
@@ -0,0 +1,102 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/CPPImplementation.h"
+#include "osoa/sca/ModuleContextImpl.h"
+#include "tuscany/sca/core/ComponentServiceWrapper.h"
+
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+namespace osoa
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ ModuleContextImpl::ModuleContextImpl(Module* mod)
+ : module(mod)
+ {
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ModuleContextImpl::~ModuleContextImpl()
+ {
+ // --------------------------------------------
+ // Delete the proxies served up by this context
+ // --------------------------------------------
+ for (PROXIES::iterator iter = proxies.begin(); iter != proxies.end(); iter++)
+ {
+ delete (ServiceProxy*)*iter;
+ }
+ }
+
+ // ===========================================================================
+ // locateService: return a proxy connected to a wrapper for the target service
+ // ===========================================================================
+ void* ModuleContextImpl::locateService(const char* serviceName)
+ {
+ LOGENTRY(1, "ModuleContextImpl::locateService");
+
+
+ // ----------------------------
+ // Locate the component service
+ // ----------------------------
+ Service* service = module->findComponentService(serviceName);
+ string msg;
+ if (!service)
+ {
+ msg = "Service not found: ";
+ msg = msg + serviceName;
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // -------------------------
+ // Create the ServiceWrapper
+ // -------------------------
+ ComponentServiceWrapper* serviceWrapper = ComponentServiceWrapper::createServiceWrapper(service);
+
+ // ----------------------------
+ // Get a Proxy for this service
+ // ----------------------------
+ try
+ {
+ ServiceProxy* serviceProxy = new ServiceProxy(service->getComponent(), service->getName(), serviceWrapper);
+ proxies.push_back(serviceProxy);
+ LOGEXIT(1, "ModuleContextImpl::locateService");
+ return serviceProxy->getProxy();
+ }
+ catch (ServiceRuntimeException&)
+ {
+ delete serviceWrapper;
+ throw ;
+ }
+
+ }
+
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.h
new file mode 100644
index 0000000000..5950313a06
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.h
@@ -0,0 +1,71 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_modulecontextimpl_h
+#define osoa_sca_modulecontextimpl_h
+#include "tuscany/sca/model/Module.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+ /**
+ * Contains the actual implementation of a ModuleContext interface.
+ */
+ class ModuleContextImpl
+ {
+
+ public:
+ /**
+ * Constructor that takes a Module which represents the runtime
+ * model for this context.
+ */
+ ModuleContextImpl(tuscany::sca::model::Module* module);
+
+ /**
+ * See ModuleContext#locateService.
+ */
+ void* locateService(const char* serviceName);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ModuleContextImpl();
+ private:
+ ModuleContextImpl(const ModuleContextImpl&);
+ ModuleContextImpl& operator=(const ModuleContextImpl&);
+
+ /**
+ * Pointer to the runtime model Module object to which this
+ * context refers.
+ */
+ tuscany::sca::model::Module* module;
+
+ typedef vector<tuscany::sca::ServiceProxy*> PROXIES;
+ /**
+ * Vector of proxies created from calls to the locateService
+ * method.
+ */
+ PROXIES proxies;
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_modulecontextimpl_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/SCA.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/SCA.cpp
new file mode 100644
index 0000000000..bcca254028
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/SCA.cpp
@@ -0,0 +1,21 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev: $ $Date: $ */
+
+#include "osoa/sca/sca.h"
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.cpp
new file mode 100644
index 0000000000..ba2b418a7c
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.cpp
@@ -0,0 +1,105 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ServiceList.h"
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ ServiceList::ServiceList(unsigned int numTargets)
+ : maxServices(numTargets), numServices(0)
+ {
+ services = new void*[numTargets];
+ }
+
+ // ==========================================
+ // Copy comstructor: create new service array
+ // ==========================================
+ ServiceList::ServiceList(const ServiceList& sl)
+ : maxServices(sl.maxServices), numServices(sl.numServices)
+ {
+ services = new void*[maxServices];
+ for (unsigned int i=0; i<numServices; i++)
+ {
+ services[i] = sl.services[i];
+ }
+ }
+
+ // ===================================
+ // operator=: create new service array
+ // ===================================
+ ServiceList& ServiceList::operator=(const ServiceList& sl)
+ {
+ if (this != &sl)
+ {
+ maxServices = sl.maxServices;
+ numServices = sl.numServices;
+
+ services = new void*[maxServices];
+ for (unsigned int i=0; i<numServices; i++)
+ {
+ services[i] = sl.services[i];
+ }
+ }
+ return *this;
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ServiceList::~ServiceList()
+ {
+ delete [] services;
+ }
+
+ // =================================
+ // operator[]: return service at pos
+ // =================================
+ void* ServiceList::operator[] (unsigned int pos)
+ {
+ if (pos < numServices)
+ {
+ return services[pos];
+ }
+ else
+ {
+ throw ServiceRuntimeException("ServiceList: index out of bounds");
+ }
+ }
+
+ // ====================================
+ // addService: add service to the array
+ // ====================================
+ void ServiceList::addService(void* service)
+ {
+ if (numServices < maxServices)
+ {
+ services[numServices] = service;
+ numServices++;
+ }
+ }
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.h
new file mode 100644
index 0000000000..be6f6c9b1a
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.h
@@ -0,0 +1,84 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_servicelist_h
+#define osoa_sca_servicelist_h
+
+#include "osoa/sca/export.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ /**
+ * Holds a list of services that can be accessed from an SCA
+ * component. Each entry can be cast to the business interface
+ * of the target component. All the entries will be of the
+ * same type.
+ */
+ class SCA_API ServiceList
+ {
+
+ public:
+ /**
+ * Return the number of services in the list.
+ * @return Number of services.
+ */
+ unsigned int size() {return numServices;}
+
+ /**
+ * Return the service at this position.
+ */
+ void* operator[] (unsigned int pos);
+
+ ServiceList(const ServiceList& serviceList);
+ ServiceList& operator=(const ServiceList& serviceList);
+ virtual ~ServiceList();
+
+ private:
+ friend class ComponentContextImpl;
+
+ /**
+ * Create a new service list with the known number of
+ * target services. Once created, the service list can only
+ * have services added to it up to the number of targets
+ * specified on this constructor.
+ * @param numTargets Number of target services to be held in this list.
+ */
+ ServiceList(unsigned int numTargets);
+
+ /**
+ * Add a service to this list.
+ */
+ void addService(void* service);
+
+ unsigned int maxServices;
+ unsigned int numServices;
+
+ /**
+ * Pointer to an array of services.
+ */
+ void** services;
+
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_servicelist_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp
new file mode 100644
index 0000000000..9f275c9c10
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp
@@ -0,0 +1,208 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ServiceRuntimeException.h"
+using namespace std;
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ // ========================================================================
+ // Constructor
+ // ========================================================================
+ ServiceRuntimeException :: ServiceRuntimeException(const char* name,
+ severity_level sev,
+ const char* msg_text)
+ : severity(sev), location_set(0)
+ {
+ class_name = new char[strlen(name) + 1];
+ strcpy(class_name,name);
+ message_text = new char[strlen(msg_text)+1];
+ strcpy(message_text,msg_text);
+
+ } // end ServiceRuntimeException constuctor
+
+ // ========================================================================
+ // Constructor
+ // ========================================================================
+ ServiceRuntimeException :: ServiceRuntimeException(const ServiceRuntimeException& c)
+ :
+ severity(c.getSeverity()), location_set(c.location_set)
+
+ {
+ class_name = new char[strlen(c.getEClassName()) + 1];
+ strcpy(class_name, c.getEClassName());
+ message_text = new char[strlen(c.getMessageText())+1];
+ strcpy(message_text,c.getMessageText());
+ for (int i=0;i<c.location_set;i++)
+ {
+ locations[i].file = new char[strlen(c.locations[i].file) + 1];
+ strcpy(locations[i].file,c.locations[i].file);
+ locations[i].line = c.locations[i].line;
+ locations[i].function = new char[strlen(c.locations[i].function) + 1];
+ strcpy(locations[i].function, c.locations[i].function);
+ }
+ }
+
+ // ========================================================================
+ // Destructor
+ // ========================================================================
+ ServiceRuntimeException :: ~ServiceRuntimeException()
+ {
+ if (class_name) delete class_name;
+ if (message_text) delete message_text;
+ for (int i=0;i<location_set;i++)
+ {
+ if (locations[i].file) delete locations[i].file;
+ if (locations[i].function) delete locations[i].function;
+ }
+
+ } // end ServiceRuntimeException destructor
+
+ // ========================================================================
+ // Return class name of this exception
+ // ========================================================================
+ const char* ServiceRuntimeException :: getEClassName() const
+ {
+ return class_name;
+ } // end getClassName()
+
+ // ========================================================================
+ // Return severity
+ // ========================================================================
+ ServiceRuntimeException::severity_level ServiceRuntimeException :: getSeverity() const
+ {
+ return severity;
+ } // end getSeverity()
+
+ // ========================================================================
+ // Return message text associated with exception
+ // ========================================================================
+ const char* ServiceRuntimeException :: getMessageText() const
+ {
+ return message_text;
+ } // end getMessageText()
+
+ // ========================================================================
+ // Return file name where exception was raised
+ // ========================================================================
+ const char* ServiceRuntimeException :: getFileName() const
+ {
+ return locations[0].file;
+ } // end getFileName()
+
+ // ========================================================================
+ // Return line number where exception was raised
+ // ========================================================================
+ unsigned long ServiceRuntimeException :: getLineNumber() const
+ {
+ return locations[0].line;
+ } // end getLineNumber()
+
+ // ========================================================================
+ // Return function name where exception was raised
+ // ========================================================================
+ const char* ServiceRuntimeException :: getFunctionName() const
+ {
+ return locations[0].function;
+ } // end getFunctionName()
+
+
+ // ========================================================================
+ // set severity of exception
+ // ========================================================================
+ void ServiceRuntimeException :: setSeverity(severity_level sev)
+ {
+ severity = sev;
+ } // end setSeverity(severity_level sev) const
+
+ // ========================================================================
+ // set message text associated with exception
+ // ========================================================================
+ void ServiceRuntimeException :: setMessageText(const char* msg_text)
+ {
+ if (message_text != 0) delete message_text;
+ message_text = new char[strlen(msg_text) + 1];
+ strcpy(message_text,msg_text);
+ } // end setMessageText(const string &msg_text) const
+
+ // ========================================================================
+ // set location of most recent throw/handling of the exception
+ // ========================================================================
+ void ServiceRuntimeException :: setLocation(const char* file,
+ unsigned long line,
+ const char* function)
+ {
+ if (location_set < num_locations)
+ {
+ locations[location_set].file = new char[strlen(file) + 1];
+ strcpy(locations[location_set].file,file);
+ locations[location_set].line = line;
+ locations[location_set].function = new char[strlen(function) + 1];
+ strcpy(locations[location_set].function,function);
+
+ location_set++;
+ }
+ } // end setLocation()
+
+
+ // ========================================================================
+ // print self
+ // ========================================================================
+ ostream& ServiceRuntimeException :: PrintSelf(ostream &os) const
+ {
+
+ os << "Exception object :" << endl;
+ os << " class: " << class_name << endl;
+ os << " description: " << message_text << endl;
+ if (location_set != 0)
+ {
+ os << " file name: " << locations[0].file << endl;
+ char lineNumber[100];
+ sprintf(lineNumber, "%lu",locations[0].line);
+ os << " line number: " << lineNumber << endl;
+ os << " function: " << locations[0].function << endl;
+ os << " location history:" << endl;
+
+ int i=1;
+ while (i < location_set)
+ {
+ os << " " << i << ")" << endl;
+ os << " file: " << locations[i].file << endl;
+ os << " line: " << locations[i].line << endl;
+ os << " function: " << locations[i].function << endl;
+ i++;
+ }
+ }
+ return os;
+ } // end ostream operator <<
+
+ // ========================================================================
+ // ostream operator <<
+ // ========================================================================
+ SCA_API ostream& operator<< (ostream &os, const ServiceRuntimeException &except)
+ {
+ return except.PrintSelf(os);
+ } // end ostream operator <<
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.h
new file mode 100644
index 0000000000..a78514e90c
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.h
@@ -0,0 +1,236 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_serviceruntimeexception_h
+#define osoa_sca_serviceruntimeexception_h
+
+#include "osoa/sca/export.h"
+
+#include <ostream>
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ /**
+ * Top level exception to represent all the exceptions that may be
+ * thrown by an SCA runtime implementation.
+ */
+ class SCA_API ServiceRuntimeException
+ {
+ 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.
+ */
+ ServiceRuntimeException(
+ const char *name="ServiceRuntimeException",
+ severity_level sev=Severe,
+ const char* msg_text="");
+
+ ServiceRuntimeException(const ServiceRuntimeException& c);
+
+ // Destructor
+ virtual ~ServiceRuntimeException();
+
+ /**
+ * 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 ServiceRuntimeException &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 ServiceRuntimeException#location).
+ */
+ int location_set;
+
+
+ }; // End ServiceRuntimeException class definition
+
+
+ /**
+ * A remotable service is currently unavailable. It is possible that a retry
+ * may resolve this exception.
+ */
+ class SCA_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 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 ComponentContextException: public ServiceRuntimeException
+ {
+ public:
+ ComponentContextException(const char* msg)
+ : ServiceRuntimeException("ComponentContextException", Error,
+ msg)
+ {
+ }
+ private:
+ }; // End ComponentContextException class definition
+
+ /**
+ * Unable to find the specified entry point in the module.
+ */
+ class EntryPointNotFoundException: public ServiceRuntimeException
+ {
+ public:
+ EntryPointNotFoundException(const char* msg)
+ : ServiceRuntimeException("EntryPointNotFoundException", Error,
+ msg)
+ {
+ }
+ private:
+ }; // End EntryPointNotFoundException class definition
+
+
+
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_serviceruntimeexception_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/export.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/export.h
new file mode 100644
index 0000000000..6ef7960284
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/export.h
@@ -0,0 +1,39 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_export_h
+#define osoa_sca_export_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef SCA_EXPORTS
+#define SCA_API __declspec(dllexport)
+#else
+#define SCA_API __declspec(dllimport)
+#endif
+
+#else
+#include <sys/time.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#define SCA_API
+#endif
+
+#endif // osoa_sca_export_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/sca.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/sca.h
new file mode 100644
index 0000000000..528bd91c4a
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/sca.h
@@ -0,0 +1,29 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_sca_h
+#define osoa_sca_sca_h
+
+#include "osoa/sca/export.h"
+#include "osoa/sca/ModuleContext.h"
+#include "osoa/sca/ComponentContext.h"
+#include "osoa/sca/ServiceList.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#endif // osoa_sca_sca_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp
new file mode 100644
index 0000000000..9db068a2ff
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp
@@ -0,0 +1,202 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/ComponentServiceWrapper.h"
+
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/CPPImplementation.h"
+using namespace osoa::sca;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ // ===================
+ // Static data members
+ // ===================
+ void* ComponentServiceWrapper::staticImpl = 0;
+
+ // ===========
+ // Constructor
+ // ===========
+ ComponentServiceWrapper::ComponentServiceWrapper(Service* target)
+ : ServiceWrapper(target), service(target)
+ {
+ LOGENTRY(1,"ComponentServiceWrapper::constructor");
+ if (target->getServiceType() != WireTarget::ComponentServiceType)
+ {
+ throw ServiceRuntimeException("ComponentServiceWrapper: target is not a component service");
+ }
+
+ component = target->getComponent();
+ interf = (CPPInterface*)target->getInterface();
+
+ remotable = interf->getRemotable();
+
+
+ LOGEXIT(1,"ComponentServiceWrapper::constructor");
+
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ComponentServiceWrapper::~ComponentServiceWrapper()
+ {
+ LOGENTRY(1,"ComponentServiceWrapper::destructor");
+ LOGEXIT(1,"ComponentServiceWrapper::destructor");
+ }
+
+
+ // ======================================================================
+ // getImplementation: get an implementation for this scope
+ // ======================================================================
+ void* ComponentServiceWrapper::getImplementation()
+ {
+ CPPInterface::SCOPE scope = interf->getScope();
+ if (scope == CPPInterface::MODULE)
+ {
+ if (!staticImpl)
+ {
+ staticImpl = newImplementation();
+ }
+ return staticImpl;
+ }
+ else // (scope == CPPInterface::STATELESS)
+ {
+ return newImplementation();
+ }
+ }
+
+ // ======================================================================
+ // releaseImplementation: release the implementation for this scope
+ // ======================================================================
+ void ComponentServiceWrapper::releaseImplementation()
+ {
+ CPPInterface::SCOPE scope = interf->getScope();
+ if (scope == CPPInterface::STATELESS)
+ {
+ deleteImplementation();
+ }
+ }
+
+ // ======================================================================
+ // invoke: wrapper call to service with setting the component context
+ // ======================================================================
+ void ComponentServiceWrapper::invoke(Operation& operation)
+ {
+
+ SCARuntime* runtime = SCARuntime::getInstance();
+ runtime->setCurrentComponent(component);
+
+ try
+ {
+ invokeService(operation);
+ }
+ catch (...)
+ {
+ runtime->unsetCurrentComponent();
+ throw;
+ }
+ runtime->unsetCurrentComponent();
+
+ }
+
+ void ComponentServiceWrapper::setLibrary(Library* lib)
+ {
+ wrapperLibrary = lib;
+ }
+
+ // ======================================================================
+ // createServiceWrapper: create a wrapper for the target ComponentService
+ // ======================================================================
+ ComponentServiceWrapper* ComponentServiceWrapper::createServiceWrapper(Service* service)
+ {
+ string msg;
+ ComponentServiceWrapper* serviceWrapper = 0;
+
+ // -----------------------------------------------
+ // Get the implementation for the target component
+ // -----------------------------------------------
+ Component* targetComponent = service->getComponent();
+ Implementation* impl = targetComponent->getImplementation();
+ if (!impl)
+ {
+ msg = "Component " + targetComponent->getName() + " has no implementation defined";
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // TODO: This only handle CPP implementation for now
+ if (impl->getImplementationType() == Implementation::CPP)
+ {
+ // ----------------------------------------------------
+ // Get implementation dll name and wrapper factory name
+ // ----------------------------------------------------
+ string dllName = ((CPPImplementation*)impl)->getDll();
+ string wrapperFactoryName = ((CPPImplementation*)impl)->getHeaderStub()
+ + "_" + service->getName() + "_Wrapper_Factory";
+
+ // ------------
+ // Load the dll
+ // ------------
+ string fullDllName = targetComponent->getModule()->getRoot() + "/" + dllName;
+ typedef ComponentServiceWrapper* (* WRAPPERFACTORY) (Service*);
+ Library* wrapperLib = new Library(fullDllName);
+
+ // -------------------------
+ // Locate the factory method
+ // -------------------------
+ WRAPPERFACTORY wrapperFactory = (WRAPPERFACTORY)wrapperLib->getSymbol(wrapperFactoryName);
+ if (!wrapperFactory)
+ {
+ LOGERROR_2(1, "ComponentServiceWrapper::createServiceWrapper: Unable to locate %s in library %s",
+ wrapperFactoryName.c_str(), fullDllName.c_str());
+ msg = "Unable to locate " + wrapperFactoryName + " in library " + fullDllName;
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // -------------------------------------
+ // Now create an instance of the wrapper
+ // -------------------------------------
+ serviceWrapper = wrapperFactory(service);
+ if (!serviceWrapper)
+ {
+ LOGERROR_2(1, "ComponentServiceWrapper::createServiceWrapper: Factory method %s in library %s returned null",
+ wrapperFactoryName.c_str(), fullDllName.c_str());
+ msg = "Factory method " + wrapperFactoryName + " in library " + fullDllName + " returned null";
+ throw ServiceNotFoundException(msg.c_str());
+ }
+ serviceWrapper->setLibrary(wrapperLib);
+ }
+ else
+ {
+ // ----------------------
+ // Non CPP Implementation
+ // ----------------------
+ msg = "Unsupported implementation type for service: " + service->getName();
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ return serviceWrapper;
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h
new file mode 100644
index 0000000000..3a5e990bf0
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h
@@ -0,0 +1,156 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_core_componentservicewrapper_h
+#define tuscany_sca_core_componentservicewrapper_h
+
+#include "osoa/sca/export.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/CPPInterface.h"
+#include "tuscany/sca/util/Library.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * 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 ComponentServiceWrapper : public ServiceWrapper
+ {
+ public:
+ /**
+ * Factory method to create a new ComponentServiceWrapper 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 SCA_API ComponentServiceWrapper* createServiceWrapper(Service* target);
+
+ /**
+ * Constructor.
+ * @param target The component service to which this wrapper refers.
+ */
+ SCA_API ComponentServiceWrapper(Service* target);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~ComponentServiceWrapper();
+
+ /**
+ * 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.
+ */
+ SCA_API virtual void invoke(Operation& operation);
+
+ /**
+ * Return the loaded shared library for the target component.
+ */
+ Library* getLibrary() {return wrapperLibrary;}
+ protected:
+ /**
+ * Delegated method to invoke the correct method on the target component.
+ * Implemented by the subtype.
+ */
+ SCA_API 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.
+ */
+ SCA_API virtual void* newImplementation() = 0;
+
+ /**
+ * Delegated method to delete the current instance of the component
+ * implementation.
+ * Implemented by the subtype.
+ */
+ SCA_API virtual void deleteImplementation() = 0;
+
+ /**
+ * Return the current instance of the component implementation.
+ * @return A pointer to an instance of the component implementation class.
+ */
+ SCA_API virtual void* getImplementation();
+
+ /**
+ * Indicates that the current instance of the component implementation
+ * has been finished with.
+ * Will call ComponentServiceWrapper#deleteImplementation if the
+ * implementation is stateless (so that a new instance is returned
+ * for each call).
+ */
+ SCA_API virtual void releaseImplementation();
+
+ private:
+ /**
+ * Holds an implementation instance if the scope is set to module.
+ */
+ static void* staticImpl;
+
+ /**
+ * The component to which this wrapper refers.
+ */
+ Component* component;
+
+ /**
+ * The service on the component to which this wrapper refers.
+ */
+ Service* service;
+
+ /**
+ * A pointer to the interface which the service exposes.
+ */
+ CPPInterface* interf;
+
+ /**
+ * Set to true if the service is remotable.
+ */
+ bool remotable;
+
+ /**
+ * 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 sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_componentservicewrapper_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp
new file mode 100644
index 0000000000..2838bbe4d4
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp
@@ -0,0 +1,102 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/ExternalServiceWrapper.h"
+#include <stdarg.h>
+
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+#include "tuscany/sca/ws/WSServiceWrapper.h"
+using tuscany::sca::ws::WSServiceWrapper;
+
+using namespace osoa::sca;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ //////////////////////////////////////////////////////////////////////
+ // Construction/Destruction
+ //////////////////////////////////////////////////////////////////////
+
+ ExternalServiceWrapper::ExternalServiceWrapper(tuscany::sca::model::WireTarget* target)
+ : ServiceWrapper(target)
+ {
+ LOGENTRY(1,"ExternalServiceWrapper::constructor");
+ if (target->getServiceType() != WireTarget::ExternalServiceType)
+ {
+ throw ServiceRuntimeException("ExternalServiceWrapper: target is not an ExternalService");
+ }
+
+ LOGEXIT(1,"ExternalServiceWrapper::constructor");
+
+ }
+
+ ExternalServiceWrapper::~ExternalServiceWrapper()
+ {
+ LOGENTRY(1,"ExternalServiceWrapper::destructor");
+ LOGEXIT(1,"ExternalServiceWrapper::destructor");
+ }
+
+ // ======================================================================
+ // createServiceWrapper: create a wrapper for the target ExternalService
+ // ======================================================================
+ ExternalServiceWrapper* ExternalServiceWrapper::createServiceWrapper(ExternalService* service)
+ {
+ string msg;
+ ExternalServiceWrapper* serviceWrapper = 0;
+
+ // -----------------------------------------------
+ // Get the binding for the target component
+ // -----------------------------------------------
+ Binding* targetBinding = service->getBinding();
+ if (!targetBinding)
+ {
+ msg = "External service " + service->getName() + " has no binding defined";
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // TODO: This only handles ws implementation for now
+ if (targetBinding->getBindingType() == Binding::WS)
+ {
+ // -------------------------------------
+ // Create an instance of the wrapper
+ // -------------------------------------
+ serviceWrapper = new WSServiceWrapper(service);
+
+ }
+ else
+ {
+ // ----------------------
+ // Non WS Binding
+ // ----------------------
+ msg = "Unsupported binding type for externalService: " + service->getName();
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ return serviceWrapper;
+ }
+
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h
new file mode 100644
index 0000000000..b2dcfb3a6b
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h
@@ -0,0 +1,81 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_core_externalservicewrapper_h
+#define tuscany_sca_core_externalservicewrapper_h
+
+#include "osoa/sca/export.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/ExternalService.h"
+using tuscany::sca::model::ExternalService;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ /**
+ * Wraps an SCA external service so that it can be called by a
+ * proxy.
+ * This abstract class will be extended by a class which supports
+ * a specific external service binding (for example, the web services binding).
+ */
+ class SCA_API ExternalServiceWrapper : public ServiceWrapper
+ {
+ public:
+ /**
+ * Factory method to create a new ExternaServiceWrapper for a given
+ * external service described in the SCA module.
+ */
+ static ExternalServiceWrapper* createServiceWrapper(ExternalService* service);
+
+ /**
+ * Constructor.
+ * @param target The target external service for which this wrapper is to be
+ * created.
+ * @return A wrapper that references the given target.
+ */
+ ExternalServiceWrapper(tuscany::sca::model::WireTarget* target);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ExternalServiceWrapper();
+
+ /**
+ * Return the external service (in the runtime model) that is wrapped by
+ * the instance of this class.
+ */
+ virtual ExternalService* getExternalService() {return (ExternalService*)getTarget();};
+
+ /**
+ * All business method calls to the external service go through the invoke method.
+ * This is a delegated method which will be implemented by the subclass.
+ * @param operation The details of the method, paramaters and return value for the
+ * business method to be called on the external service.
+ */
+ virtual void invoke(Operation& operation) = 0;
+ private:
+
+ };
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_externalservicewrapper_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/Operation.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/Operation.cpp
new file mode 100644
index 0000000000..ea9dfdb15a
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/Operation.cpp
@@ -0,0 +1,88 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/Operation.h"
+#include <stdarg.h>
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ Operation::Operation(const char* operationName, unsigned int numParameters)
+ : name(operationName), nparms(numParameters)
+ {
+ LOGENTRY(1,"Operation::constructor");
+
+ parameters = new void*[nparms];
+
+ LOGEXIT(1,"Operation::constructor");
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ Operation::~Operation()
+ {
+ LOGENTRY(1,"Operation::destructor");
+ LOGEXIT(1,"Operation::destructor");
+ }
+
+
+ // ==============================================
+ // getParameter: return parameter at position pos
+ // ==============================================
+ void* Operation::getParameter(unsigned int pos)
+ {
+ if (pos < nparms)
+ {
+ return parameters[pos];
+ }
+
+ return 0;
+ }
+
+ // ===========================================
+ // setParameter: set parameter at position pos
+ // ===========================================
+ void Operation::setParameter(unsigned int pos, void* parm)
+ {
+ if (pos < nparms)
+ {
+ parameters[pos] = parm;
+ }
+ }
+
+ // ====================================
+ // setReturnValue: set the return value
+ // ====================================
+ void Operation::setReturnValue(void* val)
+ {
+ returnType = val;
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/Operation.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/Operation.h
new file mode 100644
index 0000000000..9e080363aa
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/Operation.h
@@ -0,0 +1,115 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_core_operation_h
+#define tuscany_sca_core_operation_h
+#include "osoa/sca/export.h"
+
+#include <string>
+using std::string;
+
+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, unsigned int numParameters);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~Operation();
+
+ /**
+ * Return the operation name.
+ * @return The name of the operation.
+ */
+ SCA_API const char* getName() {return name;}
+
+ /**
+ * 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 setParameter(unsigned int pos, void* parm);
+
+ /**
+ * 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* getParameter(unsigned int pos);
+
+ /**
+ * Get the return value on the operation.
+ * Normally the client
+ * would set the return value and the service will get this
+ * return value pointer and set the return value.
+ * @return Pointer to the return type.
+ */
+ SCA_API void* getReturnValue() {return returnType;}
+
+ /**
+ * Set the return value on the operation.
+ * Normally the client
+ * would set the return value pointer so that the service can
+ * return a value
+ * @param valPtr Pointer to the return type.
+ */
+ SCA_API void setReturnValue(void* valPtr);
+
+ private:
+ /**
+ * Operation name (method name).
+ */
+ const char* name;
+
+ /**
+ * Number of paramaters passed for this operation.
+ */
+ unsigned int nparms;
+
+ /**
+ * Pointer to the array of parameters.
+ */
+ void** parameters;
+
+ /**
+ * The return value.
+ */
+ void* returnType;
+ };
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_operation_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp
new file mode 100644
index 0000000000..a505ba9636
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp
@@ -0,0 +1,215 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/SCAEntryPoint.h"
+
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/core/ComponentServiceWrapper.h"
+#include "tuscany/sca/core/ExternalServiceWrapper.h"
+using namespace osoa::sca;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ SCAEntryPoint::SCAEntryPoint(const char* epName)
+ : subsystem(0), entrypoint(0), module(0)
+ {
+ LOGENTRY(1,"SCAEntryPoint::constructor");
+ string message;
+
+ // initialize the system if necessary
+ System* system = SCARuntime::getInstance()->getSystem();
+
+ string subsystemName;
+ string entrypointName;
+
+ Utils::tokeniseUri(epName, subsystemName, entrypointName);
+
+ // --------------------
+ // locate the Subsystem
+ // --------------------
+ subsystem = system->findSubsystem(subsystemName);
+ if (!subsystem)
+ {
+ throw EntryPointNotFoundException(epName);
+ }
+
+ // ---------------------
+ // locate the EntryPoint
+ // ---------------------
+ entrypoint = subsystem->findEntryPoint(entrypointName);
+ if (entrypoint)
+ {
+ // found Subsystem EntryPoint
+ throw EntryPointNotFoundException("Subsystem EntryPoint not yet supported");
+ }
+ else
+ {
+ // -----------------------------------
+ // locate the EntryPoint in the Module
+ // -----------------------------------
+ string moduleComponentName;
+ Utils::tokeniseUri(entrypointName, moduleComponentName, entrypointName);
+ module = subsystem->findModuleByComponentName(moduleComponentName);
+ if (module)
+ {
+ dataFactory = module->getDataFactory();
+ entrypoint = module->findEntryPoint(entrypointName);
+ }
+ }
+
+ if (!entrypoint)
+ {
+ throw EntryPointNotFoundException(epName);
+ }
+
+ // ---------------------------------
+ // Get Wrappers for each wire target
+ // ---------------------------------
+
+ // Get the target services from the EntryPoint
+ const EntryPoint::TARGETS& targets = entrypoint->getTargets();
+
+ // --------------------
+ // Validate the request
+ // --------------------
+ switch (entrypoint->getMultiplicity())
+ {
+ case EntryPoint::ONE_MANY:
+ case EntryPoint::ONE_ONE:
+ {
+ if (targets.size() == 0)
+ {
+ message = "EntryPoint " + entrypoint->getName() + " not wired";
+ throw ServiceNotFoundException(message.c_str());
+ }
+ }
+ default:
+ {
+ }
+ } // end switch
+
+ for (EntryPoint::TARGETS::const_iterator iter = targets.begin();
+ iter!=targets.end();
+ iter++)
+ {
+ ServiceWrapper* service = getServiceWrapper(*iter);
+ if (service)
+ {
+ services.push_back(service);
+ }
+ }
+
+ LOGEXIT(1,"SCAEntryPoint::constructor");
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ SCAEntryPoint::~SCAEntryPoint()
+ {
+ LOGENTRY(1,"SCAEntryPoint::destructor");
+
+ // Delete any ServiceWrappers
+ for (SERVICES::iterator iter = services.begin(); iter < services.end(); iter++)
+ {
+ delete (*iter);
+ }
+ LOGEXIT(1,"SCAEntryPoint::destructor");
+ }
+
+
+ // ======================================================================
+ // invoke:
+ // ======================================================================
+ SCA_API DataObjectPtr SCAEntryPoint::invoke(const char* operationName, DataObjectPtr inDataObject)
+ {
+ string message;
+
+ // --------------------
+ // Validate the request
+ // --------------------
+ if (services.size() == 0)
+ {
+ message = "EntryPoint " + entrypoint->getName() + " not wired";
+ throw ServiceNotFoundException(message.c_str());
+ }
+
+ // -------------------
+ // Invoke each target
+ // -------------------
+ Operation operation(operationName, 1);
+ operation.setParameter(0, &inDataObject);
+ DataObjectPtr ret;
+ operation.setReturnValue((void *)&ret);
+
+ for (SERVICES::iterator iter = services.begin(); iter < services.end(); iter++)
+ {
+ (*iter)->invoke(operation);
+ }
+
+ return ret;
+ }
+
+
+ // ======================================================================
+ // getServiceWrapper: Create and return an instance of the ServiceWrapper
+ // ======================================================================
+ ServiceWrapper* SCAEntryPoint::getServiceWrapper(WireTarget* target)
+ {
+ // -------------------------
+ // Determine type of Service
+ // -------------------------
+ switch (target->getServiceType())
+ {
+ case WireTarget::ExternalServiceType:
+ {
+ // ----------------
+ // External Service
+ // ----------------
+ return ExternalServiceWrapper::createServiceWrapper((ExternalService*)target);
+ }
+
+ case WireTarget::ComponentServiceType:
+ {
+ // -----------------
+ // Component Service
+ // -----------------
+ return ComponentServiceWrapper::createServiceWrapper((Service*)target);
+ }
+
+ default:
+ {
+ string message = "Undefined wire target type for : ";
+ message = message + target->getName();
+ throw ServiceNotFoundException(message.c_str());
+ }
+ } // end switch
+ }
+
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCAEntryPoint.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCAEntryPoint.h
new file mode 100644
index 0000000000..34c9f3e0d8
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCAEntryPoint.h
@@ -0,0 +1,126 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_core_scaentrypoint_h
+#define tuscany_sca_core_scaentrypoint_h
+
+#include "osoa/sca/export.h"
+
+#include <vector>
+using std::vector;
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/WireTarget.h"
+#include "tuscany/sca/model/Subsystem.h"
+#include "tuscany/sca/model/EntryPoint.h"
+#include "tuscany/sca/model/Module.h"
+using namespace tuscany::sca::model;
+#include "commonj/sdo/SDO.h"
+using commonj::sdo::DataObjectPtr;
+using commonj::sdo::DataFactoryPtr;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * A runtime class which is used by external bindings to provide the entry
+ * point into the SCA runtime. An entry point will be defined in an SCA
+ * module, and a binding class will be provided to service the
+ * communication between the external binding (e.g. for web services the
+ * SOAP/HTTP communication) and the SCA runtime. The binding class will
+ * use SCAEntryPoint to call into the SCA runtime.
+ */
+ class SCAEntryPoint
+ {
+ public:
+ /**
+ * Constructor to create a new instance which will be associated with
+ * a given entry point in an SCA module.
+ * @param entryPointName The qualified name of the entry point in an
+ * SCA module. It is of the form
+ * "subsystem name"/"module component name"/"entry point name".
+ */
+ SCA_API SCAEntryPoint(const char* entryPointName);
+
+ /**
+ * Destructor.
+ */
+ SCA_API virtual ~SCAEntryPoint();
+
+ /**
+ * Invokes an operation on the component to which the SCA entry point
+ * is wired in the SCA module.
+ * Note that the operation must take a single data object as a parameter, and
+ * the return is a single data object.
+ * @param operationName Name of the operation.
+ * @param inDataObject The parameter for the operation.
+ * @return The data object which holds the result of the operation.
+ */
+ SCA_API virtual DataObjectPtr invoke(const char* operationName, DataObjectPtr inDataObject);
+
+ /**
+ * Returns a SDO data factory from which all the types associated with the entry point
+ * and module can be created.
+ */
+ SCA_API DataFactoryPtr getDataFactory() {return dataFactory;}
+
+ protected:
+
+ private:
+ /**
+ * The subsystem in which this entry point is found.
+ */
+ Subsystem* subsystem;
+
+ /**
+ * The entry point in the module.
+ */
+ EntryPoint* entrypoint;
+
+ /**
+ * The module component in the subsystem.
+ */
+ Module* module;
+
+ /**
+ * Cached data factory which has all the types defined for the module in which
+ * this entry point is found.
+ */
+ DataFactoryPtr dataFactory;
+
+ typedef vector<ServiceWrapper*> SERVICES;
+ /**
+ * Vector of all the service wrappers created for this entry point.
+ * Used to destroy the wrappers when this class is destroyed.
+ */
+ SERVICES services;
+
+ /**
+ * Creates and returns the service wrapper for a given target.
+ * @param target The target of the wire for which a service wrapper is
+ * to be created.
+ * @return A service wrapper to be used for invoking the target implementation.
+ */
+ ServiceWrapper* getServiceWrapper(WireTarget* target);
+
+ };
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_scaentrypoint_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCARuntime.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
new file mode 100644
index 0000000000..deca72c378
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
@@ -0,0 +1,288 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/core/ComponentServiceWrapper.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Exceptions.h"
+
+#include "tuscany/sca/model/System.h"
+#include "tuscany/sca/model/Subsystem.h"
+#include "tuscany/sca/model/ModelLoader.h"
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#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_MODULE = "TUSCANY_SCACPP_DEFAULT_MODULE";
+
+
+ // ==========================================================
+ // Initialize static class member to not pointing at anything
+ // ==========================================================
+ SCARuntime* SCARuntime::instance = 0;
+
+
+ // ===================================================================
+ // Constructor for the SCARuntime class. This will be a singleton that
+ // holds all the information about the current runtime.
+ // ===================================================================
+ SCARuntime::SCARuntime() : system(new System()), defaultModule(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");
+ }
+
+ // =============================================================
+ // 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 the runtime
+ // Get root from environment variable TUSCANY_SCACPP_SYSTEM_ROOT
+ char* systemRoot = getenv(TUSCANY_SCACPP_SYSTEM_ROOT);
+ if (systemRoot == 0)
+ {
+ string msg = TUSCANY_SCACPP_SYSTEM_ROOT;
+ msg += " environment variable not set";
+ throw SystemConfigurationException(msg.c_str());
+ }
+ instance->load(systemRoot);
+ }
+
+ LOGEXIT(1, "SCARuntime::getInstance");
+
+ return instance;
+
+ }
+
+ // ======================================
+ // Load up all the details of the runtime
+ // ======================================
+ void SCARuntime::load(const char *configurationRoot)
+ {
+ LOGENTRY(1, "SCARuntime::load");
+ std::string root = configurationRoot;
+
+ LOGINFO_1(2,"configuration root: %s", configurationRoot);
+
+ ModelLoader loader(system);
+ // Load details of the module
+ loader.load(configurationRoot);
+
+ LOGEXIT(1, "SCARuntime::load");
+ }
+
+
+ // ===================================
+ // Return the top of the runtime model
+ // ===================================
+ System* SCARuntime::getSystem()
+ {
+ 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;
+ }
+
+ }
+
+
+ // ===========================================
+ // getCurrentModule: return the current module
+ // ===========================================
+ Module* SCARuntime::getCurrentModule()
+ {
+ // ---------------------------------------------
+ // Get module from current component if possible
+ // ---------------------------------------------
+ Component* comp = getCurrentComponent();
+ if (comp != 0)
+ {
+ return comp->getModule();
+ }
+
+ // ----------------------
+ // Get the default Module
+ // ----------------------
+ string message;
+ if (!defaultModule)
+ {
+ // -------------------------------------------
+ // Get the default module from the environment
+ // -------------------------------------------
+ const char* defMod = getenv(TUSCANY_SCACPP_DEFAULT_MODULE);
+ if (!defMod)
+ {
+ message = TUSCANY_SCACPP_DEFAULT_MODULE;
+ message += " environment variable not set";
+ throw SystemConfigurationException(message.c_str());
+ }
+
+ string subsystemName, moduleName;
+ Utils::tokeniseUri(defMod, subsystemName, moduleName);
+
+ // ---------------------------
+ // Subsystem must be specified
+ // ---------------------------
+ Subsystem* subsystem = system->findSubsystem(subsystemName);
+ if (!subsystem)
+ {
+ message = "Default subsystem \'" + subsystemName + "\' not found";
+ throw SystemConfigurationException(message.c_str());
+ }
+
+ // --------------------------------------------------------------------------
+ // If module is not specified then get the default module for this subsystem.
+ // This will be the ONLY module for this subsystem
+ // --------------------------------------------------------------------------
+ if (moduleName == "")
+ {
+ defaultModule = subsystem->getDefaultModule();
+ if (!defaultModule)
+ {
+ message = "Default module not found for subsystem \'" + subsystemName + "\'";
+ throw SystemConfigurationException(message.c_str());
+ }
+ }
+ else
+ {
+ // -----------------------------
+ // get the named ModuleComponent
+ // -----------------------------
+ defaultModule = subsystem->findModuleByComponentName(moduleName);
+ if (!defaultModule)
+ {
+ message = "Default module \'" + moduleName + "\' not found in subsystem \'" + subsystemName +"\'";
+ throw SystemConfigurationException(message.c_str());
+ }
+ }
+ }
+ return defaultModule;
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCARuntime.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCARuntime.h
new file mode 100644
index 0000000000..42deb85751
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/SCARuntime.h
@@ -0,0 +1,166 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_core_scaruntime_h
+#define tuscany_sca_core_scaruntime_h
+
+#include "osoa/sca/export.h"
+
+#include "osoa/sca/ComponentContext.h"
+using osoa::sca::ComponentContext;
+
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/System.h"
+using namespace tuscany::sca::model;
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <pthread.h>
+#endif
+
+#include <stack>
+#include <string>
+#include <map>
+using namespace std;
+
+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();
+
+ /**
+ * 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.
+ */
+ System* getSystem();
+
+ /**
+ * The directory in which the Tuscany runtime has been installed.
+ */
+ const string& getInstallRoot() {return SCARoot;}
+
+ /**
+ * Return the current component for this thread.
+ * @return The current component for this thread.
+ */
+ Component* getCurrentComponent();
+
+ /**
+ * Get the current module. The current module will either
+ * be the module in which the current component for this thread
+ * is defined, or it will be the default module if there is no current
+ * component. There will not be a current component if a client of
+ * the SCA runtime is making a call into the SCA runtime.
+ */
+ Module* getCurrentModule();
+
+ private:
+ /**
+ * Default constructor is private to prevent more than one instance.
+ */
+ SCARuntime();
+
+ /**
+ * Load the SCA configuration from the scdl files (sca.module,
+ * *.fragment, etc).
+ * This will create the runtime model from which the SCA runtime
+ * will operate.
+ * @param configurationRoot The path to the configuration of the
+ * SCA runtime. Under this root will be the subsystems and modules
+ * directories.
+ */
+ void load(const char* configurationRoot);
+
+ /**
+ * The single instance of this class.
+ */
+ static SCARuntime* instance;
+
+ /**
+ * Pointer to the top of the runtime model.
+ */
+ System* system;
+
+ /**
+ * The installed path of the Tuscany runtime.
+ */
+ string SCARoot;
+
+ /**
+ * Get the default module set for this runtime.
+ * @return The default module.
+ */
+ Module* getDefaultModule() {return defaultModule;}
+
+ /**
+ * The default module set for this runtime.
+ */
+ Module* defaultModule;
+
+
+ typedef stack<Component*> COMPONENT_STACK;
+#if defined(WIN32) || defined (_WINDOWS)
+ typedef map<DWORD, COMPONENT_STACK> COMPONENTS_MAP;
+#else
+ typedef map<pthread_t, COMPONENT_STACK> COMPONENTS_MAP;
+#endif
+
+ /**
+ * A map of threads to components.
+ */
+ COMPONENTS_MAP components;
+ };
+
+
+ } // End namespace sca
+} // End namespace tuscany
+
+
+
+
+#endif // tuscany_sca_core_scaruntime_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp
new file mode 100644
index 0000000000..ef2f2744eb
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp
@@ -0,0 +1,121 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/ServiceProxy.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/CPPImplementation.h"
+
+using namespace osoa::sca;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ ServiceProxy::ServiceProxy(Component* component, const string& name, ServiceWrapper* target)
+ {
+ LOGENTRY(1,"ServiceProxy::constructor");
+ string msg;
+
+ // ----------------------
+ // Get the implementation
+ // ----------------------
+ Implementation* impl = component->getImplementation();
+ if (!impl)
+ {
+ msg = "Component " + component->getName() + " has no implementation defined";
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // TODO: This only handle CPP implementation for now
+ if (impl->getImplementationType() == Implementation::CPP)
+ {
+ // ----------------------------------------------------
+ // Get implementation dll name and service factory name
+ // ----------------------------------------------------
+ string dllName = ((CPPImplementation*)impl)->getDll();
+ string headerStub = ((CPPImplementation*)impl)->getHeaderStub();
+
+ string fullDllName = component->getModule()->getRoot() + "/" + dllName;
+ string proxyFactoryName = headerStub + "_" + name + "_Proxy_Factory";
+ string proxyDestructorName = headerStub + "_" + name + "_Proxy_Destructor";
+ typedef void* (* PROXYFACTORY) (ServiceWrapper*);
+
+ // ------------
+ // Load the dll
+ // ------------
+ proxyLibrary = Library(fullDllName);
+
+ // -------------------------
+ // Locate the factory method
+ // -------------------------
+ PROXYFACTORY proxyFactory = (PROXYFACTORY)proxyLibrary.getSymbol(proxyFactoryName);
+ if (!proxyFactory)
+ {
+ LOGERROR_2(1, "ComponentContextImpl::getServiceProxy: Unable to locate %s in library %s",
+ proxyFactoryName.c_str(), fullDllName.c_str());
+ msg = "Unable to locate " + proxyFactoryName + " in library " + fullDllName;
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // -----------------------------------
+ // Now create an instance of the proxy
+ // -----------------------------------
+ proxy = proxyFactory(target);
+ if (!proxy)
+ {
+ LOGERROR_2(1, "ComponentContextImpl::getServiceProxy: Factory method %s in library %s returned null",
+ proxyFactoryName.c_str(), fullDllName.c_str());
+ msg = "Factory method " + proxyFactoryName + " in library " + fullDllName + " returned null";
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // -------------------------
+ // Get the destructor method
+ // -------------------------
+ destructor = (PROXYDESTRUCTOR)proxyLibrary.getSymbol(proxyDestructorName);
+ }
+
+ LOGEXIT(1,"ServiceProxy::constructor");
+
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ServiceProxy::~ServiceProxy()
+ {
+ LOGENTRY(1,"ServiceProxy::destructor");
+
+ // Delete the proxy
+ if (destructor)
+ {
+ destructor(proxy);
+ }
+ LOGEXIT(1,"ServiceProxy::destructor");
+ }
+
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceProxy.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceProxy.h
new file mode 100644
index 0000000000..073b379cd7
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceProxy.h
@@ -0,0 +1,89 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_core_serviceproxy_h
+#define tuscany_sca_core_serviceproxy_h
+
+#include "osoa/sca/export.h"
+
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/util/Library.h"
+
+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 ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a given component and reference name. The
+ * create proxy will contain a pointer to the target ServiceWrapper.
+ * @param component The component for which this proxy will be created (the
+ * source component).
+ * @param name The name of the reference on the component.
+ * @param target The wrapper of the component which is wired to this component and
+ * reference.
+ */
+ ServiceProxy(Component* component, const string& name, ServiceWrapper* target);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ServiceProxy();
+
+ /**
+ * Return an instance of the proxy created for this particular component and reference.
+ * @return The proxy.
+ */
+ void* getProxy() {return proxy;}
+
+
+ private:
+ /**
+ * Holds the instance of the code generated proxy.
+ */
+ void* proxy;
+
+ typedef void (* PROXYDESTRUCTOR) (void*);
+
+ /**
+ * A function pointer to the destructor of the proxy.
+ */
+ PROXYDESTRUCTOR destructor;
+
+ /**
+ * The library which contains the code for the proxy.
+ */
+ Library proxyLibrary;
+
+ };
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_serviceproxy_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp
new file mode 100644
index 0000000000..5936f526f1
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include <stdarg.h>
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ // ===========
+ // Constructor
+ // ===========
+ ServiceWrapper::ServiceWrapper(WireTarget* targ)
+ : target(targ)
+ {
+ 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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceWrapper.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceWrapper.h
new file mode 100644
index 0000000000..21c162d77f
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/core/ServiceWrapper.h
@@ -0,0 +1,73 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_core_servicewrapper_h
+#define tuscany_sca_core_servicewrapper_h
+
+#include "osoa/sca/export.h"
+
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/WireTarget.h"
+using tuscany::sca::model::WireTarget;
+
+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(WireTarget* target);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ServiceWrapper();
+
+ /**
+ * Get the target represented by this wrapper.
+ * @return The target represented by this wrapper.
+ */
+ virtual WireTarget* getTarget() {return target;}
+
+ /**
+ * 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.
+ */
+ WireTarget* target;
+ };
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_servicewrapper_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Binding.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Binding.cpp
new file mode 100644
index 0000000000..c312d7a077
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Binding.cpp
@@ -0,0 +1,44 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#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)
+ {
+ }
+
+ Binding::~Binding()
+ {
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Binding.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Binding.h
new file mode 100644
index 0000000000..ff97990dc6
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Binding.h
@@ -0,0 +1,85 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_binding_h
+#define tuscany_sca_model_binding_h
+#include <string>
+using std::string;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Information about the binding for EntryPoint and ExternalService. An
+ * abstract class which will be extended by classes that hold specific
+ * information for each type of binding.
+ */
+ class Binding
+ {
+
+ public:
+ /**
+ * Supported binding types.
+ */
+ enum Type
+ {
+ WS,
+ SCA
+ };
+
+ /**
+ * Constructor to create a new binding.
+ * @param uri The uri specified in the scdl file.
+ */
+ Binding(const string& uri);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Binding();
+
+ /**
+ * Return the enumerated type of binding.
+ * @return The type of the binding (see Binding#Type).
+ */
+ virtual Type getBindingType() = 0;
+
+ /**
+ * Return the uri of the binding.
+ * @return The uri of the binding.
+ */
+ string getUri() {return uri;};
+
+ private:
+ /**
+ * The uri of the binding.
+ */
+ string uri;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_binding_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPImplementation.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPImplementation.cpp
new file mode 100644
index 0000000000..7212e777b1
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPImplementation.cpp
@@ -0,0 +1,54 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/CPPImplementation.h"
+#include "tuscany/sca/util/Utils.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ CPPImplementation::CPPImplementation(const string& dllName, const string& head, const string& classN)
+ : dll(dllName), header(head), className(classN)
+ {
+ // Separate any path element
+ Utils::rTokeniseString("/", head, headerPath, headerStub);
+ if (headerPath != "")
+ {
+ headerPath += "/";
+ }
+
+ // Determine the header stub name
+ string tmp;
+ Utils::rTokeniseString(".h", headerStub, headerStub, tmp);
+ }
+
+ CPPImplementation::~CPPImplementation()
+ {
+ }
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPImplementation.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPImplementation.h
new file mode 100644
index 0000000000..0294649af7
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPImplementation.h
@@ -0,0 +1,125 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_cppimplementation_h
+#define tuscany_sca_model_cppimplementation_h
+#include "tuscany/sca/model/Implementation.h"
+
+#include <map>
+using std::map;
+#include <string>
+using std::string;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Holds informatio about an SCA implementation written in C++
+ */
+ class CPPImplementation : public Implementation
+ {
+
+ public:
+ /**
+ * 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(const string& dllName, const string& header, const string& className);
+
+ /**
+ * Destructor
+ */
+ virtual ~CPPImplementation();
+
+ /**
+ * Return the implementation type.
+ * @return Always returns CPP.
+ */
+ virtual Type getImplementationType() {return CPP;}
+
+ /**
+ * Returns the name of the shared library.
+ * @return The name of the shared library.
+ */
+ const string& getDll() {return dll;}
+
+ /**
+ * Get the name of the header file.
+ * @return Name of the header file.
+ */
+ const string& getHeader() {return header;}
+
+ /**
+ * Get the header file name without the extension.
+ * @return The name of the header file without any extension.
+ */
+ const string& getHeaderStub() {return headerStub;}
+
+ /**
+ * Get the header path.
+ * @return The pathe element of the header.
+ */
+ const string& getHeaderPath() {return headerPath;}
+
+ /**
+ * Get the name of the class.
+ * @return The class name if specified.
+ */
+ const string& getClass() {return className;}
+ private:
+ /**
+ * Name of the shared library.
+ */
+ string dll;
+
+ /**
+ * 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;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_cppimplementation_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPInterface.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPInterface.cpp
new file mode 100644
index 0000000000..015b54c259
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPInterface.cpp
@@ -0,0 +1,67 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/CPPInterface.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ CPPInterface::CPPInterface(
+ const string& head,
+ const string& classN,
+ const string& scop,
+ bool remote)
+ : header(head), className(classN), remotable(remote)
+ {
+ string::size_type dot = header.rfind(".h"); // this will also find .hpp
+ if (dot != string::npos)
+ {
+ headerStub = header.substr(0, dot);
+ }
+ else
+ {
+ headerStub = header;
+ }
+
+ if (scop == "module")
+ {
+ scope = MODULE;
+ }
+ else
+ {
+ scope = STATELESS;
+ }
+ }
+
+ CPPInterface::~CPPInterface()
+ {
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPInterface.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPInterface.h
new file mode 100644
index 0000000000..7b37b1892e
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/CPPInterface.h
@@ -0,0 +1,143 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_cppinterface_h
+#define tuscany_sca_model_cppinterface_h
+
+#include "tuscany/sca/model/Interface.h"
+
+
+#include <map>
+using std::map;
+#include <string>
+using std::string;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * 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 module).
+ * @param remotable True if the interface is remotable.
+ */
+ CPPInterface(
+ const string& header,
+ const string& className,
+ const string& scope,
+ bool remotable);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPInterface();
+
+ /**
+ * Return the type of the interface.
+ * @return Always returns CPP.
+ */
+ virtual Type getInterfaceType() {return CPP;}
+
+ /**
+ * 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;}
+
+ /**
+ * Scope of interface.
+ */
+ enum SCOPE
+ {
+ MODULE,
+ STATELESS
+ };
+
+ /**
+ * Get the scope of the interface.
+ * @return The scope of the interface.
+ */
+ SCOPE getScope() {return scope;}
+
+ /**
+ * Return whether the interface is remotable or local.
+ * @return True if the interface is remotable, otherwise false.
+ */
+ bool getRemotable() {return remotable;}
+
+ 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;
+
+ /**
+ * Scope of the interface.
+ */
+ SCOPE scope;
+
+ /**
+ * Remotable interface or not.
+ */
+ bool remotable;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_cppinterface_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Component.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Component.cpp
new file mode 100644
index 0000000000..3e52591b3d
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Component.cpp
@@ -0,0 +1,303 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+// Component.cpp : Represent a loaded Component
+//
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/Component.h"
+
+using namespace commonj::sdo;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ // Constructor
+ Component::Component(const std::string& componentName, Module* module)
+ : name(componentName), containingModule(module), implementation(0)
+ {
+ LOGENTRY(1, "Component::constructor");
+ LOGINFO_1(3, "Component::constructor: Component name: %s", name.c_str());
+ LOGEXIT(1, "Component::constructor");
+ }
+
+ Component::~Component()
+ {
+ }
+
+ Service* Component::addService(const std::string& serviceName)
+ {
+ Service* service = new Service(serviceName, this);
+ services[serviceName] = service;
+ return service;
+ }
+
+ Service* Component::findService(const std::string& serviceName)
+ {
+ // If serviceName is null then return the ONLY service
+ if (serviceName == ""
+ && services.size() == 1)
+ {
+ return services.begin()->second;
+ }
+ else
+ {
+ return services[serviceName];
+ }
+ }
+
+ ServiceReference* Component::findReference(const std::string& referenceName)
+ {
+ return references[referenceName];
+ }
+
+ ServiceReference* Component::addReference(const std::string& referenceName)
+ {
+ ServiceReference* serviceReference = references[referenceName];
+ if (!serviceReference)
+ {
+ references[referenceName] = new ServiceReference(referenceName);
+ }
+ return references[referenceName];
+ }
+
+ void Component::setImplementation(Implementation* impl)
+ {
+ implementation = impl;
+ }
+
+ void Component::addProperty(const string& name,
+ const string& type,
+ bool many,
+ bool required,
+ const char* 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
+
+
+ // Add to list of required properties
+ if (required)
+ {
+ }
+ }
+
+ DataFactoryPtr Component::getPropertyDataFactory()
+ {
+ if (!propertyFactory)
+ {
+ propertyFactory = DataFactory::getDataFactory();
+ // Add the root type
+ propertyFactory->addType("org/osoa/sca", "Properties", false, false, false, false);
+ }
+ return propertyFactory;
+ }
+
+ DataObjectPtr Component::getProperties()
+ {
+ if (!properties)
+ {
+ properties = getPropertyDataFactory()->create("org/osoa/sca", "Properties");
+ }
+ return properties;
+ }
+
+ void Component::addProperties(DataObjectPtr values)
+ {
+ if (!values)
+ {
+ return;
+ }
+
+ DataObjectPtr props = getProperties();
+
+ PropertyList pl = values->getInstanceProperties();
+ for (int i=0; i < pl.size(); i++)
+ {
+ if (!values->isSet(i))
+ {
+ continue;
+ }
+
+ // Add the property value to the component to be resolved later
+ string propName = pl[i].getName();
+
+ // Get the property's type
+ try
+ {
+ const Property& propProperty = props->getProperty(pl[i].getName());
+ const Type& propType = propProperty.getType();
+
+ DataObjectList& proplist = values->getList(pl[i]);
+ for (int proplistI=0; proplistI<proplist.size(); proplistI++)
+ {
+ if (propType.isDataType())
+ {
+ if (propProperty.isMany())
+ {
+ DataObjectList& dol = props->getList(pl[i]);
+ dol.append(proplist.getCString(proplistI));
+ }
+ else
+ {
+ props->setCString(pl[i], proplist.getCString(proplistI));
+ }
+ }
+ else
+ {
+ // Create a new instance of the DO
+ // iterate over properties setting each one
+ }
+ }
+ }
+ catch (SDOPropertyNotFoundException&)
+ {
+ // Configuration error: property is not defined
+ string message = "Undefined property: " + propName;
+ throw SystemConfigurationException(message.c_str());
+ }
+
+ }
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Component.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Component.h
new file mode 100644
index 0000000000..f40690c859
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Component.h
@@ -0,0 +1,202 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_component_h
+#define tuscany_sca_model_component_h
+
+#include <string>
+using std::string;
+
+#include <map>
+
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Implementation.h"
+#include "tuscany/sca/model/ServiceReference.h"
+
+#include "commonj/sdo/SDO.h"
+using commonj::sdo::DataObjectPtr;
+using commonj::sdo::DataFactoryPtr;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ class Module;
+
+ /**
+ * Information about an SCA component.
+ */
+ class Component
+ {
+ public:
+ /**
+ * Constructor
+ * @param name The name of the component.
+ * @param module The module containing this component.
+ */
+ Component(const std::string& name, Module* module);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Component();
+
+ /**
+ * Returns the name of the component.
+ * @return The name of the component.
+ */
+ const string& getName() {return name;}
+
+ /**
+ * Get the module containing this component.
+ * @return The containing module.
+ */
+ Module* getModule() {return containingModule;}
+
+ /**
+ * Add a new service to this component.
+ * @param serviceName The name of the service to add.
+ * @return The newly added service.
+ */
+ Service* addService(const std::string& serviceName);
+
+ /**
+ * 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.
+ */
+ Service* findService(const std::string& serviceName);
+
+ /**
+ * Add a new reference to this component.
+ * @param referenceName The name of the reference to add.
+ * @return The newly added reference.
+ */
+ ServiceReference* addReference(const std::string& referenceName);
+
+ /**
+ * 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.
+ */
+ ServiceReference* findReference(const std::string& referenceName);
+
+ /**
+ * Set the details of the implementation of this component.
+ * @param impl The details of the implementation.
+ */
+ void setImplementation(Implementation* impl);
+
+ /**
+ * Returns the details of the implementation of this component.
+ * @return The details of the implementation.
+ */
+ Implementation* getImplementation() {return implementation;}
+
+ /**
+ * Add a new property to this component. Properties are
+ * added one at a time. The property definitions come from the component
+ * type file.
+ * @param name The name of the property.
+ * @param type The full name of the type (including uri and local name).
+ * @param many True if this is a many valued property.
+ * @param required True if this property must have a value set.
+ * @param defaultValue The default value if the property does not have a
+ * value set.
+ */
+ void addProperty(const string& name,
+ const string& type,
+ bool many,
+ bool required,
+ const char* defaultValue = 0);
+
+ /**
+ * Add the property values to the properties defined on this
+ * component. The values will come from the sca.module file.
+ * @param properties A data object representing all the values set
+ * for this component.
+ */
+ void addProperties(DataObjectPtr properties);
+
+ /**
+ * Returns a data object from which all the properties and their
+ * values can be accessed.
+ * @return A data object holding the property values.
+ */
+ DataObjectPtr getProperties();
+ private:
+ /**
+ * Name of the component.
+ */
+ string name;
+
+ /**
+ * Module containing this component for navigating up the tree.
+ */
+ Module* containingModule;
+
+ /**
+ * Information about the implementation of this component.
+ */
+ Implementation* implementation;
+
+ typedef std::map<std::string, Service*> SERVICE_MAP;
+ /**
+ * Map of all the services defined on this component.
+ */
+ SERVICE_MAP services;
+
+ typedef std::map<std::string, ServiceReference*> REFERENCE_MAP;
+ /**
+ * Map of all the references defined on this component.
+ */
+ REFERENCE_MAP references;
+
+ /**
+ * SDO data factory which has all the property types defined from
+ * the component type file
+ */
+ DataFactoryPtr propertyFactory;
+
+ /**
+ * Return the SDO data factory which has the property types defined
+ * in it.
+ * @return The data factory.
+ */
+ DataFactoryPtr getPropertyDataFactory();
+
+ /**
+ * The properties and their values for this component.
+ */
+ DataObjectPtr properties;
+
+ };
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_component_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/EntryPoint.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/EntryPoint.cpp
new file mode 100644
index 0000000000..3ca0f8cc5e
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/EntryPoint.cpp
@@ -0,0 +1,96 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/EntryPoint.h"
+#include "tuscany/sca/util/Exceptions.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ EntryPoint::EntryPoint(const std::string& epName)
+ : name(epName)
+ {
+ LOGENTRY(1, "EntryPoint::constructor");
+ LOGERROR_1(0, "EntryPoint::constructor: EntryPoint name: %s", name.c_str());
+ LOGEXIT(1, "EntryPoint::constructor");
+ }
+
+ EntryPoint::~EntryPoint()
+ {
+ }
+
+ void EntryPoint::addTarget(WireTarget* targ)
+ {
+ if (multiplicity == ONE_ONE || multiplicity == ZERO_ONE)
+ {
+ if (targets.size() > 0)
+ {
+ // throw exception
+ string message = "Duplicate wire for reference: " + name;
+ throw SystemConfigurationException(message.c_str());
+ }
+ }
+
+ // TODO - must be remotable
+
+ targets.push_back(targ);
+ }
+
+ void EntryPoint::setMultiplicity(const std::string& multip)
+ {
+ if (multip == "0..1")
+ {
+ multiplicity = ZERO_ONE;
+ }
+ else if (multip == "1..1")
+ {
+ multiplicity = ONE_ONE;
+ }
+ else if (multip == "0..n")
+ {
+ multiplicity = ZERO_MANY;
+ }
+ else if (multip == "1..n")
+ {
+ multiplicity = ONE_MANY;
+ }
+ else
+ {
+ string msg = "Invalid multiplicity specified, " + multip + ", for reference: " +name;
+ throw SystemConfigurationException(msg.c_str());
+ }
+ }
+
+ void EntryPoint::setInterface(Interface* interf)
+ {
+ iface = interf;
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/EntryPoint.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/EntryPoint.h
new file mode 100644
index 0000000000..f6e4b485f9
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/EntryPoint.h
@@ -0,0 +1,138 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_entrypoint_h
+#define tuscany_sca_model_entrypoint_h
+
+#include <string>
+using std::string;
+#include <vector>
+using std::vector;
+
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/model/WireTarget.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Represents the information about an entry point.
+ */
+ class EntryPoint
+ {
+
+ public:
+ /**
+ * Constructor.
+ * @param name The name of the entry point.
+ */
+ EntryPoint(const std::string& name);
+
+ /**
+ * Destructor.
+ */
+ virtual ~EntryPoint();
+
+ /**
+ * Return the name of the entry point.
+ * @return The name of the entry point.
+ */
+ const string& getName() {return name;}
+
+ /**
+ * How many wires can be wired from this entry point.
+ */
+ enum Multiplicity
+ {
+ ZERO_ONE,
+ ONE_ONE,
+ ZERO_MANY,
+ ONE_MANY
+ };
+
+ /**
+ * Set the multiplicity of this entry point.
+ * @param multiplicity One of 0..1, 1..1, 0..n, 1..n
+ */
+ void setMultiplicity(const std::string& multiplicity);
+
+ /**
+ * Return the multiplicity of this entry point (how
+ * many wires can be wired from this entry point).
+ * @return The multiplicity.
+ */
+ Multiplicity getMultiplicity() {return multiplicity;}
+
+ /**
+ * Set the interface describing this entry point.
+ * @param iface The interface.
+ */
+ void setInterface(Interface* iface);
+
+ /**
+ * Get the interface describing this entry point. Use
+ * Interface#getType to find out the type of interface
+ * describing this entry point.
+ * @return iface The interface.
+ */
+ Interface* getInterface() {return iface;}
+
+ /**
+ * Add a target to the entry point.
+ * @param target Add a target (derived from a wire) to
+ * the entry point.
+ */
+ void addTarget(WireTarget* target);
+ typedef vector<WireTarget*> TARGETS;
+
+ /**
+ * Get a vector of targets added to this entry point.
+ */
+ const TARGETS& getTargets() {return targets;}
+ private:
+ /**
+ * Name of the entry point.
+ */
+ string name;
+
+ /**
+ * The interface describing this entry point.
+ */
+ Interface* iface;
+
+ /**
+ * The multiplicity of this entry point..
+ */
+ Multiplicity multiplicity;
+
+ /**
+ * The vector of targets added to this entry point.
+ */
+ TARGETS targets;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_entrypoint_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ExternalService.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ExternalService.cpp
new file mode 100644
index 0000000000..c0e3afc682
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ExternalService.cpp
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/ExternalService.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ ExternalService::ExternalService(const std::string& serviceName, Module *module)
+ : WireTarget(serviceName), containingModule(module)
+ {
+ LOGENTRY(1, "ExternalService::constructor");
+ LOGERROR_1(0, "ExternalService::constructor: ExternalService name: %s", getName().c_str());
+ LOGEXIT(1, "ExternalService::constructor");
+ }
+
+ ExternalService::~ExternalService()
+ {
+ delete binding;
+ }
+
+ void ExternalService::setBinding(Binding* bind)
+ {
+ binding = bind;
+ }
+
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ExternalService.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ExternalService.h
new file mode 100644
index 0000000000..fe9640d1b8
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ExternalService.h
@@ -0,0 +1,97 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_externalservice_h
+#define tuscany_sca_model_externalservice_h
+
+#include <string>
+
+#include "tuscany/sca/model/WireTarget.h"
+#include "tuscany/sca/model/Binding.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+ class Module;
+
+ /**
+ * Information about an external service.
+ */
+ class ExternalService : public WireTarget
+ {
+ public:
+ /**
+ * Constructor.
+ * @param name The name of the external service.
+ * @param module The module containing this external service.
+ */
+ ExternalService(const std::string& name, Module *module);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ExternalService();
+
+ /**
+ * Return the type of service.
+ * @return Always returns ExternalServiceType
+ */
+ virtual Type getServiceType() {return ExternalServiceType;}
+
+ /**
+ * Set the binding for this external service.
+ * @param binding The binding to set.
+ */
+ virtual void setBinding(Binding* binding);
+
+ /**
+ * Get the binding set for this external service.
+ * @return The binding.
+ */
+ virtual Binding* getBinding() {return binding;};
+
+ /**
+ * Get the module containing this external service.
+ * @return The containing module.
+ */
+ Module* getContainingModule() {return containingModule;};
+
+ private:
+ /**
+ * The binding for this external service.
+ */
+ Binding* binding;
+
+ /**
+ * The module containing this external service.
+ */
+ Module* containingModule;
+
+
+ };
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_externalservice_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Implementation.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Implementation.cpp
new file mode 100644
index 0000000000..9703d1bab3
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Implementation.cpp
@@ -0,0 +1,44 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/Implementation.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ Implementation::Implementation()
+ {
+ }
+
+ Implementation::~Implementation()
+ {
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Implementation.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Implementation.h
new file mode 100644
index 0000000000..17414c359b
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Implementation.h
@@ -0,0 +1,66 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_implementation_h
+#define tuscany_sca_model_implementation_h
+
+#include <string>
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Abstract class representing information about an implementation
+ * of a component. The subtypes will hold information specific to
+ * the type of implementation.
+ */
+ class Implementation
+ {
+
+ public:
+ /**
+ * Supported types of implementation.
+ */
+ enum Type
+ {
+ CPP,
+ JAVA
+ };
+
+ Implementation();
+ virtual ~Implementation();
+
+ /**
+ * Return the type of the implementation.
+ * @return Will depend on the subtype.
+ */
+ virtual Type getImplementationType() = 0;
+
+ private:
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_implementation_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Interface.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Interface.cpp
new file mode 100644
index 0000000000..9e0aa45889
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Interface.cpp
@@ -0,0 +1,44 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/Interface.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ Interface::Interface()
+ {
+ }
+
+ Interface::~Interface()
+ {
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Interface.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Interface.h
new file mode 100644
index 0000000000..24bb43224b
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Interface.h
@@ -0,0 +1,65 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_interface_h
+#define tuscany_sca_model_interface_h
+
+#include <string>
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Information about an interface. Subtypes will hold information
+ * specific to a type of interface.
+ */
+ class Interface
+ {
+
+ public:
+ /**
+ * The supported types of interface.
+ */
+ enum Type
+ {
+ CPP,
+ JAVA
+ };
+
+ Interface();
+ virtual ~Interface();
+
+ /**
+ * Returns the type of the interface.
+ * @return Will depend on the subtype.
+ */
+ virtual Type getInterfaceType() = 0;
+
+ private:
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_interface_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ModelLoader.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
new file mode 100644
index 0000000000..751bbe0c9c
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
@@ -0,0 +1,1555 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "osoa/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/CPPImplementation.h"
+#include "tuscany/sca/model/CPPInterface.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/WSBinding.h"
+
+
+using namespace commonj::sdo;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+ // ===========
+ // Constructor
+ // ===========
+ ModelLoader::ModelLoader(System* system) : system(system)
+ {
+ LOGENTRY(1, "ModelLoader::constructor");
+
+
+ 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 SCA scdl files to the SCA runtime's in memory model.
+ // =========================================================
+ void ModelLoader::load(const char* configurationRoot)
+ {
+ LOGENTRY(1, "ModelLoader::load");
+ LOGINFO_1(2,"configuration root: %s", configurationRoot);
+
+ // The configuration root path will point to a directory structure:
+ // root/
+ // The sca.subsystem files can be located anywhere under this directory
+ // structure.
+ loadSubsystems(configurationRoot);
+
+ // sca.module files represent the root of a module, and can occur anywhere
+ // under the directory structure
+ loadModules(configurationRoot);
+
+ system->resolveWires();
+ LOGEXIT(1, "ModelLoader::load");
+ }
+
+ // ========================================================================
+ // loadSubsystems:
+ // Load all the subsystems from any directory below the configuration root.
+ // Translate the subsystem information to the runtime information
+ // ========================================================================
+ void ModelLoader::loadSubsystems(const char* configurationRoot)
+ {
+ // Get all the sca.subsystem files in the module
+ LOGENTRY(1, "ModelLoader::loadSubsystems");
+ Files files(configurationRoot, "sca.subsystem", true);
+ for (unsigned int i=0; i < files.size(); i++)
+ {
+ loadSubsystemFile(files[i]);
+ }
+ LOGEXIT(1, "ModelLoader::loadSubsystems");
+ }
+
+
+ // =====================================================================
+ // loadSubsystemFile:
+ // This method is called for each sca.subsystem file found in the module
+ // folder structure
+ // =====================================================================
+ void ModelLoader::loadSubsystemFile(const File& file)
+ {
+ LOGENTRY(1, "ModelLoader::loadSubsystemFile");
+ LOGINFO_1(2, "subsystem filename: %s", file.getFileName().c_str());
+
+ try
+ {
+ string filename = file.getDirectory() + "/" + file.getFileName();
+ XMLDocumentPtr subsystemFile = getXMLHelper()->loadFile(filename.c_str());
+ if (subsystemFile->getRootDataObject() == 0)
+ {
+ LOGERROR_1(0, "ModelLoader::loadSubsystemFile: Unable to load file: %s", filename.c_str());
+ }
+ else
+ {
+ //Utils::printDO(subsystemFile->getRootDataObject());
+ mapSubsystem(subsystemFile->getRootDataObject());
+ }
+ } catch (SDORuntimeException ex)
+ {
+ LOGERROR_1(0, "ModelLoader::loadSubsytemFile: Exception caught: %s", ex.getMessageText());
+ }
+
+ LOGEXIT(1, "ModelLoader::loadSubsystemFile");
+ }
+
+ // ===============
+ // mapSubsystem:
+ // ===============
+ void ModelLoader::mapSubsystem(DataObjectPtr root)
+ {
+ LOGENTRY(1, "ModelLoader::mapSubsystem");
+
+ LOGINFO_1(2, "ModelLoader::mapSubsystem: Loaded subsystem: %s", root->getCString("name"));
+
+ Subsystem* subsystem;
+ subsystem = system->addSubsystem(root->getCString("name"));
+
+ DataObjectList& Modules = root->getList("moduleComponent");
+ LOGINFO_1(2, "ModelLoader::mapSubsystem: number of module components: %d", Modules.size());
+
+ // Iterate over module components
+ for (int i=0; i<Modules.size(); i++)
+ {
+ // Add each module component to the subsystem
+ Module* Module;
+ Module = subsystem->addModuleComponent(Modules[i]->getCString("name"), Modules[i]->getCString("module"));
+ }
+
+
+ /// @todo Add external services and entry points
+
+
+ LOGEXIT(1, "ModelLoader::mapSubsystem");
+ }
+
+
+ // =====================================================================
+ // loadModules:
+ // Load all the modules from any directory below the configuration root.
+ // Translate the module information to the runtime information
+ // =====================================================================
+ void ModelLoader::loadModules(const char* configurationRoot)
+ {
+ // Get all the sca.module files in the module
+ LOGENTRY(1, "ModelLoader::loadModules");
+ Files files(configurationRoot, "sca.module", true);
+ for (unsigned int i=0; i < files.size(); i++)
+ {
+ loadModuleFile(files[i]);
+ }
+ LOGEXIT(1, "ModelLoader::loadModules");
+ }
+
+
+ // ====================================================================
+ // loadModuleFile:
+ // This method is called for each sca.module file found in the module
+ // folder structure
+ // The location of this module file will indicate the root of a module
+ // ====================================================================
+ void ModelLoader::loadModuleFile(const File& file)
+ {
+ LOGENTRY(1, "ModelLoader::loadModuleFile");
+ LOGINFO_1(2, "module filename: %s", file.getFileName().c_str());
+
+ try
+ {
+ string filename = file.getDirectory() + "/" + file.getFileName();
+
+ XMLDocumentPtr moduleFile = getXMLHelper()->loadFile(filename.c_str());
+ if (moduleFile->getRootDataObject() == 0)
+ {
+ LOGERROR_1(0, "ModelLoader::loadModuleFile: Unable to load file: %s", filename.c_str());
+ }
+ else
+ {
+ string moduleName = moduleFile->getRootDataObject()->getCString("name");
+ mapModule(moduleName, moduleFile->getRootDataObject(), file.getDirectory());
+
+ // --------------------------------------------------------------
+ // Load any module Fragments in the same folder as the sca.module
+ // --------------------------------------------------------------
+ Files files(file.getDirectory(), "*.fragment", false);
+ for (unsigned int i=0; i < files.size(); i++)
+ {
+ filename = file.getDirectory() + "/" + files[i].getFileName();
+ moduleFile = getXMLHelper()->loadFile(filename.c_str());
+ if (moduleFile->getRootDataObject() == 0)
+ {
+ LOGERROR_1(0, "ModelLoader::loadModuleFile: Unable to load file: %s", filename.c_str());
+ }
+ else
+ {
+ mapModule(moduleName, moduleFile->getRootDataObject(), file.getDirectory());
+ }
+ }
+
+ // Load the xsd types and wsdl files in the module
+ loadModuleConfig(file.getDirectory(), moduleName);
+ }
+
+ } catch (SDORuntimeException ex)
+ {
+ LOGERROR_1(0, "ModelLoader::loadModuleFile: Exception caught: %s", ex.getMessageText());
+ }
+
+ LOGEXIT(1, "ModelLoader::loadModuleFile");
+ }
+
+ // ===========
+ // mapModule
+ // ===========
+ void ModelLoader::mapModule(const string& moduleName, DataObjectPtr root, string moduleRootDir)
+ {
+ LOGENTRY(1, "ModelLoader::mapModule");
+
+ LOGINFO_2(2, "ModelLoader::mapModule: Loading module: %s, root Dir: %s", moduleName.c_str(), moduleRootDir.c_str());
+
+ // Find the ModuleComponent(s) that refer to this module. If a ModuleComponent does not refer to this
+ // module then ignore it
+ MODULE_LIST moduleList = system->findModules(moduleName);
+ MODULE_LIST::iterator moduleIter;
+
+ for (moduleIter = moduleList.begin();
+ moduleIter != moduleList.end();
+ moduleIter++ )
+ {
+ LOGINFO_1(2, "ModelLoader::mapModule: Loading module details for module component: %s", (*moduleIter)->getName().c_str());
+
+ string message; // for exceptions
+ // Set module root
+ (*moduleIter)->setRoot(moduleRootDir);
+
+ // ----------------------------
+ // Add components to the module
+ // ----------------------------
+ DataObjectList& componentList = root->getList("component");
+ int i;
+ for (i=0; i < componentList.size(); i++)
+ {
+ addComponent(*moduleIter, componentList[i]);
+ }
+
+ // ------------
+ // Entry points
+ // ------------
+ DataObjectList& entryPointList = root->getList("entryPoint");
+ for (i=0; i < entryPointList.size(); i++)
+ {
+ addEntryPoint(*moduleIter, entryPointList[i]);
+ }
+
+
+ // -----------------
+ // External services
+ // -----------------
+ DataObjectList& externalServiceList = root->getList("externalService");
+ for (i=0; i < externalServiceList.size(); i++)
+ {
+ addExternalService(*moduleIter, externalServiceList[i]);
+ }
+
+ // -----
+ // Wires
+ // -----
+ DataObjectList& wireList = root->getList("wire");
+ for (int l=0; l < wireList.size(); l++)
+ {
+ string source = wireList[l]->getCString("sourceUri");
+ string target = wireList[l]->getCString("targetUri");
+ (*moduleIter)->addWire(source, target);
+ }
+
+ }
+
+ LOGEXIT(1, "ModelLoader::mapModule");
+ }
+
+ // =================================
+ // addComponent:
+ // =================================
+ void ModelLoader::addComponent(Module* module, DataObjectPtr componentDO)
+ {
+ Component* component = module->addComponent(componentDO->getCString("name"));
+
+ string message;
+
+ // -------------------
+ // Implementation type
+ // -------------------
+ DataObjectPtr impl = componentDO->getDataObject("implementation");
+ if (!impl)
+ {
+ message = "No implementation for component: ";
+ message = message + componentDO->getCString("name");
+ throw SystemConfigurationException(message.c_str());
+ }
+ // Determine the type
+ string componentTypeName;
+ string componentTypePath;
+ string implType = impl->getType().getName();
+ if (implType == "CPPImplementation")
+ {
+ string dll = impl->getCString("dll");
+ string header = impl->getCString("header");
+ string className = impl->getCString("class");
+ CPPImplementation* cppImpl = new CPPImplementation(dll, header, className);
+ componentTypePath = cppImpl->getHeaderPath();
+ componentTypeName = cppImpl->getHeaderStub();
+ component->setImplementation(cppImpl);
+
+ }
+ else if (implType == "JavaImplementation")
+ {
+ }
+
+ // -----------------------
+ // Load the .componentType
+ // -----------------------
+ string typeFileName = module->getRoot() + "/" + componentTypePath + componentTypeName + ".componentType";
+ try
+ {
+ XMLDocumentPtr componentTypeFile = getXMLHelper()->loadFile(typeFileName.c_str());
+ if (componentTypeFile->getRootDataObject() == 0)
+ {
+ LOGERROR_1(0, "ModelLoader::mapModule: Unable to load file: %s", typeFileName.c_str());
+ }
+ else
+ {
+ //Utils::printDO(componentTypeFile->getRootDataObject());
+ //commonj::sdo::SDOUtils::printDataObject(componentTypeFile->getRootDataObject());
+ addServices(component, componentTypeFile->getRootDataObject());
+ addReferences(component, componentTypeFile->getRootDataObject());
+ addProperties(component, componentTypeFile->getRootDataObject());
+ }
+ } catch (SDORuntimeException& ex)
+ {
+ LOGERROR_1(0, "ModelLoader::mapModule: Exception caught: %s", ex.getMessageText());
+ throw SystemConfigurationException(ex.getMessageText());
+ }
+
+ // ----------
+ // Properties
+ // ----------
+ DataObjectPtr props = componentDO->getDataObject("properties");
+ component->addProperties(props);
+
+ // ----------
+ // References
+ // ----------
+ DataObjectPtr refs = componentDO->getDataObject("references");
+ if (refs)
+ {
+ PropertyList pl = refs->getInstanceProperties();
+ for (int refI=0; refI < pl.size(); refI++)
+ {
+ // ----------------------------------------------------------
+ // Add the reference to the module wires to be resolved later
+ // ----------------------------------------------------------
+ string refName = pl[refI].getName();
+ if (!component->findReference(pl[refI].getName()))
+ {
+ // Configuration error: reference is not defined
+ message = "Undefined reference: " + refName;
+ throw SystemConfigurationException(message.c_str());
+ }
+
+ string src = component->getName() + "/" + refName;
+ DataObjectList& reflist = refs->getList(pl[refI]);
+ for (int refslistI=0; refslistI<reflist.size(); refslistI++)
+ {
+ string targ = reflist.getCString(refslistI);
+ module->addWire(src, targ);
+ }
+ }
+ }
+ }
+
+
+ // =====================================================================
+ // addServices: add the services from the componentType to the component
+ // =====================================================================
+ void ModelLoader::addServices(Component* component, DataObjectPtr componentType)
+ {
+ DataObjectList& services = componentType->getList("service");
+ for (int i=0; i<services.size(); i++)
+ {
+ Service* service = component->addService(services[i]->getCString("name"));
+ service->setInterface(getInterface(services[i]));
+ }
+ }
+
+ // ===================================================
+ // addReferences: add the references to the component
+ // ===================================================
+ void ModelLoader::addReferences(Component* component, DataObjectPtr componentType)
+ {
+ DataObjectList& refs = componentType->getList("reference");
+ for (int i=0; i<refs.size(); i++)
+ {
+ ServiceReference* serviceRef = component->addReference(refs[i]->getCString("name"));
+ string multiplicity = "1..1";
+ if (refs[i]->isSet("multiplicity"))
+ {
+ multiplicity = refs[i]->getCString("multiplicity");
+ }
+ serviceRef->setMultiplicity(multiplicity);
+ serviceRef->setInterface(getInterface(refs[i]));
+ }
+ }
+
+
+ // ==============
+ // getInterface
+ // ==============
+ Interface* ModelLoader::getInterface(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());
+ }
+
+ // Determine the type
+ string componentTypeName;
+ string ifType = iface->getType().getName();
+ if (ifType == "CPPInterface")
+ {
+ string header = iface->getCString("header");
+ string className = iface->getCString("class");
+ string scope = iface->getCString("scope");
+ bool remotable = iface->getBoolean("remotable");
+
+ return new CPPInterface(header, className, scope, remotable);
+ }
+ else
+ {
+ // Error?
+ return 0;
+ }
+ }
+
+ // ==============================================
+ // addProperties: add Properties to the component
+ // ==============================================
+ void ModelLoader::addProperties(Component* component, DataObjectPtr componentType)
+ {
+ DataObjectList& props = componentType->getList("property");
+ for (int i=0; i<props.size(); i++)
+ {
+ string name = props[i]->getCString("name");
+ string type = props[i]->getCString("type");
+ bool many=false;
+ if (props[i]->isSet("many"))
+ {
+ many = props[i]->getBoolean("many");
+ }
+
+ bool required=false;
+ if (props[i]->isSet("required"))
+ {
+ many = props[i]->getBoolean("required");
+ }
+
+ const char* defaultValue = 0;
+ if (props[i]->isSet("default"))
+ {
+ defaultValue = props[i]->getCString("default");
+ }
+
+ component->addProperty(name, type, many, required, defaultValue);
+ }
+ }
+
+ // ===============================================
+ // addEntryPoint: add an EntryPoint to the module
+ // ===============================================
+ void ModelLoader::addEntryPoint(Module* module, DataObjectPtr entryPointDO)
+ {
+ //Utils::printDO(entryPointDO);
+ EntryPoint* entryPoint = module->addEntryPoint(entryPointDO->getCString("name"));
+
+ string multiplicity = "1..1";
+ if (entryPointDO->isSet("multiplicity"))
+ {
+ multiplicity = entryPointDO->getCString("multiplicity");
+ }
+
+ entryPoint->setMultiplicity(multiplicity);
+ entryPoint->setInterface(getInterface(entryPointDO));
+
+ DataObjectList& refs = entryPointDO->getList("reference");
+ for (int i=0; i<refs.size(); i++)
+ {
+ // ----------------------------------------------------------
+ // Add the reference to the module wires to be resolved later
+ // ----------------------------------------------------------
+ string targ = refs.getCString(i);
+ module->addWire(entryPoint->getName(), targ);
+ }
+ }
+
+
+ // =========================================================
+ // addExternalService: add an ExternalService to the module
+ // =========================================================
+ void ModelLoader::addExternalService(Module* module, DataObjectPtr externalServiceDO)
+ {
+ string message;
+
+ ExternalService* externalService = module->addExternalService(externalServiceDO->getCString("name"));
+ // Add the interface
+ externalService->setInterface(getInterface(externalServiceDO));
+
+ // Get binding, it will be the first and only binding
+ DataObjectPtr binding = externalServiceDO->getList("binding")[0];
+ if (!binding)
+ {
+ message = "No binding for externalService: ";
+ message = message + externalServiceDO->getCString("name");
+ throw SystemConfigurationException(message.c_str());
+ }
+
+ //Utils::printDO(binding);
+
+ string uri = binding->getCString("uri");
+
+ // Determine the binding type
+ string bindingType = binding->getType().getName();
+ if (bindingType == "WebServiceBinding")
+ {
+ string port = binding->getCString("port");
+
+ WSBinding* wsBinding = new WSBinding(uri,port);
+
+ externalService->setBinding(wsBinding);
+
+ }
+ else if (bindingType == "SCABinding")
+ {
+ }
+ }
+
+
+
+ ///
+ /// Use the Tuscany-model.config file in the module root directory to
+ /// determine which xsds and wsdls to load into a dataFactory.
+ ///
+ void ModelLoader::loadModuleConfig(const string &moduleRootDir, const string &moduleName)
+ {
+ LOGENTRY(1, "ModelLoader::loadModuleConfig");
+
+ // Load the "Tuscany-model.config" file, if it exists
+ Files files(moduleRootDir, "Tuscany-model.config", false);
+ for (unsigned int i=0; i < files.size(); i++)
+ {
+ string filename = moduleRootDir + "/" + files[i].getFileName();
+ XMLDocumentPtr moduleConfigFile = getXMLHelper()->loadFile(filename.c_str());
+ if (moduleConfigFile->getRootDataObject() == 0)
+ {
+ LOGERROR_1(0, "ModelLoader::loadModuleConfig: Unable to load file: %s", filename.c_str());
+ }
+ else
+ {
+ LOGINFO_2(2, "ModelLoader::loadModuleConfig: Loading module config for: %s, root Dir: %s", moduleName.c_str(), moduleRootDir.c_str());
+
+ DataObjectList& xsds = moduleConfigFile->getRootDataObject()->getList("xsd/file");
+ for (int i=0; i<xsds.size(); i++)
+ {
+
+ // Load a xsd file -> set the types in the moduleComponents data factory file
+ string xsdName = moduleRootDir + "/" +xsds[i]->getCString("name");
+ loadTypes(xsdName.c_str(), moduleName);
+
+
+ }
+
+ DataObjectList& wsdls = moduleConfigFile->getRootDataObject()->getList("wsdl/file");
+ for (int j=0; j<wsdls.size(); j++)
+ {
+ string wsdlName = moduleRootDir + "/" +wsdls[j]->getCString("name");
+ // Load a wsdl file -> get the types, then the contents of the wsdl
+ loadTypes(wsdlName.c_str(), moduleName);
+
+ // Load the contents of the wsdl files
+ loadWsdl(wsdlName.c_str(), moduleName);
+
+ }
+
+ }
+ }
+
+
+ LOGEXIT(1, "ModelLoader::loadModuleConfig");
+ }
+
+
+ ///
+ /// Use the types from an xsd or wsdl file
+ ///
+ void ModelLoader::loadTypes(const char *fileName, const string &moduleName)
+ {
+
+
+ // Load a xsd file -> set the types in the moduleComponents data factory file
+
+ MODULE_LIST moduleList = system->findModules(moduleName);
+ MODULE_LIST::iterator moduleIter;
+
+ for (moduleIter = moduleList.begin();
+ moduleIter != moduleList.end();
+ moduleIter++ )
+ {
+ try {
+ (*moduleIter)->getXSDHelper()->defineFile(fileName);
+ //Utils::printTypes((*moduleIter)->getXSDHelper()->getDataFactory());
+
+ } catch (SDOTypeNotFoundException ex)
+ {
+ LOGERROR_1(0, "ModuleLoader: Exception caught: %s", ex.getMessageText());
+ throw ex;
+ }
+ }
+
+ }
+
+ ///
+ /// Load the web services definition from a wsdl
+ ///
+ void ModelLoader::loadWsdl(const char *fileName, const string &moduleName)
+ {
+
+ try {
+ // Load the wsdl file
+ XMLDocumentPtr doc = getXMLHelper()->loadFile(fileName);
+
+
+ if (doc->getRootDataObject()!=0)
+ {
+ MODULE_LIST moduleList = system->findModules(moduleName);
+ MODULE_LIST::iterator moduleIter;
+
+ for (moduleIter = moduleList.begin();
+ moduleIter != moduleList.end();
+ moduleIter++ )
+ {
+ // Add the root object to the module
+ (*moduleIter)->addWsdl(doc->getRootDataObject());
+
+ }
+
+ }
+ else
+ {
+ LOGERROR_1(0, "ModuleLoader: Unable to load %s", fileName);
+ }
+
+ } catch (SDOTypeNotFoundException ex)
+ {
+ LOGERROR_1(0, "ModuleLoader: Exception caught: %s", ex.getMessageText());
+ throw ex;
+ }
+
+
+
+ }
+
+ //////////////////////////////////////////////////////////////////////////////
+ // 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();
+
+ // Now add to it some xsd files
+ try {
+ 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());
+
+ // Load types derived from WSDL schema
+ loadWSDLTypes(myXSDHelper->getDataFactory());
+
+ //Utils::printTypes(myXSDHelper->getDataFactory());
+
+ } catch (SDOTypeNotFoundException ex)
+ {
+ LOGERROR_1(0, "ModuleLoader: Exception caught: %s", ex.getMessageText());
+ throw ex;
+ }
+ }
+
+
+ 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::loadWSDLTypes(DataFactoryPtr dataFactory)
+ {
+ 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);
+ 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);
+ }
+
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ModelLoader.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ModelLoader.h
new file mode 100644
index 0000000000..6d6e19a510
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ModelLoader.h
@@ -0,0 +1,104 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_modelloader_h
+#define tuscany_sca_model_modelloader_h
+
+#include "osoa/sca/export.h"
+#include "commonj/sdo/SDO.h"
+using commonj::sdo::DataObjectPtr;
+using commonj::sdo::DataFactoryPtr;
+
+#include "tuscany/sca/model/System.h"
+#include "tuscany/sca/model/Subsystem.h"
+
+#include "tuscany/sca/util/File.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Provides methods to load the runtime model from the SCDL file.
+ */
+ class ModelLoader {
+ public:
+ /**
+ * Constructor.
+ * @param system The SCA system to load.
+ */
+ ModelLoader(System* system);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ModelLoader();
+
+ /**
+ * Load the model from the configuration information.
+ * @param configurationRoot The location of the deployed SCA
+ * modules and subsystems.
+ */
+ void load(const char *configurationRoot);
+
+ private:
+ System* system;
+ void loadModule(const char *moduleRoot);
+
+
+ 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);
+
+ void loadSubsystems(const char *configurationRoot);
+ void loadSubsystemFile(const File& file);
+ void mapSubsystem(commonj::sdo::DataObjectPtr rootDO);
+
+ void loadModules(const char *configurationRoot);
+ void loadModuleFile(const File& file);
+ void mapModule(const string& moduleName, commonj::sdo::DataObjectPtr rootDO, std::string moduleRootDir);
+
+ void addComponent(Module* module, DataObjectPtr componentDO);
+ void addEntryPoint(Module* module, DataObjectPtr entryPointDO);
+ void addExternalService(Module* module, DataObjectPtr externalServiceDO);
+
+ void addServices(Component* component, DataObjectPtr componentType);
+ void addReferences(Component* component, DataObjectPtr componentType);
+ void addProperties(Component* component, DataObjectPtr componentType);
+
+
+ void loadModuleConfig(const string &moduleRootDir, const string &moduleName);
+ void loadTypes(const char *fileName, const string &moduleName);
+ void loadWsdl(const char *fileName, const string &moduleName);
+
+ void loadWSDLTypes(DataFactoryPtr dataFactory);
+
+ Interface* getInterface(DataObjectPtr obj);
+
+
+ };
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_modelloader_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Module.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Module.cpp
new file mode 100644
index 0000000000..43702144a2
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Module.cpp
@@ -0,0 +1,235 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/Module.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ Module::Module(const std::string& moduleName)
+ : name(moduleName)
+ {
+ LOGENTRY(1, "Module::constructor");
+ LOGEXIT(1, "Module::constructor");
+ }
+
+ Module::~Module()
+ {
+ }
+
+ void Module::setRoot(const std::string& rootDirectory)
+ {
+ moduleRoot = rootDirectory;
+ }
+
+
+ ///
+ /// Add a new component to the module component
+ ///
+ Component* Module::addComponent(const std::string& name)
+ {
+ LOGENTRY(1, "Module::addComponent");
+ Component* newComponent = new Component(name, this);
+ components[name] = newComponent;
+ LOGEXIT(1, "Module::addComponent");
+ return newComponent;
+ }
+
+ Component* Module::findComponent(const std::string& name)
+ {
+ LOGENTRY(1, "Module::findComponent");
+ Component* foundComponent = components[name];
+ LOGEXIT(1, "Module::findComponent");
+ return foundComponent;
+ }
+
+ Service* Module::findComponentService(const std::string& name)
+ {
+ LOGENTRY(1, "Module::findComponentService");
+
+ Service* service = 0;
+
+ string componentName;
+ string serviceName;
+ Utils::tokeniseUri(name, componentName, serviceName);
+
+ // Locate the component
+ Component* foundComponent = components[name];
+ if (foundComponent)
+ {
+ // Locate the service
+ service = foundComponent->findService(serviceName);
+ }
+ LOGEXIT(1, "Module::findComponentService");
+ return service;
+ }
+
+ ExternalService* Module::findExternalService(const std::string& name)
+ {
+ LOGENTRY(1, "Module::findExternalService");
+ ExternalService* foundService = externalServices[name];
+ LOGEXIT(1, "Module::findExternalService");
+ return foundService;
+ }
+
+
+ EntryPoint* Module::addEntryPoint(const std::string& name)
+ {
+ LOGENTRY(1, "Module::addEntryPoint");
+ EntryPoint* ep = new EntryPoint(name);
+ entryPoints[name] = ep;
+ LOGEXIT(1, "Module::addEntryPoint");
+ return findEntryPoint(name);
+ }
+
+ EntryPoint* Module::findEntryPoint(const std::string& name)
+ {
+ return entryPoints[name];
+ }
+
+
+ ExternalService* Module::addExternalService(const std::string& name)
+ {
+ LOGENTRY(1, "Module::addExternalService");
+ ExternalService* es = new ExternalService(name, this);
+ externalServices[name] = es;
+ LOGEXIT(1, "Module::addExternalService");
+ return es;
+ }
+
+ void Module::addWire(const std::string& source, const std::string& target)
+ {
+ LOGENTRY(1, "Module::addWire");
+ wires.push_back(Wire(source, target));
+ LOGEXIT(1, "Module::addWire");
+ }
+
+
+ void Module::resolveWires()
+ {
+ LOGENTRY(1, "Module::resolveWires");
+ for (WIRES::iterator iter = wires.begin();
+ iter != wires.end();
+ iter++)
+ {
+ // -----------------
+ // Locate the target
+ // -----------------
+ WireTarget* target = findComponentService(iter->getTarget());
+ if (!target)
+ {
+ target = findExternalService(iter->getTarget());
+ }
+ if (!target)
+ {
+ LOGERROR_1(0, "Module::resolveWires: Wire target %s not found", iter->getTarget().c_str());
+ }
+ else
+ {
+ EntryPoint* entrypoint = findEntryPoint(iter->getSourceComponent());
+ if (entrypoint)
+ {
+ entrypoint->addTarget(target);
+ }
+ else
+ {
+ Component* component = findComponent(iter->getSourceComponent());
+ if (component)
+ {
+ ServiceReference* serviceReference = component->findReference(iter->getSourceReference());
+ if (serviceReference)
+ {
+ serviceReference->addTarget(target);
+ }
+ else
+ {
+ LOGERROR_1(0, "Module::resolveWires: Wire source reference %s not found", iter->getSourceReference().c_str());
+ }
+ }
+ else
+ {
+ LOGERROR_1(0, "Module::resolveWires: Wire source %s not found", iter->getSourceComponent().c_str());
+ }
+ }
+ }
+ }
+
+ LOGEXIT(1, "Module::resolveWires");
+ }
+
+
+
+ void Module::addWsdl(commonj::sdo::DataObjectPtr wsdlModel)
+ {
+ LOGENTRY(1, "Module::addWsdl");
+ Wsdl* wsdl = new Wsdl(wsdlModel);
+ wsdls[wsdl->getNamespace()] = wsdl;
+ LOGEXIT(1, "Module::addWsdl");
+
+ }
+
+ Wsdl* Module::findWsdl(const std::string& wsdlNamespace )
+ {
+ return wsdls[wsdlNamespace];
+
+ }
+
+
+ // Get an XSDHelper - one will be created for each module
+ commonj::sdo::XSDHelperPtr Module::getXSDHelper()
+ {
+ if (xsdHelper == 0)
+ {
+ xsdHelper = commonj::sdo::HelperProvider::getXSDHelper();
+ }
+
+ return xsdHelper;
+ }
+
+ // Get an XMLHelper - one will be created for each module
+ commonj::sdo::XMLHelperPtr Module::getXMLHelper()
+ {
+ if (xmlHelper == 0)
+ {
+ xmlHelper = commonj::sdo::HelperProvider::getXMLHelper(getXSDHelper()->getDataFactory());
+ }
+
+ return xmlHelper;
+ }
+
+
+ // Get a data factory - the one in the xsd/xml helper
+ commonj::sdo::DataFactoryPtr Module::getDataFactory()
+ {
+ return getXSDHelper()->getDataFactory();
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Module.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Module.h
new file mode 100644
index 0000000000..f73f1d36bc
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Module.h
@@ -0,0 +1,235 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_module_h
+#define tuscany_sca_model_module_h
+
+#include <string>
+using std::string;
+
+#include <map>
+using std::map;
+#include <vector>
+using std::vector;
+
+#include "commonj/sdo/SDO.h"
+
+
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ExternalService.h"
+#include "tuscany/sca/model/EntryPoint.h"
+#include "tuscany/sca/model/Wire.h"
+#include "tuscany/sca/model/Wsdl.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+ /**
+ * Information about a module.
+ */
+ class Module
+ {
+ public:
+ /**
+ * Constructor.
+ * @param name the name of the module.
+ */
+ Module(const std::string& name);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Module();
+
+ /**
+ * Set the root directory of the module information.
+ * @param rootDirectory The root of the module in the file system.
+ */
+ void setRoot(const std::string& rootDirectory);
+
+ /**
+ * Get the root directory of the module.
+ * @return The root of the module in the file system.
+ */
+ const std::string& getRoot() {return moduleRoot;}
+
+ /**
+ * Return the name of the module.
+ * @return Name of the module.
+ */
+ const std::string& getName() {return name;}
+
+ /**
+ * Add a new component to the module.
+ * @param componentName The name of the new component.
+ * @return The Component added to the module.
+ */
+ Component* addComponent(const std::string& componentName);
+
+ /**
+ * Add a new entry point to the module.
+ * @param name The name of the new entry point.
+ * @return The entry point added to the module.
+ */
+ EntryPoint* addEntryPoint(const std::string& name);
+
+ /**
+ * Find an entry point by name.
+ * @param name The name of the entry point to be found.
+ * @return The entry point that was found, or 0 if not found.
+ */
+ EntryPoint* findEntryPoint(const std::string& name);
+
+ /**
+ * Add a new external service to the module.
+ * @param name The name of the new external service.
+ * @return The external service added to the module.
+ */
+ ExternalService* addExternalService(const std::string& name);
+
+ /**
+ * 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.
+ */
+ void addWire(const std::string& source, const std::string& target);
+
+ /**
+ * Find a component by name.
+ * @param componentName The name of the component to be found.
+ * @return The component that was found, or 0 if not found.
+ */
+ Component* findComponent(const std::string& componentName);
+
+ /**
+ * Find a component and service by name.
+ * @param componentServiceName A string of the form
+ * "componentName"/"serviceName" where the service name is optional
+ * if there is only one service on the component.
+ * @return The Service that was found, or 0 if not found.
+ */
+ Service* findComponentService(const std::string& componentServiceName);
+
+ /**
+ * Find an external service by name.
+ * @param serviceName The name of the external service to be found.
+ * @return The external service that was found, or 0 if not found.
+ */
+ ExternalService* findExternalService(const std::string& serviceName);
+
+ /**
+ * Add a WSDL definition to the module.
+ * @param wsdlModel A data object holding all the information about
+ * the WSDL definition from a WSDL file.
+ */
+ void addWsdl(commonj::sdo::DataObjectPtr wsdlModel);
+
+ /**
+ * Find a WSDL definition by target namespace.
+ * @param wsdlNamespace The namespace of the WSDL definitions to find.
+ */
+ Wsdl* findWsdl(const std::string& wsdlNamespace);
+
+ /**
+ * Return a cached SDO XSDHelper.
+ */
+ commonj::sdo::XSDHelperPtr getXSDHelper(void);
+
+ /**
+ * Return a cached SDO XMLHelper.
+ */
+ commonj::sdo::XMLHelperPtr getXMLHelper(void);
+
+ /**
+ * Return a data factory which has all the types defined in XSDs and
+ * WSDL files configured for this module.
+ * @return The data factory for this module.
+ */
+ commonj::sdo::DataFactoryPtr getDataFactory(void);
+
+ /**
+ * Work through the list of wires and connect the source and target uris.
+ */
+ void resolveWires();
+
+ private:
+ /**
+ * Name of the module.
+ */
+ string name;
+
+ /**
+ * Directory of the root of the module.
+ */
+ string moduleRoot;
+
+ /**
+ * Cached XSDHelper.
+ */
+ commonj::sdo::XSDHelperPtr xsdHelper;
+
+ /**
+ * Cached XMLHelper.
+ */
+ commonj::sdo::XMLHelperPtr xmlHelper;
+
+ typedef map<std::string, Component*> COMPONENT_MAP;
+ /**
+ * Map (by name) of all the components in this module.
+ */
+ COMPONENT_MAP components;
+
+ typedef map<std::string, ExternalService*> EXTERNALSERVICE_MAP;
+ /**
+ * Map (by name) of all the external services in this module.
+ */
+ EXTERNALSERVICE_MAP externalServices;
+
+ typedef map<std::string, EntryPoint*> ENTRYPOINT_MAP;
+ /**
+ * Map (by name) of all the entry points in this module.
+ */
+ ENTRYPOINT_MAP entryPoints;
+
+ typedef vector<Wire> WIRES;
+ /**
+ * Vector of all the wires in this module.
+ */
+ WIRES wires;
+
+ typedef map<std::string, Wsdl*> WSDL_MAP;
+ /**
+ * Map by namespace of all the wsdl definitions in this module.
+ */
+ WSDL_MAP wsdls;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // SCA_ModuleComponent_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Service.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Service.cpp
new file mode 100644
index 0000000000..42ccecbc99
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Service.cpp
@@ -0,0 +1,47 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/Service.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+
+ // Constructor
+ Service::Service(const std::string& serviceName, Component* comp)
+ : WireTarget(serviceName),
+ component(comp)
+ {
+ LOGENTRY(1, "Service::constructor (Component)");
+ LOGINFO_1(3, "Service::constructor: Service name: %s", serviceName.c_str());
+ LOGEXIT(1, "Service::constructor");
+ }
+
+ Service::~Service()
+ {
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Service.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Service.h
new file mode 100644
index 0000000000..6c37dabb3e
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Service.h
@@ -0,0 +1,81 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_service_h
+#define tuscany_sca_model_service_h
+
+#include <string>
+using std::string;
+
+#include "tuscany/sca/model/WireTarget.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ class Component;
+
+ /**
+ * Information about a service defined on a component.
+ */
+ class Service : public WireTarget
+ {
+ public:
+ /**
+ * Destructor.
+ */
+ virtual ~Service();
+
+ /**
+ * Return the type of the wire target.
+ * @return Always returns ComponentServiceType.
+ */
+ virtual Type getServiceType() {return ComponentServiceType;}
+
+ /**
+ * Get the component on which this service is defined.
+ * @return The component on which this service is defined.
+ */
+ Component* getComponent() {return component;}
+
+
+ private:
+ friend class Component;
+ /**
+ * Constructor.
+ * @param name The name of the service.
+ * @param component The component on which this service is defined.
+ */
+ Service(const std::string& name, Component* component);
+
+ /**
+ * The component on which this service is defined.
+ */
+ Component* component;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_service_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ServiceReference.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ServiceReference.cpp
new file mode 100644
index 0000000000..cada38dec2
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ServiceReference.cpp
@@ -0,0 +1,89 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/model/ServiceReference.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+
+ // Constructor
+ ServiceReference::ServiceReference(const std::string& referenceName)
+ : name(referenceName), multiplicity(ONE_ONE)
+ {
+ }
+
+ ServiceReference::~ServiceReference()
+ {
+ }
+
+ void ServiceReference::addTarget(WireTarget* targ)
+ {
+ if (multiplicity == ONE_ONE || multiplicity == ZERO_ONE)
+ {
+ if (targets.size() > 0)
+ {
+ // throw exception
+ string message = "Duplicate wire for reference: " + name;
+ throw SystemConfigurationException(message.c_str());
+ }
+ }
+
+ targets.push_back(targ);
+ }
+
+ void ServiceReference::setMultiplicity(const std::string& multip)
+ {
+ if (multip == "0..1")
+ {
+ multiplicity = ZERO_ONE;
+ }
+ else if (multip == "1..1")
+ {
+ multiplicity = ONE_ONE;
+ }
+ else if (multip == "0..n")
+ {
+ multiplicity = ZERO_MANY;
+ }
+ else if (multip == "1..n")
+ {
+ multiplicity = ONE_MANY;
+ }
+ else
+ {
+ string msg = "Invalid multiplicity specified, " + multip + ", for reference: " +name;
+ throw SystemConfigurationException(msg.c_str());
+ }
+ }
+
+ void ServiceReference::setInterface(Interface* interf)
+ {
+ iface = interf;
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ServiceReference.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ServiceReference.h
new file mode 100644
index 0000000000..062d7a4c19
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/ServiceReference.h
@@ -0,0 +1,136 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_servicereference_h
+#define tuscany_sca_model_servicereference_h
+
+#include <string>
+using std::string;
+#include <vector>
+using std::vector;
+
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/model/WireTarget.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Information about a reference on a serivce.
+ */
+ class ServiceReference
+ {
+ public:
+ /**
+ * Constructor.
+ * @param name The name of the reference.
+ */
+ ServiceReference(const std::string& name)
+
+ /**
+ * Destructor.
+ */;
+ virtual ~ServiceReference();
+
+ /**
+ * Get the name of the service.
+ * @return The name of the service.
+ */
+ const std::string& getName() {return name;}
+
+ /**
+ * Multiplicity (how many wires can be attached to this
+ * reference as their source)
+ */
+ enum Multiplicity
+ {
+ ZERO_ONE,
+ ONE_ONE,
+ ZERO_MANY,
+ ONE_MANY
+ };
+
+ /**
+ * Set the multiplicity of this reference.
+ * @param multiplicity One of "0..1", "1..1", "0..n", "1..n"
+ */
+ void setMultiplicity(const std::string& multiplicity);
+
+ /**
+ * Get the multiplicity of this reference.
+ * @return The multiplicity.
+ */
+ Multiplicity getMultiplicity() {return multiplicity;}
+
+ /**
+ * Set the interface required by this reference.
+ * @param iface The interface.
+ */
+ void setInterface(Interface* iface);
+
+ /**
+ * Get the interface.
+ * @return The interface.
+ */
+ Interface* getInterface() {return iface;}
+
+ /**
+ * Add a target for a reference. There may be more than
+ * one if the multiplicity is 0..n or 1..n.
+ * @param target The target for a wire.
+ */
+ void addTarget(WireTarget* target);
+ typedef vector<WireTarget*> TARGETS;
+
+ /**
+ * Get a vector of all the targets from this reference.
+ * @return The targets of this reference.
+ */
+ const TARGETS& getTargets() {return targets;}
+ private:
+ /**
+ * Name of this reference.
+ */
+ string name;
+
+ /**
+ * The interface defining this reference.
+ */
+ Interface* iface;
+
+ /**
+ * The multiplicity of this reference.
+ */
+ Multiplicity multiplicity;
+
+ /**
+ * Vector of all the targets wired from this reference.
+ */
+ TARGETS targets;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_servicereference_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Subsystem.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Subsystem.cpp
new file mode 100644
index 0000000000..08ef0dde49
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Subsystem.cpp
@@ -0,0 +1,122 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/Subsystem.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ // Constructor
+ Subsystem::Subsystem(const std::string& subsystemName) : name(subsystemName)
+ {
+ LOGENTRY(1, "Subsystem::constructor");
+
+
+ LOGEXIT(1, "Subsystem::constructor");
+ }
+
+ Subsystem::~Subsystem()
+ {
+ }
+
+ ///
+ /// Add a new module component
+ ///
+ Module* Subsystem::addModuleComponent(const std::string& name, const std::string& moduleName)
+ {
+ LOGENTRY(1, "Subsystem::addModuleComponent");
+
+ Module* newModule = new Module(moduleName);
+
+ // TODO: Should check for duplicates and throw exception
+ moduleComponents[name] = newModule;
+
+ LOGEXIT(1, "Subsystem::addModuleComponent");
+
+ return newModule;
+ }
+
+ Module* Subsystem::findModule(const std::string& moduleName)
+ {
+ for (MODULECOMPONENT_MAP::iterator moduleComponentIter = moduleComponents.begin();
+ moduleComponentIter != moduleComponents.end();
+ moduleComponentIter++)
+ {
+ if (moduleName == moduleComponentIter->second->getName())
+ {
+ return (Module*)moduleComponentIter->second;
+ }
+ }
+ return 0;
+ }
+
+ Module* Subsystem::findModuleByComponentName(const std::string& moduleComponentName)
+ {
+ return moduleComponents[moduleComponentName];
+ }
+
+ Module* Subsystem::getDefaultModule()
+ {
+ if (moduleComponents.size() == 1)
+ {
+ MODULECOMPONENT_MAP::iterator moduleComponentIter = moduleComponents.begin();
+ return moduleComponentIter->second;
+ }
+ return 0;
+ }
+
+ ///
+ /// Add a new entrypoint
+ ///
+ EntryPoint* Subsystem::addEntryPoint(const std::string& name)
+ {
+ LOGENTRY(1, "Subsystem::addEntryPoint");
+
+ EntryPoint* newEntryPoint = new EntryPoint(name);
+ entryPoints[name] = newEntryPoint;
+ LOGEXIT(1, "Subsystem::addEntryPoint");
+ return findEntryPoint(name);
+ }
+
+ EntryPoint* Subsystem::findEntryPoint(const std::string& name)
+ {
+ return entryPoints[name];
+ }
+
+ void Subsystem::resolveWires()
+ {
+ for (MODULECOMPONENT_MAP::iterator moduleComponentIter = moduleComponents.begin();
+ moduleComponentIter != moduleComponents.end();
+ moduleComponentIter++)
+ {
+ moduleComponentIter->second->resolveWires();
+ }
+
+ // Resolve EntryPoint wires
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Subsystem.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Subsystem.h
new file mode 100644
index 0000000000..b3c59898eb
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Subsystem.h
@@ -0,0 +1,131 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_h
+#define tuscany_sca_model_h
+
+#include <string>
+using std::string;
+#include <map>
+using std::map;
+
+#include "tuscany/sca/model/Module.h"
+#include "tuscany/sca/model/EntryPoint.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Information about a subsystem.
+ */
+ class Subsystem {
+ public:
+ /**
+ * Constructor.
+ * @param name The name of the subsystem.
+ */
+ Subsystem(const std::string& name);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Subsystem();
+
+ /**
+ * Add a new module component to the subsystem.
+ * @param name The name of the module component.
+ * @param moduleName The name of the module.
+ * @return The new Module added to the subsystem.
+ */
+ Module* addModuleComponent(const std::string& name, const std::string& moduleName);
+
+ /**
+ * Find a module by module name.
+ * @param moduleName The name of the module to be found.
+ * @return The Module that was found, or 0 if not found.
+ */
+ Module* findModule(const std::string& moduleName);
+
+ /**
+ * Find a module by the module component name.
+ * @param moduleComponentName The module component name to be used to find
+ * the module.
+ * @return The Module that was found, or 0 if not found.
+ */
+ Module* findModuleByComponentName(const std::string& moduleComponentName);
+
+ /**
+ * Get the default module set for this subsystem.
+ * @return The default module.
+ */
+ Module* getDefaultModule();
+
+ /**
+ * Add an new entry point to the subsystem.
+ * @param name The name of the entry point.
+ * @return The new EntryPoint added to the subsystem.
+ */
+ EntryPoint* addEntryPoint(const std::string& name);
+
+ /**
+ * Find an entry point by name.
+ * @param name The name of the entry point to be found.
+ * @return The EntryPoint that was found, or 0 if not found.
+ */
+ EntryPoint* findEntryPoint(const std::string& name);
+
+ /**
+ * Return the name of the subsystem.
+ * @return The name.
+ */
+ const std::string& getName() {return name;}
+
+ /**
+ * Resolve all the wires configured in all the modules in this
+ * subsystem.
+ */
+ void resolveWires();
+
+ private:
+ /**
+ * The name of the subsystem.
+ */
+ std::string name;
+
+ typedef std::map<std::string, Module*> MODULECOMPONENT_MAP;
+ /**
+ * A map by module component name of modules.
+ */
+ MODULECOMPONENT_MAP moduleComponents;
+
+ typedef map<string, EntryPoint*> ENTRYPOINT_MAP;
+ /**
+ * A map of entry points defined in this subsystem.
+ */
+ ENTRYPOINT_MAP entryPoints;
+ };
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/System.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/System.cpp
new file mode 100644
index 0000000000..dfc4a21b1c
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/System.cpp
@@ -0,0 +1,118 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/System.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ // ============
+ // Constructor
+ // ============
+ System::System()
+ {
+ LOGENTRY(1, "System::constructor");
+
+
+ LOGEXIT(1, "System::constructor");
+ }
+
+ System::~System()
+ {
+ SUBSYSTEM_MAP::iterator subsystemsIter;
+ for (subsystemsIter = subsystemMap.begin();
+ subsystemsIter != subsystemMap.end();
+ subsystemsIter++ )
+ {
+ delete subsystemsIter->second;
+ }
+ }
+
+ // =================================
+ // Add a new subsystem to the system
+ // =================================
+ Subsystem* System::addSubsystem(const std::string& name)
+ {
+ LOGENTRY(1, "System::addSubsystem");
+
+ Subsystem* newSubsystem = new Subsystem(name);
+
+ subsystemMap[name] = newSubsystem;
+
+ LOGEXIT(1, "System::addSubsystem");
+
+ return newSubsystem;
+ }
+
+ // ====================================================================
+ // Get a map of all the moduleComponents that use a particular module
+ // ====================================================================
+ MODULE_LIST System::findModules(const std::string& name)
+ {
+ LOGENTRY(1, "System::findModules");
+ MODULE_LIST foundModules;
+
+ SUBSYSTEM_MAP::iterator subsystemsIter;
+ for (subsystemsIter = subsystemMap.begin();
+ subsystemsIter != subsystemMap.end(); subsystemsIter++ ) {
+ LOGINFO_1(2, "System::findModules: Found subsystem: %s", subsystemsIter->second->getName().c_str());
+ // In each subsystem, find module components with this module defined
+
+ Module* module = subsystemsIter->second->findModule(name);
+ if (module)
+ {
+ LOGINFO_1(2, "System::findModules: Found module: %s", module->getName().c_str());
+ foundModules.push_back(module);
+ }
+ }
+ LOGEXIT(1, "System::findModules");
+
+ return foundModules;
+ }
+
+
+ // ====================================================================
+ // Get a map of all the moduleComponents that use a particular module
+ // ====================================================================
+ Subsystem* System::findSubsystem(const std::string& subsystem)
+ {
+ return subsystemMap[subsystem];
+ }
+
+ void System::resolveWires()
+ {
+ SUBSYSTEM_MAP::iterator subsystemsIter;
+ for (subsystemsIter = subsystemMap.begin();
+ subsystemsIter != subsystemMap.end();
+ subsystemsIter++ )
+ {
+ subsystemsIter->second->resolveWires();
+ }
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/System.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/System.h
new file mode 100644
index 0000000000..a0f62ce67a
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/System.h
@@ -0,0 +1,89 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_system_h
+#define tuscany_sca_model_system_h
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "tuscany/sca/model/Subsystem.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ typedef std::vector<Module*> MODULE_LIST;
+
+ /**
+ * The root of the runtime model supported by a Tuscany runtime.
+ */
+ class System {
+ public:
+ System();
+ virtual ~System();
+
+ /**
+ * Add a new subsystem to the system.
+ * @param subsystemName The name of the new subsystem to add.
+ * @return The new Subsystem added to the system.
+ */
+ Subsystem* addSubsystem(const std::string& subsystemName);
+
+ /**
+ * Find subsystem by name.
+ * @param subsystemName The name of the subsystem to be found.
+ * @return The Subsystem found, or 0 if not found.
+ */
+ Subsystem* findSubsystem(const std::string& subsystemName);
+
+ typedef std::vector<Module*> MODULE_LIST;
+
+ /**
+ * Return a vector of all the modules with a given module name.
+ * @param moduleName The name of the module to find
+ * @return A vector of all the times the module appears in the
+ * system. It can be more than once because the same module name
+ * is used by more than one module component.
+ */
+ MODULE_LIST findModules(const std::string& moduleName);
+
+ /**
+ * Resolve all the wires defined in the system.
+ */
+ void resolveWires();
+
+ private:
+
+ typedef std::map<std::string, Subsystem*> SUBSYSTEM_MAP;
+
+ /**
+ * Map by name of subsystems.
+ */
+ SUBSYSTEM_MAP subsystemMap;
+ };
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_system_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WSBinding.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WSBinding.cpp
new file mode 100644
index 0000000000..85cb7482bd
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WSBinding.cpp
@@ -0,0 +1,127 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/WSBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ WSBinding::WSBinding(const string& uri, const string& port)
+ : Binding(uri), port(port)
+ {
+
+ // Port is of the form: <wsdl-namepace-uri>#wsdl.endpoint(<service-name>/<port-name>)
+ string::size_type hash = port.find("#");
+ if (hash != string::npos)
+ {
+ // Found a hash
+
+ // Namepace is the part before the #
+ wsdlNamespaceURL = port.substr(0, hash);
+
+
+ if ( (hash+1) < port.length())
+ {
+ // Check the next part is wsdl.endpoint(
+ int ending = hash+15;
+ string check = port.substr(hash+1, 14);
+ if (check.compare("wsdl.endpoint(") == 0)
+ {
+ // Find the matching )
+ int endBracket = port.find(")",ending);
+ if (endBracket-1 > ending+1)
+ {
+ string serviceAndPort = port.substr(ending, endBracket-ending);
+ // Look for a '/'
+ string::size_type slash = serviceAndPort.find("/");
+ if (slash != string::npos)
+ {
+ serviceName = serviceAndPort.substr(0, slash);
+
+ if ( (slash+1) < serviceAndPort.length())
+ {
+ portName = serviceAndPort.substr(slash+1);
+ }
+ else
+ {
+ portName = "";
+ }
+
+ }
+ else
+ {
+ // No '/' so all of it is the service name
+ serviceName = serviceAndPort;
+ portName = "";
+
+ }
+ }
+ else
+ {
+ // Nothing between the ()
+ serviceName = "";
+ portName = "";
+ }
+ }
+ else
+ {
+ // not the correct characters after the #, ignore the rest
+ serviceName = "";
+ portName = "";
+ }
+
+ }
+ else
+ {
+ // Nothing after the hash
+ serviceName = "";
+ portName = "";
+ }
+ }
+ else
+ {
+ // No hash at all
+ wsdlNamespaceURL = port;
+ serviceName = "";
+ portName = "";
+ }
+
+
+
+
+
+
+ }
+
+ WSBinding::~WSBinding()
+ {
+ }
+
+ } // End namespace model
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WSBinding.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WSBinding.h
new file mode 100644
index 0000000000..e7963d205b
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WSBinding.h
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_wsbinding_h
+#define tuscany_sca_model_wsbinding_h
+
+#include "tuscany/sca/model/Binding.h"
+
+#include <string>
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Information about a web service binding for an entry point or an
+ * external service.
+ */
+ class WSBinding : public Binding
+ {
+ 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")
+ */
+ WSBinding(const string&uri, const string& port);
+
+ /**
+ * Destructor.
+ */
+ virtual ~WSBinding();
+
+ /**
+ * Return the type of the binding.
+ * @return Always returns WS.
+ */
+ virtual Type getBindingType() {return WS;};
+
+ /**
+ * Return the part of the port definition describing the wsdl
+ * namespace.
+ * @return The wsdl namespace.
+ */
+ string getWSDLNamespaceURL() {return wsdlNamespaceURL;};
+
+ /**
+ * Return the service part of the port definition.
+ * @return The service to use.
+ */
+ string getServiceName() {return serviceName;};
+
+ /**
+ * Return the port name part of the port definition.
+ * @return The port name to use.
+ */
+ string getPortName() {return portName;};
+
+ private:
+ /**
+ * The full port string.
+ */
+ string port;
+
+ /**
+ * Namespace from the port.
+ */
+ string wsdlNamespaceURL;
+
+ /**
+ * Service name from the port.
+ */
+ string serviceName;
+
+ /**
+ * Port name from the port.
+ */
+ string portName;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_wsbinding_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wire.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wire.cpp
new file mode 100644
index 0000000000..6c1b14940f
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wire.cpp
@@ -0,0 +1,46 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wire.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wire.h
new file mode 100644
index 0000000000..b126137118
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wire.h
@@ -0,0 +1,91 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_wire_h
+#define tuscany_sca_model_wire_h
+
+#include <string>
+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.
+ */
+ Wire(const std::string& source, const std::string& target);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Wire();
+
+ /**
+ * Get the component name defined by the source of the wire.
+ * @return The component name which is the source of the wire.
+ */
+ const std::string& getSourceComponent() {return sourceComponent;}
+
+ /**
+ * Get the reference name defined by the source of the wire.
+ * @return The reference name which is the source of the wire.
+ */
+ const std::string& getSourceReference() {return sourceReference;}
+
+ /**
+ * Get the target uri defined by the target of the wire.
+ * @return The target uri which is the source of the wire.
+ */
+ const std::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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WireTarget.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WireTarget.cpp
new file mode 100644
index 0000000000..a35b07f5fe
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WireTarget.cpp
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/WireTarget.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ // Constructor
+ WireTarget::WireTarget(const std::string& targetName)
+ : name(targetName)
+ {
+ }
+
+ WireTarget::~WireTarget()
+ {
+ }
+
+ void WireTarget::setInterface(Interface* interf)
+ {
+ iface = interf;
+ }
+
+ } // End namespace model
+
+
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WireTarget.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WireTarget.h
new file mode 100644
index 0000000000..312d20a704
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WireTarget.h
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_wiretarget_h
+#define tuscany_sca_model_wiretarget_h
+
+#include <string>
+using std::string;
+
+#include "tuscany/sca/model/Interface.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ /**
+ * Represents the target of a wire. This could be a service on a
+ * component or an external service.
+ */
+ class WireTarget
+ {
+ public:
+ /**
+ * Supported types of wire target.
+ */
+ enum Type
+ {
+ ComponentServiceType,
+ ExternalServiceType
+ };
+
+ /**
+ * Constructor.
+ * @param name The name of the wire target.
+ */
+ WireTarget(const std::string& name);
+
+ /**
+ * Destructor.
+ */
+ virtual ~WireTarget();
+
+ /**
+ * Return the name of the wire target.
+ */
+ string getName() {return name;}
+
+ /**
+ * Get the type of the wire target.
+ * @return Depends on the type of the wire target.
+ */
+ virtual Type getServiceType() = 0;
+
+ /**
+ * Set the interface describing the wire target.
+ * @param iface The interface.
+ */
+ void setInterface(Interface* iface);
+
+ /**
+ * Get the interface describing the wire target.
+ * @return The interface.
+ */
+ Interface* getInterface() {return iface;}
+
+ private:
+ /**
+ * Name of the wire target (service name or external service name)
+ */
+ string name;
+
+ /**
+ * Type of the service.
+ */
+ Type serviceType;
+
+ /**
+ * Interface describing the wire target.
+ */
+ Interface* iface;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_wiretarget_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wsdl.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wsdl.cpp
new file mode 100644
index 0000000000..fcc86c78e5
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wsdl.cpp
@@ -0,0 +1,345 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/Wsdl.h"
+#include "tuscany/sca/util/Exceptions.h"
+
+using namespace tuscany::sca;
+
+using namespace commonj::sdo;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+
+ // Constructor
+ Wsdl::Wsdl(DataObjectPtr wsdlModel)
+ : wsdlModel(wsdlModel)
+ {
+ LOGENTRY(1, "Wsdl::constructor");
+
+ // Trace
+ Utils::printDO(wsdlModel);
+
+
+
+ LOGEXIT(1, "Wsdl::constructor");
+ }
+
+ Wsdl::~Wsdl()
+ {
+ }
+
+
+ ///
+ /// The namespace of the service and other definitions defined in this wsdl definition
+ string Wsdl::getNamespace()
+ {
+
+ return wsdlModel->getCString("targetNamespace");
+
+ }
+
+ ///
+ /// Find the operation defined in this wsdl
+ ///
+ WsdlOperation Wsdl::findOperation(const string& serviceName,
+ const string& portName,
+ const string& operationName)
+ {
+ string message;
+
+ // 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; j<portList.size();j++)
+ {
+ string portListName(portList[j]->getCString("name"));
+ if (portListName.compare(portName) == 0)
+ {
+
+ // found port
+ // Add address at this point
+ string targetAddress(portList[j]->getCString("address/location"));
+
+ // find operation by traversing the binding, portType then operation
+ string wsBindingName(portList[j]->getCString("binding"));
+
+ DataObjectPtr wsBinding = findBinding(wsBindingName);
+ if (!wsBinding)
+ {
+ message = "Unable to find binding ";
+ message = message + wsBindingName;
+ message = message + " in the WSDL definition";
+ throw SystemConfigurationException(message.c_str());
+ }
+
+ // Get the soapAction
+ string soapAction = getSoapAction(wsBinding, operationName);
+
+
+ // 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"));
+ string requestTypeName;
+ string requestTypeUri;
+ // Utils::tokeniseQName(requestType, requestTypeUri, requestTypeName);
+ Utils::rTokeniseString(":", requestType, requestTypeUri, requestTypeName);
+
+ // 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"));
+ string responseTypeName;
+ string responseTypeUri;
+ // Utils::tokeniseQName(responseType, responseTypeUri, responseTypeName);
+ Utils::rTokeniseString(":", responseType, responseTypeUri, responseTypeName);
+
+ return WsdlOperation(requestTypeName,
+ soapAction,
+ targetAddress,
+ responseTypeName);
+ }
+
+ }
+
+ 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 a service
+ ///
+ DataObjectPtr Wsdl::findService(const string& serviceName)
+ {
+ DataObjectPtr service = 0;
+
+
+ // Find the binding
+ DataObjectList& serviceList = wsdlModel->getList("service");
+ for (int i=0; i<serviceList.size(); i++)
+ {
+ string name(serviceList[i]->getCString("name"));
+
+ if (name.compare(serviceName) == 0)
+ {
+ return serviceList[i];
+ }
+ }
+
+ return service;
+ }
+
+
+ ///
+ /// Find a named binding
+ ///
+ DataObjectPtr Wsdl::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; i<bindingList.size(); i++)
+ {
+ string nameBinding(bindingList[i]->getCString("name"));
+
+ if (nameBinding.compare(name) == 0)
+ {
+ return bindingList[i];
+ }
+ }
+
+ return binding;
+ }
+
+ ///
+ /// Find a named portType
+ ///
+ DataObjectPtr Wsdl::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; i<portTypeList.size(); i++)
+ {
+ string namePortType(portTypeList[i]->getCString("name"));
+
+ if (namePortType.compare(name) == 0)
+ {
+ return portTypeList[i];
+ }
+ }
+
+ return portType;
+ }
+
+ ///
+ /// Find a named message
+ ///
+ DataObjectPtr Wsdl::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; i<messageList.size(); i++)
+ {
+ string nameMessage(messageList[i]->getCString("name"));
+
+ if (nameMessage.compare(name) == 0)
+ {
+ return messageList[i];
+ }
+ }
+
+ return message;
+ }
+
+ ///
+ /// Get the soap action
+ ///
+ string Wsdl::getSoapAction(DataObjectPtr binding, const string& operationName)
+ {
+
+
+ // Find the binding operation
+ DataObjectList& bindingOperationList = binding->getList("operation");
+ for (int i=0; i<bindingOperationList.size(); i++)
+ {
+ string name(bindingOperationList[i]->getCString("name"));
+
+ if (name.compare(operationName) == 0)
+ {
+ // Found the binding operation, return the soap action
+ string soapAction(bindingOperationList[i]->getCString("operation/soapAction"));
+ return soapAction;
+ }
+ }
+
+ return string("");
+ }
+
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wsdl.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wsdl.h
new file mode 100644
index 0000000000..440ecc4c2d
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/Wsdl.h
@@ -0,0 +1,132 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_wsdl_h
+#define tuscany_sca_model_wsdl_h
+
+#include <string>
+using std::string;
+
+#include "tuscany/sca/model/WsdlOperation.h"
+
+#include "commonj/sdo/SDO.h"
+using commonj::sdo::DataObjectPtr;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ /**
+ * Holds information about a WSDL definition loaded into the runtime.
+ */
+ class Wsdl
+ {
+ public:
+ /**
+ * Constructor.
+ * @param wsdlModel The data object representing the WSDL document
+ * defining a web service.
+ */
+ Wsdl(DataObjectPtr wsdlModel);
+
+ /**
+ * Destructor.
+ */
+ ~Wsdl();
+
+
+ /**
+ * Returns the target namespace of the WSDL definitions.
+ * @return The target namespace.
+ */
+ 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.
+ */
+ WsdlOperation findOperation(const string& serviceName,
+ const string& portName,
+ 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 the details of the soap action setting for an operation
+ * on a soap binding.
+ * @param binding The data object describing the binding.
+ * @param operationName The name of the operation.
+ * @return The soap action setting from the WSDL.
+ */
+ string getSoapAction(DataObjectPtr binding, const string& operationName);
+
+
+ /**
+ * The data object representation of the WSDL document.
+ */
+ DataObjectPtr wsdlModel;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_wsdl_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WsdlOperation.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WsdlOperation.cpp
new file mode 100644
index 0000000000..e248f64caf
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WsdlOperation.cpp
@@ -0,0 +1,57 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/Wsdl.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+
+ // Constructor
+ WsdlOperation::WsdlOperation(const string& operation,
+ const string& soapAct,
+ const string& endpointAddress,
+ const string& response)
+ : operationName(operation),
+ responseName(response),
+ soapAction(soapAct),
+ endpoint(endpointAddress)
+ {
+ LOGENTRY(1, "WsdlOperation::constructor");
+
+
+
+
+ LOGEXIT(1, "WsdlOperation::constructor");
+ }
+
+ WsdlOperation::~WsdlOperation()
+ {
+ }
+
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WsdlOperation.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WsdlOperation.h
new file mode 100644
index 0000000000..a77d576a4f
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model/WsdlOperation.h
@@ -0,0 +1,117 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_model_wsdlOperation_h
+#define tuscany_sca_model_wsdlOperation_h
+
+#include <string>
+using std::string;
+
+
+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.
+ */
+ WsdlOperation(const string& operation,
+ const string& soapAction,
+ const string& endpoint,
+ const string& responseName);
+
+ /**
+ * Destructor.
+ */
+ ~WsdlOperation();
+
+ /**
+ * Return the name of the operation for use when serializing an
+ * outgoing message.
+ * @return The name of the element in the request message.
+ */
+ const string& getOperationName() {return operationName;};
+
+ /**
+ * Return the name of the response for use when deserializing an
+ * incoming message.
+ * @return The name of the element in the response message.
+ */
+ const string& getResponseName() {return responseName;};
+
+ /**
+ * The soap action string for this operation.
+ * @return The soap action.
+ */
+ const string& getSoapAction() {return soapAction;};
+
+ /**
+ * Return the endpoint address for the target web service.
+ * @return The endpoint address.
+ */
+ const string& getEndpoint() {return endpoint;};
+
+
+
+ private:
+ /**
+ * The name of the operation for use when serializing an
+ * outgoing message.
+ */
+ string operationName;
+
+ /**
+ * The name of the response for use when deserializing an
+ * incoming message.
+ */
+ string responseName;
+
+ /**
+ * The soap action string for this operation.
+ */
+ string soapAction;
+
+ /**
+ * The endpoint address of the target web service.
+ */
+ string endpoint;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_wsdlOperation_h
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp
new file mode 100644
index 0000000000..3ea2212f7c
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp
@@ -0,0 +1,43 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/DefaultLogWriter.h"
+#include <iostream>
+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 <<endl;
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h
new file mode 100644
index 0000000000..4d45579907
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h
@@ -0,0 +1,46 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_defaultlogwriter_h
+#define tuscany_sca_util_defaultlogwriter_h
+
+#include "tuscany/sca/util/LogWriter.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Log writer to write out to standard out.
+ */
+ class DefaultLogWriter : public LogWriter
+ {
+ public:
+ virtual ~DefaultLogWriter();
+
+ /**
+ * Will write to the console.
+ * See LogWriter#log.
+ */
+ virtual void log(int level, const char* msg);
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_defaultlogwriter_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Exceptions.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Exceptions.h
new file mode 100644
index 0000000000..afaa5513b5
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Exceptions.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_exceptions_h
+#define tuscany_sca_util_exceptions_h
+
+#include "osoa/sca/ServiceRuntimeException.h"
+using osoa::sca::ServiceRuntimeException;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Indicates a problem in the consistency of the SCA model provided to the
+ * Tuscany runtime.
+ */
+ class SystemConfigurationException: public ServiceRuntimeException
+ {
+ public:
+ SystemConfigurationException(const char* msg)
+ : ServiceRuntimeException("SystemConfigurationException", Severe,
+ msg)
+ {
+ }
+ private:
+ };
+
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_exceptions_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.cpp
new file mode 100644
index 0000000000..5f54fff8bc
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.cpp
@@ -0,0 +1,216 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/File.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include <iostream>
+
+#include <string>
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <unistd.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#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 ServiceRuntimeException("Files::operator[] index out of bounds");
+ }
+
+ FILES::iterator iter = files.begin();
+ for (unsigned int i=0; i<index; i++)
+ {
+ iter++;
+ }
+
+ return *iter;
+ }
+
+
+ void Files::findFiles(const string& rootDir, const string& pattern, bool subdirectories)
+ {
+
+#if defined(WIN32) || defined (_WINDOWS)
+ char currentDir[ _MAX_FNAME];
+
+
+ GetCurrentDirectory(_MAX_FNAME, currentDir);
+
+ // Set current directory, from which to search.
+ if (!SetCurrentDirectory(rootDir.c_str()))
+ {
+ cout << "Unable to set current directory to: " << rootDir.c_str() << endl;
+ return;
+ }
+ char fullDirname[ _MAX_FNAME];
+ GetCurrentDirectory(_MAX_FNAME, fullDirname);
+
+ // First, look for all files in this directory that meet the pattern
+ char search[ _MAX_FNAME];
+ strcpy(search, pattern.c_str());
+
+ // Find the first file in the directory
+ WIN32_FIND_DATA data;
+ HANDLE searchHandle = FindFirstFile(search, &data);
+
+ int more = TRUE;
+ if (searchHandle != INVALID_HANDLE_VALUE)
+ {
+ // Found some matching files, so call the function with the details of each one
+ while (more)
+ {
+ // Skip over directories
+ if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ // Add the file to our list
+ files.push_back(File(fullDirname, data.cFileName));
+ }
+
+ more = FindNextFile(searchHandle, &data);
+ }
+ }
+
+
+ if (!subdirectories)
+ return;
+
+ // Now recurse down all the directories
+ // Find the first file in the directory
+ searchHandle = FindFirstFile( "*.*", &data);
+ more = TRUE;
+
+ if (searchHandle != INVALID_HANDLE_VALUE)
+ {
+ // Found some files in the directory.
+ while (more)
+ {
+ // If directory
+ if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ // Skip over '.' and '..'
+ if ((strcmp(data.cFileName, ".")) && (strcmp("..", data.cFileName)))
+ {
+ // Recurse
+ findFiles(data.cFileName, pattern, subdirectories);
+ }
+ }
+
+ more = FindNextFile(searchHandle, &data);
+ }
+ }
+ SetCurrentDirectory(currentDir);
+#else
+ // Linux
+ //char fullDirname[MAX_PATH];
+ //getcwd(fullDirname, MAX_PATH);
+
+ DIR* root = opendir(rootDir.c_str());
+ if (!root)
+ {
+ cout << "Unable to open directory: " << rootDir.c_str() << endl;
+ return;
+ }
+
+ bool exactMatch = true;
+ string token1, token2;
+ if (pattern.find('*') != string::npos)
+ {
+ exactMatch = false;
+ Utils::tokeniseString("*", pattern, token1, token2);
+ }
+
+ struct dirent *entry=0;
+ while ((entry = readdir(root)))
+ {
+ string entryName = rootDir + "/" + entry->d_name;
+ struct stat statbuf;
+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
+ continue;
+ if (stat(entryName.c_str(), &statbuf) != 0)
+ {
+ 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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.h
new file mode 100644
index 0000000000..f177401442
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.h
@@ -0,0 +1,133 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_file_h
+#define tuscany_sca_util_file_h
+
+#include <string>
+using std::string;
+#include <vector>
+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<File> FILES;
+
+ /**
+ * Vector of File.
+ */
+ FILES files;
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_file_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp
new file mode 100644
index 0000000000..c3749c1be2
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/FileLogWriter.h"
+#include <iostream>
+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 <<endl;
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.h
new file mode 100644
index 0000000000..4f230a8f0b
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.h
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_filelogwriter_h
+#define tuscany_sca_util_filelogwriter_h
+
+#include "tuscany/sca/util/LogWriter.h"
+#include <iostream>
+#include <fstream>
+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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.cpp
new file mode 100644
index 0000000000..452d185dcd
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.cpp
@@ -0,0 +1,119 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+using namespace osoa::sca;
+
+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)
+ hDLL = LoadLibrary(name.c_str());
+#else
+ hDLL = dlopen(name.c_str(), RTLD_NOW);
+#endif
+ if (hDLL == NULL)
+ {
+ LOGERROR_1(1, "Library::load: Unable to load library %s", name.c_str());
+ msg = "Unable to load dll: " + name;
+ throw ServiceRuntimeException(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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.h
new file mode 100644
index 0000000000..69b2f5352a
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.h
@@ -0,0 +1,97 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_library_h
+#define tuscany_sca_util_library_h
+
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <unistd.h>
+#include <dlfcn.h>
+#endif
+
+#include <string>
+using std::string;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Information about shared libraries and methods to
+ * access these shared libraries.
+ */
+ class 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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.cpp
new file mode 100644
index 0000000000..d77d1e4bfd
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.cpp
@@ -0,0 +1,32 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/LogWriter.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ LogWriter::~LogWriter()
+ {
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.h
new file mode 100644
index 0000000000..edb07c3684
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.h
@@ -0,0 +1,47 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_logwriter_h
+#define tuscany_sca_util_logwriter_h
+
+#include "osoa/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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.cpp
new file mode 100644
index 0000000000..0a888a69ef
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.cpp
@@ -0,0 +1,107 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include <iostream>
+#include <stdarg.h>
+
+#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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.h
new file mode 100644
index 0000000000..8ba934afa5
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.h
@@ -0,0 +1,89 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_logger_h
+#define tuscany_sca_util_logger_h
+
+#include "osoa/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.
+ */
+ 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.
+ */
+ static void logArgs(int level, const char* msg, ...);
+
+ /**
+ * The currently set logging level
+ */
+ 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/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logging.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logging.h
new file mode 100644
index 0000000000..066f6a5733
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logging.h
@@ -0,0 +1,72 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_logging_h
+#define tuscany_sca_util_logging_h
+
+#include "tuscany/sca/util/Logger.h"
+
+#ifdef _DEBUG
+#define LOGENTRY(level, methodName) \
+if (Logger::loggingLevel >= level) \
+Logger::log(level, "Entering: " methodName);
+
+#define LOGEXIT(level, methodName) \
+if (Logger::loggingLevel >= level) \
+Logger::log(level, "Exiting: " methodName);
+
+#define LOGINFO(level, message) \
+if (Logger::loggingLevel >= level) \
+Logger::log(level, message);
+
+#define LOGINFO_1(level, message, arg1) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(level, message, arg1);
+
+#define LOGINFO_2(level, message, arg1, arg2) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(level, message, arg1, arg2);
+
+#define LOGERROR(level, message) \
+if (Logger::loggingLevel >= level) \
+Logger::log(level, message);
+
+#define LOGERROR_1(level, message, arg1) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(level, message, arg1);
+
+#define LOGERROR_2(level, message, arg1, arg2) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(level, message, arg1, arg2);
+#else // Not DEBUG
+#define LOGENTRY(level, methodName)
+
+#define LOGEXIT(level, methodName)
+
+#define LOGINFO(level, message)
+
+#define LOGINFO_1(level, message, arg1)
+
+#define LOGINFO_2(level, message, arg1, arg2)
+#define LOGERROR(level, message)
+#define LOGERROR_1(level, message, arg1)
+#define LOGERROR_2(level, message, arg1, arg2)
+
+#endif
+#endif // tuscany_sca_util_logging_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.cpp
new file mode 100644
index 0000000000..7f457e68ed
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.cpp
@@ -0,0 +1,212 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#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;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Print a DatObject tree
+ //////////////////////////////////////////////////////////////////////////
+ void Utils::tabs(int inc)
+ {
+ for (int ind=0; ind <inc; ind++)
+ {
+ cout << " ";
+ }
+ }
+
+ 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();
+ 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 <dol.size(); j++)
+ {
+ tabs(inc);
+ cout << "Value " << j <<endl;
+ inc++;
+
+ if (propertyType.isDataType())
+ {
+ tabs(inc);
+ cout<< "Property Value: " << dol.getCString(j) <<endl ;
+ }
+ else
+ printDO(dol[j], inc);
+ inc--;
+ }
+ inc--;
+ } // end IsMany
+
+
+ //////////////////////////////////////////////////////////////////////
+ // For a primitive data type print the value
+ //////////////////////////////////////////////////////////////////////
+ else if (propertyType.isDataType())
+ {
+ tabs(inc);
+ cout<< "Property Value: " << dataObject->getCString(pl[i]) <<endl ;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // For a dataobject print the do
+ //////////////////////////////////////////////////////////////////////
+ else
+ {
+ inc++;
+ printDO(dataObject->getDataObject(pl[i]), inc);
+ inc--;
+ }
+ }
+ else
+ {
+ tabs(inc);
+ cout<< "Property Value: not set" <<endl ;
+ }
+
+ }
+ inc--;
+ }
+
+ void Utils::printTypes(DataFactoryPtr df)
+ {
+ //////////////////////////////////////////////////////////////////////////
+ // Retrieve the DataFactory from the mediator
+ // get the list of Types in the DataFactory and list them
+ //////////////////////////////////////////////////////////////////////////
+ TypeList tl = df->getTypes();
+ for (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: " <<pl[j].getType().getURI()<<"#"<<pl[j].getType().getName()<< endl;
+
+ }
+ }
+
+ }
+
+
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.h
new file mode 100644
index 0000000000..184bcd3dad
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.h
@@ -0,0 +1,61 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_utils_h
+#define tuscany_sca_util_utils_h
+#include <string>
+using std::string;
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/export.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Utility methods to parse strings and provide debugging information.
+ */
+ class 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);
+
+ SCA_API static void printDO(commonj::sdo::DataObjectPtr dataObject, int increment=0);
+ SCA_API static void printTypes(commonj::sdo::DataFactoryPtr df);
+
+ private:
+ static void tabs(int increment=0);
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_utils_h
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/SDOStub.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/SDOStub.cpp
new file mode 100644
index 0000000000..704097833e
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/SDOStub.cpp
@@ -0,0 +1,448 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "SDOStub.h"
+#include "commonj/sdo/HelperProvider.h"
+#include "osoa/sca/export.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+
+
+// For Axis stub code
+#include <axis/AxisWrapperAPI.hpp>
+#include <axis/client/Stub.hpp>
+#include <axis/OtherFaultException.hpp>
+#include <axis/ISoapFault.hpp>
+
+using namespace std;
+
+AXIS_CPP_NAMESPACE_USE
+
+using namespace commonj::sdo;
+using namespace tuscany::sca;
+
+
+namespace tuscany
+{
+namespace sca
+{
+ namespace ws
+ {
+ /** Construct an SDOStub using the default HTTP 1.1 transport.
+ */
+ SDOStub::SDOStub()
+ : Stub(" ", APTHTTP1_1),
+ m_strEndpoint(""),
+ m_strTargetNamespace(""),
+ m_strOperationName(""),
+ m_strOperationResponseName(""),
+ m_strSoapAction("")
+ {
+ }
+
+
+ /** Construct an SDOStub using the default HTTP 1.1 transport
+ * and set the web service endpoint URI.
+ * @param endpoint - web service endpoint URI
+ */
+ SDOStub::SDOStub(const char* endpoint)
+ : Stub(endpoint, APTHTTP1_1),
+ m_strEndpoint(endpoint),
+ m_strTargetNamespace(""),
+ m_strOperationName(""),
+ m_strOperationResponseName(""),
+ m_strSoapAction("")
+ {
+ }
+
+
+ /** Destruct the SDOStub
+ */
+ SDOStub::~SDOStub()
+ {
+ }
+
+ /** Set the web service endpoint URI.
+ * The endpoint is the value of the soap:address element in the WSDL.
+ * @param endpoint - web service endpoint URI.
+ */
+ void SDOStub::setEndpoint(const char* endpoint)
+ {
+ m_strEndpoint = endpoint;
+ // Stub::setEndPoint
+ setEndPoint(endpoint);
+ }
+
+ /** Get the web service endpoint URI.
+ * @return web service endpoint URI.
+ */
+ const char* SDOStub::getEndpoint()
+ {
+ return m_strEndpoint.c_str();
+ }
+
+ /** Set the target namespace for elements and operations.
+ * @param targetNamespace - the target namespace.
+ */
+ void SDOStub::setTargetNamespace(const char* targetNamespace)
+ {
+ m_strTargetNamespace = targetNamespace;
+ }
+
+ /** Get the target namespace.
+ * @return - target namespace.
+ */
+ const char* SDOStub::getTargetNamesapce()
+ {
+ return m_strTargetNamespace.c_str();
+ }
+
+ /** Set the name of the operation to invoke.
+ * @param operationName - operation name
+ */
+ void SDOStub::setOperationName(const char* operationName)
+ {
+ m_strOperationName = operationName;
+ }
+
+ /** Get the operation name.
+ * @return operation name.
+ */
+ const char* SDOStub::getOperationName()
+ {
+ return m_strOperationName.c_str();
+ }
+
+ /** Set the name of the element that is returned as the result of a soap method.
+ * @param operationResponseName - name of the response element.
+ */
+ void SDOStub::setOperationResponseName(const char* operationResponseName)
+ {
+ m_strOperationResponseName = operationResponseName;
+ }
+
+ /** Get the name of the element that is returned as the result of a soap method.
+ * @return operation response name.
+ */
+ const char* SDOStub::getOperationResponseName()
+ {
+ return m_strOperationResponseName.c_str();
+ }
+
+ /** Set the SOAPAction header.
+ * @param soapAction - the soap action.
+ */
+ void SDOStub::setSoapAction(const char* soapAction)
+ {
+ m_strSoapAction = soapAction;
+ }
+
+ /** Get the SoapAction header.
+ * @return soap action.
+ */
+ const char* SDOStub::getSoapAction()
+ {
+ return m_strSoapAction.c_str();
+ }
+
+ /** Invoke the operation on the web service.
+ * @param requestDO - SDO containing the input parameters for the operation.
+ * @param dataFactory - DataFactory for de/serialzing the SDOs.
+ * @return DataObjectPtr - SDO containg the response from the web service.
+ */
+ DataObjectPtr SDOStub::invoke(DataObjectPtr requestDO, DataFactoryPtr dataFactory)
+ {
+ LOGENTRY(2, "SDOStub::invoke");
+
+ // SDO return object
+ DataObjectPtr pReturn;
+
+ // For faults
+ //const char* pcCmplxFaultName = NULL;
+
+ // Get an XMLHelper
+ XMLHelperPtr xmlHelper = HelperProvider::getXMLHelper(dataFactory);
+
+
+ try
+ {
+ // Initialize the call structure for Doc Literal request/response.
+ if (AXIS_SUCCESS != m_pCall->initialize(CPP_DOC_PROVIDER))
+ {
+ return pReturn; // Return if there is a failure
+ }
+
+ // Set the SoapAction if it is not already set.
+ if (NULL == m_pCall->getTransportProperty("SOAPAction",false))
+ {
+ m_pCall->setTransportProperty(SOAPACTION_HEADER , m_strSoapAction.c_str());
+ }
+
+ // Set the Soap Version.
+ m_pCall->setSOAPVersion(SOAP_VER_1_1);
+
+ // Set the Operation (operationName and targetNamespace)
+ m_pCall->setOperation(m_strOperationName.c_str(), m_strTargetNamespace.c_str());
+
+ //includeSecure();
+ //applyUserPreferences();
+
+ //
+ // Serialize the DataObject.
+ //
+
+ // DEBUG
+ XMLDocumentPtr requestDoc =
+ xmlHelper->createDocument(requestDO,
+ m_strTargetNamespace.c_str(),
+ m_strOperationName.c_str());
+ requestDoc->setXMLDeclaration(false);
+ char *requestXML = xmlHelper->save(requestDoc);
+ LOGINFO_1(2, "SDOStub::invoke: Request XML=%s", requestXML);
+
+ // Loop through the top level data object, serializing individual properties.
+ // We cannot simply serialize the request DataObject to an XML string and add
+ // the XML as an AnyType parameter because Axis will wrap the request with an
+ // element named for the operationName (Doc Literal/Wrapped), duplicating the
+ // top-level element.
+ PropertyList properties = requestDO->getInstanceProperties();
+ for (int i=0; i < properties.size() ; i++)
+ {
+ Property& property = properties[i];
+ const char *propertyName = property.getName();
+
+ // If the property is not set, don't bother adding it as a parameter.
+ if (!requestDO->isValid(property)) continue;
+
+ switch (property.getTypeEnum())
+ {
+ // Simple string property - add it as an XSD_STRING parameter.
+ case Type::StringType:
+ {
+ if (!property.isMany())
+ {
+ string strPrefixAndParamName;
+ const char *namespacePrefix =
+ m_pCall->getNamespacePrefix(m_strTargetNamespace.c_str());
+ strPrefixAndParamName.append(namespacePrefix);
+ strPrefixAndParamName.append(":");
+ strPrefixAndParamName.append(propertyName);
+ const char *paramValue = requestDO->getCString(i);
+ m_pCall->addParameter((void *)paramValue,
+ strPrefixAndParamName.c_str(),
+ XSD_STRING);
+ }
+ }
+ break;
+
+ // DataObject property.
+ case Type::DataObjectType:
+ {
+ const char *dobXML = NULL;
+ if (property.isMany())
+ {
+ // Many valued property - get the list.
+ DataObjectList& dobList = requestDO->getList(property);
+ for (int j=0; j< dobList.size(); j++)
+ {
+ DataObjectPtr dob = dobList[j];
+ if (dob != 0)
+ {
+ // Create an XML string from the DataObject.
+ XMLDocumentPtr doc =
+ xmlHelper->createDocument(dob,
+ m_strTargetNamespace.c_str(),
+ propertyName);
+ doc->setXMLDeclaration(false);
+ dobXML = xmlHelper->save(doc);
+
+ // Add the XML to the call as an AnyType.
+ AnyType* pAny = new AnyType();
+ pAny->_size = 1;
+ pAny->_array = new char*[1];
+ pAny->_array[0] = strdup(dobXML);
+ m_pCall->addAnyObject(pAny);
+ }
+ }
+ } // if isMany
+ else
+ {
+ // Single valued property.
+ DataObjectPtr dob = requestDO->getDataObject(property);
+ if (dob != 0)
+ {
+ // Create an XML string from the DataObject.
+ XMLDocumentPtr doc =
+ xmlHelper->createDocument(dob,
+ m_strTargetNamespace.c_str(),
+ propertyName);
+ doc->setXMLDeclaration(false);
+ dobXML = xmlHelper->save(doc);
+
+ // Add the XML to the call as an AnyType.
+ AnyType* pAny = new AnyType();
+ pAny->_size = 1;
+ pAny->_array = new char*[1];
+ pAny->_array[0] = strdup(dobXML);
+ m_pCall->addAnyObject(pAny);
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ // Invoke the operation.
+ if (AXIS_SUCCESS == m_pCall->invoke())
+ {
+ // Make sure the response element is what we expect; ie that the element matches
+ // the operation response name set on the stub and its targetNamespace matches
+ // the targetNamespace set on the stub.
+ if (AXIS_SUCCESS == m_pCall->checkMessage(m_strOperationResponseName.c_str(),
+ m_strTargetNamespace.c_str()))
+ {
+ LOGINFO(2, "SDOStub::invoke: invoke returned AXIS_SUCCESS");
+
+ // Deserialize the soap response.
+ string strResponse = getSoapResponse();
+
+ // Create an XMLDocument from the soap reponse
+ XMLDocumentPtr returnDoc =
+ xmlHelper->load(strResponse.c_str(), m_strTargetNamespace.c_str());
+ // Get the root DataObject to return as the result.
+ pReturn = returnDoc->getRootDataObject();
+
+ }
+ }
+ else
+ {
+ LOGINFO_2(2, "SDOStub::invoke: checkMessage failed. Expected: %s \' element with namespace \' %s \'.",
+ m_strOperationResponseName.c_str(),
+ m_strTargetNamespace.c_str());
+ }
+
+
+ // Invoked the operation successfully - uninitialize the Call object.
+ m_pCall->unInitialize();
+
+ }
+ catch (AxisException& e)
+ {
+ // Get the exception code.
+ int iExceptionCode = e.getExceptionCode();
+ LOGINFO_2(0, "SDOStub::invoke Caught AxisException: %d code: %s", iExceptionCode, e.what());
+ if (AXISC_NODE_VALUE_MISMATCH_EXCEPTION != iExceptionCode)
+ {
+ m_pCall->unInitialize();
+ throw ServiceRuntimeException("AxisException", ServiceRuntimeException::Error, e.what());
+ }
+
+ // Get the details of the SoapFault.
+ ISoapFault* pSoapFault = (ISoapFault*) m_pCall->checkFault("Fault", m_strEndpoint.c_str());
+
+ if (pSoapFault)
+ {
+ const char *detail = pSoapFault->getSimpleFaultDetail();
+ bool deleteDetail=false;
+
+ if (NULL==detail || 0==strlen(detail))
+ {
+ detail=m_pCall->getFaultAsXMLString();
+
+
+ if (NULL==detail)
+ {
+ detail="";
+ }
+ else
+ {
+ deleteDetail=true;
+ }
+ }
+
+ OtherFaultException ofe(pSoapFault->getFaultcode(),
+ pSoapFault->getFaultstring(),
+ pSoapFault->getFaultactor(),
+ detail, iExceptionCode);
+
+ if (deleteDetail && NULL!=detail)
+ {
+ delete [] const_cast<char*>(detail);
+ }
+
+ m_pCall->unInitialize();
+ throw ofe;
+ }
+ else
+ {
+ m_pCall->unInitialize();
+ throw ServiceRuntimeException("AxisException", ServiceRuntimeException::Error, e.what());
+ }
+ }
+ catch(SDORuntimeException sdoE)
+ {
+ throw ServiceRuntimeException("SDORuntimeException", ServiceRuntimeException::Error, sdoE.getMessageText());
+ }
+
+ LOGEXIT(2, "SDOStub::invoke");
+ return pReturn;
+
+ }
+
+ // Deserialize the soap response from the web service.
+ string SDOStub::getSoapResponse()
+ {
+ // Get the response as an XML string.
+ AnyType* soapAny = m_pCall->getAnyObject();
+
+ // The Doc Literal response does not include the top level
+ // response element if we use getAnyObject - we need to wrap
+ // the response with the response element.
+ string strResponse("<");
+ strResponse.append(m_strOperationResponseName);
+ strResponse.append(" xmlns=\"");
+ strResponse.append(m_strTargetNamespace);
+ strResponse.append("\">");
+
+ for (int j=0; j < soapAny->_size ; j++)
+ {
+ // DEBUG
+ cout << "SDOStub::getSoapResponse: soapAny->_array[" << j << "]=" << endl;
+ cout << soapAny->_array[j] << endl;
+ cout << endl;
+ // DEBUG
+
+ strResponse.append(soapAny->_array[j]);
+ }
+
+ strResponse.append("</");
+ strResponse.append(m_strOperationResponseName);
+ strResponse.append(">");
+
+ return strResponse;
+ }
+
+ } // end namespace ws
+} // end namespace sca
+} // end namespace tuscany
+
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/SDOStub.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/SDOStub.h
new file mode 100644
index 0000000000..d5743c9c78
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/SDOStub.h
@@ -0,0 +1,143 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#if !defined(SDOSTUB_H_INCLUDED)
+#define SDOSTUB_H_INCLUDED
+
+#include "osoa/sca/export.h"
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "commonj/sdo/SDO.h"
+
+// For stub code
+#include <axis/client/Stub.hpp>
+#include <axis/OtherFaultException.hpp>
+#include <axis/ISoapFault.hpp>
+
+#include <string>
+
+AXIS_CPP_NAMESPACE_USE
+using namespace commonj::sdo;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ /**
+ * The SDOStub class is an Axis Stub that is used to invoke operations on a Web Service
+ * using SDO objects as input parameters and return values.
+ */
+ class SDOStub : public Stub
+ {
+ public:
+
+ /** Construct an SDOStub using the default HTTP 1.1 transport.
+ */
+ SCA_API SDOStub();
+
+ /** Construct an SDOStub using the default HTTP 1.1 transport
+ * and set the web service endpoint URI.
+ * @param endpointURI - web service endpoint URI
+ */
+ SCA_API SDOStub(const char* endpointURI);
+
+ /** Destruct the SDOStub
+ */
+ SCA_API virtual ~SDOStub();
+
+ /** Set the web service endpoint URI.
+ * The endpoint is the value of the soap:address element in the WSDL.
+ * @param endpoint - web service endpoint URI.
+ */
+ SCA_API void setEndpoint(const char* endpoint);
+
+ /** Get the web service endpoint URI.
+ * @return web service endpoint URI.
+ */
+ SCA_API const char* getEndpoint();
+
+ /** Set the target namespace for elements and operations.
+ * @param targetNamespace - the target namespace.
+ */
+ SCA_API void setTargetNamespace(const char* targetNamespace);
+
+ /** Get the target namespace.
+ * @return - target namespace.
+ */
+ SCA_API const char* getTargetNamesapce();
+
+ /** Set the name of the operation to invoke.
+ * @param operationName - operation name
+ */
+ SCA_API void setOperationName(const char* operationName);
+
+ /** Get the operation name.
+ * @return operation name.
+ */
+ SCA_API const char* getOperationName();
+
+ /** Set the name of the element that is returned as the result of a soap method.
+ * @param operationResponseName - name of the response element.
+ */
+ SCA_API void setOperationResponseName(const char* operationResponseName);
+
+ /** Get the name of the element that is returned as the result of a soap method.
+ * @return operation response name.
+ */
+ SCA_API const char* getOperationResponseName();
+
+ /** Set the SOAPAction header.
+ * @param soapAction - the soap action.
+ */
+ SCA_API void setSoapAction(const char* soapAction);
+
+ /** Get the SoapAction header.
+ * @return soap action.
+ */
+ SCA_API const char* getSoapAction();
+
+ /** Invoke the operation on the web service.
+ * @param requestDO - SDO containing the input parameters for the operation.
+ * @param dataFactory - DataFactory for de/serialzing the SDOs.
+ * @return DataObjectPtr - SDO containg the response from the web service.
+ */
+ SCA_API DataObjectPtr invoke(DataObjectPtr requestDO, DataFactoryPtr dataFactory);
+
+ private:
+ // Deserialize the soap response from the web service.
+ string getSoapResponse();
+
+ string m_strEndpoint;
+ string m_strTargetNamespace;
+ string m_strOperationName;
+ string m_strOperationResponseName;
+ string m_strSoapAction;
+ };
+
+ } // end namespace ws
+ } // end namespace sca
+} // end namespace tuscany
+
+
+#endif // !defined(SDOSTUB_H_INCLUDED)
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.cpp
new file mode 100644
index 0000000000..672a48b697
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.cpp
@@ -0,0 +1,116 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/ws/WSServiceWrapper.h"
+
+#include "osoa/sca/sca.h"
+using namespace osoa::sca;
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/WSBinding.h"
+#include "tuscany/sca/model/Wsdl.h"
+#include "tuscany/sca/ws/SDOStub.h"
+#include "tuscany/sca/util/Utils.h"
+using namespace tuscany::sca;
+using namespace tuscany::sca::ws;
+
+
+
+extern "C"
+{
+ ///
+ /// Factory function for creating service wrappers for web services.
+ ///
+ SCA_API WSServiceWrapper* WSServiceWrapper_Factory(tuscany::sca::model::WireTarget* target)
+ {
+ return new WSServiceWrapper(target);
+ }
+}
+
+
+WSServiceWrapper::WSServiceWrapper(tuscany::sca::model::WireTarget* target) : ExternalServiceWrapper(target)
+{
+
+}
+
+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,"External service: %s, Operation: %s", getTarget()->getName().c_str() , operationName.c_str());
+
+
+ // Check one parameter in/ one parameter out and that they are data objects.
+
+ // Get the data factory for the module (it will already have the types loaded for the xsds)
+
+ // From the external service ws-binding, get the namespace of the wsdl endpoint
+ ExternalService* externalService = getExternalService();
+ WSBinding* binding = (WSBinding *)externalService->getBinding();
+
+ string portNamespace = binding->getWSDLNamespaceURL();
+
+ // Lookup the wsdl model from the module, keyed on the namespace
+ // (the wsdl will have been loaded at startup, based on the information in the config file)
+ Wsdl* wsdlDefinition = externalService->getContainingModule()->findWsdl(portNamespace);
+
+ // Match the operation in Operation to the operation in the wsdl port type.
+ WsdlOperation wsdlOperation = wsdlDefinition->findOperation(
+ binding->getServiceName()
+ , binding->getPortName()
+ , operationName);
+
+ // Get the name of the response by navigating from the wsdl operation to the return type
+
+ // Get the name of the SoapAction by navigating from the wsdl.
+
+ // Create an SDOStub
+ try
+ {
+ SDOStub wsStub(wsdlOperation.getEndpoint().c_str());
+ wsStub.setTargetNamespace(portNamespace.c_str());
+ wsStub.setOperationName(wsdlOperation.getOperationName().c_str());
+ wsStub.setOperationResponseName(wsdlOperation.getResponseName().c_str());
+ wsStub.setSoapAction(wsdlOperation.getSoapAction().c_str());
+
+
+ // Call the service via the SDOStub
+ *(DataObjectPtr *)operation.getReturnValue() = wsStub.invoke(*((DataObjectPtr*)operation.getParameter(0)),
+ externalService->getContainingModule()->getDataFactory());
+
+ }
+ catch (AxisException& e)
+ {
+ throw ServiceRuntimeException("AxisException", ServiceRuntimeException::Error, e.what());
+ }
+
+
+ LOGEXIT(1, "WSServiceWrapper::invoke");
+
+}
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.h b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.h
new file mode 100644
index 0000000000..7ae765950c
--- /dev/null
+++ b/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_ws_wsservicewrapper_h
+#define tuscany_sca_ws_wsservicewrapper_h
+
+#include "osoa/sca/export.h"
+
+#include "tuscany/sca/core/ExternalServiceWrapper.h"
+#include "tuscany/sca/model/ExternalService.h"
+#include "tuscany/sca/core/Operation.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace ws
+ {
+
+ class SCA_API WSServiceWrapper : public tuscany::sca::ExternalServiceWrapper
+ {
+ public:
+ WSServiceWrapper(tuscany::sca::model::WireTarget* target);
+ virtual ~WSServiceWrapper();
+
+ virtual void invoke(Operation& operation);
+ };
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_ws_wsservicewrapper_h