From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../cpp/src/tuscany/sca/cpp/CPPExtension.cpp | 72 +++++++ .../cpp/src/tuscany/sca/cpp/CPPExtension.h | 57 ++++++ .../tuscany/sca/cpp/CPPImplementationExtension.cpp | 101 ++++++++++ .../tuscany/sca/cpp/CPPImplementationExtension.h | 74 ++++++++ .../src/tuscany/sca/cpp/CPPInterfaceExtension.cpp | 71 +++++++ .../src/tuscany/sca/cpp/CPPInterfaceExtension.h | 74 ++++++++ .../cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp | 192 +++++++++++++++++++ .../cpp/src/tuscany/sca/cpp/CPPServiceProxy.h | 117 ++++++++++++ .../cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp | 198 ++++++++++++++++++++ .../cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h | 160 ++++++++++++++++ .../src/tuscany/sca/cpp/ComponentContextImpl.cpp | 208 +++++++++++++++++++++ .../cpp/src/tuscany/sca/cpp/ComponentContextImpl.h | 119 ++++++++++++ .../src/tuscany/sca/cpp/CompositeContextImpl.cpp | 128 +++++++++++++ .../cpp/src/tuscany/sca/cpp/CompositeContextImpl.h | 89 +++++++++ .../cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp | 83 ++++++++ .../cpp/src/tuscany/sca/cpp/TuscanyRuntime.h | 77 ++++++++ .../tuscany/sca/cpp/model/CPPImplementation.cpp | 85 +++++++++ .../src/tuscany/sca/cpp/model/CPPImplementation.h | 148 +++++++++++++++ .../cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp | 63 +++++++ .../cpp/src/tuscany/sca/cpp/model/CPPInterface.h | 117 ++++++++++++ .../tuscany/sca/cpp/model/CPPReferenceBinding.cpp | 61 ++++++ .../tuscany/sca/cpp/model/CPPReferenceBinding.h | 96 ++++++++++ .../tuscany/sca/cpp/model/CPPServiceBinding.cpp | 54 ++++++ .../src/tuscany/sca/cpp/model/CPPServiceBinding.h | 81 ++++++++ 24 files changed, 2525 insertions(+) create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp create mode 100644 tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h (limited to 'tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany') diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp new file mode 100644 index 0000000000..74a30fb772 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/cpp/CPPExtension.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/cpp/CPPImplementationExtension.h" +#include "tuscany/sca/cpp/CPPInterfaceExtension.h" + + +extern "C" +{ +#if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) +#endif + void tuscany_sca_cpp_initialize() + { + tuscany::sca::cpp::CPPExtension::initialize(); + } +} + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + // =================================================================== + // Constructor for the CPPExtension class. + // =================================================================== + CPPExtension::CPPExtension() + { + logentry(); + } + + // =================================================================== + // Destructor for the CPPExtension class. + // =================================================================== + CPPExtension::~CPPExtension() + { + logentry(); + } + + void CPPExtension::initialize() + { + logentry(); + SCARuntime* runtime = SCARuntime::getCurrentRuntime(); + runtime->registerImplementationExtension(new CPPImplementationExtension()); + runtime->registerInterfaceExtension(new CPPInterfaceExtension()); + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h new file mode 100644 index 0000000000..d6c872629d --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_cppextension_h +#define tuscany_sca_cpp_cppextension_h + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + class CPPExtension + { + public: + /** + * Default constructor + */ + CPPExtension(); + + /** + * Destructor + */ + virtual ~CPPExtension(); + + static void initialize(); + + private: + + }; + + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppextension_h + diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp new file mode 100644 index 0000000000..b5312ab243 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/cpp/CPPImplementationExtension.h" +#include "tuscany/sca/cpp/model/CPPImplementation.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" + +using namespace std; +using namespace commonj::sdo; +using namespace tuscany::sca::util; +using namespace tuscany::sca::model; + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + // =================================================================== + // Constructor for the CPPImplementationExtension class. + // =================================================================== + CPPImplementationExtension::CPPImplementationExtension() + { + logentry(); + } + + // =================================================================== + // Destructor for the CPPImplementationExtension class. + // =================================================================== + CPPImplementationExtension::~CPPImplementationExtension() + { + logentry(); + } + + const string CPPImplementationExtension::extensionName("cpp"); + const string CPPImplementationExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPImplementation"); + + // =================================================================== + // loadModelElement - load the info from implementation.cpp + // =================================================================== + ComponentType* CPPImplementationExtension::getImplementation(Composite *composite, DataObjectPtr scdlImplementation) + { + logentry(); + string library = scdlImplementation->getCString("library"); + string header = scdlImplementation->getCString("header"); + string className = scdlImplementation->getCString("class"); + string scopeName = scdlImplementation->getCString("scope"); + + CPPImplementation::Scope scope; + if (scopeName == "composite") + { + scope = CPPImplementation::COMPOSITE; + } + else + { + scope = CPPImplementation::STATELESS; + } + + string headerPath; + string headerStub; + + // Separate any path element + Utils::rTokeniseString("/", header, headerPath, headerStub); + if (headerPath != "") + { + headerPath += "/"; + } + + // Determine the header stub name + string tmp; + Utils::rTokeniseString(".h", headerStub, headerStub, tmp); + + CPPImplementation* cppImpl = new CPPImplementation( + composite, library, header, headerPath, headerStub, className, scope); + + return cppImpl; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h new file mode 100644 index 0000000000..8eb7b88691 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_cppimplementationextension_h +#define tuscany_sca_cpp_cppimplementationextension_h + +#include "tuscany/sca/extension/ImplementationExtension.h" + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + class CPPImplementationExtension : public ImplementationExtension + { + public: + /** + * Default constructor + */ + CPPImplementationExtension(); + + /** + * Destructor + */ + virtual ~CPPImplementationExtension(); + + /** + * return the name of the extension + */ + virtual const std::string& getExtensionName() {return extensionName;} + + /** + * return the QName of schema type for this implementation extension + * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.cpp") + */ + virtual const std::string& getExtensionTypeQName() {return typeQName;} + + virtual tuscany::sca::model::ComponentType* getImplementation( + tuscany::sca::model::Composite* composite, + commonj::sdo::DataObjectPtr scdlImplementation); + + private: + static const std::string extensionName; + static const std::string typeQName; + + }; + + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppimplementationextension_h + diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp new file mode 100644 index 0000000000..7bb84a7673 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/cpp/CPPInterfaceExtension.h" +#include "tuscany/sca/cpp/model/CPPInterface.h" +#include "tuscany/sca/util/Logging.h" + +using namespace std; +using namespace commonj::sdo; +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + // =================================================================== + // Constructor for the CPPInterfaceExtension class. + // =================================================================== + CPPInterfaceExtension::CPPInterfaceExtension() + { + logentry(); + } + + // =================================================================== + // Destructor for the CPPInterfaceExtension class. + // =================================================================== + CPPInterfaceExtension::~CPPInterfaceExtension() + { + logentry(); + } + + const string CPPInterfaceExtension::extensionName("cpp"); + const string CPPInterfaceExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPInterface"); + + // =================================================================== + // loadModelElement - load the info from interface.cpp + // =================================================================== + tuscany::sca::model::Interface* CPPInterfaceExtension::getInterface(Composite* composite, DataObjectPtr scdlInterface) + { + logentry(); + + string header = scdlInterface->getCString("header"); + string className = scdlInterface->getCString("class"); + bool remotable = scdlInterface->getBoolean("remotable"); + + return new CPPInterface(header, className, remotable, false); + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h new file mode 100644 index 0000000000..04ac9f6970 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_cppinterfaceextension_h +#define tuscany_sca_cpp_cppinterfaceextension_h + +#include "tuscany/sca/extension/InterfaceExtension.h" + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + class CPPInterfaceExtension : public InterfaceExtension + { + public: + /** + * Default constructor + */ + CPPInterfaceExtension(); + + /** + * Destructor + */ + virtual ~CPPInterfaceExtension(); + + /** + * return the name of the extension + */ + virtual const std::string& getExtensionName() {return extensionName;} + + /** + * return the QName of schema type for this interface extension + * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp") + */ + virtual const std::string& getExtensionTypeQName() {return typeQName;} + + virtual tuscany::sca::model::Interface* getInterface( + tuscany::sca::model::Composite* composite, + commonj::sdo::DataObjectPtr scdlInterface); + + private: + static const std::string extensionName; + static const std::string typeQName; + + }; + + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppinterfaceextension_h + diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp new file mode 100644 index 0000000000..cc45ea9fb8 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp @@ -0,0 +1,192 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "osoa/sca/ServiceRuntimeException.h" + +#include "tuscany/sca/cpp/CPPServiceProxy.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/model/ReferenceType.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/ServiceType.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/ComponentType.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/ServiceBinding.h" +#include "tuscany/sca/cpp/model/CPPImplementation.h" +#include "tuscany/sca/cpp/model/CPPReferenceBinding.h" + +using namespace std; +using namespace osoa::sca; +using namespace tuscany::sca::model; +using namespace tuscany::sca::util; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // ============================ + // Constructor: Create a proxy + // ============================ + CPPServiceProxy::CPPServiceProxy(Reference* reference) + : ServiceProxy(reference) + { + logentry(); + + // ---------------------- + // Get the component + // ---------------------- + Component* component = reference->getComponent(); + string name = reference->getType()->getName(); + + // Get the service wrapper + CPPReferenceBinding* referenceBinding = (CPPReferenceBinding*)reference->getBinding(); + + ServiceWrapper* serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper(); + + createProxy(component, name, serviceWrapper); + } + + // ============================ + // Constructor: Create a proxy + // ============================ + CPPServiceProxy::CPPServiceProxy(Service* service) + : ServiceProxy(0) + { + logentry(); + + // ---------------------- + // Get the component + // ---------------------- + Component* component = service->getComponent(); + string name = service->getType()->getName(); + + // Get the service wrapper + ServiceWrapper* serviceWrapper = service->getBinding()->getServiceWrapper(); + + createProxy(component, name, serviceWrapper); + } + + void CPPServiceProxy::createProxy(Component* component, const string& name, ServiceWrapper* serviceWrapper) + { + logentry(); + + ComponentType* componentType = component->getType(); + if (!componentType) + { + string msg = "Component " + component->getName() + " has no implementation defined"; + throwException(ServiceNotFoundException, msg.c_str()); + } + + // If we got here we have a CPP implementation + CPPImplementation* impl = (CPPImplementation *)componentType; + + // ---------------------------------------------------- + // Get implementation dll name and service factory name + // ---------------------------------------------------- + string library = impl->getLibrary(); + string headerStub = impl->getHeaderStub(); + + string fullLibraryName = component->getComposite()->getRoot() + "/" + library; + string proxyFactoryName = headerStub + "_" + name + "_Proxy_Factory"; + string proxyDestructorName = headerStub + "_" + name + "_Proxy_Destructor"; + typedef void* (* PROXYFACTORY) (ServiceWrapper*); + + // ------------ + // Load the dll + // ------------ + proxyLibrary = Library(fullLibraryName); + + // ------------------------- + // Locate the factory method + // ------------------------- + PROXYFACTORY proxyFactory = (PROXYFACTORY)proxyLibrary.getSymbol(proxyFactoryName); + if (!proxyFactory) + { + logerror("Unable to locate %s in library %s", + proxyFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Unable to locate " + proxyFactoryName + " in library " + fullLibraryName; + throwException(ServiceNotFoundException, msg.c_str()); + } + + // ----------------------------------- + // Now create an instance of the proxy + // ----------------------------------- + void* proxy = proxyFactory(serviceWrapper); + if (!proxy) + { + logerror("Factory method %s in library %s returned null", + proxyFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Factory method " + proxyFactoryName + " in library " + fullLibraryName + " returned null"; + throwException(ServiceNotFoundException, msg.c_str()); + } + else + { + proxies.push_back(proxy); + } + + // ------------------------- + // Get the destructor method + // ------------------------- + destructor = (PROXYDESTRUCTOR)proxyLibrary.getSymbol(proxyDestructorName); + } + + // ========== + // Destructor + // ========== + CPPServiceProxy::~CPPServiceProxy() + { + logentry(); + + // Delete the proxies + if (destructor != NULL && proxies.size() != 0) + { + destructor(*proxies.begin()); + } + } + + CPPServiceProxy::PROXIES CPPServiceProxy::getProxies() + { + return proxies; + } + + void* CPPServiceProxy::getProxy() + { + logentry(); + + if (proxies.size() != 0) + { + return *proxies.begin(); + } + else + { + return NULL; + } + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h new file mode 100644 index 0000000000..8406e9bc44 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + + +#ifndef tuscany_sca_cpp_cppserviceproxy_h +#define tuscany_sca_cpp_cppserviceproxy_h + +#include "osoa/sca/export.h" + +#include "tuscany/sca/core/ServiceProxy.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/util/Library.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/model/Service.h" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + /** + * Holds a proxy for a given component and reference. + * The proxy which is held inside a ServiceProxy will be specific to the component + * and reference and will have been code generated and be contained in a dll + * created by a developer of an SCA application. + */ + class CPPServiceProxy : public ServiceProxy + { + public: + /** + * Create a new service proxy for a reference. The proxy will contain a pointer to + * the target ServiceWrapper. + * @param reference The reference on the source component. + * @param target The wrapper of the service which is wired to this reference. + */ + CPPServiceProxy(tuscany::sca::model::Reference* reference); + + /** + * Create a new service proxy for a service. The proxy will contain a pointer to + * the target ServiceWrapper. + * @param reference The service on the target component. + * @param target The wrapper of the target service. + */ + CPPServiceProxy(tuscany::sca::model::Service* service); + + /** + * Destructor. + */ + virtual ~CPPServiceProxy(); + + /** + * Return an instance of the proxy created for this particular component and reference. + * @return The proxy. + */ + virtual void* getProxy(); + + /** + * Return the proxies created for this particular component and reference. + * @return The proxies. + */ + typedef std::list PROXIES; + virtual PROXIES getProxies(); + + private: + + /** + * Create the proxy + */ + void createProxy(tuscany::sca::model::Component* component, + const std::string& name, + ServiceWrapper* serviceWrapper); + + /** + * Holds the instances of the code generated proxies. + */ + PROXIES proxies; + + /** + * A function pointer to the destructor of the proxy. + */ + typedef void (* PROXYDESTRUCTOR) (void*); + PROXYDESTRUCTOR destructor; + + /** + * The library which contains the code for the proxy. + */ + tuscany::sca::util::Library proxyLibrary; + + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppserviceproxy_h diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp new file mode 100644 index 0000000000..fbf8281178 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp @@ -0,0 +1,198 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "osoa/sca/ServiceRuntimeException.h" + +#include "tuscany/sca/cpp/CPPServiceWrapper.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/Library.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/ServiceType.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/cpp/model/CPPImplementation.h" +#include "tuscany/sca/model/Interface.h" + +using namespace std; +using namespace osoa::sca; +using namespace tuscany::sca::model; +using namespace tuscany::sca::util; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // =================== + // Static data members + // =================== + void* CPPServiceWrapper::staticImpl = 0; + + // =========== + // Constructor + // =========== + CPPServiceWrapper::CPPServiceWrapper(Service* service) + : ServiceWrapper(service) + { + logentry(); + + component = service->getComponent(); + interf = service->getType()->getInterface(); + implementation = (CPPImplementation*)component->getType(); + } + + // ========== + // Destructor + // ========== + CPPServiceWrapper::~CPPServiceWrapper() + { + logentry(); + } + + + // ====================================================================== + // getImplementation: get an implementation for this scope + // ====================================================================== + void* CPPServiceWrapper::getImplementation() + { + logentry(); + if (implementation->getScope() == CPPImplementation::COMPOSITE) + { + if (!staticImpl) + { + staticImpl = newImplementation(); + } + return staticImpl; + } + else // (scope == CPPInterface::STATELESS) + { + return newImplementation(); + } + } + + // ====================================================================== + // releaseImplementation: release the implementation for this scope + // ====================================================================== + void CPPServiceWrapper::releaseImplementation() + { + logentry(); + if (implementation->getScope() == CPPImplementation::STATELESS) + { + deleteImplementation(); + } + } + + // ====================================================================== + // invoke: wrapper call to service with setting the component context + // ====================================================================== + void CPPServiceWrapper::invoke(Operation& operation) + { + logentry(); + + SCARuntime* runtime = SCARuntime::getCurrentRuntime(); + runtime->setCurrentComponent(component); + + try + { + invokeService(operation); + } + catch (...) + { + runtime->unsetCurrentComponent(); + throw; + } + runtime->unsetCurrentComponent(); + } + + void CPPServiceWrapper::setLibrary(Library* lib) + { + wrapperLibrary = lib; + } + + // ====================================================================== + // getServiceWrapper: create a wrapper for the target ComponentService + // ====================================================================== + CPPServiceWrapper* CPPServiceWrapper::getServiceWrapper(Service* service) + { + logentry(); + + CPPServiceWrapper* serviceWrapper = 0; + + // ----------------------------------------------- + // Get the implementation for the target component + // ----------------------------------------------- + Component* component = service->getComponent(); + CPPImplementation* impl = (CPPImplementation*)component->getType(); + if (!impl) + { + string msg = "Component " + component->getName() + " has no implementation defined"; + throwException(ServiceNotFoundException, msg.c_str()); + } + + // ---------------------------------------------------- + // Get implementation dll name and wrapper factory name + // ---------------------------------------------------- + string libraryName = impl->getLibrary(); + string wrapperFactoryName = impl->getHeaderStub() + + "_" + service->getType()->getName() + "_Wrapper_Factory"; + + // ------------ + // Load the dll + // ------------ + string fullLibraryName = component->getComposite()->getRoot() + "/" + libraryName; + typedef CPPServiceWrapper* (* WRAPPERFACTORY) (Service*); + Library* wrapperLib = new Library(fullLibraryName); + + // ------------------------- + // Locate the factory method + // ------------------------- + WRAPPERFACTORY wrapperFactory = (WRAPPERFACTORY)wrapperLib->getSymbol(wrapperFactoryName); + if (!wrapperFactory) + { + logerror("Unable to locate %s in library %s", + wrapperFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Unable to locate " + wrapperFactoryName + " in library " + fullLibraryName; + throwException(ServiceNotFoundException, msg.c_str()); + } + + // ------------------------------------- + // Now create an instance of the wrapper + // ------------------------------------- + serviceWrapper = wrapperFactory(service); + if (!serviceWrapper) + { + logerror("Factory method %s in library %s returned null", + wrapperFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Factory method " + wrapperFactoryName + " in library " + fullLibraryName + " returned null"; + throwException(ServiceNotFoundException, msg.c_str()); + } + serviceWrapper->setLibrary(wrapperLib); + + return serviceWrapper; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h new file mode 100644 index 0000000000..e8111b6423 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h @@ -0,0 +1,160 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_cppservicewrapper_h +#define tuscany_sca_cpp_cppservicewrapper_h + +#include "osoa/sca/export.h" + +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/core/Operation.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Interface.h" +#include "tuscany/sca/cpp/model/CPPImplementation.h" +#include "tuscany/sca/util/Library.h" + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + /** + * Wraps the service on a component implementation. + * This abstract class is extended by generated code which provides + * the implementation of some of the methods. + * An instance of this class wraps the actual component implementation which + * has been written by a developer of an SCA application. + */ + class SCA_CPP_API CPPServiceWrapper : public ServiceWrapper + { + public: + /** + * Factory method to create a new CPPServiceWrapper for a given target + * service. This method will provide all the loading of dlls required to + * create the target component. + * @param target The service on the component for which this wrapper is to be + * created. + * @return A wrapper that references the given target. + */ + static CPPServiceWrapper* getServiceWrapper(tuscany::sca::model::Service* service); + + /** + * Constructor. + * @param target The component service to which this wrapper refers. + */ + CPPServiceWrapper(tuscany::sca::model::Service* service); + + /** + * Destructor. + */ + virtual ~CPPServiceWrapper(); + + /** + * All business method calls to the target component go through the invoke method. + * @param operation The details of the method, paramaters and return value for the + * business method to be called on the target component. + */ + virtual void invoke(Operation& operation); + + /** + * Return the loaded shared library for the target component. + */ + tuscany::sca::util::Library* getLibrary() const { return wrapperLibrary; } + + protected: + + /** + * Delegated method to invoke the correct method on the target component. + * Implemented by the subtype. + */ + virtual void invokeService(Operation& operation) = 0; + + /** + * Delegated method to create a new component implementation. + * Implemented by the subtype. + * @return A pointer to an instance of the component implementation class. + */ + virtual void* newImplementation() = 0; + + /** + * Delegated method to delete the current instance of the component + * implementation. + * Implemented by the subtype. + */ + virtual void deleteImplementation() = 0; + + /** + * Return the current instance of the component implementation. + * @return A pointer to an instance of the component implementation class. + */ + virtual void* getImplementation(); + + /** + * Indicates that the current instance of the component implementation + * has been finished with. + * Will call CPPServiceWrapper#deleteImplementation if the + * implementation is stateless (so that a new instance is returned + * for each call). + */ + virtual void releaseImplementation(); + + private: + /** + * Holds an implementation instance if the scope is set to composite. + */ + static void* staticImpl; + + /** + * The component to which this wrapper refers. + */ + tuscany::sca::model::Component* component; + + /** + * A pointer to the interface which the service exposes. + */ + tuscany::sca::model::Interface* interf; + + /** + * The component implementation + */ + CPPImplementation* implementation; + + /** + * Pointer to the loaded library which contains the component + * implementation. + */ + tuscany::sca::util::Library* wrapperLibrary; + + /** + * Set the loaded library which contains the component + * implementation. + * @param lib The library. + */ + void setLibrary(tuscany::sca::util::Library* lib); + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppservicewrapper_h diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp new file mode 100644 index 0000000000..3de0cb968c --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp @@ -0,0 +1,208 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "osoa/sca/ServiceRuntimeException.h" + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/cpp/ComponentContextImpl.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/ReferenceBinding.h" +#include "tuscany/sca/model/ReferenceType.h" +#include "tuscany/sca/model/ServiceBinding.h" + +using namespace std; +using namespace osoa::sca; +using namespace commonj::sdo; +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // =========== + // Constructor + // =========== + ComponentContextImpl::ComponentContextImpl(Component* comp) + : ComponentContext(0), component(comp) + { + logentry(); + } + + // ========== + // Destructor + // ========== + ComponentContextImpl::~ComponentContextImpl() + { + logentry(); + } + + + // ========================================================================== + // getServices: return a list of Proxies for services wired to this reference + // ========================================================================== + std::list ComponentContextImpl::getServices(const std::string& referenceName) + { + logentry(); + try + { + // -------------------------------------------------------------- + // locate reference in the current component and determine target + // -------------------------------------------------------------- + Reference* reference = component->findReference(referenceName); + if (!reference) + { + string message = "Reference not defined: "; + message = message + referenceName; + throwException(ServiceNotFoundException, message.c_str()); + } + + // Get a service proxy from the binding configured on the reference + CPPServiceProxy* serviceProxy = (CPPServiceProxy*)reference->getBinding()->getServiceProxy(); + if (serviceProxy == NULL) + { + string message = "Reference "; + message = message + referenceName + " not wired"; + throwException(ServiceNotFoundException, message.c_str()); + } + + return serviceProxy->getProxies(); + } + catch (ServiceRuntimeException&) + { + throw; + } + catch (TuscanyRuntimeException& e) + { + throwException(ServiceRuntimeException, e); + } + + } // End getServices() + + + // =================================================================== + // getService: return a Proxy for the services wired to this reference + // =================================================================== + void* ComponentContextImpl::getService(const std::string& referenceName) + { + logentry(); + try + { + // -------------------------------------------------------------- + // locate reference in the current component and determine target + // -------------------------------------------------------------- + Reference* reference = component->findReference(referenceName); + if (!reference) + { + string message = "Reference not defined: "; + message = message + referenceName; + throwException(ServiceNotFoundException, message.c_str()); + } + + // -------------------- + // Validate the request + // -------------------- + switch (reference->getType()->getMultiplicity()) + { + case ReferenceType::ZERO_MANY: + case ReferenceType::ONE_MANY: + { + string message = "getService() called for reference with multiplicity >1 :"; + message = message + referenceName; + throwException(ServiceNotFoundException, message.c_str()); + } + default: + { + } + } // end switch + + // Get a service proxy from the binding configured on the reference + CPPServiceProxy* serviceProxy = (CPPServiceProxy*)reference->getBinding()->getServiceProxy(); + if (serviceProxy == NULL) + { + string message = "Reference "; + message = message + referenceName + " not wired"; + throwException(ServiceNotFoundException, message.c_str()); + } + + void* service = serviceProxy->getProxy(); + + return service; + } + catch (ServiceRuntimeException&) + { + throw; + } + catch (TuscanyRuntimeException& e) + { + throwException(ServiceRuntimeException, e); + } + + } // End getService() + + // ============================================== + // getProperties: return the component properties + // ============================================== + DataObjectPtr ComponentContextImpl::getProperties() + { + logentry(); + try + { + DataObjectPtr properties = component->getProperties(); + return properties; + } + catch (ServiceRuntimeException&) + { + throw; + } + catch (TuscanyRuntimeException& e) + { + throwException(ServiceRuntimeException, e); + } + } + + // ============================================== + // getDataFactory: return the data factory for the composite in which + // this component resides + // ============================================== + commonj::sdo::DataFactoryPtr ComponentContextImpl::getDataFactory() + { + logentry(); + try + { + commonj::sdo::DataFactoryPtr dataFactory = component->getComposite()->getDataFactory(); + return dataFactory; + } + catch (ServiceRuntimeException&) + { + throw; + } + catch (TuscanyRuntimeException& e) + { + throwException(ServiceRuntimeException, e); + } + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h new file mode 100644 index 0000000000..412c276d8c --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_componentcontextimpl_h +#define tuscany_sca_cpp_componentcontextimpl_h + +#include "osoa/sca/ComponentContext.h" + +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/cpp/CPPServiceProxy.h" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + /** + * Contains the actual implementation of a ComponentContext interface. + */ + class ComponentContextImpl : public osoa::sca::ComponentContext + { + + public: + /** + * Constructor that takes a Component which represents the runtime + * model for this context. + */ + ComponentContextImpl(tuscany::sca::model::Component* component); + + /** + * Default constructor. + */ + virtual ~ComponentContextImpl(); + + /** + * See ComponentContext. + */ + virtual void* getService(const std::string& referenceName); + + /** + * See ComponentContext. + */ + virtual std::list getServices(const std::string& referenceName); + + /** + * See ComponentContext. + */ + virtual commonj::sdo::DataObjectPtr getProperties(); + + /** + * See ComponentContext. + */ + virtual commonj::sdo::DataFactoryPtr getDataFactory(); + + /** + * Returns the contained Component. + * @return The Component to which this context refers. + */ + virtual tuscany::sca::model::Component* getComponent() {return component;} + + private: + ComponentContextImpl(const ComponentContextImpl&); + ComponentContextImpl& operator=(const ComponentContextImpl&); + + /** + * Pointer to the runtime model Component to which this + * context refers. + */ + tuscany::sca::model::Component* component; + + /** + * Helper method to return a proxy to a service. + * @param serviceReference The source reference. + * @param target The target to which this source reference is wired. + * @return A pointer to an object which can be cast to the business + * class representing the target. + */ + void* getServiceProxy( + tuscany::sca::model::Reference* serviceReference, + tuscany::sca::model::Service* target); + + /** + * Helper method to return a wrapper for a target service. + * @param target The target for which this wrapper is to be created. + * @return The service wrapper. + */ + ServiceWrapper* getServiceWrapper(tuscany::sca::model::Service* target); + + }; + + } // End namespaca cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_componentcontextimpl_h diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp new file mode 100644 index 0000000000..ae8183231e --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "commonj/sdo/SDO.h" + +#include "osoa/sca/ServiceRuntimeException.h" + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/cpp/CompositeContextImpl.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/ServiceBinding.h" +#include "tuscany/sca/model/ServiceType.h" +#include "tuscany/sca/core/ServiceProxy.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/cpp/CPPServiceProxy.h" + +using namespace std; +using namespace commonj::sdo; +using namespace osoa::sca; +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // =========== + // Constructor + // =========== + CompositeContextImpl::CompositeContextImpl(Component* component) + : CompositeContext(0), component(component), composite((Composite*)component->getType()) + { + logentry(); + } + + // ========== + // Destructor + // ========== + CompositeContextImpl::~CompositeContextImpl() + { + logentry(); + } + + // =========================================================================== + // locateService: return a proxy connected to a wrapper for the target service + // =========================================================================== + void* CompositeContextImpl::locateService(const std::string& serviceName) + { + logentry(); + try + { + // ---------------------------- + // Locate the component service + // ---------------------------- + Service* service = composite->findComponentService(serviceName); + string msg; + if (!service) + { + msg = "Service not found: "; + msg = msg + serviceName; + throwException(ServiceNotFoundException, msg.c_str()); + } + + // ---------------------------- + // Get a Proxy for this service + // ---------------------------- + + // The locate service API is used from CPP clients so we are using + // our default service proxy here + CPPServiceProxy* serviceProxy = new CPPServiceProxy(service); + return serviceProxy->getProxy(); + } + catch (ServiceRuntimeException&) + { + throw; + } + catch (TuscanyRuntimeException& e) + { + throwException(ServiceRuntimeException, e); + } + } + + // ============================================== + // getDataFactory: return the data factory for the current composite + // ============================================== + DataFactoryPtr CompositeContextImpl::getDataFactory() + { + logentry(); + try + { + DataFactoryPtr dataFactory = composite->getDataFactory(); + return dataFactory; + } + catch (ServiceRuntimeException&) + { + throw; + } + catch (TuscanyRuntimeException& e) + { + throwException(ServiceRuntimeException, e); + } + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h new file mode 100644 index 0000000000..ed0bb8b51c --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_compositecontextimpl_h +#define tuscany_sca_cpp_compositecontextimpl_h + +#include "osoa/sca/CompositeContext.h" + +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/cpp/CPPServiceProxy.h" + +namespace tuscany +{ + namespace sca + { + + namespace cpp + { + + /** + * Contains the actual implementation of a CompositeContext interface. + */ + class CompositeContextImpl : public osoa::sca::CompositeContext + { + + public: + /** + * Constructor that takes a Composite which represents the runtime + * model for this context. + */ + CompositeContextImpl(tuscany::sca::model::Component* component); + + /** + * See CompositeContext#locateService. + */ + virtual void* locateService(const std::string& serviceName); + + /** + * See CompositeContext. + */ + virtual commonj::sdo::DataFactoryPtr getDataFactory(); + + /** + * Destructor. + */ + virtual ~CompositeContextImpl(); + + private: + CompositeContextImpl(const CompositeContextImpl&); + CompositeContextImpl& operator=(const CompositeContextImpl&); + + /** + * Pointer to the runtime model Composite object to which this + * context refers. + */ + tuscany::sca::model::Composite* composite; + + /** + * Pointer to the runtime model Component object to which this + * context refers. + */ + tuscany::sca::model::Component* component; + + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_compositecontextimpl_h diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp new file mode 100644 index 0000000000..f8aad90f7a --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/cpp/TuscanyRuntime.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/core/Exceptions.h" +#include "tuscany/sca/core/SCARuntime.h" + +using namespace std; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // =================================================================== + // Constructor for the TuscanyRuntime class. + // =================================================================== + TuscanyRuntime::TuscanyRuntime(const string& componentName, const string& root, const string& path) + { + logentry(); + loginfo("System root: %s", root.c_str()); + systemRoot = root; + loginfo("System path: %s", path.c_str()); + systemPath = path; + loginfo("Default component name: %s", componentName.c_str()); + defaultComponentName = componentName; + + runtime = new SCARuntime("", systemRoot, systemPath, "", defaultComponentName); + } + + // =================================================================== + // Destructor for the TuscanyRuntime class. + // =================================================================== + TuscanyRuntime::~TuscanyRuntime() + { + logentry(); + + delete (SCARuntime*)runtime; + } + + // =================================================================== + // Start the runtime. + // =================================================================== + void TuscanyRuntime::start() + { + logentry(); + SCARuntime::setCurrentRuntime((SCARuntime*)runtime); + } + + // =================================================================== + // Stop the runtime. + // =================================================================== + void TuscanyRuntime::stop() + { + logentry(); + SCARuntime::setCurrentRuntime(NULL); + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h new file mode 100644 index 0000000000..b4cf31220a --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_tuscanyruntime_h +#define tuscany_sca_cpp_tuscanyruntime_h + +#include + +#include "osoa/sca/export.h" + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + /** + * A singleton which represents the executing SCA runtime. + */ + class SCA_CPP_API TuscanyRuntime + { + public: + /** + * Default constructor + */ + TuscanyRuntime(const std::string& defaultComponentName = "", + const std::string& root = "", const std::string& path = ""); + + /** + * Destructor + */ + virtual ~TuscanyRuntime(); + + /** + * start the runtime + */ + void start(); + + /** + * stop the runtime + */ + void stop(); + + + private: + std::string systemRoot; + std::string systemPath; + std::string defaultComponentName; + + void* defaultComponent; + void* runtime; + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_tuscanyruntime_h diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp new file mode 100644 index 0000000000..9e5a227f01 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/cpp/model/CPPImplementation.h" +#include "tuscany/sca/cpp/model/CPPServiceBinding.h" +#include "tuscany/sca/cpp/model/CPPReferenceBinding.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/util/Utils.h" + +using namespace std; +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + + namespace cpp + { + + // Constructor + CPPImplementation::CPPImplementation(Composite* composite, const string& library, const string& header, + const string&headerPath, const string& headerStub, const string& className, Scope scope) + : ComponentType(composite, headerPath + headerStub), + library(library), header(header), headerPath(headerPath), + headerStub(headerStub), className(className), scope(scope) + { + } + + CPPImplementation::~CPPImplementation() + { + } + + void CPPImplementation::initializeComponent(Component* component) + { + ComponentType::initializeComponent(component); + + // Create CPP bindings for all the services + const Component::SERVICE_MAP& services = component->getServices(); + Component::SERVICE_MAP::const_iterator iter = services.begin(); + for (unsigned int i=0; i< services.size(); i++) + { + Service *service = iter->second; + CPPServiceBinding* binding = new CPPServiceBinding(service); + service->setBinding(binding); + iter++; + } + + // Create CPP bindings for all the references + const Component::REFERENCE_MAP& references = component->getReferences(); + Component::REFERENCE_MAP::const_iterator refiter = references.begin(); + for (unsigned int ri=0; ri< references.size(); ri++) + { + Reference *reference = refiter->second; + CPPReferenceBinding* binding = new CPPReferenceBinding(reference); + reference->setBinding(binding); + refiter++; + } + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h new file mode 100644 index 0000000000..11f487361d --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_model_cppimplementation_h +#define tuscany_sca_cpp_model_cppimplementation_h + +#include +#include + +#include "tuscany/sca/model/ComponentType.h" + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Holds information about an SCA implementation written in C++ + */ + class CPPImplementation : public tuscany::sca::model::ComponentType + { + + public: + /** + * Scope of the component implementation. + */ + enum Scope + { + COMPOSITE, + STATELESS + }; + + /** + * Constructor. + * @param dllName Name of the shared library. + * @param header Name of the header file that contains the class declaring the + * implementation class. + * @param className Name of the class in the header file (could be a blank string + * if this is not specified). + */ + CPPImplementation(tuscany::sca::model::Composite* composite, + const std::string& library, const std::string& header, const std::string&headerPath, + const std::string& headerStub, const std::string& className, Scope scope); + + /** + * Destructor + */ + virtual ~CPPImplementation(); + + /** + * Initialize a component of this type. + * @param component The component to initialize. + */ + virtual void initializeComponent(tuscany::sca::model::Component* component); + + /** + * Returns the name of the shared library. + * @return The name of the shared library. + */ + const std::string& getLibrary() const { return library; } + + /** + * Get the name of the header file. + * @return Name of the header file. + */ + const std::string& getHeader() const { return header; } + + /** + * Get the header file name without the extension. + * @return The name of the header file without any extension. + */ + const std::string& getHeaderStub() const { return headerStub; } + + /** + * Get the header path. + * @return The pathe element of the header. + */ + const std::string& getHeaderPath() const { return headerPath; } + + /** + * Get the name of the class. + * @return The class name if specified. + */ + const std::string& getClass() const { return className; } + + /** + * Returns the implementation scope + */ + Scope getScope() { return scope; } + + private: + + /** + * Name of the shared library. + */ + std::string library; + + /** + * Name of the header file describing the interface. + */ + std::string header; + + /** + * Name of the header file without the extension. + */ + std::string headerStub; + + /** + * Path element of the header. + */ + std::string headerPath; + + /** + * Name of the class in the header file declaring the implementation. + * May be an empty string if not set in the SCDL file. + */ + std::string className; + + /** + * Scope of the implementation + */ + Scope scope; + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_model_cppimplementation_h diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp new file mode 100644 index 0000000000..2322d1bdf5 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/cpp/model/CPPInterface.h" + +using namespace std; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + const string CPPInterface::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPInterface"); + + // Constructor + CPPInterface::CPPInterface( + const string& header, + const string& className, + bool remotable, + bool conversational) + : Interface(remotable, conversational), header(header), className(className) + { + string::size_type dot = header.rfind(".h"); // this will also find .hpp + if (dot != string::npos) + { + headerStub = header.substr(0, dot); + } + else + { + headerStub = header; + } + + } + + CPPInterface::~CPPInterface() + { + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h new file mode 100644 index 0000000000..fdbf314d3d --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_model_cppinterface_h +#define tuscany_sca_cpp_model_cppinterface_h + +#include + +#include "tuscany/sca/model/Interface.h" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Holds information about an interface described using a C++ + * header file. + */ + class CPPInterface : public tuscany::sca::model::Interface + { + + public: + /** + * Constuctor. + * @param header Name of the header file containing the class that + * describes the interface. + * @param className Name of the class in the header file that + * describes the interface. + * @param scope The scope of the interface (stateless or composite). + * @param remotable True if the interface is remotable. + */ + CPPInterface( + const std::string& header, + const std::string& className, + bool remotable, + bool conversational); + + /** + * Destructor. + */ + virtual ~CPPInterface(); + + /** + * Get the name of the header file. + * @return The name of the header file containing the definition of the + * interface. + */ + const std::string& getHeader() { return header; } + + /** + * Return the name of the header file without the extension. + * @return Header file name without any extension. + */ + const std::string& getHeaderStub() { return headerStub; } + + /** + * Get the name of the class. + * @return The name of the class defining the interface. + */ + const std::string& getClass() { return className; } + + /** + * return the QName of the schema type for this interface type + * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp") + */ + virtual const std::string& getInterfaceTypeQName() { return typeQName; }; + + private: + + /** + * Name of the header file containing the definition of the interface. + */ + std::string header; + + /** + * Name of the header file without the extension. + */ + std::string headerStub; + + /** + * Name of the class in the header file. + */ + std::string className; + + /** + * The QName of the schema type for this interface type. + */ + static const std::string typeQName; + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_model_cppinterface_h + diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp new file mode 100644 index 0000000000..ba20a1d5a0 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/cpp/model/CPPReferenceBinding.h" +#include "tuscany/sca/cpp/CPPServiceProxy.h" + +using namespace tuscany::sca::model; + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // Constructor + CPPReferenceBinding::CPPReferenceBinding(Reference* reference) + : ReferenceBinding(reference, ""), serviceProxy(NULL), targetServiceBinding(NULL) + { + } + + // Destructor + CPPReferenceBinding::~CPPReferenceBinding() + { + } + + ServiceProxy* CPPReferenceBinding::getServiceProxy() + { + return serviceProxy; + } + + void CPPReferenceBinding::configure(ServiceBinding* binding) + { + targetServiceBinding = binding; + + serviceProxy = new CPPServiceProxy(getReference()); + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h new file mode 100644 index 0000000000..398417011f --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_model_cppreferencebinding_h +#define tuscany_sca_cpp_model_cppreferencebinding_h + +#include + +#include "tuscany/sca/model/ReferenceBinding.h" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Information about a CPP service binding for service or a reference. + */ + class CPPReferenceBinding : public tuscany::sca::model::ReferenceBinding + { + public: + + /** + * Constructor. + * @param uri The uri of the binding. + * @param port The definition of the port to which the entrypoint + * or external service is to be bound. This is of the form + * "namespace"#endpoint("service"/"port") + */ + CPPReferenceBinding(tuscany::sca::model::Reference* reference); + + /** + * Destructor. + */ + virtual ~CPPReferenceBinding(); + + /** + * Returns the type of binding. + */ + virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#CPPImplementationBinding"; }; + + /** + * Create a proxy representing the reference to the + * client component. + */ + virtual ServiceProxy* getServiceProxy(); + + /** + * Configure this binding from a service binding. + */ + virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding); + + /** + * Returns the target service binding. + */ + tuscany::sca::model::ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; }; + + private: + + /** + * The proxy representing the reference to the client + * component. + */ + ServiceProxy* serviceProxy; + + /** + * The service binding of the target + */ + tuscany::sca::model::ServiceBinding* targetServiceBinding; + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_model_cppreferencebinding_h diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp new file mode 100644 index 0000000000..45afea8375 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/cpp/model/CPPServiceBinding.h" +#include "tuscany/sca/cpp/CPPServiceWrapper.h" + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // Constructor + CPPServiceBinding::CPPServiceBinding(Service* service) + : ServiceBinding(service, "") + { + serviceWrapper = CPPServiceWrapper::getServiceWrapper(service); + } + + // Destructor + CPPServiceBinding::~CPPServiceBinding() + { + } + + ServiceWrapper* CPPServiceBinding::getServiceWrapper() + { + return (ServiceWrapper*)serviceWrapper; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h new file mode 100644 index 0000000000..13b88a84dd --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3-RC4/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_model_cppservicebinding_h +#define tuscany_sca_cpp_model_cppservicebinding_h + +#include + +#include "tuscany/sca/model/ServiceBinding.h" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Information about a CPP service binding for service or a reference. + */ + class CPPServiceBinding : public tuscany::sca::model::ServiceBinding + { + public: + + /** + * Constructor. + * @param uri The uri of the binding. + * @param port The definition of the port to which the entrypoint + * or external service is to be bound. This is of the form + * "namespace"#endpoint("service"/"port") + */ + CPPServiceBinding(tuscany::sca::model::Service* service); + + /** + * Destructor. + */ + virtual ~CPPServiceBinding(); + + /** + * Returns the type of binding. + */ + virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#CPPImplementationBinding"; }; + + /** + * Create a wrapper for the service configured by this + * binding. + */ + virtual ServiceWrapper* getServiceWrapper(); + + private: + + /** + * The wrapper for the service configured by this binding. + */ + ServiceWrapper* serviceWrapper; + + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_model_cppservicebinding_h -- cgit v1.2.3