summaryrefslogtreecommitdiffstats
path: root/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/cpp/src/osoa/sca')
-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
7 files changed, 671 insertions, 0 deletions
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