summaryrefslogtreecommitdiffstats
path: root/sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/model')
-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
38 files changed, 5746 insertions, 0 deletions
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
+