summaryrefslogtreecommitdiffstats
path: root/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src')
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/Makefile.am55
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp150
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h117
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp127
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h99
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h105
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/export.h42
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/sca.h31
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp72
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h57
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp101
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h74
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp71
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h74
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp192
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h117
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp194
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h155
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp208
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h119
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp128
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h89
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp83
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h77
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp90
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h163
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp63
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h117
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp61
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h87
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp54
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h81
32 files changed, 3253 insertions, 0 deletions
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/Makefile.am
new file mode 100644
index 0000000000..f234261f5b
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/Makefile.am
@@ -0,0 +1,55 @@
+# 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/TuscanyRuntime.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
+
+moduledir=$(prefix)/extensions/cpp/module
+extension = libtuscany_sca_cpp$(libsuffix)
+
+install-exec-hook:
+ test -z $(moduledir) || $(mkdir_p) $(moduledir);
+ -rm -f $(moduledir)/$(extension)
+ $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension)
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp
new file mode 100644
index 0000000000..d686c4c09f
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp
@@ -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$ */
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/ComponentContext.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/ComponentContextImpl.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace commonj::sdo;
+using namespace tuscany::sca;
+using namespace tuscany::sca::cpp;
+using namespace tuscany::sca::model;
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ // =======================================================
+ // getCurrent: create a context from the current component
+ // =======================================================
+ ComponentContext ComponentContext::getCurrent()
+ {
+ logentry();
+ try
+ {
+ Component* component = tuscany::sca::SCARuntime::getCurrentRuntime()->getCurrentComponent();
+ if (!component)
+ {
+ throwException(ComponentContextException, "No current component");
+ }
+ ComponentContext* cci = new ComponentContextImpl(component);
+ return ComponentContext(cci);
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ // ===========
+ // Constructor
+ // ===========
+ ComponentContext::ComponentContext(ComponentContext* implementation)
+ : impl(implementation)
+ {
+ logentry();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ComponentContext::~ComponentContext()
+ {
+ logentry();
+ delete impl;
+ }
+
+ // ===================================
+ // Copy constructor: create a new impl
+ // ===================================
+ ComponentContext::ComponentContext(const ComponentContext& ctx)
+ {
+ logentry();
+ Component* component = ((ComponentContextImpl*)impl)->getComponent();
+ impl = new ComponentContextImpl(component);
+ }
+
+ // =============================
+ // operator= : create a new impl
+ // =============================
+ ComponentContext& ComponentContext::operator=(const ComponentContext& ctx)
+ {
+ logentry();
+ if (this != &ctx)
+ {
+ Component* component = ((ComponentContextImpl*)impl)->getComponent();
+ impl = new ComponentContextImpl(component);
+ }
+ return *this;
+ }
+
+ // ==========
+ // getService
+ // ==========
+ void* ComponentContext::getService(const std::string& referenceName)
+ {
+ logentry();
+ void* service = impl->getService(referenceName);
+ return service;
+ }
+
+ // ===========
+ // getServices
+ // ===========
+ std::list<void*> ComponentContext::getServices(const std::string& referenceName)
+ {
+ logentry();
+ return impl->getServices(referenceName);
+ }
+
+ // ============
+ // getProperties
+ // =============
+ DataObjectPtr ComponentContext::getProperties()
+ {
+ logentry();
+ DataObjectPtr properties = impl->getProperties();
+ return properties;
+ }
+
+ // ============
+ // getDataFactory
+ // =============
+ DataFactoryPtr ComponentContext::getDataFactory()
+ {
+ logentry();
+ DataFactoryPtr dataFactory = impl->getDataFactory();
+ return dataFactory;
+ }
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h
new file mode 100644
index 0000000000..2c305c5161
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ComponentContext.h
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef osoa_sca_componentcontext_h
+#define osoa_sca_componentcontext_h
+
+#include <string>
+#include <list>
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/export.h"
+
+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<void*> 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/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp
new file mode 100644
index 0000000000..d3f06e1b12
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/CompositeContext.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/CompositeContextImpl.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace commonj::sdo;
+using namespace tuscany::sca;
+using namespace tuscany::sca::cpp;
+
+
+namespace osoa
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ CompositeContext::CompositeContext(CompositeContext* implementation)
+ : impl(implementation)
+ {
+ logentry();
+ }
+
+ // ===================================
+ // Copy constructor: create a new impl
+ // ===================================
+ CompositeContext::CompositeContext(const CompositeContext& ctx)
+ {
+ logentry();
+ impl = new CompositeContextImpl(
+ tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent());
+ }
+
+ // =============================
+ // operator= : create a new impl
+ // =============================
+ CompositeContext& CompositeContext::operator=(const CompositeContext& ctx)
+ {
+ logentry();
+ if (this != &ctx)
+ {
+ impl = new CompositeContextImpl(
+ tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent());
+ }
+ return *this;
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ CompositeContext::~CompositeContext()
+ {
+ logentry();
+ delete impl;
+ }
+
+ // ====================================================
+ // getCurrent: create a context from the current composite
+ // ====================================================
+ CompositeContext CompositeContext::getCurrent()
+ {
+ logentry();
+ try
+ {
+ CompositeContext* cci = new CompositeContextImpl(
+ tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent());
+
+ return CompositeContext(cci);
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ // =============
+ // locateService
+ // =============
+ void* CompositeContext::locateService(const std::string& serviceName)
+ {
+ logentry();
+ void* sp = impl->locateService(serviceName);
+ return sp;
+ }
+
+ // =============
+ // getDataFactory
+ // =============
+ DataFactoryPtr CompositeContext::getDataFactory()
+ {
+ logentry();
+ DataFactoryPtr df = impl->getDataFactory();
+ return df;
+ }
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/CompositeContext.h
new file mode 100644
index 0000000000..a047f82e46
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/CompositeContext.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 osoa_sca_compositecontext_h
+#define osoa_sca_compositecontext_h
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/export.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/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h
new file mode 100644
index 0000000000..6d64a32dd6
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h
@@ -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$ */
+
+#ifndef osoa_sca_serviceruntimeexception_h
+#define osoa_sca_serviceruntimeexception_h
+
+#include "osoa/sca/export.h"
+
+#include "tuscany/sca/core/Exceptions.h"
+
+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 tuscany::sca::TuscanyRuntimeException
+ {
+ public:
+ ServiceRuntimeException(
+ const char *name="ServiceRuntimeException",
+ severity_level sev=Severe,
+ const char* msg_text="")
+ : tuscany::sca::TuscanyRuntimeException(name, sev, msg_text)
+ {
+ }
+
+ ServiceRuntimeException(const tuscany::sca::TuscanyRuntimeException& e)
+ : tuscany::sca::TuscanyRuntimeException(e)
+ {
+ }
+ }; // 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/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/export.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/export.h
new file mode 100644
index 0000000000..8a69913be4
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/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 <sys/time.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#define SCA_CPP_API
+#endif
+
+#endif // osoa_sca_export_h
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/sca.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca/sca.h
new file mode 100644
index 0000000000..6cce9453d7
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/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/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp
new file mode 100644
index 0000000000..74a30fb772
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/cpp/CPPExtension.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/cpp/CPPImplementationExtension.h"
+#include "tuscany/sca/cpp/CPPInterfaceExtension.h"
+
+
+extern "C"
+{
+#if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+#endif
+ void tuscany_sca_cpp_initialize()
+ {
+ tuscany::sca::cpp::CPPExtension::initialize();
+ }
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ // ===================================================================
+ // Constructor for the CPPExtension class.
+ // ===================================================================
+ CPPExtension::CPPExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the CPPExtension class.
+ // ===================================================================
+ CPPExtension::~CPPExtension()
+ {
+ logentry();
+ }
+
+ void CPPExtension::initialize()
+ {
+ logentry();
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ runtime->registerImplementationExtension(new CPPImplementationExtension());
+ runtime->registerInterfaceExtension(new CPPInterfaceExtension());
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h
new file mode 100644
index 0000000000..d6c872629d
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/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/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp
new file mode 100644
index 0000000000..b5312ab243
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/cpp/CPPImplementationExtension.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::util;
+using namespace tuscany::sca::model;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ // ===================================================================
+ // Constructor for the CPPImplementationExtension class.
+ // ===================================================================
+ CPPImplementationExtension::CPPImplementationExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the CPPImplementationExtension class.
+ // ===================================================================
+ CPPImplementationExtension::~CPPImplementationExtension()
+ {
+ logentry();
+ }
+
+ const string CPPImplementationExtension::extensionName("cpp");
+ const string CPPImplementationExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPImplementation");
+
+ // ===================================================================
+ // loadModelElement - load the info from implementation.cpp
+ // ===================================================================
+ ComponentType* CPPImplementationExtension::getImplementation(Composite *composite, DataObjectPtr scdlImplementation)
+ {
+ logentry();
+ string library = scdlImplementation->getCString("library");
+ string header = scdlImplementation->getCString("header");
+ string className = scdlImplementation->getCString("class");
+ string scopeName = scdlImplementation->getCString("scope");
+
+ CPPImplementation::Scope scope;
+ if (scopeName == "composite")
+ {
+ scope = CPPImplementation::COMPOSITE;
+ }
+ else
+ {
+ scope = CPPImplementation::STATELESS;
+ }
+
+ string headerPath;
+ string headerStub;
+
+ // Separate any path element
+ Utils::rTokeniseString("/", header, headerPath, headerStub);
+ if (headerPath != "")
+ {
+ headerPath += "/";
+ }
+
+ // Determine the header stub name
+ string tmp;
+ Utils::rTokeniseString(".h", headerStub, headerStub, tmp);
+
+ CPPImplementation* cppImpl = new CPPImplementation(
+ composite, library, header, headerPath, headerStub, className, scope);
+
+ return cppImpl;
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h
new file mode 100644
index 0000000000..8eb7b88691
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_cppimplementationextension_h
+#define tuscany_sca_cpp_cppimplementationextension_h
+
+#include "tuscany/sca/extension/ImplementationExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ class CPPImplementationExtension : public ImplementationExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ CPPImplementationExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~CPPImplementationExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema type for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.cpp")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::ComponentType* getImplementation(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlImplementation);
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppimplementationextension_h
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp
new file mode 100644
index 0000000000..7bb84a7673
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/cpp/CPPInterfaceExtension.h"
+#include "tuscany/sca/cpp/model/CPPInterface.h"
+#include "tuscany/sca/util/Logging.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ // ===================================================================
+ // Constructor for the CPPInterfaceExtension class.
+ // ===================================================================
+ CPPInterfaceExtension::CPPInterfaceExtension()
+ {
+ logentry();
+ }
+
+ // ===================================================================
+ // Destructor for the CPPInterfaceExtension class.
+ // ===================================================================
+ CPPInterfaceExtension::~CPPInterfaceExtension()
+ {
+ logentry();
+ }
+
+ const string CPPInterfaceExtension::extensionName("cpp");
+ const string CPPInterfaceExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPInterface");
+
+ // ===================================================================
+ // loadModelElement - load the info from interface.cpp
+ // ===================================================================
+ tuscany::sca::model::Interface* CPPInterfaceExtension::getInterface(Composite* composite, DataObjectPtr scdlInterface)
+ {
+ logentry();
+
+ string header = scdlInterface->getCString("header");
+ string className = scdlInterface->getCString("class");
+ bool remotable = scdlInterface->getBoolean("remotable");
+
+ return new CPPInterface(header, className, remotable, false);
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h
new file mode 100644
index 0000000000..04ac9f6970
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_cppinterfaceextension_h
+#define tuscany_sca_cpp_cppinterfaceextension_h
+
+#include "tuscany/sca/extension/InterfaceExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ class CPPInterfaceExtension : public InterfaceExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ CPPInterfaceExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~CPPInterfaceExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const std::string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema type for this interface extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp")
+ */
+ virtual const std::string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::Interface* getInterface(
+ tuscany::sca::model::Composite* composite,
+ commonj::sdo::DataObjectPtr scdlInterface);
+
+ private:
+ static const std::string extensionName;
+ static const std::string typeQName;
+
+ };
+
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppinterfaceextension_h
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp
new file mode 100644
index 0000000000..cc45ea9fb8
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/cpp/model/CPPReferenceBinding.h"
+
+using namespace std;
+using namespace osoa::sca;
+using namespace tuscany::sca::model;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ CPPServiceProxy::CPPServiceProxy(Reference* reference)
+ : ServiceProxy(reference)
+ {
+ logentry();
+
+ // ----------------------
+ // Get the component
+ // ----------------------
+ Component* component = reference->getComponent();
+ string name = reference->getType()->getName();
+
+ // Get the service wrapper
+ CPPReferenceBinding* referenceBinding = (CPPReferenceBinding*)reference->getBinding();
+
+ ServiceWrapper* serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
+
+ createProxy(component, name, serviceWrapper);
+ }
+
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ CPPServiceProxy::CPPServiceProxy(Service* service)
+ : ServiceProxy(0)
+ {
+ logentry();
+
+ // ----------------------
+ // Get the component
+ // ----------------------
+ Component* component = service->getComponent();
+ string name = service->getType()->getName();
+
+ // Get the service wrapper
+ ServiceWrapper* serviceWrapper = service->getBinding()->getServiceWrapper();
+
+ createProxy(component, name, serviceWrapper);
+ }
+
+ void CPPServiceProxy::createProxy(Component* component, const string& name, ServiceWrapper* serviceWrapper)
+ {
+ logentry();
+
+ ComponentType* componentType = component->getType();
+ if (!componentType)
+ {
+ string msg = "Component " + component->getName() + " has no implementation defined";
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+
+ // If we got here we have a CPP implementation
+ CPPImplementation* impl = (CPPImplementation *)componentType;
+
+ // ----------------------------------------------------
+ // Get implementation dll name and service factory name
+ // ----------------------------------------------------
+ string library = impl->getLibrary();
+ string headerStub = impl->getHeaderStub();
+
+ string fullLibraryName = component->getComposite()->getRoot() + "/" + library;
+ string proxyFactoryName = headerStub + "_" + name + "_Proxy_Factory";
+ string proxyDestructorName = headerStub + "_" + name + "_Proxy_Destructor";
+ typedef void* (* PROXYFACTORY) (ServiceWrapper*);
+
+ // ------------
+ // Load the dll
+ // ------------
+ proxyLibrary = Library(fullLibraryName);
+
+ // -------------------------
+ // Locate the factory method
+ // -------------------------
+ PROXYFACTORY proxyFactory = (PROXYFACTORY)proxyLibrary.getSymbol(proxyFactoryName);
+ if (!proxyFactory)
+ {
+ logerror("Unable to locate %s in library %s",
+ proxyFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Unable to locate " + proxyFactoryName + " in library " + fullLibraryName;
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+
+ // -----------------------------------
+ // Now create an instance of the proxy
+ // -----------------------------------
+ void* proxy = proxyFactory(serviceWrapper);
+ if (!proxy)
+ {
+ logerror("Factory method %s in library %s returned null",
+ proxyFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Factory method " + proxyFactoryName + " in library " + fullLibraryName + " returned null";
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+ else
+ {
+ proxies.push_back(proxy);
+ }
+
+ // -------------------------
+ // Get the destructor method
+ // -------------------------
+ destructor = (PROXYDESTRUCTOR)proxyLibrary.getSymbol(proxyDestructorName);
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ CPPServiceProxy::~CPPServiceProxy()
+ {
+ logentry();
+
+ // Delete the proxies
+ if (destructor != NULL && proxies.size() != 0)
+ {
+ destructor(*proxies.begin());
+ }
+ }
+
+ CPPServiceProxy::PROXIES CPPServiceProxy::getProxies()
+ {
+ return proxies;
+ }
+
+ void* CPPServiceProxy::getProxy()
+ {
+ logentry();
+
+ if (proxies.size() != 0)
+ {
+ return *proxies.begin();
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h
new file mode 100644
index 0000000000..8406e9bc44
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+
+#ifndef tuscany_sca_cpp_cppserviceproxy_h
+#define tuscany_sca_cpp_cppserviceproxy_h
+
+#include "osoa/sca/export.h"
+
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ /**
+ * Holds a proxy for a given component and reference.
+ * The proxy which is held inside a ServiceProxy will be specific to the component
+ * and reference and will have been code generated and be contained in a dll
+ * created by a developer of an SCA application.
+ */
+ class CPPServiceProxy : public ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a reference. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The reference on the source component.
+ * @param target The wrapper of the service which is wired to this reference.
+ */
+ CPPServiceProxy(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Create a new service proxy for a service. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The service on the target component.
+ * @param target The wrapper of the target service.
+ */
+ CPPServiceProxy(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPServiceProxy();
+
+ /**
+ * Return an instance of the proxy created for this particular component and reference.
+ * @return The proxy.
+ */
+ virtual void* getProxy();
+
+ /**
+ * Return the proxies created for this particular component and reference.
+ * @return The proxies.
+ */
+ typedef std::list<void*> PROXIES;
+ virtual PROXIES getProxies();
+
+ private:
+
+ /**
+ * Create the proxy
+ */
+ void createProxy(tuscany::sca::model::Component* component,
+ const std::string& name,
+ ServiceWrapper* serviceWrapper);
+
+ /**
+ * Holds the instances of the code generated proxies.
+ */
+ PROXIES proxies;
+
+ /**
+ * A function pointer to the destructor of the proxy.
+ */
+ typedef void (* PROXYDESTRUCTOR) (void*);
+ PROXYDESTRUCTOR destructor;
+
+ /**
+ * The library which contains the code for the proxy.
+ */
+ tuscany::sca::util::Library proxyLibrary;
+
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppserviceproxy_h
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp
new file mode 100644
index 0000000000..1304ab92a0
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp
@@ -0,0 +1,194 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/cpp/CPPServiceWrapper.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/model/Interface.h"
+
+using namespace std;
+using namespace osoa::sca;
+using namespace tuscany::sca::model;
+using namespace tuscany::sca::util;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ===========
+ // Constructor
+ // ===========
+ CPPServiceWrapper::CPPServiceWrapper(Service* service)
+ : ServiceWrapper(service)
+ {
+ logentry();
+
+ component = service->getComponent();
+ interf = service->getType()->getInterface();
+ implementation = (CPPImplementation*)component->getType();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ CPPServiceWrapper::~CPPServiceWrapper()
+ {
+ logentry();
+ }
+
+
+ // ======================================================================
+ // getImplementation: get an implementation for this scope
+ // ======================================================================
+ void* CPPServiceWrapper::getImplementation()
+ {
+ logentry();
+ if (implementation->getScope() == CPPImplementation::COMPOSITE)
+ {
+ // fill the cache if needed
+ if ( !implementation->getStaticImplementation() )
+ {
+ implementation->setStaticImplementation(newImplementation());
+ }
+ return implementation->getStaticImplementation();
+ }
+ else // (scope == CPPInterface::STATELESS)
+ {
+ return newImplementation();
+ }
+ }
+
+ // ======================================================================
+ // releaseImplementation: release the implementation for this scope
+ // ======================================================================
+ void CPPServiceWrapper::releaseImplementation()
+ {
+ logentry();
+ if (implementation->getScope() == CPPImplementation::STATELESS)
+ {
+ deleteImplementation();
+ }
+ }
+
+ // ======================================================================
+ // invoke: wrapper call to service with setting the component context
+ // ======================================================================
+ void CPPServiceWrapper::invoke(Operation& operation)
+ {
+ logentry();
+
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ runtime->setCurrentComponent(component);
+
+ try
+ {
+ invokeService(operation);
+ }
+ catch (...)
+ {
+ runtime->unsetCurrentComponent();
+ throw;
+ }
+ runtime->unsetCurrentComponent();
+ }
+
+ void CPPServiceWrapper::setLibrary(Library* lib)
+ {
+ wrapperLibrary = lib;
+ }
+
+ // ======================================================================
+ // getServiceWrapper: create a wrapper for the target ComponentService
+ // ======================================================================
+ CPPServiceWrapper* CPPServiceWrapper::getServiceWrapper(Service* service)
+ {
+ logentry();
+
+ CPPServiceWrapper* serviceWrapper = 0;
+
+ // -----------------------------------------------
+ // Get the implementation for the target component
+ // -----------------------------------------------
+ Component* component = service->getComponent();
+ CPPImplementation* impl = (CPPImplementation*)component->getType();
+ if (!impl)
+ {
+ string msg = "Component " + component->getName() + " has no implementation defined";
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+
+ // ----------------------------------------------------
+ // Get implementation dll name and wrapper factory name
+ // ----------------------------------------------------
+ string libraryName = impl->getLibrary();
+ string wrapperFactoryName = impl->getHeaderStub()
+ + "_" + service->getType()->getName() + "_Wrapper_Factory";
+
+ // ------------
+ // Load the dll
+ // ------------
+ string fullLibraryName = component->getComposite()->getRoot() + "/" + libraryName;
+ typedef CPPServiceWrapper* (* WRAPPERFACTORY) (Service*);
+ Library* wrapperLib = new Library(fullLibraryName);
+
+ // -------------------------
+ // Locate the factory method
+ // -------------------------
+ WRAPPERFACTORY wrapperFactory = (WRAPPERFACTORY)wrapperLib->getSymbol(wrapperFactoryName);
+ if (!wrapperFactory)
+ {
+ logerror("Unable to locate %s in library %s",
+ wrapperFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Unable to locate " + wrapperFactoryName + " in library " + fullLibraryName;
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+
+ // -------------------------------------
+ // Now create an instance of the wrapper
+ // -------------------------------------
+ serviceWrapper = wrapperFactory(service);
+ if (!serviceWrapper)
+ {
+ logerror("Factory method %s in library %s returned null",
+ wrapperFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Factory method " + wrapperFactoryName + " in library " + fullLibraryName + " returned null";
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+ serviceWrapper->setLibrary(wrapperLib);
+
+ return serviceWrapper;
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h
new file mode 100644
index 0000000000..899deca07a
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_cppservicewrapper_h
+#define tuscany_sca_cpp_cppservicewrapper_h
+
+#include "osoa/sca/export.h"
+
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/util/Library.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ /**
+ * Wraps the service on a component implementation.
+ * This abstract class is extended by generated code which provides
+ * the implementation of some of the methods.
+ * An instance of this class wraps the actual component implementation which
+ * has been written by a developer of an SCA application.
+ */
+ class SCA_CPP_API CPPServiceWrapper : public ServiceWrapper
+ {
+ public:
+ /**
+ * Factory method to create a new CPPServiceWrapper for a given target
+ * service. This method will provide all the loading of dlls required to
+ * create the target component.
+ * @param target The service on the component for which this wrapper is to be
+ * created.
+ * @return A wrapper that references the given target.
+ */
+ static CPPServiceWrapper* getServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Constructor.
+ * @param target The component service to which this wrapper refers.
+ */
+ CPPServiceWrapper(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPServiceWrapper();
+
+ /**
+ * All business method calls to the target component go through the invoke method.
+ * @param operation The details of the method, paramaters and return value for the
+ * business method to be called on the target component.
+ */
+ virtual void invoke(Operation& operation);
+
+ /**
+ * Return the loaded shared library for the target component.
+ */
+ tuscany::sca::util::Library* getLibrary() const { return wrapperLibrary; }
+
+ protected:
+
+ /**
+ * Delegated method to invoke the correct method on the target component.
+ * Implemented by the subtype.
+ */
+ virtual void invokeService(Operation& operation) = 0;
+
+ /**
+ * Delegated method to create a new component implementation.
+ * Implemented by the subtype.
+ * @return A pointer to an instance of the component implementation class.
+ */
+ virtual void* newImplementation() = 0;
+
+ /**
+ * Delegated method to delete the current instance of the component
+ * implementation.
+ * Implemented by the subtype.
+ */
+ virtual void deleteImplementation() = 0;
+
+ /**
+ * Return the current instance of the component implementation.
+ * @return A pointer to an instance of the component implementation class.
+ */
+ virtual void* getImplementation();
+
+ /**
+ * Indicates that the current instance of the component implementation
+ * has been finished with.
+ * Will call CPPServiceWrapper#deleteImplementation if the
+ * implementation is stateless (so that a new instance is returned
+ * for each call).
+ */
+ virtual void releaseImplementation();
+
+ private:
+ /**
+ * The component to which this wrapper refers.
+ */
+ tuscany::sca::model::Component* component;
+
+ /**
+ * A pointer to the interface which the service exposes.
+ */
+ tuscany::sca::model::Interface* interf;
+
+ /**
+ * The component implementation
+ */
+ CPPImplementation* implementation;
+
+ /**
+ * Pointer to the loaded library which contains the component
+ * implementation.
+ */
+ tuscany::sca::util::Library* wrapperLibrary;
+
+ /**
+ * Set the loaded library which contains the component
+ * implementation.
+ * @param lib The library.
+ */
+ void setLibrary(tuscany::sca::util::Library* lib);
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppservicewrapper_h
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp
new file mode 100644
index 0000000000..3de0cb968c
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/ComponentContextImpl.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ReferenceBinding.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+
+using namespace std;
+using namespace osoa::sca;
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ===========
+ // Constructor
+ // ===========
+ ComponentContextImpl::ComponentContextImpl(Component* comp)
+ : ComponentContext(0), component(comp)
+ {
+ logentry();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ComponentContextImpl::~ComponentContextImpl()
+ {
+ logentry();
+ }
+
+
+ // ==========================================================================
+ // getServices: return a list of Proxies for services wired to this reference
+ // ==========================================================================
+ std::list<void*> ComponentContextImpl::getServices(const std::string& referenceName)
+ {
+ logentry();
+ try
+ {
+ // --------------------------------------------------------------
+ // locate reference in the current component and determine target
+ // --------------------------------------------------------------
+ Reference* reference = component->findReference(referenceName);
+ if (!reference)
+ {
+ string message = "Reference not defined: ";
+ message = message + referenceName;
+ throwException(ServiceNotFoundException, message.c_str());
+ }
+
+ // Get a service proxy from the binding configured on the reference
+ CPPServiceProxy* serviceProxy = (CPPServiceProxy*)reference->getBinding()->getServiceProxy();
+ if (serviceProxy == NULL)
+ {
+ string message = "Reference ";
+ message = message + referenceName + " not wired";
+ throwException(ServiceNotFoundException, message.c_str());
+ }
+
+ return serviceProxy->getProxies();
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+
+ } // End getServices()
+
+
+ // ===================================================================
+ // getService: return a Proxy for the services wired to this reference
+ // ===================================================================
+ void* ComponentContextImpl::getService(const std::string& referenceName)
+ {
+ logentry();
+ try
+ {
+ // --------------------------------------------------------------
+ // locate reference in the current component and determine target
+ // --------------------------------------------------------------
+ Reference* reference = component->findReference(referenceName);
+ if (!reference)
+ {
+ string message = "Reference not defined: ";
+ message = message + referenceName;
+ throwException(ServiceNotFoundException, message.c_str());
+ }
+
+ // --------------------
+ // Validate the request
+ // --------------------
+ switch (reference->getType()->getMultiplicity())
+ {
+ case ReferenceType::ZERO_MANY:
+ case ReferenceType::ONE_MANY:
+ {
+ string message = "getService() called for reference with multiplicity >1 :";
+ message = message + referenceName;
+ throwException(ServiceNotFoundException, message.c_str());
+ }
+ default:
+ {
+ }
+ } // end switch
+
+ // Get a service proxy from the binding configured on the reference
+ CPPServiceProxy* serviceProxy = (CPPServiceProxy*)reference->getBinding()->getServiceProxy();
+ if (serviceProxy == NULL)
+ {
+ string message = "Reference ";
+ message = message + referenceName + " not wired";
+ throwException(ServiceNotFoundException, message.c_str());
+ }
+
+ void* service = serviceProxy->getProxy();
+
+ return service;
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+
+ } // End getService()
+
+ // ==============================================
+ // getProperties: return the component properties
+ // ==============================================
+ DataObjectPtr ComponentContextImpl::getProperties()
+ {
+ logentry();
+ try
+ {
+ DataObjectPtr properties = component->getProperties();
+ return properties;
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ // ==============================================
+ // getDataFactory: return the data factory for the composite in which
+ // this component resides
+ // ==============================================
+ commonj::sdo::DataFactoryPtr ComponentContextImpl::getDataFactory()
+ {
+ logentry();
+ try
+ {
+ commonj::sdo::DataFactoryPtr dataFactory = component->getComposite()->getDataFactory();
+ return dataFactory;
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h
new file mode 100644
index 0000000000..412c276d8c
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_componentcontextimpl_h
+#define tuscany_sca_cpp_componentcontextimpl_h
+
+#include "osoa/sca/ComponentContext.h"
+
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ /**
+ * Contains the actual implementation of a ComponentContext interface.
+ */
+ class ComponentContextImpl : public osoa::sca::ComponentContext
+ {
+
+ public:
+ /**
+ * Constructor that takes a Component which represents the runtime
+ * model for this context.
+ */
+ ComponentContextImpl(tuscany::sca::model::Component* component);
+
+ /**
+ * Default constructor.
+ */
+ virtual ~ComponentContextImpl();
+
+ /**
+ * See ComponentContext.
+ */
+ virtual void* getService(const std::string& referenceName);
+
+ /**
+ * See ComponentContext.
+ */
+ virtual std::list<void*> getServices(const std::string& referenceName);
+
+ /**
+ * See ComponentContext.
+ */
+ virtual commonj::sdo::DataObjectPtr getProperties();
+
+ /**
+ * See ComponentContext.
+ */
+ virtual commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Returns the contained Component.
+ * @return The Component to which this context refers.
+ */
+ virtual tuscany::sca::model::Component* getComponent() {return component;}
+
+ private:
+ ComponentContextImpl(const ComponentContextImpl&);
+ ComponentContextImpl& operator=(const ComponentContextImpl&);
+
+ /**
+ * Pointer to the runtime model Component to which this
+ * context refers.
+ */
+ tuscany::sca::model::Component* component;
+
+ /**
+ * Helper method to return a proxy to a service.
+ * @param serviceReference The source reference.
+ * @param target The target to which this source reference is wired.
+ * @return A pointer to an object which can be cast to the business
+ * class representing the target.
+ */
+ void* getServiceProxy(
+ tuscany::sca::model::Reference* serviceReference,
+ tuscany::sca::model::Service* target);
+
+ /**
+ * Helper method to return a wrapper for a target service.
+ * @param target The target for which this wrapper is to be created.
+ * @return The service wrapper.
+ */
+ ServiceWrapper* getServiceWrapper(tuscany::sca::model::Service* target);
+
+ };
+
+ } // End namespaca cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_componentcontextimpl_h
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp
new file mode 100644
index 0000000000..ae8183231e
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.cpp
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/CompositeContextImpl.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace osoa::sca;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ===========
+ // Constructor
+ // ===========
+ CompositeContextImpl::CompositeContextImpl(Component* component)
+ : CompositeContext(0), component(component), composite((Composite*)component->getType())
+ {
+ logentry();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ CompositeContextImpl::~CompositeContextImpl()
+ {
+ logentry();
+ }
+
+ // ===========================================================================
+ // locateService: return a proxy connected to a wrapper for the target service
+ // ===========================================================================
+ void* CompositeContextImpl::locateService(const std::string& serviceName)
+ {
+ logentry();
+ try
+ {
+ // ----------------------------
+ // Locate the component service
+ // ----------------------------
+ Service* service = composite->findComponentService(serviceName);
+ string msg;
+ if (!service)
+ {
+ msg = "Service not found: ";
+ msg = msg + serviceName;
+ throwException(ServiceNotFoundException, msg.c_str());
+ }
+
+ // ----------------------------
+ // Get a Proxy for this service
+ // ----------------------------
+
+ // The locate service API is used from CPP clients so we are using
+ // our default service proxy here
+ CPPServiceProxy* serviceProxy = new CPPServiceProxy(service);
+ return serviceProxy->getProxy();
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ // ==============================================
+ // getDataFactory: return the data factory for the current composite
+ // ==============================================
+ DataFactoryPtr CompositeContextImpl::getDataFactory()
+ {
+ logentry();
+ try
+ {
+ DataFactoryPtr dataFactory = composite->getDataFactory();
+ return dataFactory;
+ }
+ catch (ServiceRuntimeException&)
+ {
+ throw;
+ }
+ catch (TuscanyRuntimeException& e)
+ {
+ throwException(ServiceRuntimeException, e);
+ }
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h
new file mode 100644
index 0000000000..ed0bb8b51c
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/CompositeContextImpl.h
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_compositecontextimpl_h
+#define tuscany_sca_cpp_compositecontextimpl_h
+
+#include "osoa/sca/CompositeContext.h"
+
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace cpp
+ {
+
+ /**
+ * Contains the actual implementation of a CompositeContext interface.
+ */
+ class CompositeContextImpl : public osoa::sca::CompositeContext
+ {
+
+ public:
+ /**
+ * Constructor that takes a Composite which represents the runtime
+ * model for this context.
+ */
+ CompositeContextImpl(tuscany::sca::model::Component* component);
+
+ /**
+ * See CompositeContext#locateService.
+ */
+ virtual void* locateService(const std::string& serviceName);
+
+ /**
+ * See CompositeContext.
+ */
+ virtual commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Destructor.
+ */
+ virtual ~CompositeContextImpl();
+
+ private:
+ CompositeContextImpl(const CompositeContextImpl&);
+ CompositeContextImpl& operator=(const CompositeContextImpl&);
+
+ /**
+ * Pointer to the runtime model Composite object to which this
+ * context refers.
+ */
+ tuscany::sca::model::Composite* composite;
+
+ /**
+ * Pointer to the runtime model Component object to which this
+ * context refers.
+ */
+ tuscany::sca::model::Component* component;
+
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_compositecontextimpl_h
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp
new file mode 100644
index 0000000000..f8aad90f7a
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/cpp/TuscanyRuntime.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/core/Exceptions.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ===================================================================
+ // Constructor for the TuscanyRuntime class.
+ // ===================================================================
+ TuscanyRuntime::TuscanyRuntime(const string& componentName, const string& root, const string& path)
+ {
+ logentry();
+ loginfo("System root: %s", root.c_str());
+ systemRoot = root;
+ loginfo("System path: %s", path.c_str());
+ systemPath = path;
+ loginfo("Default component name: %s", componentName.c_str());
+ defaultComponentName = componentName;
+
+ runtime = new SCARuntime("", systemRoot, systemPath, "", defaultComponentName);
+ }
+
+ // ===================================================================
+ // Destructor for the TuscanyRuntime class.
+ // ===================================================================
+ TuscanyRuntime::~TuscanyRuntime()
+ {
+ logentry();
+
+ delete (SCARuntime*)runtime;
+ }
+
+ // ===================================================================
+ // Start the runtime.
+ // ===================================================================
+ void TuscanyRuntime::start()
+ {
+ logentry();
+ SCARuntime::setCurrentRuntime((SCARuntime*)runtime);
+ }
+
+ // ===================================================================
+ // Stop the runtime.
+ // ===================================================================
+ void TuscanyRuntime::stop()
+ {
+ logentry();
+ SCARuntime::setCurrentRuntime(NULL);
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h
new file mode 100644
index 0000000000..b4cf31220a
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_tuscanyruntime_h
+#define tuscany_sca_cpp_tuscanyruntime_h
+
+#include <string>
+
+#include "osoa/sca/export.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ /**
+ * A singleton which represents the executing SCA runtime.
+ */
+ class SCA_CPP_API TuscanyRuntime
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ TuscanyRuntime(const std::string& defaultComponentName = "",
+ const std::string& root = "", const std::string& path = "");
+
+ /**
+ * Destructor
+ */
+ virtual ~TuscanyRuntime();
+
+ /**
+ * start the runtime
+ */
+ void start();
+
+ /**
+ * stop the runtime
+ */
+ void stop();
+
+
+ private:
+ std::string systemRoot;
+ std::string systemPath;
+ std::string defaultComponentName;
+
+ void* defaultComponent;
+ void* runtime;
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_tuscanyruntime_h
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp
new file mode 100644
index 0000000000..56098ced93
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.cpp
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/cpp/model/CPPServiceBinding.h"
+#include "tuscany/sca/cpp/model/CPPReferenceBinding.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace cpp
+ {
+
+ // Constructor
+ CPPImplementation::CPPImplementation(Composite* composite, const string& library, const string& header,
+ const string&headerPath, const string& headerStub, const string& className, Scope scope)
+ : ComponentType(composite, headerPath + headerStub),
+ library(library), header(header), headerPath(headerPath),
+ headerStub(headerStub), className(className), scope(scope), staticImpl(0)
+ {
+ }
+
+ CPPImplementation::~CPPImplementation()
+ {
+ }
+
+ void CPPImplementation::initializeComponent(Component* component)
+ {
+ ComponentType::initializeComponent(component);
+
+ // Create CPP bindings for all the services
+ const Component::SERVICE_MAP& services = component->getServices();
+ Component::SERVICE_MAP::const_iterator iter = services.begin();
+ for (unsigned int i=0; i< services.size(); i++)
+ {
+ Service *service = iter->second;
+ CPPServiceBinding* binding = new CPPServiceBinding(service);
+ service->setBinding(binding);
+ iter++;
+ }
+
+ // Create CPP bindings for all the references
+ const Component::REFERENCE_MAP& references = component->getReferences();
+ Component::REFERENCE_MAP::const_iterator refiter = references.begin();
+ for (unsigned int ri=0; ri< references.size(); ri++)
+ {
+ Reference *reference = refiter->second;
+ CPPReferenceBinding* binding = new CPPReferenceBinding(reference);
+ reference->setBinding(binding);
+ refiter++;
+ }
+ }
+
+ void CPPImplementation::setStaticImplementation(void* staticImpl)
+ {
+ this->staticImpl = staticImpl;
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h
new file mode 100644
index 0000000000..2dfdac616e
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPImplementation.h
@@ -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$ */
+
+#ifndef tuscany_sca_cpp_model_cppimplementation_h
+#define tuscany_sca_cpp_model_cppimplementation_h
+
+#include <map>
+#include <string>
+
+#include "tuscany/sca/model/ComponentType.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ /**
+ * Holds information about an SCA implementation written in C++
+ */
+ class CPPImplementation : public tuscany::sca::model::ComponentType
+ {
+
+ public:
+ /**
+ * Scope of the component implementation.
+ */
+ enum Scope
+ {
+ COMPOSITE,
+ STATELESS
+ };
+
+ /**
+ * Constructor.
+ * @param dllName Name of the shared library.
+ * @param header Name of the header file that contains the class declaring the
+ * implementation class.
+ * @param className Name of the class in the header file (could be a blank string
+ * if this is not specified).
+ */
+ CPPImplementation(tuscany::sca::model::Composite* composite,
+ const std::string& library, const std::string& header, const std::string&headerPath,
+ const std::string& headerStub, const std::string& className, Scope scope);
+
+ /**
+ * Destructor
+ */
+ virtual ~CPPImplementation();
+
+ /**
+ * Initialize a component of this type.
+ * @param component The component to initialize.
+ */
+ virtual void initializeComponent(tuscany::sca::model::Component* component);
+
+ /**
+ * Returns the name of the shared library.
+ * @return The name of the shared library.
+ */
+ const std::string& getLibrary() const { return library; }
+
+ /**
+ * Get the name of the header file.
+ * @return Name of the header file.
+ */
+ const std::string& getHeader() const { return header; }
+
+ /**
+ * Get the header file name without the extension.
+ * @return The name of the header file without any extension.
+ */
+ const std::string& getHeaderStub() const { return headerStub; }
+
+ /**
+ * Get the header path.
+ * @return The pathe element of the header.
+ */
+ const std::string& getHeaderPath() const { return headerPath; }
+
+ /**
+ * Get the name of the class.
+ * @return The class name if specified.
+ */
+ const std::string& getClass() const { return className; }
+
+ /**
+ * Returns the implementation scope
+ */
+ Scope getScope() { return scope; }
+
+ /**
+ * Returns the implementation instance (to be used if the scope is set to composite)
+ */
+ void* getStaticImplementation() { return staticImpl; }
+
+ /**
+ * Sets the implementation instance (to be used if the scope is set to composite)
+ */
+ void setStaticImplementation(void* staticImpl);
+
+ private:
+
+ /**
+ * Name of the shared library.
+ */
+ std::string library;
+
+ /**
+ * Name of the header file describing the interface.
+ */
+ std::string header;
+
+ /**
+ * Name of the header file without the extension.
+ */
+ std::string headerStub;
+
+ /**
+ * Path element of the header.
+ */
+ std::string headerPath;
+
+ /**
+ * Name of the class in the header file declaring the implementation.
+ * May be an empty string if not set in the SCDL file.
+ */
+ std::string className;
+
+ /**
+ * Scope of the implementation
+ */
+ Scope scope;
+
+ /**
+ * Holds the implementation instance if the scope is set to composite.
+ */
+ void* staticImpl;
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_model_cppimplementation_h
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp
new file mode 100644
index 0000000000..2322d1bdf5
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.cpp
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/cpp/model/CPPInterface.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ const string CPPInterface::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPInterface");
+
+ // Constructor
+ CPPInterface::CPPInterface(
+ const string& header,
+ const string& className,
+ bool remotable,
+ bool conversational)
+ : Interface(remotable, conversational), header(header), className(className)
+ {
+ string::size_type dot = header.rfind(".h"); // this will also find .hpp
+ if (dot != string::npos)
+ {
+ headerStub = header.substr(0, dot);
+ }
+ else
+ {
+ headerStub = header;
+ }
+
+ }
+
+ CPPInterface::~CPPInterface()
+ {
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h
new file mode 100644
index 0000000000..fdbf314d3d
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPInterface.h
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_model_cppinterface_h
+#define tuscany_sca_cpp_model_cppinterface_h
+
+#include <string>
+
+#include "tuscany/sca/model/Interface.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ /**
+ * Holds information about an interface described using a C++
+ * header file.
+ */
+ class CPPInterface : public tuscany::sca::model::Interface
+ {
+
+ public:
+ /**
+ * Constuctor.
+ * @param header Name of the header file containing the class that
+ * describes the interface.
+ * @param className Name of the class in the header file that
+ * describes the interface.
+ * @param scope The scope of the interface (stateless or composite).
+ * @param remotable True if the interface is remotable.
+ */
+ CPPInterface(
+ const std::string& header,
+ const std::string& className,
+ bool remotable,
+ bool conversational);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPInterface();
+
+ /**
+ * Get the name of the header file.
+ * @return The name of the header file containing the definition of the
+ * interface.
+ */
+ const std::string& getHeader() { return header; }
+
+ /**
+ * Return the name of the header file without the extension.
+ * @return Header file name without any extension.
+ */
+ const std::string& getHeaderStub() { return headerStub; }
+
+ /**
+ * Get the name of the class.
+ * @return The name of the class defining the interface.
+ */
+ const std::string& getClass() { return className; }
+
+ /**
+ * return the QName of the schema type for this interface type
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#interface.cpp")
+ */
+ virtual const std::string& getInterfaceTypeQName() { return typeQName; };
+
+ private:
+
+ /**
+ * Name of the header file containing the definition of the interface.
+ */
+ std::string header;
+
+ /**
+ * Name of the header file without the extension.
+ */
+ std::string headerStub;
+
+ /**
+ * Name of the class in the header file.
+ */
+ std::string className;
+
+ /**
+ * The QName of the schema type for this interface type.
+ */
+ static const std::string typeQName;
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_model_cppinterface_h
+
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp
new file mode 100644
index 0000000000..0c12b7af43
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.cpp
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/model/CPPReferenceBinding.h"
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+
+using namespace tuscany::sca::model;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // Constructor
+ CPPReferenceBinding::CPPReferenceBinding(Reference* reference)
+ : ReferenceBinding(reference, ""), serviceProxy(NULL)
+ {
+ }
+
+ // Destructor
+ CPPReferenceBinding::~CPPReferenceBinding()
+ {
+ }
+
+ ServiceProxy* CPPReferenceBinding::getServiceProxy()
+ {
+ return serviceProxy;
+ }
+
+ void CPPReferenceBinding::configure(ServiceBinding* binding)
+ {
+ setTargetServiceBinding(binding);
+
+ serviceProxy = new CPPServiceProxy(getReference());
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h
new file mode 100644
index 0000000000..9860f14765
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPReferenceBinding.h
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_cpp_model_cppreferencebinding_h
+#define tuscany_sca_cpp_model_cppreferencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ /**
+ * Information about a CPP service binding for service or a reference.
+ */
+ class CPPReferenceBinding : public tuscany::sca::model::ReferenceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ * @param port The definition of the port to which the entrypoint
+ * or external service is to be bound. This is of the form
+ * "namespace"#endpoint("service"/"port")
+ */
+ CPPReferenceBinding(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPReferenceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#CPPImplementationBinding"; };
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ virtual ServiceProxy* getServiceProxy();
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding);
+
+ private:
+
+ /**
+ * The proxy representing the reference to the client
+ * component.
+ */
+ ServiceProxy* serviceProxy;
+
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_model_cppreferencebinding_h
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp
new file mode 100644
index 0000000000..45afea8375
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.cpp
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/cpp/model/CPPServiceBinding.h"
+#include "tuscany/sca/cpp/CPPServiceWrapper.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // Constructor
+ CPPServiceBinding::CPPServiceBinding(Service* service)
+ : ServiceBinding(service, "")
+ {
+ serviceWrapper = CPPServiceWrapper::getServiceWrapper(service);
+ }
+
+ // Destructor
+ CPPServiceBinding::~CPPServiceBinding()
+ {
+ }
+
+ ServiceWrapper* CPPServiceBinding::getServiceWrapper()
+ {
+ return (ServiceWrapper*)serviceWrapper;
+ }
+
+ } // End namespace ws
+ } // End namespace sca
+} // End namespace tuscany
diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/tuscany/sca/cpp/model/CPPServiceBinding.h
new file mode 100644
index 0000000000..13b88a84dd
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/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 <string>
+
+#include "tuscany/sca/model/ServiceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ /**
+ * Information about a CPP service binding for service or a reference.
+ */
+ class CPPServiceBinding : public tuscany::sca::model::ServiceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ * @param uri The uri of the binding.
+ * @param port The definition of the port to which the entrypoint
+ * or external service is to be bound. This is of the form
+ * "namespace"#endpoint("service"/"port")
+ */
+ CPPServiceBinding(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPServiceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#CPPImplementationBinding"; };
+
+ /**
+ * Create a wrapper for the service configured by this
+ * binding.
+ */
+ virtual ServiceWrapper* getServiceWrapper();
+
+ private:
+
+ /**
+ * The wrapper for the service configured by this binding.
+ */
+ ServiceWrapper* serviceWrapper;
+
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_model_cppservicebinding_h