summaryrefslogtreecommitdiffstats
path: root/tags/cpp-sca-20060405/runtime/core/src/osoa/sca
diff options
context:
space:
mode:
Diffstat (limited to 'tags/cpp-sca-20060405/runtime/core/src/osoa/sca')
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.cpp132
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.h105
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.cpp270
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.h120
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.cpp93
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.h80
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.cpp102
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.h71
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/SCA.cpp21
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.cpp105
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.h84
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp208
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.h236
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/export.h39
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/osoa/sca/sca.h29
15 files changed, 1695 insertions, 0 deletions
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.cpp b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.cpp
new file mode 100644
index 0000000000..73c3ed2e36
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.cpp
@@ -0,0 +1,132 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ComponentContext.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "osoa/sca/ComponentContextImpl.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace tuscany::sca;
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ // =======================================================
+ // getCurrent: create a context from the current component
+ // =======================================================
+ ComponentContext ComponentContext::getCurrent()
+ {
+ LOGENTRY(1, "ComponentContext::getCurrent");
+ Component* component = SCARuntime::getInstance()->getCurrentComponent();
+ if (!component)
+ {
+ throw ComponentContextException("No current component");
+ }
+ ComponentContextImpl* cci = new ComponentContextImpl(component);
+ LOGEXIT(1, "ComponentContext::constructor");
+ return ComponentContext(cci);
+ }
+
+ // ===========
+ // Constructor
+ // ===========
+ ComponentContext::ComponentContext(ComponentContextImpl* implementation)
+ : impl(implementation)
+ {
+ LOGENTRY(1, "ComponentContext::constructor");
+ LOGEXIT(1, "ComponentContext::constructor");
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ComponentContext::~ComponentContext()
+ {
+ LOGENTRY(1, "ComponentContext::destructor");
+ delete impl;
+ LOGEXIT(1, "ComponentContext::destructor");
+ }
+
+ // ===================================
+ // Copy constructor: create a new impl
+ // ===================================
+ ComponentContext::ComponentContext(const ComponentContext& ctx)
+ {
+ impl = new ComponentContextImpl(impl->getComponent());
+ }
+
+ // =============================
+ // operator= : create a new impl
+ // =============================
+ ComponentContext& ComponentContext::operator=(const ComponentContext& ctx)
+ {
+ if (this != &ctx)
+ {
+ impl = new ComponentContextImpl(impl->getComponent());
+ }
+ return *this;
+ }
+
+ // ==========
+ // getService
+ // ==========
+ void* ComponentContext::getService(const char* referenceName)
+ {
+ LOGENTRY(1, "ComponentContext::getService");
+ void* service = impl->getService(referenceName);
+ LOGEXIT(1, "ComponentContext::getService");
+ return service;
+ }
+
+ // ===========
+ // getServices
+ // ===========
+ ServiceList ComponentContext::getServices(const char* referenceName)
+ {
+ return impl->getServices(referenceName);
+ }
+
+ // ============
+ // getProperties
+ // =============
+ DataObjectPtr ComponentContext::getProperties()
+ {
+ LOGENTRY(1, "ComponentContext::getProperties");
+ DataObjectPtr properties = impl->getProperties();
+ LOGEXIT(1, "ComponentContext::getProperties");
+ return properties;
+ }
+
+ // ============
+ // getDataFactory
+ // =============
+ DataFactoryPtr ComponentContext::getDataFactory()
+ {
+ LOGENTRY(1, "ComponentContext::getDataFactory");
+ DataFactoryPtr dataFactory = impl->getDataFactory();
+ LOGEXIT(1, "ComponentContext::getDataFactory");
+ return dataFactory;
+ }
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.h b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.h
new file mode 100644
index 0000000000..10d334a936
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContext.h
@@ -0,0 +1,105 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_componentcontext_h
+#define osoa_sca_componentcontext_h
+
+#include "osoa/sca/export.h"
+#include "osoa/sca/ServiceList.h"
+#include "commonj/sdo/SDO.h"
+namespace osoa
+{
+ namespace sca
+ {
+ class ComponentContextImpl;
+
+ /**
+ * An SCA component implementation uses the ComponentContext class to
+ * retrieve information about the configured SCA component.
+ */
+ class SCA_API ComponentContext
+ {
+
+ public:
+ /**
+ * Return a new ComponentContext for the current Component.
+ */
+ static ComponentContext getCurrent();
+
+ /**
+ * Resolve a reference name into a single configured service.
+ * If the component's reference is wired to more than one service
+ * then theis method will return an exception.
+ * @param referenceName The reference to be resolved. This must match
+ * the name of a reference configured in the component type file for
+ * this component.
+ */
+ void* getService(const char* referenceName);
+
+ /**
+ * Resolve a reference name into a list of configured services.
+ * @param referenceName The reference to be resolved. This must match
+ * the name of a reference configured in the component type file for
+ * this component.
+ */
+ ServiceList getServices(const char* referenceName);
+
+ /**
+ * Get the configured properties for the component.
+ * @return A data object representing all the properties that
+ * are configured for this component.
+ */
+ commonj::sdo::DataObjectPtr getProperties();
+
+ /**
+ * Get an SDO data factory which will allow the component to
+ * create data objects for all the types configured for this
+ * component.
+ * @return A data factory to be used by the component to create
+ * new data objects.
+ */
+ commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Destructor
+ */
+ virtual ~ComponentContext();
+
+
+ ComponentContext(const ComponentContext&);
+ ComponentContext& operator=(const ComponentContext&);
+
+ private:
+ /**
+ * Constructor to create an interface class from the contained
+ * implementation.
+ * @param implementation the actual implementation class
+ */
+ ComponentContext(ComponentContextImpl* implementation);
+
+ /**
+ * Pointer to the class which provides the actual implementation.
+ */
+ ComponentContextImpl* impl;
+
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_componentcontext_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.cpp b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.cpp
new file mode 100644
index 0000000000..436e44d5e1
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.cpp
@@ -0,0 +1,270 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "osoa/sca/ComponentContextImpl.h"
+#include "tuscany/sca/model/WireTarget.h"
+#include "tuscany/sca/core/ComponentServiceWrapper.h"
+#include "tuscany/sca/core/ExternalServiceWrapper.h"
+#include "tuscany/sca/model/CPPImplementation.h"
+#include "tuscany/sca/model/Module.h"
+
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+namespace osoa
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ ComponentContextImpl::ComponentContextImpl(Component* comp)
+ : component(comp)
+ {
+ LOGENTRY(1, "ComponentContextImpl::constructor");
+ LOGEXIT(1, "ComponentContextImpl::constructor");
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ComponentContextImpl::~ComponentContextImpl()
+ {
+ // --------------------------------------------
+ // Delete the proxies served up by this context
+ // --------------------------------------------
+ for (PROXIES::iterator iter = proxies.begin(); iter != proxies.end(); iter++)
+ {
+ delete (ServiceProxy*)*iter;
+ }
+ }
+
+
+ // ==========================================================================
+ // getServices: return a list of Proxies for services wired to this reference
+ // ==========================================================================
+ ServiceList ComponentContextImpl::getServices(const char* referenceName)
+ {
+ LOGENTRY(1, "ComponentContextImpl::getServices");
+
+ string message;
+
+ // --------------------------------------------------------------
+ // locate reference in the current component and determine target
+ // --------------------------------------------------------------
+ ServiceReference* serviceReference = component->findReference(referenceName);
+ if (!serviceReference)
+ {
+ message = "Reference not defined: ";
+ message = message + referenceName;
+ throw ServiceNotFoundException(message.c_str());
+ }
+
+ // Get the target services from the ServiceReference
+ const ServiceReference::TARGETS& targets = serviceReference->getTargets();
+
+ // --------------------
+ // Validate the request
+ // --------------------
+ switch (serviceReference->getMultiplicity())
+ {
+ case ServiceReference::ONE_MANY:
+ case ServiceReference::ONE_ONE:
+ {
+ if (targets.size() == 0)
+ {
+ message = "Reference ";
+ message = message + referenceName + " not wired";
+ throw ServiceNotFoundException(message.c_str());
+ }
+ }
+ default:
+ {
+ }
+ } // end switch
+
+ // ------------------------------
+ // Create a proxy for each target
+ // ------------------------------
+ ServiceList services(targets.size());
+ for (ServiceReference::TARGETS::const_iterator iter = targets.begin();
+ iter!=targets.end();
+ iter++)
+ {
+ services.addService(getServiceProxy(serviceReference, *iter));
+ }
+
+ return services;
+
+ } // End getServices()
+
+
+ // ===================================================================
+ // getService: return a Proxy for the services wired to this reference
+ // ===================================================================
+ void* ComponentContextImpl::getService(const char* referenceName)
+ {
+ LOGENTRY(1, "ComponentContextImpl::getService");
+
+ string message;
+
+ // --------------------------------------------------------------
+ // locate reference in the current component and determine target
+ // --------------------------------------------------------------
+ ServiceReference* serviceReference = component->findReference(referenceName);
+ if (!serviceReference)
+ {
+ message = "Reference not defined: ";
+ message = message + referenceName;
+ throw ServiceNotFoundException(message.c_str());
+ }
+
+ // Get the target service from the ServiceReference
+ const ServiceReference::TARGETS& targets = serviceReference->getTargets();
+
+ // --------------------
+ // Validate the request
+ // --------------------
+ switch (serviceReference->getMultiplicity())
+ {
+ case ServiceReference::ZERO_MANY:
+ case ServiceReference::ONE_MANY:
+ {
+ message = "getService() called for reference with multiplicity >1 :";
+ message = message + referenceName;
+ throw ServiceNotFoundException(message.c_str());
+ }
+ case ServiceReference::ONE_ONE:
+ {
+ if (targets.size() == 0)
+ {
+ message = "Reference ";
+ message = message + referenceName + " not wired";
+ throw ServiceNotFoundException(message.c_str());
+ }
+ }
+ default:
+ {
+ }
+ } // end switch
+
+ // Return the proxy
+ return getServiceProxy(serviceReference, *targets.begin());
+
+ } // End getService()
+
+
+ // ==================================================================
+ // getServiceProxy: Create and return an instance of the ServiceProxy
+ // ==================================================================
+ void* ComponentContextImpl::getServiceProxy(
+ ServiceReference* serviceReference,
+ WireTarget* target)
+ {
+ // -----------------------------------
+ // Get a ServiceWrapper for the target
+ // -----------------------------------
+ ServiceWrapper* serviceWrapper = getServiceWrapper(target);
+
+ // ------------------------------
+ // Get a Proxy for this reference
+ // ------------------------------
+ try
+ {
+ ServiceProxy* serviceProxy = new ServiceProxy(component, serviceReference->getName(), serviceWrapper);
+ void* service = serviceProxy->getProxy();
+ // service MUST be set here or an exception will have been thrown
+ proxies.push_back(serviceProxy);
+ return service;
+ }
+ catch (ServiceRuntimeException&)
+ {
+ delete serviceWrapper;
+ throw ;
+ }
+ }
+
+
+ // ======================================================================
+ // getServiceWrapper: Create and return an instance of the ServiceWrapper
+ // ======================================================================
+ ServiceWrapper* ComponentContextImpl::getServiceWrapper(WireTarget* target)
+ {
+ // -------------------------
+ // Determine type of Service
+ // -------------------------
+ switch (target->getServiceType())
+ {
+ case WireTarget::ExternalServiceType:
+ {
+ // ----------------
+ // External Service
+ // ----------------
+ return ExternalServiceWrapper::createServiceWrapper((ExternalService*)target);
+ }
+
+ case WireTarget::ComponentServiceType:
+ {
+ // -----------------
+ // Component Service
+ // -----------------
+ return ComponentServiceWrapper::createServiceWrapper((Service*)target);
+ }
+
+ default:
+ {
+ string message = "Undefined wire target type for : ";
+ message = message + target->getName();
+ throw ServiceNotFoundException(message.c_str());
+ }
+ } // end switch
+ }
+
+
+
+ // ==============================================
+ // getProperties: return the component properties
+ // ==============================================
+ DataObjectPtr ComponentContextImpl::getProperties()
+ {
+ LOGENTRY(1, "ComponentContextImpl::getProperties");
+ DataObjectPtr properties = component->getProperties();
+
+ LOGEXIT(1, "ComponentContextImpl::getProperties");
+ return properties;
+ }
+
+ // ==============================================
+ // getDataFactory: return the data factory for the module in which
+ // this component resides
+ // ==============================================
+ DataFactoryPtr ComponentContextImpl::getDataFactory()
+ {
+ LOGENTRY(1, "ComponentContextImpl::getProperties");
+ DataFactoryPtr dataFactory = component->getModule()->getDataFactory();
+
+ LOGEXIT(1, "ComponentContextImpl::getDataFactory");
+ return dataFactory;
+ }
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.h b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.h
new file mode 100644
index 0000000000..bd3a0d106a
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ComponentContextImpl.h
@@ -0,0 +1,120 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_componentcontextimpl_h
+#define osoa_sca_componentcontextimpl_h
+
+#include "osoa/sca/ServiceList.h"
+
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/model/Service.h"
+
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+namespace osoa
+{
+ namespace sca
+ {
+ /**
+ * Contains the actual implementation of a ComponentContext interface.
+ */
+ class ComponentContextImpl
+ {
+
+ public:
+ /**
+ * Constructor that takes a Component which represents the runtime
+ * model for this context.
+ */
+ ComponentContextImpl(Component* component);
+
+ /**
+ * Default constructor.
+ */
+ virtual ~ComponentContextImpl();
+
+ /**
+ * See ComponentContext.
+ */
+ void* getService(const char* referenceName);
+
+ /**
+ * See ComponentContext.
+ */
+ ServiceList getServices(const char* referenceName);
+
+ /**
+ * See ComponentContext.
+ */
+ DataObjectPtr getProperties();
+
+ /**
+ * See ComponentContext.
+ */
+ commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Returns the contained Component.
+ * @return The Component to which this context refers.
+ */
+ Component* getComponent() {return component;}
+
+ private:
+ ComponentContextImpl(const ComponentContextImpl&);
+ ComponentContextImpl& operator=(const ComponentContextImpl&);
+
+ /**
+ * Pointer to the runtime model Component to which this
+ * context refers.
+ */
+ Component* component;
+
+ /**
+ * Helper method to return a proxy to a service.
+ * @param serviceReference The source reference.
+ * @param target The target to which this source reference is wired.
+ * @return A pointer to an object which can be cast to the business
+ * class representing the target.
+ */
+ void* getServiceProxy(
+ ServiceReference* serviceReference,
+ WireTarget* target);
+
+ /**
+ * Helper method to return a wrapper for a target service.
+ * @param target The target for which this wrapper is to be created.
+ * @return The service wrapper.
+ */
+ ServiceWrapper* getServiceWrapper(WireTarget* target);
+
+
+ typedef vector<ServiceProxy*> PROXIES;
+ /**
+ * A vector of the proxies created by this ComponentContext. The
+ * proxies will be destroyed when the ComponentContext is destroyed.
+ */
+ PROXIES proxies;
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_componentcontextimpl_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.cpp b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.cpp
new file mode 100644
index 0000000000..93e36b297f
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.cpp
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ModuleContext.h"
+#include "tuscany/sca/util/Logging.h"
+#include "osoa/sca/ModuleContextImpl.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace tuscany::sca;
+
+namespace osoa
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ ModuleContext::ModuleContext(ModuleContextImpl* implementation)
+ : impl(implementation)
+ {
+ }
+
+ // ===================================
+ // Copy constructor: create a new impl
+ // ===================================
+ ModuleContext::ModuleContext(const ModuleContext& ctx)
+ {
+ impl = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule());
+ }
+
+ // =============================
+ // operator= : create a new impl
+ // =============================
+ ModuleContext& ModuleContext::operator=(const ModuleContext& ctx)
+ {
+ if (this != &ctx)
+ {
+ impl = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule());
+ }
+ return *this;
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ModuleContext::~ModuleContext()
+ {
+ LOGENTRY(1, "ModuleContext::destructor");
+ delete impl;
+ LOGEXIT(1, "ModuleContext::destructor");
+ }
+
+ // ====================================================
+ // getCurrent: create a context from the current module
+ // ====================================================
+ ModuleContext ModuleContext::getCurrent()
+ {
+ LOGENTRY(1, "ModuleContext::getCurrent");
+ ModuleContextImpl* mci = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule());
+ LOGEXIT(1, "ModuleContext::getCurrent");
+ return ModuleContext(mci);
+ }
+
+ // =============
+ // locateService
+ // =============
+ void* ModuleContext::locateService(const char* serviceName)
+ {
+ LOGENTRY(1, "ModuleContext::locateService");
+ void* sp = impl->locateService(serviceName);
+ LOGEXIT(1, "ModuleContext::locateService");
+ return sp;
+ }
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.h b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.h
new file mode 100644
index 0000000000..7aacb00123
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContext.h
@@ -0,0 +1,80 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_modulecontext_h
+#define osoa_sca_modulecontext_h
+
+#include "osoa/sca/export.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+ class ModuleContextImpl;
+
+ /**
+ * An SCA component implementation, or a non-SCA client, uses the
+ * ModuleContext class to retrieve information about the configured
+ * SCA module.
+ */
+ class SCA_API ModuleContext
+ {
+
+ public:
+ /**
+ * Return a new ModuleContext for the current Component.
+ */
+ static ModuleContext getCurrent();
+
+ /**
+ * Resolve a service name into a single component service.
+ * @param serviceName The name of the service in the form
+ * "component name"/"service name". The service name is
+ * optional in the component has one service.
+ * @return A pointer to an object which can be cast to the
+ * business interface of the target service.
+ */
+ void* locateService(const char* serviceName);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ModuleContext();
+
+ ModuleContext(const ModuleContext&);
+ ModuleContext& operator=(const ModuleContext&);
+
+ private:
+ /**
+ * Constructor to create an interface class from the contained
+ * implementation.
+ * @param implementation The actual implementation class.
+ */
+ ModuleContext(ModuleContextImpl* implementation);
+
+ /**
+ * Pointer to the class which provides the actual implementation.
+ */
+ ModuleContextImpl* impl;
+
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_modulecontext_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.cpp b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.cpp
new file mode 100644
index 0000000000..4d96ee336d
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.cpp
@@ -0,0 +1,102 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/CPPImplementation.h"
+#include "osoa/sca/ModuleContextImpl.h"
+#include "tuscany/sca/core/ComponentServiceWrapper.h"
+
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+namespace osoa
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ ModuleContextImpl::ModuleContextImpl(Module* mod)
+ : module(mod)
+ {
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ModuleContextImpl::~ModuleContextImpl()
+ {
+ // --------------------------------------------
+ // Delete the proxies served up by this context
+ // --------------------------------------------
+ for (PROXIES::iterator iter = proxies.begin(); iter != proxies.end(); iter++)
+ {
+ delete (ServiceProxy*)*iter;
+ }
+ }
+
+ // ===========================================================================
+ // locateService: return a proxy connected to a wrapper for the target service
+ // ===========================================================================
+ void* ModuleContextImpl::locateService(const char* serviceName)
+ {
+ LOGENTRY(1, "ModuleContextImpl::locateService");
+
+
+ // ----------------------------
+ // Locate the component service
+ // ----------------------------
+ Service* service = module->findComponentService(serviceName);
+ string msg;
+ if (!service)
+ {
+ msg = "Service not found: ";
+ msg = msg + serviceName;
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // -------------------------
+ // Create the ServiceWrapper
+ // -------------------------
+ ComponentServiceWrapper* serviceWrapper = ComponentServiceWrapper::createServiceWrapper(service);
+
+ // ----------------------------
+ // Get a Proxy for this service
+ // ----------------------------
+ try
+ {
+ ServiceProxy* serviceProxy = new ServiceProxy(service->getComponent(), service->getName(), serviceWrapper);
+ proxies.push_back(serviceProxy);
+ LOGEXIT(1, "ModuleContextImpl::locateService");
+ return serviceProxy->getProxy();
+ }
+ catch (ServiceRuntimeException&)
+ {
+ delete serviceWrapper;
+ throw ;
+ }
+
+ }
+
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.h b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.h
new file mode 100644
index 0000000000..5950313a06
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ModuleContextImpl.h
@@ -0,0 +1,71 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_modulecontextimpl_h
+#define osoa_sca_modulecontextimpl_h
+#include "tuscany/sca/model/Module.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+ /**
+ * Contains the actual implementation of a ModuleContext interface.
+ */
+ class ModuleContextImpl
+ {
+
+ public:
+ /**
+ * Constructor that takes a Module which represents the runtime
+ * model for this context.
+ */
+ ModuleContextImpl(tuscany::sca::model::Module* module);
+
+ /**
+ * See ModuleContext#locateService.
+ */
+ void* locateService(const char* serviceName);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ModuleContextImpl();
+ private:
+ ModuleContextImpl(const ModuleContextImpl&);
+ ModuleContextImpl& operator=(const ModuleContextImpl&);
+
+ /**
+ * Pointer to the runtime model Module object to which this
+ * context refers.
+ */
+ tuscany::sca::model::Module* module;
+
+ typedef vector<tuscany::sca::ServiceProxy*> PROXIES;
+ /**
+ * Vector of proxies created from calls to the locateService
+ * method.
+ */
+ PROXIES proxies;
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_modulecontextimpl_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/SCA.cpp b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/SCA.cpp
new file mode 100644
index 0000000000..bcca254028
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/SCA.cpp
@@ -0,0 +1,21 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev: $ $Date: $ */
+
+#include "osoa/sca/sca.h"
+
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.cpp b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.cpp
new file mode 100644
index 0000000000..ba2b418a7c
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.cpp
@@ -0,0 +1,105 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ServiceList.h"
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+ // ===========
+ // Constructor
+ // ===========
+ ServiceList::ServiceList(unsigned int numTargets)
+ : maxServices(numTargets), numServices(0)
+ {
+ services = new void*[numTargets];
+ }
+
+ // ==========================================
+ // Copy comstructor: create new service array
+ // ==========================================
+ ServiceList::ServiceList(const ServiceList& sl)
+ : maxServices(sl.maxServices), numServices(sl.numServices)
+ {
+ services = new void*[maxServices];
+ for (unsigned int i=0; i<numServices; i++)
+ {
+ services[i] = sl.services[i];
+ }
+ }
+
+ // ===================================
+ // operator=: create new service array
+ // ===================================
+ ServiceList& ServiceList::operator=(const ServiceList& sl)
+ {
+ if (this != &sl)
+ {
+ maxServices = sl.maxServices;
+ numServices = sl.numServices;
+
+ services = new void*[maxServices];
+ for (unsigned int i=0; i<numServices; i++)
+ {
+ services[i] = sl.services[i];
+ }
+ }
+ return *this;
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ServiceList::~ServiceList()
+ {
+ delete [] services;
+ }
+
+ // =================================
+ // operator[]: return service at pos
+ // =================================
+ void* ServiceList::operator[] (unsigned int pos)
+ {
+ if (pos < numServices)
+ {
+ return services[pos];
+ }
+ else
+ {
+ throw ServiceRuntimeException("ServiceList: index out of bounds");
+ }
+ }
+
+ // ====================================
+ // addService: add service to the array
+ // ====================================
+ void ServiceList::addService(void* service)
+ {
+ if (numServices < maxServices)
+ {
+ services[numServices] = service;
+ numServices++;
+ }
+ }
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.h b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.h
new file mode 100644
index 0000000000..be6f6c9b1a
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceList.h
@@ -0,0 +1,84 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_servicelist_h
+#define osoa_sca_servicelist_h
+
+#include "osoa/sca/export.h"
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ /**
+ * Holds a list of services that can be accessed from an SCA
+ * component. Each entry can be cast to the business interface
+ * of the target component. All the entries will be of the
+ * same type.
+ */
+ class SCA_API ServiceList
+ {
+
+ public:
+ /**
+ * Return the number of services in the list.
+ * @return Number of services.
+ */
+ unsigned int size() {return numServices;}
+
+ /**
+ * Return the service at this position.
+ */
+ void* operator[] (unsigned int pos);
+
+ ServiceList(const ServiceList& serviceList);
+ ServiceList& operator=(const ServiceList& serviceList);
+ virtual ~ServiceList();
+
+ private:
+ friend class ComponentContextImpl;
+
+ /**
+ * Create a new service list with the known number of
+ * target services. Once created, the service list can only
+ * have services added to it up to the number of targets
+ * specified on this constructor.
+ * @param numTargets Number of target services to be held in this list.
+ */
+ ServiceList(unsigned int numTargets);
+
+ /**
+ * Add a service to this list.
+ */
+ void addService(void* service);
+
+ unsigned int maxServices;
+ unsigned int numServices;
+
+ /**
+ * Pointer to an array of services.
+ */
+ void** services;
+
+ };
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_servicelist_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp
new file mode 100644
index 0000000000..9f275c9c10
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp
@@ -0,0 +1,208 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ServiceRuntimeException.h"
+using namespace std;
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ // ========================================================================
+ // Constructor
+ // ========================================================================
+ ServiceRuntimeException :: ServiceRuntimeException(const char* name,
+ severity_level sev,
+ const char* msg_text)
+ : severity(sev), location_set(0)
+ {
+ class_name = new char[strlen(name) + 1];
+ strcpy(class_name,name);
+ message_text = new char[strlen(msg_text)+1];
+ strcpy(message_text,msg_text);
+
+ } // end ServiceRuntimeException constuctor
+
+ // ========================================================================
+ // Constructor
+ // ========================================================================
+ ServiceRuntimeException :: ServiceRuntimeException(const ServiceRuntimeException& c)
+ :
+ severity(c.getSeverity()), location_set(c.location_set)
+
+ {
+ class_name = new char[strlen(c.getEClassName()) + 1];
+ strcpy(class_name, c.getEClassName());
+ message_text = new char[strlen(c.getMessageText())+1];
+ strcpy(message_text,c.getMessageText());
+ for (int i=0;i<c.location_set;i++)
+ {
+ locations[i].file = new char[strlen(c.locations[i].file) + 1];
+ strcpy(locations[i].file,c.locations[i].file);
+ locations[i].line = c.locations[i].line;
+ locations[i].function = new char[strlen(c.locations[i].function) + 1];
+ strcpy(locations[i].function, c.locations[i].function);
+ }
+ }
+
+ // ========================================================================
+ // Destructor
+ // ========================================================================
+ ServiceRuntimeException :: ~ServiceRuntimeException()
+ {
+ if (class_name) delete class_name;
+ if (message_text) delete message_text;
+ for (int i=0;i<location_set;i++)
+ {
+ if (locations[i].file) delete locations[i].file;
+ if (locations[i].function) delete locations[i].function;
+ }
+
+ } // end ServiceRuntimeException destructor
+
+ // ========================================================================
+ // Return class name of this exception
+ // ========================================================================
+ const char* ServiceRuntimeException :: getEClassName() const
+ {
+ return class_name;
+ } // end getClassName()
+
+ // ========================================================================
+ // Return severity
+ // ========================================================================
+ ServiceRuntimeException::severity_level ServiceRuntimeException :: getSeverity() const
+ {
+ return severity;
+ } // end getSeverity()
+
+ // ========================================================================
+ // Return message text associated with exception
+ // ========================================================================
+ const char* ServiceRuntimeException :: getMessageText() const
+ {
+ return message_text;
+ } // end getMessageText()
+
+ // ========================================================================
+ // Return file name where exception was raised
+ // ========================================================================
+ const char* ServiceRuntimeException :: getFileName() const
+ {
+ return locations[0].file;
+ } // end getFileName()
+
+ // ========================================================================
+ // Return line number where exception was raised
+ // ========================================================================
+ unsigned long ServiceRuntimeException :: getLineNumber() const
+ {
+ return locations[0].line;
+ } // end getLineNumber()
+
+ // ========================================================================
+ // Return function name where exception was raised
+ // ========================================================================
+ const char* ServiceRuntimeException :: getFunctionName() const
+ {
+ return locations[0].function;
+ } // end getFunctionName()
+
+
+ // ========================================================================
+ // set severity of exception
+ // ========================================================================
+ void ServiceRuntimeException :: setSeverity(severity_level sev)
+ {
+ severity = sev;
+ } // end setSeverity(severity_level sev) const
+
+ // ========================================================================
+ // set message text associated with exception
+ // ========================================================================
+ void ServiceRuntimeException :: setMessageText(const char* msg_text)
+ {
+ if (message_text != 0) delete message_text;
+ message_text = new char[strlen(msg_text) + 1];
+ strcpy(message_text,msg_text);
+ } // end setMessageText(const string &msg_text) const
+
+ // ========================================================================
+ // set location of most recent throw/handling of the exception
+ // ========================================================================
+ void ServiceRuntimeException :: setLocation(const char* file,
+ unsigned long line,
+ const char* function)
+ {
+ if (location_set < num_locations)
+ {
+ locations[location_set].file = new char[strlen(file) + 1];
+ strcpy(locations[location_set].file,file);
+ locations[location_set].line = line;
+ locations[location_set].function = new char[strlen(function) + 1];
+ strcpy(locations[location_set].function,function);
+
+ location_set++;
+ }
+ } // end setLocation()
+
+
+ // ========================================================================
+ // print self
+ // ========================================================================
+ ostream& ServiceRuntimeException :: PrintSelf(ostream &os) const
+ {
+
+ os << "Exception object :" << endl;
+ os << " class: " << class_name << endl;
+ os << " description: " << message_text << endl;
+ if (location_set != 0)
+ {
+ os << " file name: " << locations[0].file << endl;
+ char lineNumber[100];
+ sprintf(lineNumber, "%lu",locations[0].line);
+ os << " line number: " << lineNumber << endl;
+ os << " function: " << locations[0].function << endl;
+ os << " location history:" << endl;
+
+ int i=1;
+ while (i < location_set)
+ {
+ os << " " << i << ")" << endl;
+ os << " file: " << locations[i].file << endl;
+ os << " line: " << locations[i].line << endl;
+ os << " function: " << locations[i].function << endl;
+ i++;
+ }
+ }
+ return os;
+ } // end ostream operator <<
+
+ // ========================================================================
+ // ostream operator <<
+ // ========================================================================
+ SCA_API ostream& operator<< (ostream &os, const ServiceRuntimeException &except)
+ {
+ return except.PrintSelf(os);
+ } // end ostream operator <<
+
+
+ } // End namespace sca
+} // End namespace osoa
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.h b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.h
new file mode 100644
index 0000000000..a78514e90c
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/ServiceRuntimeException.h
@@ -0,0 +1,236 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_serviceruntimeexception_h
+#define osoa_sca_serviceruntimeexception_h
+
+#include "osoa/sca/export.h"
+
+#include <ostream>
+
+namespace osoa
+{
+ namespace sca
+ {
+
+ /**
+ * Top level exception to represent all the exceptions that may be
+ * thrown by an SCA runtime implementation.
+ */
+ class SCA_API ServiceRuntimeException
+ {
+ public:
+ /**
+ * Represents the possible severity levels for an exception.
+ */
+ enum severity_level
+ {
+ Normal,
+ Warning,
+ Error,
+ Severe
+ };
+
+ /**
+ * Constructor.
+ * @param name Class name of the exception.
+ * @param sev Severity level.
+ * @param msg_text Detailed description of the exception.
+ */
+ ServiceRuntimeException(
+ const char *name="ServiceRuntimeException",
+ severity_level sev=Severe,
+ const char* msg_text="");
+
+ ServiceRuntimeException(const ServiceRuntimeException& c);
+
+ // Destructor
+ virtual ~ServiceRuntimeException();
+
+ /**
+ * Return class name of this exception.
+ */
+ const char* getEClassName() const;
+
+ /**
+ * Return severity.
+ */
+ severity_level getSeverity() const;
+
+ /**
+ * Return message text associated with exception.
+ */
+ const char* getMessageText() const;
+
+ /*
+ * Return file name where the exception was raised.
+ */
+ const char* getFileName() const;
+
+ /**
+ * Return line number where the exception was raised.
+ */
+ unsigned long getLineNumber() const;
+
+ /**
+ * Return function name where the exception was raised.
+ */
+ const char* getFunctionName() const;
+
+ /**
+ * Set the exception severity.
+ */
+ void setSeverity(severity_level sev);
+
+ /**
+ * Set the message text associated with exception.
+ */
+ void setMessageText(const char* msg_text);
+
+ /**
+ * Set the location where the exception was raised.
+ * @param file Name of the file.
+ * @param line Line number in the file.
+ * @param function Name of the function.
+ */
+ void setLocation(const char* file,
+ unsigned long line,
+ const char* function="");
+
+ /**
+ * Append exception details to ostream.
+ */
+ virtual std::ostream& PrintSelf(std::ostream &os) const;
+
+ /**
+ * Operator to send exceptions details to a stream.
+ */
+ SCA_API friend std::ostream& operator<< (std::ostream &os, const ServiceRuntimeException &except);
+ protected:
+
+ private:
+ /**
+ * Class name of the exception.
+ */
+ char* class_name;
+
+ /**
+ * Severity level of the exception.
+ */
+ severity_level severity;
+
+ /**
+ * Description of the exception.
+ */
+ char* message_text; // Description of exception
+
+ /**
+ * Location where the exception was thrown or handled and thrown.
+ */
+ class location
+ {
+ public:
+ char* file; // File name (from __FILE__)
+ unsigned long line; // Line number (from __LINE__)
+ char* function; // Function name
+ };
+
+
+ enum {num_locations=5};
+ /**
+ * Array of locations where the exception has been handled and thrown.
+ */
+ location locations[num_locations];
+
+ /**
+ * The current location (index into ServiceRuntimeException#location).
+ */
+ int location_set;
+
+
+ }; // End ServiceRuntimeException class definition
+
+
+ /**
+ * A remotable service is currently unavailable. It is possible that a retry
+ * may resolve this exception.
+ */
+ class SCA_API ServiceUnavailableException: public ServiceRuntimeException
+ {
+ public:
+ ServiceUnavailableException(const char* serviceName)
+ : ServiceRuntimeException("ServiceUnavailableException", Warning,
+ serviceName)
+ {
+ }
+ private:
+ }; // End ServiceUnavailableException class definition
+
+
+ /**
+ * The target of a wire cannot be found, or the reference has not been
+ * configured.
+ */
+ class ServiceNotFoundException: public ServiceRuntimeException
+ {
+ public:
+ ServiceNotFoundException(const char* msg)
+ : ServiceRuntimeException("ServiceNotFoundException", Error,
+ msg)
+ {
+ }
+ private:
+ }; // End ServiceNotFoundException class definition
+
+
+ /**
+ * There is no current component (for example, if a non-SCA component
+ * tries to get the current ComponentContext).
+ */
+ class ComponentContextException: public ServiceRuntimeException
+ {
+ public:
+ ComponentContextException(const char* msg)
+ : ServiceRuntimeException("ComponentContextException", Error,
+ msg)
+ {
+ }
+ private:
+ }; // End ComponentContextException class definition
+
+ /**
+ * Unable to find the specified entry point in the module.
+ */
+ class EntryPointNotFoundException: public ServiceRuntimeException
+ {
+ public:
+ EntryPointNotFoundException(const char* msg)
+ : ServiceRuntimeException("EntryPointNotFoundException", Error,
+ msg)
+ {
+ }
+ private:
+ }; // End EntryPointNotFoundException class definition
+
+
+
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_serviceruntimeexception_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/export.h b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/export.h
new file mode 100644
index 0000000000..6ef7960284
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/export.h
@@ -0,0 +1,39 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_export_h
+#define osoa_sca_export_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef SCA_EXPORTS
+#define SCA_API __declspec(dllexport)
+#else
+#define SCA_API __declspec(dllimport)
+#endif
+
+#else
+#include <sys/time.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#define SCA_API
+#endif
+
+#endif // osoa_sca_export_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/sca.h b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/sca.h
new file mode 100644
index 0000000000..528bd91c4a
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/osoa/sca/sca.h
@@ -0,0 +1,29 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_sca_h
+#define osoa_sca_sca_h
+
+#include "osoa/sca/export.h"
+#include "osoa/sca/ModuleContext.h"
+#include "osoa/sca/ComponentContext.h"
+#include "osoa/sca/ServiceList.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#endif // osoa_sca_sca_h