From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/runtime/extensions/cpp/Makefile.am | 24 +++ .../sca/runtime/extensions/cpp/deploy.bat | 74 ++++++++ .../sca/runtime/extensions/cpp/src/Makefile.am | 48 +++++ .../cpp/src/osoa/sca/ComponentContext.cpp | 139 +++++++++++++++ .../extensions/cpp/src/osoa/sca/ComponentContext.h | 114 ++++++++++++ .../cpp/src/osoa/sca/CompositeContext.cpp | 113 ++++++++++++ .../extensions/cpp/src/osoa/sca/CompositeContext.h | 98 ++++++++++ .../cpp/src/osoa/sca/ServiceRuntimeException.h | 101 +++++++++++ .../runtime/extensions/cpp/src/osoa/sca/export.h | 42 +++++ .../sca/runtime/extensions/cpp/src/osoa/sca/sca.h | 31 ++++ .../cpp/src/tuscany/sca/cpp/CPPExtension.cpp | 74 ++++++++ .../cpp/src/tuscany/sca/cpp/CPPExtension.h | 57 ++++++ .../tuscany/sca/cpp/CPPImplementationExtension.cpp | 105 +++++++++++ .../tuscany/sca/cpp/CPPImplementationExtension.h | 72 ++++++++ .../src/tuscany/sca/cpp/CPPInterfaceExtension.cpp | 74 ++++++++ .../src/tuscany/sca/cpp/CPPInterfaceExtension.h | 72 ++++++++ .../cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp | 193 ++++++++++++++++++++ .../cpp/src/tuscany/sca/cpp/CPPServiceProxy.h | 116 ++++++++++++ .../cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp | 198 +++++++++++++++++++++ .../cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h | 162 +++++++++++++++++ .../src/tuscany/sca/cpp/ComponentContextImpl.cpp | 163 +++++++++++++++++ .../cpp/src/tuscany/sca/cpp/ComponentContextImpl.h | 123 +++++++++++++ .../src/tuscany/sca/cpp/CompositeContextImpl.cpp | 106 +++++++++++ .../cpp/src/tuscany/sca/cpp/CompositeContextImpl.h | 93 ++++++++++ .../tuscany/sca/cpp/model/CPPImplementation.cpp | 82 +++++++++ .../src/tuscany/sca/cpp/model/CPPImplementation.h | 150 ++++++++++++++++ .../cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp | 62 +++++++ .../cpp/src/tuscany/sca/cpp/model/CPPInterface.h | 121 +++++++++++++ .../tuscany/sca/cpp/model/CPPReferenceBinding.cpp | 59 ++++++ .../tuscany/sca/cpp/model/CPPReferenceBinding.h | 99 +++++++++++ .../tuscany/sca/cpp/model/CPPServiceBinding.cpp | 52 ++++++ .../src/tuscany/sca/cpp/model/CPPServiceBinding.h | 81 +++++++++ .../extensions/cpp/xsd/sca-implementation-cpp.xsd | 49 +++++ .../extensions/cpp/xsd/sca-interface-cpp.xsd | 43 +++++ 34 files changed, 3190 insertions(+) create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/deploy.bat create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/Makefile.am create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/export.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/sca.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd create mode 100644 tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd (limited to 'tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp') diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/Makefile.am b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/Makefile.am new file mode 100644 index 0000000000..7fac33118a --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/Makefile.am @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +SUBDIRS = src + +datadir=$(prefix)/extensions/cpp + +nobase_data_DATA = xsd/*.xsd + +EXTRA_DIST = xsd \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/deploy.bat b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/deploy.bat new file mode 100644 index 0000000000..e87f3b4dd6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/deploy.bat @@ -0,0 +1,74 @@ +@echo off + +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. + + +setlocal + +if . == .%1 ( +echo sca root not specified +goto usage +) +set rootdir=%1 +set deploydir=%rootdir%\deploy +set extdir=%deploydir%\extensions +set cppextdir=%extdir%\cpp +set srcdir=%rootdir%\runtime\extensions\cpp\src + +if . == .%2 ( +echo input directory not specified +goto usage +) +set inpath=%2 +echo %inpath% + + +if not exist %deploydir% mkdir %deploydir% +if not exist %extdir% mkdir %extdir% +if not exist %cppextdir% mkdir %cppextdir% +if not exist %cppextdir%\bin mkdir %cppextdir%\bin +if not exist %cppextdir%\lib mkdir %cppextdir%\lib +if not exist %cppextdir%\include mkdir %cppextdir%\include +if not exist %cppextdir%\include\osoa mkdir %cppextdir%\include\osoa +if not exist %cppextdir%\include\osoa\sca mkdir %cppextdir%\include\osoa\sca +if not exist %cppextdir%\include\tuscany mkdir %cppextdir%\include\tuscany +if not exist %cppextdir%\include\tuscany\sca mkdir %cppextdir%\include\tuscany\sca +if not exist %cppextdir%\include\tuscany\sca\cpp mkdir %cppextdir%\include\tuscany\sca\cpp +if not exist %cppextdir%\include\tuscany\sca\cpp\model mkdir %cppextdir%\include\tuscany\sca\cpp\model +if not exist %cppextdir%\xsd mkdir %cppextdir%\xsd + +del %cppextdir%\bin\tuscany_sca_cpp.* +del %cppextdir%\lib\*.lib + +copy %srcdir%\osoa\sca\*.h %cppextdir%\include\osoa\sca +copy %srcdir%\tuscany\sca\cpp\*.h %cppextdir%\include\tuscany\sca\cpp +copy %srcdir%\tuscany\sca\cpp\model\*.h %cppextdir%\include\tuscany\sca\cpp\model + +copy %srcdir%\..\xsd\*.* %cppextdir%\xsd + +copy %inpath%\tuscany_sca_cpp.lib %cppextdir%\lib +copy %inpath%\tuscany_sca_cpp.dll %cppextdir%\bin + +if exist %inpath%\tuscany_sca_cpp.pdb copy %inpath%\tuscany_sca_cpp.pdb %cppextdir%\bin + +goto end +:usage +echo Usage: deploy +:end + +endlocal diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/Makefile.am new file mode 100644 index 0000000000..c579dd2598 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/Makefile.am @@ -0,0 +1,48 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +libdir=$(prefix)/extensions/cpp/lib +lib_LTLIBRARIES = libtuscany_sca_cpp.la +includedir=$(prefix)/extensions/cpp/include +nobase_include_HEADERS = \ +osoa/sca/*.h \ +tuscany/sca/cpp/*.h \ +tuscany/sca/cpp/model/*.h + +libtuscany_sca_cpp_la_SOURCES = \ +osoa/sca/ComponentContext.cpp \ +osoa/sca/CompositeContext.cpp \ +tuscany/sca/cpp/ComponentContextImpl.cpp \ +tuscany/sca/cpp/CompositeContextImpl.cpp \ +tuscany/sca/cpp/CPPExtension.cpp \ +tuscany/sca/cpp/CPPImplementationExtension.cpp \ +tuscany/sca/cpp/CPPInterfaceExtension.cpp \ +tuscany/sca/cpp/CPPServiceProxy.cpp \ +tuscany/sca/cpp/CPPServiceWrapper.cpp \ +tuscany/sca/cpp/model/CPPImplementation.cpp \ +tuscany/sca/cpp/model/CPPInterface.cpp \ +tuscany/sca/cpp/model/CPPReferenceBinding.cpp \ +tuscany/sca/cpp/model/CPPServiceBinding.cpp + +libtuscany_sca_cpp_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \ + -L$(top_builddir)/runtime/core/src -ltuscany_sca + +INCLUDES = -Imodel -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include + +AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG + \ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp new file mode 100644 index 0000000000..bd0a6c39db --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "osoa/sca/ComponentContext.h" +#include "tuscany/sca/util/Logging.h" +#include "osoa/sca/ServiceRuntimeException.h" +#include "tuscany/sca/cpp/ComponentContextImpl.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "commonj/sdo/SDO.h" +using commonj::sdo::DataFactoryPtr; + +using namespace tuscany::sca; +using namespace tuscany::sca::cpp; + +namespace osoa +{ + namespace sca + { + + // ======================================================= + // getCurrent: create a context from the current component + // ======================================================= + ComponentContext ComponentContext::getCurrent() + { + LOGENTRY(1, "ComponentContext::getCurrent"); + Component* component = tuscany::sca::SCARuntime::getInstance()->getCurrentComponent(); + if (!component) + { + throw ComponentContextException("No current component"); + } + ComponentContext* cci = new ComponentContextImpl(component); + LOGEXIT(1, "ComponentContext::constructor"); + return ComponentContext(cci); + } + + // =========== + // Constructor + // =========== + ComponentContext::ComponentContext(ComponentContext* implementation) + : impl(implementation) + { + LOGENTRY(1, "ComponentContext::constructor"); + LOGEXIT(1, "ComponentContext::constructor"); + } + + // ========== + // Destructor + // ========== + ComponentContext::~ComponentContext() + { + LOGENTRY(1, "ComponentContext::destructor"); + delete impl; + LOGEXIT(1, "ComponentContext::destructor"); + } + + // =================================== + // Copy constructor: create a new impl + // =================================== + ComponentContext::ComponentContext(const ComponentContext& ctx) + { + Component* component = ((ComponentContextImpl*)impl)->getComponent(); + impl = new ComponentContextImpl(component); + } + + // ============================= + // operator= : create a new impl + // ============================= + ComponentContext& ComponentContext::operator=(const ComponentContext& ctx) + { + if (this != &ctx) + { + Component* component = ((ComponentContextImpl*)impl)->getComponent(); + impl = new ComponentContextImpl(component); + } + return *this; + } + + // ========== + // getService + // ========== + void* ComponentContext::getService(const std::string& referenceName) + { + LOGENTRY(1, "ComponentContext::getService"); + void* service = impl->getService(referenceName); + LOGEXIT(1, "ComponentContext::getService"); + return service; + } + + // =========== + // getServices + // =========== + std::list ComponentContext::getServices(const std::string& referenceName) + { + return impl->getServices(referenceName); + } + + // ============ + // getProperties + // ============= + DataObjectPtr ComponentContext::getProperties() + { + LOGENTRY(1, "ComponentContext::getProperties"); + DataObjectPtr properties = impl->getProperties(); + LOGEXIT(1, "ComponentContext::getProperties"); + return properties; + } + + // ============ + // getDataFactory + // ============= + DataFactoryPtr ComponentContext::getDataFactory() + { + LOGENTRY(1, "ComponentContext::getDataFactory"); + DataFactoryPtr dataFactory = impl->getDataFactory(); + LOGEXIT(1, "ComponentContext::getDataFactory"); + return dataFactory; + } + + + } // End namespace sca +} // End namespace osoa diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h new file mode 100644 index 0000000000..fae62062b2 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef osoa_sca_componentcontext_h +#define osoa_sca_componentcontext_h + +#include "osoa/sca/export.h" +#include "commonj/sdo/SDO.h" +#include +#include +namespace osoa +{ + namespace sca + { + + /** + * An SCA component implementation uses the ComponentContext class to + * retrieve information about the configured SCA component. + */ + class SCA_CPP_API ComponentContext + { + + public: + /** + * Return a new ComponentContext for the current Component. + */ + static ComponentContext getCurrent(); + + /** + * Resolve a reference name into a single configured service. + * If the component's reference is wired to more than one service + * then theis method will return an exception. + * @param referenceName The reference to be resolved. This must match + * the name of a reference configured in the component type file for + * this component. + */ + virtual void* getService(const std::string& referenceName); + + /** + * Resolve a reference name into a list of configured services. + * @param referenceName The reference to be resolved. This must match + * the name of a reference configured in the component type file for + * this component. + */ + virtual std::list getServices(const std::string& referenceName); + + /** + * Get the configured properties for the component. + * @return A data object representing all the properties that + * are configured for this component. + */ + virtual commonj::sdo::DataObjectPtr getProperties(); + + /** + * Get an SDO data factory which will allow the component to + * create data objects for all the types configured for this + * component. + * @return A data factory to be used by the component to create + * new data objects. + */ + virtual commonj::sdo::DataFactoryPtr getDataFactory(); + + /** + * Destructor + */ + virtual ~ComponentContext(); + + /** + * Constructor + */ + ComponentContext(const ComponentContext&); + + /** + * Copy operator + */ + ComponentContext& operator=(const ComponentContext&); + + /** + * Constructor to create an interface class from the contained + * implementation. + * @param implementation the actual implementation class + */ + ComponentContext(ComponentContext* implementation); + + private: + + /** + * Pointer to the class which provides the actual implementation. + */ + ComponentContext* impl; + + }; + } // End namespace sca +} // End namespace osoa + +#endif // osoa_sca_componentcontext_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp new file mode 100644 index 0000000000..43e5e6806e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "osoa/sca/CompositeContext.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/cpp/CompositeContextImpl.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "commonj/sdo/SDO.h" + +using commonj::sdo::DataFactoryPtr; +using namespace tuscany::sca; +using namespace tuscany::sca::cpp; + + +namespace osoa +{ + namespace sca + { + // =========== + // Constructor + // =========== + CompositeContext::CompositeContext(CompositeContext* implementation) + : impl(implementation) + { + } + + // =================================== + // Copy constructor: create a new impl + // =================================== + CompositeContext::CompositeContext(const CompositeContext& ctx) + { + impl = new CompositeContextImpl( + tuscany::sca::SCARuntime::getInstance()->getDefaultComponent()); + } + + // ============================= + // operator= : create a new impl + // ============================= + CompositeContext& CompositeContext::operator=(const CompositeContext& ctx) + { + if (this != &ctx) + { + impl = new CompositeContextImpl( + tuscany::sca::SCARuntime::getInstance()->getDefaultComponent()); + } + return *this; + } + + // ========== + // Destructor + // ========== + CompositeContext::~CompositeContext() + { + LOGENTRY(1, "CompositeContext::destructor"); + delete impl; + LOGEXIT(1, "CompositeContext::destructor"); + } + + // ==================================================== + // getCurrent: create a context from the current composite + // ==================================================== + CompositeContext CompositeContext::getCurrent() + { + LOGENTRY(1, "CompositeContext::getCurrent"); + CompositeContext* cci = new CompositeContextImpl( + tuscany::sca::SCARuntime::getInstance()->getDefaultComponent()); + LOGEXIT(1, "CompositeContext::getCurrent"); + return CompositeContext(cci); + } + + // ============= + // locateService + // ============= + void* CompositeContext::locateService(const std::string& serviceName) + { + LOGENTRY(1, "CompositeContext::locateService"); + void* sp = impl->locateService(serviceName); + LOGEXIT(1, "CompositeContext::locateService"); + return sp; + } + + // ============= + // getDataFactory + // ============= + DataFactoryPtr CompositeContext::getDataFactory() + { + LOGENTRY(1, "CompositeContext::getDataFactory"); + DataFactoryPtr df = impl->getDataFactory(); + LOGEXIT(1, "CompositeContext::getDataFactory"); + return df; + } + + + } // End namespace sca +} // End namespace osoa diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h new file mode 100644 index 0000000000..ac13ed875e --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef osoa_sca_compositecontext_h +#define osoa_sca_compositecontext_h + +#include "osoa/sca/export.h" +#include "commonj/sdo/SDO.h" + +namespace osoa +{ + namespace sca + { + /** + * An SCA component implementation, or a non-SCA client, uses the + * CompositeContext class to retrieve information about the configured + * SCA composite. + */ + class SCA_CPP_API CompositeContext + { + + public: + /** + * Return a new CompositeContext for the current Component. + */ + static CompositeContext getCurrent(); + + /** + * Resolve a service name into a single component service. + * @param serviceName The name of the service in the form + * "component name"/"service name". The service name is + * optional in the component has one service. + * @return A pointer to an object which can be cast to the + * business interface of the target service. + */ + virtual void* locateService(const std::string& serviceName); + + /** + * Get an SDO data factory which will allow the component to + * create data objects for all the types configured for this + * component. + * @return A data factory to be used by the component to create + * new data objects. + */ + virtual commonj::sdo::DataFactoryPtr getDataFactory(); + + /** + * Destructor. + */ + virtual ~CompositeContext(); + + /** + * Constructor + */ + CompositeContext(const CompositeContext&); + + /** + * Copy operator + */ + CompositeContext& operator=(const CompositeContext&); + + /** + * Constructor to create an interface class from the contained + * implementation. + * @param implementation The actual implementation class. + */ + CompositeContext(CompositeContext* implementation); + + private: + + /** + * Pointer to the class which provides the actual implementation. + */ + CompositeContext* impl; + + }; + } // End namespace sca +} // End namespace osoa + +#endif // osoa_sca_compositecontext_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h new file mode 100644 index 0000000000..7bf8800242 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef osoa_sca_serviceruntimeexception_h +#define osoa_sca_serviceruntimeexception_h + +#include "osoa/sca/export.h" + +#include "tuscany/sca/util/Exceptions.h" +using tuscany::sca::TuscanyRuntimeException; +namespace osoa +{ + namespace sca + { + /** + * Top level exception to represent all the exceptions that may be + * thrown by an SCA runtime implementation. + */ + class SCA_CPP_API ServiceRuntimeException : public TuscanyRuntimeException + { + public: + ServiceRuntimeException( + const char *name="ServiceRuntimeException", + severity_level sev=Severe, + const char* msg_text="") + : TuscanyRuntimeException(name, sev, msg_text) + { + } + }; // End ServiceRuntimeException class definition + + + /** + * A remotable service is currently unavailable. It is possible that a retry + * may resolve this exception. + */ + class SCA_CPP_API ServiceUnavailableException: public ServiceRuntimeException + { + public: + ServiceUnavailableException(const char* serviceName) + : ServiceRuntimeException("ServiceUnavailableException", Warning, + serviceName) + { + } + private: + }; // End ServiceUnavailableException class definition + + + /** + * The target of a wire cannot be found, or the reference has not been + * configured. + */ + class SCA_CPP_API ServiceNotFoundException: public ServiceRuntimeException + { + public: + ServiceNotFoundException(const char* msg) + : ServiceRuntimeException("ServiceNotFoundException", Error, + msg) + { + } + private: + }; // End ServiceNotFoundException class definition + + + /** + * There is no current component (for example, if a non-SCA component + * tries to get the current ComponentContext). + */ + class SCA_CPP_API ComponentContextException: public ServiceRuntimeException + { + public: + ComponentContextException(const char* msg) + : ServiceRuntimeException("ComponentContextException", Error, + msg) + { + } + private: + }; // End ComponentContextException class definition + + + } // End namespace sca +} // End namespace osoa + +#endif // osoa_sca_serviceruntimeexception_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/export.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/export.h new file mode 100644 index 0000000000..8a69913be4 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/export.h @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + + +#ifndef osoa_sca_export_h +#define osoa_sca_export_h + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) + +#ifdef TUSCANY_SCA_CPP_EXPORTS +#define SCA_CPP_API __declspec(dllexport) +#else +#define SCA_CPP_API __declspec(dllimport) +#endif + +#else +#include +#include +#include +#define SCA_CPP_API +#endif + +#endif // osoa_sca_export_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/sca.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/sca.h new file mode 100644 index 0000000000..6cce9453d7 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/osoa/sca/sca.h @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + + +#ifndef osoa_sca_sca_h +#define osoa_sca_sca_h + +#include "osoa/sca/export.h" +#include "osoa/sca/CompositeContext.h" +#include "osoa/sca/ComponentContext.h" +#include "osoa/sca/ServiceRuntimeException.h" + +#endif // osoa_sca_sca_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp new file mode 100644 index 0000000000..b418a52425 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/cpp/CPPExtension.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/cpp/CPPImplementationExtension.h" +#include "tuscany/sca/cpp/CPPInterfaceExtension.h" + + +extern "C" +{ + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void tuscany_sca_extension_initialize() + { + tuscany::sca::cpp::CPPExtension::initialize(); + } +} + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + // =================================================================== + // Constructor for the CPPExtension class. + // =================================================================== + CPPExtension::CPPExtension() + { + LOGENTRY(1, "CPPExtension::constructor"); + LOGEXIT(1, "CPPExtension::constructor"); + } + + // =================================================================== + // Destructor for the CPPExtension class. + // =================================================================== + CPPExtension::~CPPExtension() + { + LOGENTRY(1, "CPPExtension::destructor");; + LOGEXIT(1, "CPPExtension::destructor"); + } + + void CPPExtension::initialize() + { + LOGENTRY(1, "CPPExtension::initialize");; + SCARuntime::getInstance()->registerImplementationExtension(new CPPImplementationExtension()); + SCARuntime::getInstance()->registerInterfaceExtension(new CPPInterfaceExtension()); + LOGEXIT(1, "CPPExtension::initialize");; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h new file mode 100644 index 0000000000..d6c872629d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_cppextension_h +#define tuscany_sca_cpp_cppextension_h + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + class CPPExtension + { + public: + /** + * Default constructor + */ + CPPExtension(); + + /** + * Destructor + */ + virtual ~CPPExtension(); + + static void initialize(); + + private: + + }; + + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp new file mode 100644 index 0000000000..5ddf4b1113 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/cpp/CPPImplementationExtension.h" +#include "tuscany/sca/cpp/model/CPPImplementation.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + // =================================================================== + // Constructor for the CPPImplementationExtension class. + // =================================================================== + CPPImplementationExtension::CPPImplementationExtension() + { + LOGENTRY(1, "CPPImplementationExtension::constructor"); + LOGEXIT(1, "CPPImplementationExtension::constructor"); + } + + // =================================================================== + // Destructor for the CPPImplementationExtension class. + // =================================================================== + CPPImplementationExtension::~CPPImplementationExtension() + { + LOGENTRY(1, "CPPImplementationExtension::destructor");; + LOGEXIT(1, "CPPImplementationExtension::destructor"); + } + + const string CPPImplementationExtension::extensionName("cpp"); + const string CPPImplementationExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPImplementation"); + + // =================================================================== + // loadModelElement - load the info from implementation.cpp + // =================================================================== + ComponentType* CPPImplementationExtension::getImplementation(Composite *composite, DataObjectPtr scdlImplementation) + { + string implType = scdlImplementation->getType().getName(); + if (implType == "CPPImplementation") + { + string library = scdlImplementation->getCString("library"); + string header = scdlImplementation->getCString("header"); + string className = scdlImplementation->getCString("class"); + string scopeName = scdlImplementation->getCString("scope"); + + CPPImplementation::Scope scope; + if (scopeName == "composite") + { + scope = CPPImplementation::COMPOSITE; + } + else + { + scope = CPPImplementation::STATELESS; + } + + string headerPath; + string headerStub; + + // Separate any path element + Utils::rTokeniseString("/", header, headerPath, headerStub); + if (headerPath != "") + { + headerPath += "/"; + } + + // Determine the header stub name + string tmp; + Utils::rTokeniseString(".h", headerStub, headerStub, tmp); + + CPPImplementation* cppImpl = new CPPImplementation( + composite, library, header, headerPath, headerStub, className, scope); + + return cppImpl; + } + else + { + return NULL; + } + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h new file mode 100644 index 0000000000..8548a208e9 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_cppimplementationextension_h +#define tuscany_sca_cpp_cppimplementationextension_h + +#include "tuscany/sca/extension/ImplementationExtension.h" + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + class CPPImplementationExtension : public ImplementationExtension + { + public: + /** + * Default constructor + */ + CPPImplementationExtension(); + + /** + * Destructor + */ + virtual ~CPPImplementationExtension(); + + /** + * return the name of the extension + */ + virtual const string& getExtensionName() {return extensionName;} + + /** + * return the QName of schema type for this implementation extension + * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.cpp") + */ + virtual const string& getExtensionTypeQName() {return typeQName;} + + virtual ComponentType* getImplementation(Composite* composite, DataObjectPtr scdlImplementation); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppimplementationextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp new file mode 100644 index 0000000000..d470949746 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/cpp/CPPInterfaceExtension.h" +#include "tuscany/sca/cpp/model/CPPInterface.h" +#include "tuscany/sca/util/Logging.h" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + // =================================================================== + // Constructor for the CPPInterfaceExtension class. + // =================================================================== + CPPInterfaceExtension::CPPInterfaceExtension() + { + LOGENTRY(1, "CPPInterfaceExtension::constructor"); + LOGEXIT(1, "CPPInterfaceExtension::constructor"); + } + + // =================================================================== + // Destructor for the CPPInterfaceExtension class. + // =================================================================== + CPPInterfaceExtension::~CPPInterfaceExtension() + { + LOGENTRY(1, "CPPInterfaceExtension::destructor");; + LOGEXIT(1, "CPPInterfaceExtension::destructor"); + } + + const string CPPInterfaceExtension::extensionName("cpp"); + const string CPPInterfaceExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPInterface"); + + // =================================================================== + // loadModelElement - load the info from interface.cpp + // =================================================================== + tuscany::sca::model::Interface* CPPInterfaceExtension::getInterface(Composite* composite, DataObjectPtr scdlInterface) + { + // Determine the type + string ifType = scdlInterface->getType().getName(); + if (ifType == "CPPInterface") + { + string header = scdlInterface->getCString("header"); + string className = scdlInterface->getCString("class"); + bool remotable = scdlInterface->getBoolean("remotable"); + + return new CPPInterface(header, className, remotable, false); + } + return 0; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h new file mode 100644 index 0000000000..62c3b9854b --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_cppinterfaceextension_h +#define tuscany_sca_cpp_cppinterfaceextension_h + +#include "tuscany/sca/extension/InterfaceExtension.h" + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + class CPPInterfaceExtension : public InterfaceExtension + { + public: + /** + * Default constructor + */ + CPPInterfaceExtension(); + + /** + * Destructor + */ + virtual ~CPPInterfaceExtension(); + + /** + * return the name of the extension + */ + virtual const string& getExtensionName() {return extensionName;} + + /** + * return the QName of schema type for this interface extension + * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp") + */ + virtual const string& getExtensionTypeQName() {return typeQName;} + + virtual tuscany::sca::model::Interface* getInterface(Composite* composite, DataObjectPtr scdlInterface); + + private: + static const string extensionName; + static const string typeQName; + + }; + + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppinterfaceextension_h + diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp new file mode 100644 index 0000000000..56511fc9e6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp @@ -0,0 +1,193 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/cpp/CPPServiceProxy.h" +#include "tuscany/sca/util/Logging.h" +#include "osoa/sca/ServiceRuntimeException.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/model/ReferenceType.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/ServiceType.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/ComponentType.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/ServiceBinding.h" +#include "tuscany/sca/cpp/model/CPPImplementation.h" +#include "tuscany/sca/cpp/model/CPPReferenceBinding.h" + +using namespace osoa::sca; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // ============================ + // Constructor: Create a proxy + // ============================ + CPPServiceProxy::CPPServiceProxy(Reference* reference) + : ServiceProxy(reference) + { + LOGENTRY(1,"CPPServiceProxy::constructor"); + + // ---------------------- + // Get the component + // ---------------------- + Component* component = reference->getComponent(); + string name = reference->getType()->getName(); + + // Get the service wrapper + CPPReferenceBinding* referenceBinding = (CPPReferenceBinding*)reference->getBinding(); + + ServiceWrapper* serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper(); + + createProxy(component, name, serviceWrapper); + + LOGEXIT(1,"CPPServiceProxy::constructor"); + } + + // ============================ + // Constructor: Create a proxy + // ============================ + CPPServiceProxy::CPPServiceProxy(Service* service) + : ServiceProxy(0) + { + LOGENTRY(1,"CPPServiceProxy::constructor"); + + // ---------------------- + // Get the component + // ---------------------- + Component* component = service->getComponent(); + string name = service->getType()->getName(); + + // Get the service wrapper + ServiceWrapper* serviceWrapper = service->getBinding()->getServiceWrapper(); + + createProxy(component, name, serviceWrapper); + + LOGEXIT(1,"CPPServiceProxy::constructor"); + } + + void CPPServiceProxy::createProxy(Component* component, const string& name, ServiceWrapper* serviceWrapper) + { + LOGENTRY(1,"CPPServiceProxy::createProxy"); + + ComponentType* componentType = component->getType(); + if (!componentType) + { + string msg = "Component " + component->getName() + " has no implementation defined"; + throw ServiceNotFoundException(msg.c_str()); + } + + // If we got here we have a CPP implementation + CPPImplementation* impl = (CPPImplementation *)componentType; + + // ---------------------------------------------------- + // Get implementation dll name and service factory name + // ---------------------------------------------------- + string library = impl->getLibrary(); + string headerStub = impl->getHeaderStub(); + + string fullLibraryName = component->getComposite()->getRoot() + "/" + library; + string proxyFactoryName = headerStub + "_" + name + "_Proxy_Factory"; + string proxyDestructorName = headerStub + "_" + name + "_Proxy_Destructor"; + typedef void* (* PROXYFACTORY) (ServiceWrapper*); + + // ------------ + // Load the dll + // ------------ + proxyLibrary = Library(fullLibraryName); + + // ------------------------- + // Locate the factory method + // ------------------------- + PROXYFACTORY proxyFactory = (PROXYFACTORY)proxyLibrary.getSymbol(proxyFactoryName); + if (!proxyFactory) + { + LOGERROR_2(1, "CPPServiceProxy::createProxy: Unable to locate %s in library %s", + proxyFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Unable to locate " + proxyFactoryName + " in library " + fullLibraryName; + throw ServiceNotFoundException(msg.c_str()); + } + + // ----------------------------------- + // Now create an instance of the proxy + // ----------------------------------- + void* proxy = proxyFactory(serviceWrapper); + if (!proxy) + { + LOGERROR_2(1, "CPPServiceProxy::createProxy: Factory method %s in library %s returned null", + proxyFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Factory method " + proxyFactoryName + " in library " + fullLibraryName + " returned null"; + throw ServiceNotFoundException(msg.c_str()); + } + else + { + proxies.push_back(proxy); + } + + // ------------------------- + // Get the destructor method + // ------------------------- + destructor = (PROXYDESTRUCTOR)proxyLibrary.getSymbol(proxyDestructorName); + + LOGEXIT(1,"CPPServiceProxy::createProxy"); + } + + // ========== + // Destructor + // ========== + CPPServiceProxy::~CPPServiceProxy() + { + LOGENTRY(1,"CPPServiceProxy::destructor"); + + // Delete the proxies + if (destructor != NULL && proxies.size() != 0) + { + destructor(*proxies.begin()); + } + LOGEXIT(1,"CPPServiceProxy::destructor"); + } + + CPPServiceProxy::PROXIES CPPServiceProxy::getProxies() + { + return proxies; + } + + void* CPPServiceProxy::getProxy() + { + if (proxies.size() != 0) + { + return *proxies.begin(); + } + else + { + return NULL; + } + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h new file mode 100644 index 0000000000..77a20d08b8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + + +#ifndef tuscany_sca_cpp_cppserviceproxy_h +#define tuscany_sca_cpp_cppserviceproxy_h + +#include "osoa/sca/export.h" +#include "tuscany/sca/core/ServiceProxy.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/util/Library.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/model/Service.h" + +using namespace tuscany::sca::model; + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + /** + * Holds a proxy for a given component and reference. + * The proxy which is held inside a ServiceProxy will be specific to the component + * and reference and will have been code generated and be contained in a dll + * created by a developer of an SCA application. + */ + class CPPServiceProxy : public ServiceProxy + { + public: + /** + * Create a new service proxy for a reference. The proxy will contain a pointer to + * the target ServiceWrapper. + * @param reference The reference on the source component. + * @param target The wrapper of the service which is wired to this reference. + */ + CPPServiceProxy(Reference* reference); + + /** + * Create a new service proxy for a service. The proxy will contain a pointer to + * the target ServiceWrapper. + * @param reference The service on the target component. + * @param target The wrapper of the target service. + */ + CPPServiceProxy(Service* service); + + /** + * Destructor. + */ + virtual ~CPPServiceProxy(); + + /** + * Return an instance of the proxy created for this particular component and reference. + * @return The proxy. + */ + virtual void* getProxy(); + + /** + * Return the proxies created for this particular component and reference. + * @return The proxies. + */ + typedef std::list PROXIES; + virtual PROXIES getProxies(); + + private: + + /** + * Create the proxy + */ + void createProxy(Component* component, const string& name, ServiceWrapper* serviceWrapper); + + /** + * Holds the instances of the code generated proxies. + */ + PROXIES proxies; + + /** + * A function pointer to the destructor of the proxy. + */ + typedef void (* PROXYDESTRUCTOR) (void*); + PROXYDESTRUCTOR destructor; + + /** + * The library which contains the code for the proxy. + */ + Library proxyLibrary; + + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppserviceproxy_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp new file mode 100644 index 0000000000..3d7df2d44d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp @@ -0,0 +1,198 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/cpp/CPPServiceWrapper.h" + +#include "osoa/sca/ServiceRuntimeException.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/Library.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/ServiceType.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/cpp/model/CPPImplementation.h" +#include "tuscany/sca/model/Interface.h" + +using namespace osoa::sca; + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // =================== + // Static data members + // =================== + void* CPPServiceWrapper::staticImpl = 0; + + // =========== + // Constructor + // =========== + CPPServiceWrapper::CPPServiceWrapper(Service* service) + : ServiceWrapper(service) + { + LOGENTRY(1,"CPPServiceWrapper::constructor"); + + component = service->getComponent(); + interf = service->getType()->getInterface(); + implementation = (CPPImplementation*)component->getType(); + + LOGEXIT(1,"CPPServiceWrapper::constructor"); + + } + + // ========== + // Destructor + // ========== + CPPServiceWrapper::~CPPServiceWrapper() + { + LOGENTRY(1,"CPPServiceWrapper::destructor"); + LOGEXIT(1,"CPPServiceWrapper::destructor"); + } + + + // ====================================================================== + // getImplementation: get an implementation for this scope + // ====================================================================== + void* CPPServiceWrapper::getImplementation() + { + if (implementation->getScope() == CPPImplementation::COMPOSITE) + { + if (!staticImpl) + { + staticImpl = newImplementation(); + } + return staticImpl; + } + else // (scope == CPPInterface::STATELESS) + { + return newImplementation(); + } + } + + // ====================================================================== + // releaseImplementation: release the implementation for this scope + // ====================================================================== + void CPPServiceWrapper::releaseImplementation() + { + if (implementation->getScope() == CPPImplementation::STATELESS) + { + deleteImplementation(); + } + } + + // ====================================================================== + // invoke: wrapper call to service with setting the component context + // ====================================================================== + void CPPServiceWrapper::invoke(Operation& operation) + { + LOGENTRY(1,"CPPServiceWrapper::invoke"); + + SCARuntime* runtime = SCARuntime::getInstance(); + runtime->setCurrentComponent(component); + + try + { + invokeService(operation); + } + catch (...) + { + runtime->unsetCurrentComponent(); + throw; + } + runtime->unsetCurrentComponent(); + LOGEXIT(1,"CPPServiceWrapper::invoke"); + + } + + void CPPServiceWrapper::setLibrary(Library* lib) + { + wrapperLibrary = lib; + } + + // ====================================================================== + // getServiceWrapper: create a wrapper for the target ComponentService + // ====================================================================== + CPPServiceWrapper* CPPServiceWrapper::getServiceWrapper(Service* service) + { + CPPServiceWrapper* serviceWrapper = 0; + + // ----------------------------------------------- + // Get the implementation for the target component + // ----------------------------------------------- + Component* component = service->getComponent(); + CPPImplementation* impl = (CPPImplementation*)component->getType(); + if (!impl) + { + string msg = "Component " + component->getName() + " has no implementation defined"; + throw ServiceNotFoundException(msg.c_str()); + } + + // ---------------------------------------------------- + // Get implementation dll name and wrapper factory name + // ---------------------------------------------------- + string libraryName = impl->getLibrary(); + string wrapperFactoryName = impl->getHeaderStub() + + "_" + service->getType()->getName() + "_Wrapper_Factory"; + + // ------------ + // Load the dll + // ------------ + string fullLibraryName = component->getComposite()->getRoot() + "/" + libraryName; + typedef CPPServiceWrapper* (* WRAPPERFACTORY) (Service*); + Library* wrapperLib = new Library(fullLibraryName); + + // ------------------------- + // Locate the factory method + // ------------------------- + WRAPPERFACTORY wrapperFactory = (WRAPPERFACTORY)wrapperLib->getSymbol(wrapperFactoryName); + if (!wrapperFactory) + { + LOGERROR_2(1, "CPPServiceWrapper::getServiceWrapper: Unable to locate %s in library %s", + wrapperFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Unable to locate " + wrapperFactoryName + " in library " + fullLibraryName; + throw ServiceNotFoundException(msg.c_str()); + } + + // ------------------------------------- + // Now create an instance of the wrapper + // ------------------------------------- + serviceWrapper = wrapperFactory(service); + if (!serviceWrapper) + { + LOGERROR_2(1, "CPPServiceWrapper::getServiceWrapper: Factory method %s in library %s returned null", + wrapperFactoryName.c_str(), fullLibraryName.c_str()); + string msg = "Factory method " + wrapperFactoryName + " in library " + fullLibraryName + " returned null"; + throw ServiceNotFoundException(msg.c_str()); + } + serviceWrapper->setLibrary(wrapperLib); + + return serviceWrapper; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h new file mode 100644 index 0000000000..eeeb9cdb82 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_cppservicewrapper_h +#define tuscany_sca_cpp_cppservicewrapper_h + +#include "osoa/sca/export.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/core/Operation.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Interface.h" +#include "tuscany/sca/cpp/model/CPPImplementation.h" +#include "tuscany/sca/util/Library.h" + +using namespace tuscany::sca::model; + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + /** + * Wraps the service on a component implementation. + * This abstract class is extended by generated code which provides + * the implementation of some of the methods. + * An instance of this class wraps the actual component implementation which + * has been written by a developer of an SCA application. + */ + class SCA_CPP_API CPPServiceWrapper : public ServiceWrapper + { + public: + /** + * Factory method to create a new CPPServiceWrapper for a given target + * service. This method will provide all the loading of dlls required to + * create the target component. + * @param target The service on the component for which this wrapper is to be + * created. + * @return A wrapper that references the given target. + */ + static CPPServiceWrapper* getServiceWrapper(Service* service); + + /** + * Constructor. + * @param target The component service to which this wrapper refers. + */ + CPPServiceWrapper(Service* service); + + /** + * Destructor. + */ + virtual ~CPPServiceWrapper(); + + /** + * All business method calls to the target component go through the invoke method. + * @param operation The details of the method, paramaters and return value for the + * business method to be called on the target component. + */ + virtual void invoke(Operation& operation); + + /** + * Return the loaded shared library for the target component. + */ + Library* getLibrary() const { return wrapperLibrary; } + + protected: + + /** + * Delegated method to invoke the correct method on the target component. + * Implemented by the subtype. + */ + virtual void invokeService(Operation& operation) = 0; + + /** + * Delegated method to create a new component implementation. + * Implemented by the subtype. + * @return A pointer to an instance of the component implementation class. + */ + virtual void* newImplementation() = 0; + + /** + * Delegated method to delete the current instance of the component + * implementation. + * Implemented by the subtype. + */ + virtual void deleteImplementation() = 0; + + /** + * Return the current instance of the component implementation. + * @return A pointer to an instance of the component implementation class. + */ + virtual void* getImplementation(); + + /** + * Indicates that the current instance of the component implementation + * has been finished with. + * Will call CPPServiceWrapper#deleteImplementation if the + * implementation is stateless (so that a new instance is returned + * for each call). + */ + virtual void releaseImplementation(); + + private: + /** + * Holds an implementation instance if the scope is set to composite. + */ + static void* staticImpl; + + /** + * The component to which this wrapper refers. + */ + Component* component; + + /** + * A pointer to the interface which the service exposes. + */ + Interface* interf; + + /** + * The component implementation + */ + CPPImplementation* implementation; + + /** + * Pointer to the loaded library which contains the component + * implementation. + */ + Library* wrapperLibrary; + + /** + * Set the loaded library which contains the component + * implementation. + * @param lib The library. + */ + void setLibrary(Library* lib); + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_cppservicewrapper_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp new file mode 100644 index 0000000000..76d6bbc5f6 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp @@ -0,0 +1,163 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "osoa/sca/ServiceRuntimeException.h" +#include "tuscany/sca/cpp/ComponentContextImpl.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/ReferenceBinding.h" +#include "tuscany/sca/model/ReferenceType.h" +#include "tuscany/sca/model/ServiceBinding.h" + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // =========== + // Constructor + // =========== + ComponentContextImpl::ComponentContextImpl(Component* comp) + : ComponentContext(0), component(comp) + { + LOGENTRY(1, "ComponentContextImpl::constructor"); + LOGEXIT(1, "ComponentContextImpl::constructor"); + } + + // ========== + // Destructor + // ========== + ComponentContextImpl::~ComponentContextImpl() + { + } + + + // ========================================================================== + // getServices: return a list of Proxies for services wired to this reference + // ========================================================================== + std::list ComponentContextImpl::getServices(const std::string& referenceName) + { + LOGENTRY(1, "ComponentContextImpl::getServices"); + + // -------------------------------------------------------------- + // locate reference in the current component and determine target + // -------------------------------------------------------------- + Reference* reference = component->findReference(referenceName); + if (!reference) + { + string message = "Reference not defined: "; + message = message + referenceName; + throw ServiceNotFoundException(message.c_str()); + } + + // Get a service proxy from the binding configured on the reference + CPPServiceProxy* serviceProxy = (CPPServiceProxy*)reference->getBinding()->getServiceProxy(); + if (serviceProxy == NULL) + { + string message = "Reference "; + message = message + referenceName + " not wired"; + throw ServiceNotFoundException(message.c_str()); + } + + return serviceProxy->getProxies(); + + } // End getServices() + + + // =================================================================== + // getService: return a Proxy for the services wired to this reference + // =================================================================== + void* ComponentContextImpl::getService(const std::string& referenceName) + { + LOGENTRY(1, "ComponentContextImpl::getService"); + + // -------------------------------------------------------------- + // locate reference in the current component and determine target + // -------------------------------------------------------------- + Reference* reference = component->findReference(referenceName); + if (!reference) + { + string message = "Reference not defined: "; + message = message + referenceName; + throw ServiceNotFoundException(message.c_str()); + } + + // -------------------- + // Validate the request + // -------------------- + switch (reference->getType()->getMultiplicity()) + { + case ReferenceType::ZERO_MANY: + case ReferenceType::ONE_MANY: + { + string message = "getService() called for reference with multiplicity >1 :"; + message = message + referenceName; + throw ServiceNotFoundException(message.c_str()); + } + default: + { + } + } // end switch + + // Get a service proxy from the binding configured on the reference + CPPServiceProxy* serviceProxy = (CPPServiceProxy*)reference->getBinding()->getServiceProxy(); + if (serviceProxy == NULL) + { + string message = "Reference "; + message = message + referenceName + " not wired"; + throw ServiceNotFoundException(message.c_str()); + } + + void* service = serviceProxy->getProxy(); + return service; + + } // End getService() + + // ============================================== + // getProperties: return the component properties + // ============================================== + DataObjectPtr ComponentContextImpl::getProperties() + { + LOGENTRY(1, "ComponentContextImpl::getProperties"); + DataObjectPtr properties = component->getProperties(); + + LOGEXIT(1, "ComponentContextImpl::getProperties"); + return properties; + } + + // ============================================== + // getDataFactory: return the data factory for the composite in which + // this component resides + // ============================================== + commonj::sdo::DataFactoryPtr ComponentContextImpl::getDataFactory() + { + LOGENTRY(1, "ComponentContextImpl::getProperties"); + commonj::sdo::DataFactoryPtr dataFactory = component->getComposite()->getDataFactory(); + + LOGEXIT(1, "ComponentContextImpl::getDataFactory"); + return dataFactory; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h new file mode 100644 index 0000000000..6d9b76feeb --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_componentcontextimpl_h +#define tuscany_sca_cpp_componentcontextimpl_h + +#include +using std::vector; + +#include "osoa/sca/ComponentContext.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/cpp/CPPServiceProxy.h" + +using namespace osoa::sca; + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + /** + * Contains the actual implementation of a ComponentContext interface. + */ + class ComponentContextImpl : public ComponentContext + { + + public: + /** + * Constructor that takes a Component which represents the runtime + * model for this context. + */ + ComponentContextImpl(Component* component); + + /** + * Default constructor. + */ + virtual ~ComponentContextImpl(); + + /** + * See ComponentContext. + */ + virtual void* getService(const std::string& referenceName); + + /** + * See ComponentContext. + */ + virtual std::list getServices(const std::string& referenceName); + + /** + * See ComponentContext. + */ + virtual DataObjectPtr getProperties(); + + /** + * See ComponentContext. + */ + virtual commonj::sdo::DataFactoryPtr getDataFactory(); + + /** + * Returns the contained Component. + * @return The Component to which this context refers. + */ + virtual Component* getComponent() {return component;} + + private: + ComponentContextImpl(const ComponentContextImpl&); + ComponentContextImpl& operator=(const ComponentContextImpl&); + + /** + * Pointer to the runtime model Component to which this + * context refers. + */ + Component* component; + + /** + * Helper method to return a proxy to a service. + * @param serviceReference The source reference. + * @param target The target to which this source reference is wired. + * @return A pointer to an object which can be cast to the business + * class representing the target. + */ + void* getServiceProxy( + Reference* serviceReference, + Service* target); + + /** + * Helper method to return a wrapper for a target service. + * @param target The target for which this wrapper is to be created. + * @return The service wrapper. + */ + ServiceWrapper* getServiceWrapper(Service* target); + + }; + + } // End namespaca cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_componentcontextimpl_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp new file mode 100644 index 0000000000..009e0ed765 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "osoa/sca/ServiceRuntimeException.h" +#include "tuscany/sca/cpp/CompositeContextImpl.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/ServiceBinding.h" +#include "tuscany/sca/model/ServiceType.h" +#include "tuscany/sca/core/ServiceProxy.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/cpp/CPPServiceProxy.h" +#include "commonj/sdo/SDO.h" + +using namespace tuscany::sca::model; +using namespace osoa::sca; +using namespace commonj::sdo; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // =========== + // Constructor + // =========== + CompositeContextImpl::CompositeContextImpl(Component* component) + : CompositeContext(0), component(component), composite((Composite*)component->getType()) + { + } + + // ========== + // Destructor + // ========== + CompositeContextImpl::~CompositeContextImpl() + { + } + + // =========================================================================== + // locateService: return a proxy connected to a wrapper for the target service + // =========================================================================== + void* CompositeContextImpl::locateService(const std::string& serviceName) + { + LOGENTRY(1, "CompositeContextImpl::locateService"); + + // ---------------------------- + // Locate the component service + // ---------------------------- + Service* service = composite->findComponentService(serviceName); + string msg; + if (!service) + { + msg = "Service not found: "; + msg = msg + serviceName; + throw ServiceNotFoundException(msg.c_str()); + } + + // ---------------------------- + // Get a Proxy for this service + // ---------------------------- + + // The locate service API is used from CPP clients so we are using + // our default service proxy here + CPPServiceProxy* serviceProxy = new CPPServiceProxy(service); + LOGEXIT(1, "CompositeContextImpl::locateService"); + return serviceProxy->getProxy(); + + } + + // ============================================== + // getDataFactory: return the data factory for the current composite + // ============================================== + DataFactoryPtr CompositeContextImpl::getDataFactory() + { + LOGENTRY(1, "CompositeContextImpl::getDataFactory"); + DataFactoryPtr dataFactory = composite->getDataFactory(); + + LOGEXIT(1, "CompositeContextImpl::getDataFactory"); + return dataFactory; + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h new file mode 100644 index 0000000000..c11af16848 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_compositecontextimpl_h +#define tuscany_sca_cpp_compositecontextimpl_h + +#include +using std::vector; + +#include "osoa/sca/CompositeContext.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/cpp/CPPServiceProxy.h" + +using namespace osoa::sca; + +namespace tuscany +{ + namespace sca + { + + namespace cpp + { + + /** + * Contains the actual implementation of a CompositeContext interface. + */ + class CompositeContextImpl : public CompositeContext + { + + public: + /** + * Constructor that takes a Composite which represents the runtime + * model for this context. + */ + CompositeContextImpl(Component* component); + + /** + * See CompositeContext#locateService. + */ + virtual void* locateService(const std::string& serviceName); + + /** + * See CompositeContext. + */ + virtual commonj::sdo::DataFactoryPtr getDataFactory(); + + /** + * Destructor. + */ + virtual ~CompositeContextImpl(); + + private: + CompositeContextImpl(const CompositeContextImpl&); + CompositeContextImpl& operator=(const CompositeContextImpl&); + + /** + * Pointer to the runtime model Composite object to which this + * context refers. + */ + Composite* composite; + + /** + * Pointer to the runtime model Component object to which this + * context refers. + */ + Component* component; + + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_compositecontextimpl_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp new file mode 100644 index 0000000000..4fb7c7cfd5 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/cpp/model/CPPImplementation.h" +#include "tuscany/sca/cpp/model/CPPServiceBinding.h" +#include "tuscany/sca/cpp/model/CPPReferenceBinding.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/util/Utils.h" + +namespace tuscany +{ + namespace sca + { + + namespace cpp + { + + // Constructor + CPPImplementation::CPPImplementation(Composite* composite, const string& library, const string& header, + const string&headerPath, const string& headerStub, const string& className, Scope scope) + : ComponentType(composite, headerPath + headerStub), + library(library), header(header), headerPath(headerPath), + headerStub(headerStub), className(className), scope(scope) + { + } + + CPPImplementation::~CPPImplementation() + { + } + + void CPPImplementation::initializeComponent(Component* component) + { + ComponentType::initializeComponent(component); + + // Create CPP bindings for all the services + const Component::SERVICE_MAP& services = component->getServices(); + Component::SERVICE_MAP::const_iterator iter = services.begin(); + for (int i=0; i< services.size(); i++) + { + Service *service = iter->second; + CPPServiceBinding* binding = new CPPServiceBinding(service); + service->setBinding(binding); + iter++; + } + + // Create CPP bindings for all the references + const Component::REFERENCE_MAP& references = component->getReferences(); + Component::REFERENCE_MAP::const_iterator refiter = references.begin(); + for (int ri=0; ri< references.size(); ri++) + { + Reference *reference = refiter->second; + CPPReferenceBinding* binding = new CPPReferenceBinding(reference); + reference->setBinding(binding); + refiter++; + } + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h new file mode 100644 index 0000000000..20636df884 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_model_cppimplementation_h +#define tuscany_sca_cpp_model_cppimplementation_h +#include "tuscany/sca/model/ComponentType.h" + +#include +using std::map; +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Holds information about an SCA implementation written in C++ + */ + class CPPImplementation : public ComponentType + { + + public: + /** + * Scope of the component implementation. + */ + enum Scope + { + COMPOSITE, + STATELESS + }; + + /** + * Constructor. + * @param dllName Name of the shared library. + * @param header Name of the header file that contains the class declaring the + * implementation class. + * @param className Name of the class in the header file (could be a blank string + * if this is not specified). + */ + CPPImplementation(Composite* composite, const string& library, const string& header, const string&headerPath, + const string& headerStub, const string& className, Scope scope); + + /** + * Destructor + */ + virtual ~CPPImplementation(); + + /** + * Initialize a component of this type. + * @param component The component to initialize. + */ + virtual void initializeComponent(Component* component); + + /** + * Returns the name of the shared library. + * @return The name of the shared library. + */ + const string& getLibrary() const { return library; } + + /** + * Get the name of the header file. + * @return Name of the header file. + */ + const string& getHeader() const { return header; } + + /** + * Get the header file name without the extension. + * @return The name of the header file without any extension. + */ + const string& getHeaderStub() const { return headerStub; } + + /** + * Get the header path. + * @return The pathe element of the header. + */ + const string& getHeaderPath() const { return headerPath; } + + /** + * Get the name of the class. + * @return The class name if specified. + */ + const string& getClass() const { return className; } + + /** + * Returns the implementation scope + */ + Scope getScope() { return scope; } + + private: + + /** + * Name of the shared library. + */ + string library; + + /** + * Name of the header file describing the interface. + */ + string header; + + /** + * Name of the header file without the extension. + */ + string headerStub; + + /** + * Path element of the header. + */ + string headerPath; + + /** + * Name of the class in the header file declaring the implementation. + * May be an empty string if not set in the SCDL file. + */ + string className; + + /** + * Scope of the implementation + */ + Scope scope; + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_model_cppimplementation_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp new file mode 100644 index 0000000000..a728880e32 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/cpp/model/CPPInterface.h" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + const string CPPInterface::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPInterface"); + + // Constructor + CPPInterface::CPPInterface( + const string& header, + const string& className, + bool remotable, + bool conversational) + : Interface(remotable, conversational), header(header), className(className) + { + string::size_type dot = header.rfind(".h"); // this will also find .hpp + if (dot != string::npos) + { + headerStub = header.substr(0, dot); + } + else + { + headerStub = header; + } + + } + + CPPInterface::~CPPInterface() + { + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h new file mode 100644 index 0000000000..d50d2f9485 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_model_cppinterface_h +#define tuscany_sca_cpp_model_cppinterface_h + +#include "tuscany/sca/model/Interface.h" + +#include +using std::map; +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Holds information about an interface described using a C++ + * header file. + */ + class CPPInterface : public Interface + { + + public: + /** + * Constuctor. + * @param header Name of the header file containing the class that + * describes the interface. + * @param className Name of the class in the header file that + * describes the interface. + * @param scope The scope of the interface (stateless or composite). + * @param remotable True if the interface is remotable. + */ + CPPInterface( + const string& header, + const string& className, + bool remotable, + bool conversational); + + /** + * Destructor. + */ + virtual ~CPPInterface(); + + /** + * Get the name of the header file. + * @return The name of the header file containing the definition of the + * interface. + */ + const string& getHeader() { return header; } + + /** + * Return the name of the header file without the extension. + * @return Header file name without any extension. + */ + const string& getHeaderStub() { return headerStub; } + + /** + * Get the name of the class. + * @return The name of the class defining the interface. + */ + const string& getClass() { return className; } + + /** + * return the QName of the schema type for this interface type + * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp") + */ + virtual const string& getInterfaceTypeQName() { return typeQName; }; + + private: + + /** + * Name of the header file containing the definition of the interface. + */ + string header; + + /** + * Name of the header file without the extension. + */ + string headerStub; + + /** + * Name of the class in the header file. + */ + string className; + + /** + * The QName of the schema type for this interface type. + */ + static const string typeQName; + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_model_cppinterface_h + diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp new file mode 100644 index 0000000000..3c87560445 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/cpp/model/CPPReferenceBinding.h" +#include "tuscany/sca/cpp/CPPServiceProxy.h" + + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // Constructor + CPPReferenceBinding::CPPReferenceBinding(Reference* reference) + : ReferenceBinding(reference, ""), serviceProxy(NULL), targetServiceBinding(NULL) + { + } + + // Destructor + CPPReferenceBinding::~CPPReferenceBinding() + { + } + + ServiceProxy* CPPReferenceBinding::getServiceProxy() + { + return serviceProxy; + } + + void CPPReferenceBinding::configure(ServiceBinding* binding) + { + targetServiceBinding = binding; + + serviceProxy = new CPPServiceProxy(getReference()); + } + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h new file mode 100644 index 0000000000..81ba88940d --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_model_cppreferencebinding_h +#define tuscany_sca_cpp_model_cppreferencebinding_h + +#include "tuscany/sca/model/ReferenceBinding.h" + + +#include +using std::string; + +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Information about a CPP service binding for service or a reference. + */ + class CPPReferenceBinding : public ReferenceBinding + { + public: + + /** + * Constructor. + * @param uri The uri of the binding. + * @param port The definition of the port to which the entrypoint + * or external service is to be bound. This is of the form + * "namespace"#endpoint("service"/"port") + */ + CPPReferenceBinding(Reference* reference); + + /** + * Destructor. + */ + virtual ~CPPReferenceBinding(); + + /** + * Returns the type of binding. + */ + virtual string getType() { return "http://www.osoa.org/xmlns/sca/1.0#CPPImplementationBinding"; }; + + /** + * Create a proxy representing the reference to the + * client component. + */ + virtual ServiceProxy* getServiceProxy(); + + /** + * Configure this binding from a service binding. + */ + virtual void configure(ServiceBinding* serviceBinding); + + /** + * Returns the target service binding. + */ + ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; }; + + private: + + /** + * The proxy representing the reference to the client + * component. + */ + ServiceProxy* serviceProxy; + + /** + * The service binding of the target + */ + ServiceBinding* targetServiceBinding; + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_model_cppreferencebinding_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp new file mode 100644 index 0000000000..641d9452f8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/cpp/model/CPPServiceBinding.h" +#include "tuscany/sca/cpp/CPPServiceWrapper.h" + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + + // Constructor + CPPServiceBinding::CPPServiceBinding(Service* service) + : ServiceBinding(service, "") + { + serviceWrapper = CPPServiceWrapper::getServiceWrapper(service); + } + + // Destructor + CPPServiceBinding::~CPPServiceBinding() + { + } + + ServiceWrapper* CPPServiceBinding::getServiceWrapper() + { + return (ServiceWrapper*)serviceWrapper; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h new file mode 100644 index 0000000000..f7db3065b3 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_cpp_model_cppservicebinding_h +#define tuscany_sca_cpp_model_cppservicebinding_h + +#include "tuscany/sca/model/ServiceBinding.h" +using namespace tuscany::sca::model; +#include +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace cpp + { + /** + * Information about a CPP service binding for service or a reference. + */ + class CPPServiceBinding : public ServiceBinding + { + public: + + /** + * Constructor. + * @param uri The uri of the binding. + * @param port The definition of the port to which the entrypoint + * or external service is to be bound. This is of the form + * "namespace"#endpoint("service"/"port") + */ + CPPServiceBinding(Service* service); + + /** + * Destructor. + */ + virtual ~CPPServiceBinding(); + + /** + * Returns the type of binding. + */ + virtual string getType() { return "http://www.osoa.org/xmlns/sca/1.0#CPPImplementationBinding"; }; + + /** + * Create a wrapper for the service configured by this + * binding. + */ + virtual ServiceWrapper* getServiceWrapper(); + + private: + + /** + * The wrapper for the service configured by this binding. + */ + ServiceWrapper* serviceWrapper; + + }; + + } // End namespace cpp + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_cpp_model_cppservicebinding_h diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd new file mode 100644 index 0000000000..7292f747b8 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/xsd/sca-implementation-cpp.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd new file mode 100644 index 0000000000..585bac0dc4 --- /dev/null +++ b/tags/cpp-1.0-incubating-M2-RC3/sca/runtime/extensions/cpp/xsd/sca-interface-cpp.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3