You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ro...@apache.org on 2006/08/29 22:03:20 UTC
svn commit: r438185 [2/3] - in /incubator/tuscany/cpp/sca/runtime:
core/src/osoa/ core/src/tuscany/sca/ core/src/tuscany/sca/core/
core/src/tuscany/sca/cpp/ core/src/tuscany/sca/extension/
core/src/tuscany/sca/model/ core/src/tuscany/sca/util/ extensio...
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.cpp?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.cpp Tue Aug 29 13:03:17 2006
@@ -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.
+ */
+
+#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_CPP_API ostream& operator<< (ostream &os, const ServiceRuntimeException &except)
+ {
+ return except.PrintSelf(os);
+ } // end ostream operator <<
+
+
+ } // End namespace sca
+} // End namespace osoa
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h Tue Aug 29 13:03:17 2006
@@ -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.
+ */
+
+#ifndef osoa_sca_serviceruntimeexception_h
+#define osoa_sca_serviceruntimeexception_h
+
+#include "osoa/sca/export.h"
+
+#include "tuscany/sca/util/Exceptions.h"
+using tuscany::sca::TuscanyRuntimeException;
+namespace osoa
+{
+ namespace sca
+ {
+ /**
+ * Top level exception to represent all the exceptions that may be
+ * thrown by an SCA runtime implementation.
+ */
+ class SCA_CPP_API ServiceRuntimeException : public TuscanyRuntimeException
+ {
+ public:
+ ServiceRuntimeException(
+ const char *name="ServiceRuntimeException",
+ severity_level sev=Severe,
+ const char* msg_text="")
+ : TuscanyRuntimeException(name, sev, msg_text)
+ {
+ }
+ }; // End ServiceRuntimeException class definition
+
+
+ /**
+ * A remotable service is currently unavailable. It is possible that a retry
+ * may resolve this exception.
+ */
+ class SCA_CPP_API ServiceUnavailableException: public ServiceRuntimeException
+ {
+ public:
+ ServiceUnavailableException(const char* serviceName)
+ : ServiceRuntimeException("ServiceUnavailableException", Warning,
+ serviceName)
+ {
+ }
+ private:
+ }; // End ServiceUnavailableException class definition
+
+
+ /**
+ * The target of a wire cannot be found, or the reference has not been
+ * configured.
+ */
+ class SCA_CPP_API ServiceNotFoundException: public ServiceRuntimeException
+ {
+ public:
+ ServiceNotFoundException(const char* msg)
+ : ServiceRuntimeException("ServiceNotFoundException", Error,
+ msg)
+ {
+ }
+ private:
+ }; // End ServiceNotFoundException class definition
+
+
+ /**
+ * There is no current component (for example, if a non-SCA component
+ * tries to get the current ComponentContext).
+ */
+ class SCA_CPP_API ComponentContextException: public ServiceRuntimeException
+ {
+ public:
+ ComponentContextException(const char* msg)
+ : ServiceRuntimeException("ComponentContextException", Error,
+ msg)
+ {
+ }
+ private:
+ }; // End ComponentContextException class definition
+
+
+ } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_serviceruntimeexception_h
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ServiceRuntimeException.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/export.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/export.h?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/export.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/export.h Tue Aug 29 13:03:17 2006
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+
+#ifndef osoa_sca_export_h
+#define osoa_sca_export_h
+#include "tuscany/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
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/export.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/export.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/sca.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/sca.h?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/sca.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/sca.h Tue Aug 29 13:03:17 2006
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+
+#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/ServiceList.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#endif // osoa_sca_sca_h
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/sca.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/sca.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp Tue Aug 29 13:03:17 2006
@@ -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.
+*/
+
+#include "tuscany/sca/cpp/CPPExtension.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/cpp/CPPImplementationExtension.h"
+#include "tuscany/sca/cpp/CPPInterfaceExtension.h"
+
+
+extern "C"
+{
+ #if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+ #endif
+ void tuscany_sca_extension_initialize()
+ {
+ tuscany::sca::cpp::CPPExtension::initialize();
+ }
+}
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ // ===================================================================
+ // Constructor for the CPPExtension class.
+ // ===================================================================
+ CPPExtension::CPPExtension()
+ {
+ LOGENTRY(1, "CPPExtension::constructor");
+ LOGEXIT(1, "CPPExtension::constructor");
+ }
+
+ // ===================================================================
+ // Destructor for the CPPExtension class.
+ // ===================================================================
+ CPPExtension::~CPPExtension()
+ {
+ LOGENTRY(1, "CPPExtension::destructor");;
+ LOGEXIT(1, "CPPExtension::destructor");
+ }
+
+ void CPPExtension::initialize()
+ {
+ LOGENTRY(1, "CPPExtension::initialize");;
+ SCARuntime::getInstance()->registerImplementationExtension(new CPPImplementationExtension());
+ SCARuntime::getInstance()->registerInterfaceExtension(new CPPInterfaceExtension());
+ LOGEXIT(1, "CPPExtension::initialize");;
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h Tue Aug 29 13:03:17 2006
@@ -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.
+ */
+
+#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
+
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp Tue Aug 29 13:03:17 2006
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+#include "tuscany/sca/cpp/CPPImplementationExtension.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ // ===================================================================
+ // Constructor for the CPPImplementationExtension class.
+ // ===================================================================
+ CPPImplementationExtension::CPPImplementationExtension()
+ {
+ LOGENTRY(1, "CPPImplementationExtension::constructor");
+ LOGEXIT(1, "CPPImplementationExtension::constructor");
+ }
+
+ // ===================================================================
+ // Destructor for the CPPImplementationExtension class.
+ // ===================================================================
+ CPPImplementationExtension::~CPPImplementationExtension()
+ {
+ LOGENTRY(1, "CPPImplementationExtension::destructor");;
+ LOGEXIT(1, "CPPImplementationExtension::destructor");
+ }
+
+ const string CPPImplementationExtension::extensionName("cpp");
+ const string CPPImplementationExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPImplementation");
+
+ // ===================================================================
+ // loadModelElement - load the info from implementation.cpp
+ // ===================================================================
+ ComponentType* CPPImplementationExtension::getImplementation(Composite *composite, DataObjectPtr scdlImplementation)
+ {
+ string implType = scdlImplementation->getType().getName();
+ if (implType == "CPPImplementation")
+ {
+ string library = scdlImplementation->getCString("library");
+ string header = scdlImplementation->getCString("header");
+ string className = scdlImplementation->getCString("class");
+
+ string 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(library, header, headerPath, headerStub, className);
+
+ return cppImpl;
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h Tue Aug 29 13:03:17 2006
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+#ifndef tuscany_sca_cpp_cppimplementationextension_h
+#define tuscany_sca_cpp_cppimplementationextension_h
+
+#include "tuscany/sca/extension/ImplementationExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ class CPPImplementationExtension : public ImplementationExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ CPPImplementationExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~CPPImplementationExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.cpp")
+ */
+ virtual const string& getExtensionTypeQName() {return typeQName;}
+
+ virtual ComponentType* getImplementation(Composite* composite, DataObjectPtr scdlImplementation);
+
+ private:
+ static const string extensionName;
+ static const string typeQName;
+
+ };
+
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppimplementationextension_h
+
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPImplementationExtension.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp Tue Aug 29 13:03:17 2006
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+#include "tuscany/sca/cpp/CPPInterfaceExtension.h"
+#include "tuscany/sca/cpp/model/CPPInterface.h"
+#include "tuscany/sca/util/Logging.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ // ===================================================================
+ // Constructor for the CPPInterfaceExtension class.
+ // ===================================================================
+ CPPInterfaceExtension::CPPInterfaceExtension()
+ {
+ LOGENTRY(1, "CPPInterfaceExtension::constructor");
+ LOGEXIT(1, "CPPInterfaceExtension::constructor");
+ }
+
+ // ===================================================================
+ // Destructor for the CPPInterfaceExtension class.
+ // ===================================================================
+ CPPInterfaceExtension::~CPPInterfaceExtension()
+ {
+ LOGENTRY(1, "CPPInterfaceExtension::destructor");;
+ LOGEXIT(1, "CPPInterfaceExtension::destructor");
+ }
+
+ const string CPPInterfaceExtension::extensionName("cpp");
+ const string CPPInterfaceExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#CPPInterface");
+
+ // ===================================================================
+ // loadModelElement - load the info from interface.cpp
+ // ===================================================================
+ tuscany::sca::model::Interface* CPPInterfaceExtension::getInterface(Composite* composite, DataObjectPtr scdlInterface)
+ {
+ // Determine the type
+ string ifType = scdlInterface->getType().getName();
+ if (ifType == "CPPInterface")
+ {
+ string header = scdlInterface->getCString("header");
+ string className = scdlInterface->getCString("class");
+ string scope = scdlInterface->getCString("scope");
+ bool remotable = scdlInterface->getBoolean("remotable");
+
+ return new CPPInterface(header, className, scope, remotable);
+ }
+ return 0;
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h Tue Aug 29 13:03:17 2006
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+#ifndef tuscany_sca_cpp_cppinterfaceextension_h
+#define tuscany_sca_cpp_cppinterfaceextension_h
+
+#include "tuscany/sca/extension/InterfaceExtension.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ class CPPInterfaceExtension : public InterfaceExtension
+ {
+ public:
+ /**
+ * Default constructor
+ */
+ CPPInterfaceExtension();
+
+ /**
+ * Destructor
+ */
+ virtual ~CPPInterfaceExtension();
+
+ /**
+ * return the name of the extension
+ */
+ virtual const string& getExtensionName() {return extensionName;}
+
+ /**
+ * return the QName of schema elemant for this implementation extension
+ * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.cpp")
+ */
+ virtual const string& getExtensionTypeQName() {return typeQName;}
+
+ virtual tuscany::sca::model::Interface* getInterface(Composite* composite, DataObjectPtr scdlInterface);
+
+ private:
+ static const string extensionName;
+ static const string typeQName;
+
+ };
+
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppinterfaceextension_h
+
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPInterfaceExtension.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp Tue Aug 29 13:03:17 2006
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+
+#include "tuscany/sca/cpp/CPPServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/cpp/model/CPPReferenceBinding.h"
+
+using namespace osoa::sca;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ CPPServiceProxy::CPPServiceProxy(Reference* reference)
+ : ServiceProxy(reference)
+ {
+ LOGENTRY(1,"CPPServiceProxy::constructor");
+
+ // ----------------------
+ // Get the component
+ // ----------------------
+ Component* component = reference->getComponent();
+ string name = reference->getType()->getName();
+
+ // Get the service wrapper
+ CPPReferenceBinding* referenceBinding = (CPPReferenceBinding*)reference->getBinding();
+
+ ServiceWrapper* serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
+
+ createProxy(component, name, serviceWrapper);
+
+ LOGEXIT(1,"CPPServiceProxy::constructor");
+ }
+
+ // ============================
+ // Constructor: Create a proxy
+ // ============================
+ CPPServiceProxy::CPPServiceProxy(Service* service)
+ : ServiceProxy(0)
+ {
+ LOGENTRY(1,"CPPServiceProxy::constructor");
+
+ // ----------------------
+ // Get the component
+ // ----------------------
+ Component* component = service->getComponent();
+ string name = service->getType()->getName();
+
+ // Get the service wrapper
+ ServiceWrapper* serviceWrapper = service->getBinding()->getServiceWrapper();
+
+ createProxy(component, name, serviceWrapper);
+
+ LOGEXIT(1,"CPPServiceProxy::constructor");
+ }
+
+ void CPPServiceProxy::createProxy(Component* component, const string& name, ServiceWrapper* serviceWrapper)
+ {
+ LOGENTRY(1,"CPPServiceProxy::createProxy");
+
+ ComponentType* componentType = component->getType();
+ if (!componentType)
+ {
+ string msg = "Component " + component->getName() + " has no implementation defined";
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // If we got here we have a CPP implementation
+ CPPImplementation* impl = (CPPImplementation *)componentType;
+
+ // ----------------------------------------------------
+ // Get implementation dll name and service factory name
+ // ----------------------------------------------------
+ string library = impl->getLibrary();
+ string headerStub = impl->getHeaderStub();
+
+ string fullLibraryName = component->getComposite()->getRoot() + "/" + library;
+ string proxyFactoryName = headerStub + "_" + name + "_Proxy_Factory";
+ string proxyDestructorName = headerStub + "_" + name + "_Proxy_Destructor";
+ typedef void* (* PROXYFACTORY) (ServiceWrapper*);
+
+ // ------------
+ // Load the dll
+ // ------------
+ proxyLibrary = Library(fullLibraryName);
+
+ // -------------------------
+ // Locate the factory method
+ // -------------------------
+ PROXYFACTORY proxyFactory = (PROXYFACTORY)proxyLibrary.getSymbol(proxyFactoryName);
+ if (!proxyFactory)
+ {
+ LOGERROR_2(1, "CPPServiceProxy::createProxy: Unable to locate %s in library %s",
+ proxyFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Unable to locate " + proxyFactoryName + " in library " + fullLibraryName;
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // -----------------------------------
+ // Now create an instance of the proxy
+ // -----------------------------------
+ void* proxy = proxyFactory(serviceWrapper);
+ if (!proxy)
+ {
+ LOGERROR_2(1, "CPPServiceProxy::createProxy: Factory method %s in library %s returned null",
+ proxyFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Factory method " + proxyFactoryName + " in library " + fullLibraryName + " returned null";
+ throw ServiceNotFoundException(msg.c_str());
+ }
+ else
+ {
+ proxies.push_back(proxy);
+ }
+
+ // -------------------------
+ // Get the destructor method
+ // -------------------------
+ destructor = (PROXYDESTRUCTOR)proxyLibrary.getSymbol(proxyDestructorName);
+
+ LOGEXIT(1,"CPPServiceProxy::createProxy");
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ CPPServiceProxy::~CPPServiceProxy()
+ {
+ LOGENTRY(1,"CPPServiceProxy::destructor");
+
+ // Delete the proxies
+ if (destructor != NULL && proxies.size() != 0)
+ {
+ destructor(proxies[0]);
+ }
+ LOGEXIT(1,"CPPServiceProxy::destructor");
+ }
+
+ ServiceProxy::PROXIES CPPServiceProxy::getProxies()
+ {
+ return proxies;
+ }
+
+ void* CPPServiceProxy::getProxy()
+ {
+ if (proxies.size() != 0)
+ {
+ return proxies[0];
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h Tue Aug 29 13:03:17 2006
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+#ifndef tuscany_sca_cpp_cppserviceproxy_h
+#define tuscany_sca_cpp_cppserviceproxy_h
+
+#include "osoa/sca/export.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+
+using namespace tuscany::sca::model;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ /**
+ * Holds a proxy for a given component and reference.
+ * The proxy which is held inside a ServiceProxy will be specific to the component
+ * and reference and will have been code generated and be contained in a dll
+ * created by a developer of an SCA application.
+ */
+ class CPPServiceProxy : public ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a reference. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The reference on the source component.
+ * @param target The wrapper of the service which is wired to this reference.
+ */
+ CPPServiceProxy(Reference* reference);
+
+ /**
+ * Create a new service proxy for a service. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The service on the target component.
+ * @param target The wrapper of the target service.
+ */
+ CPPServiceProxy(Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPServiceProxy();
+
+ /**
+ * Return an instance of the proxy created for this particular component and reference.
+ * @return The proxy.
+ */
+ virtual void* getProxy();
+
+ /**
+ * Return the proxies created for this particular component and reference.
+ * @return The proxies.
+ */
+ virtual PROXIES getProxies();
+
+ private:
+
+ /**
+ * Create the proxy
+ */
+ void createProxy(Component* component, const string& name, ServiceWrapper* serviceWrapper);
+
+ /**
+ * Holds the instances of the code generated proxies.
+ */
+ PROXIES proxies;
+
+ /**
+ * A function pointer to the destructor of the proxy.
+ */
+ typedef void (* PROXYDESTRUCTOR) (void*);
+ PROXYDESTRUCTOR destructor;
+
+ /**
+ * The library which contains the code for the proxy.
+ */
+ Library proxyLibrary;
+
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppserviceproxy_h
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceProxy.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp Tue Aug 29 13:03:17 2006
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "tuscany/sca/cpp/CPPServiceWrapper.h"
+
+#include "osoa/sca/ServiceRuntimeException.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/cpp/model/CPPImplementation.h"
+#include "tuscany/sca/cpp/model/CPPInterface.h"
+
+using namespace osoa::sca;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ===================
+ // Static data members
+ // ===================
+ void* CPPServiceWrapper::staticImpl = 0;
+
+ // ===========
+ // Constructor
+ // ===========
+ CPPServiceWrapper::CPPServiceWrapper(Service* service)
+ : ServiceWrapper(service)
+ {
+ LOGENTRY(1,"CPPServiceWrapper::constructor");
+
+ component = service->getComponent();
+ interf = (CPPInterface*)service->getType()->getInterface();
+ remotable = interf->getRemotable();
+
+ LOGEXIT(1,"CPPServiceWrapper::constructor");
+
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ CPPServiceWrapper::~CPPServiceWrapper()
+ {
+ LOGENTRY(1,"CPPServiceWrapper::destructor");
+ LOGEXIT(1,"CPPServiceWrapper::destructor");
+ }
+
+
+ // ======================================================================
+ // getImplementation: get an implementation for this scope
+ // ======================================================================
+ void* CPPServiceWrapper::getImplementation()
+ {
+ CPPInterface::SCOPE scope = interf->getScope();
+ if (scope == CPPInterface::COMPOSITE)
+ {
+ if (!staticImpl)
+ {
+ staticImpl = newImplementation();
+ }
+ return staticImpl;
+ }
+ else // (scope == CPPInterface::STATELESS)
+ {
+ return newImplementation();
+ }
+ }
+
+ // ======================================================================
+ // releaseImplementation: release the implementation for this scope
+ // ======================================================================
+ void CPPServiceWrapper::releaseImplementation()
+ {
+ CPPInterface::SCOPE scope = interf->getScope();
+ if (scope == CPPInterface::STATELESS)
+ {
+ deleteImplementation();
+ }
+ }
+
+ // ======================================================================
+ // invoke: wrapper call to service with setting the component context
+ // ======================================================================
+ void CPPServiceWrapper::invoke(Operation& operation)
+ {
+ LOGENTRY(1,"CPPServiceWrapper::invoke");
+
+ SCARuntime* runtime = SCARuntime::getInstance();
+ runtime->setCurrentComponent(component);
+
+ try
+ {
+ invokeService(operation);
+ }
+ catch (...)
+ {
+ runtime->unsetCurrentComponent();
+ throw;
+ }
+ runtime->unsetCurrentComponent();
+ LOGEXIT(1,"CPPServiceWrapper::invoke");
+
+ }
+
+ void CPPServiceWrapper::setLibrary(Library* lib)
+ {
+ wrapperLibrary = lib;
+ }
+
+ // ======================================================================
+ // getServiceWrapper: create a wrapper for the target ComponentService
+ // ======================================================================
+ CPPServiceWrapper* CPPServiceWrapper::getServiceWrapper(Service* service)
+ {
+ CPPServiceWrapper* serviceWrapper = 0;
+
+ // -----------------------------------------------
+ // Get the implementation for the target component
+ // -----------------------------------------------
+ Component* component = service->getComponent();
+ CPPImplementation* impl = (CPPImplementation*)component->getType();
+ if (!impl)
+ {
+ string msg = "Component " + component->getName() + " has no implementation defined";
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // ----------------------------------------------------
+ // Get implementation dll name and wrapper factory name
+ // ----------------------------------------------------
+ string libraryName = impl->getLibrary();
+ string wrapperFactoryName = impl->getHeaderStub()
+ + "_" + service->getType()->getName() + "_Wrapper_Factory";
+
+ // ------------
+ // Load the dll
+ // ------------
+ string fullLibraryName = component->getComposite()->getRoot() + "/" + libraryName;
+ typedef CPPServiceWrapper* (* WRAPPERFACTORY) (Service*);
+ Library* wrapperLib = new Library(fullLibraryName);
+
+ // -------------------------
+ // Locate the factory method
+ // -------------------------
+ WRAPPERFACTORY wrapperFactory = (WRAPPERFACTORY)wrapperLib->getSymbol(wrapperFactoryName);
+ if (!wrapperFactory)
+ {
+ LOGERROR_2(1, "CPPServiceWrapper::getServiceWrapper: Unable to locate %s in library %s",
+ wrapperFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Unable to locate " + wrapperFactoryName + " in library " + fullLibraryName;
+ throw ServiceNotFoundException(msg.c_str());
+ }
+
+ // -------------------------------------
+ // Now create an instance of the wrapper
+ // -------------------------------------
+ serviceWrapper = wrapperFactory(service);
+ if (!serviceWrapper)
+ {
+ LOGERROR_2(1, "CPPServiceWrapper::getServiceWrapper: Factory method %s in library %s returned null",
+ wrapperFactoryName.c_str(), fullLibraryName.c_str());
+ string msg = "Factory method " + wrapperFactoryName + " in library " + fullLibraryName + " returned null";
+ throw ServiceNotFoundException(msg.c_str());
+ }
+ serviceWrapper->setLibrary(wrapperLib);
+
+ return serviceWrapper;
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h Tue Aug 29 13:03:17 2006
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+
+#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/util/Library.h"
+
+using namespace tuscany::sca::model;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+ class CPPInterface;
+
+ /**
+ * Wraps the service on a component implementation.
+ * This abstract class is extended by generated code which provides
+ * the implementation of some of the methods.
+ * An instance of this class wraps the actual component implementation which
+ * has been written by a developer of an SCA application.
+ */
+ class SCA_CPP_API CPPServiceWrapper : public ServiceWrapper
+ {
+ public:
+ /**
+ * Factory method to create a new CPPServiceWrapper for a given target
+ * service. This method will provide all the loading of dlls required to
+ * create the target component.
+ * @param target The service on the component for which this wrapper is to be
+ * created.
+ * @return A wrapper that references the given target.
+ */
+ static CPPServiceWrapper* getServiceWrapper(Service* service);
+
+ /**
+ * Constructor.
+ * @param target The component service to which this wrapper refers.
+ */
+ CPPServiceWrapper(Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CPPServiceWrapper();
+
+ /**
+ * All business method calls to the target component go through the invoke method.
+ * @param operation The details of the method, paramaters and return value for the
+ * business method to be called on the target component.
+ */
+ virtual void invoke(Operation& operation);
+
+ /**
+ * Return the loaded shared library for the target component.
+ */
+ Library* getLibrary() const { return wrapperLibrary; }
+
+ protected:
+
+ /**
+ * Delegated method to invoke the correct method on the target component.
+ * Implemented by the subtype.
+ */
+ virtual void invokeService(Operation& operation) = 0;
+
+ /**
+ * Delegated method to create a new component implementation.
+ * Implemented by the subtype.
+ * @return A pointer to an instance of the component implementation class.
+ */
+ virtual void* newImplementation() = 0;
+
+ /**
+ * Delegated method to delete the current instance of the component
+ * implementation.
+ * Implemented by the subtype.
+ */
+ virtual void deleteImplementation() = 0;
+
+ /**
+ * Return the current instance of the component implementation.
+ * @return A pointer to an instance of the component implementation class.
+ */
+ virtual void* getImplementation();
+
+ /**
+ * Indicates that the current instance of the component implementation
+ * has been finished with.
+ * Will call CPPServiceWrapper#deleteImplementation if the
+ * implementation is stateless (so that a new instance is returned
+ * for each call).
+ */
+ virtual void releaseImplementation();
+
+ private:
+ /**
+ * Holds an implementation instance if the scope is set to composite.
+ */
+ static void* staticImpl;
+
+ /**
+ * The component to which this wrapper refers.
+ */
+ Component* component;
+
+ /**
+ * A pointer to the interface which the service exposes.
+ */
+ CPPInterface* interf;
+
+ /**
+ * Set to true if the service is remotable.
+ */
+ bool remotable;
+
+ /**
+ * Pointer to the loaded library which contains the component
+ * implementation.
+ */
+ Library* wrapperLibrary;
+
+ /**
+ * Set the loaded library which contains the component
+ * implementation.
+ * @param lib The library.
+ */
+ void setLibrary(Library* lib);
+ };
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_cppservicewrapper_h
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp Tue Aug 29 13:03:17 2006
@@ -0,0 +1,179 @@
+/*
+ *
+ * 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 "tuscany/sca/util/Logging.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+#include "tuscany/sca/cpp/ComponentContextImpl.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/ReferenceBinding.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ // ===========
+ // Constructor
+ // ===========
+ ComponentContextImpl::ComponentContextImpl(Component* comp)
+ : ComponentContext(0), component(comp)
+ {
+ LOGENTRY(1, "ComponentContextImpl::constructor");
+ LOGEXIT(1, "ComponentContextImpl::constructor");
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ ComponentContextImpl::~ComponentContextImpl()
+ {
+ // --------------------------------------------
+ // 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");
+
+ // --------------------------------------------------------------
+ // locate reference in the current component and determine target
+ // --------------------------------------------------------------
+ Reference* reference = component->findReference(referenceName);
+ if (!reference)
+ {
+ string message = "Reference not defined: ";
+ message = message + referenceName;
+ throw ServiceNotFoundException(message.c_str());
+ }
+
+ // Get a service proxy from the binding configured on the reference
+ ServiceProxy* serviceProxy = reference->getBinding()->getServiceProxy();
+ if (serviceProxy == NULL)
+ {
+ string message = "Reference ";
+ message = message + referenceName + " not wired";
+ throw ServiceNotFoundException(message.c_str());
+ }
+ proxies.push_back(serviceProxy);
+
+ ServiceProxy::PROXIES proxies = serviceProxy->getProxies();
+ ServiceList services(proxies.size());
+ for (ServiceProxy::PROXIES::const_iterator iter = proxies.begin();
+ iter!=proxies.end();
+ iter++)
+ {
+ services.addService(*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");
+
+ // --------------------------------------------------------------
+ // locate reference in the current component and determine target
+ // --------------------------------------------------------------
+ Reference* reference = component->findReference(referenceName);
+ if (!reference)
+ {
+ string message = "Reference not defined: ";
+ message = message + referenceName;
+ throw ServiceNotFoundException(message.c_str());
+ }
+
+ // --------------------
+ // Validate the request
+ // --------------------
+ switch (reference->getType()->getMultiplicity())
+ {
+ case ReferenceType::ZERO_MANY:
+ case ReferenceType::ONE_MANY:
+ {
+ string message = "getService() called for reference with multiplicity >1 :";
+ message = message + referenceName;
+ throw ServiceNotFoundException(message.c_str());
+ }
+ default:
+ {
+ }
+ } // end switch
+
+ // Get a service proxy from the binding configured on the reference
+ ServiceProxy* serviceProxy = reference->getBinding()->getServiceProxy();
+ if (serviceProxy == NULL)
+ {
+ string message = "Reference ";
+ message = message + referenceName + " not wired";
+ throw ServiceNotFoundException(message.c_str());
+ }
+
+ void* service = serviceProxy->getProxy();
+ proxies.push_back(serviceProxy);
+ return service;
+
+ } // End getService()
+
+ // ==============================================
+ // getProperties: return the component properties
+ // ==============================================
+ DataObjectPtr ComponentContextImpl::getProperties()
+ {
+ LOGENTRY(1, "ComponentContextImpl::getProperties");
+ DataObjectPtr properties = component->getProperties();
+
+ LOGEXIT(1, "ComponentContextImpl::getProperties");
+ return properties;
+ }
+
+ // ==============================================
+ // getDataFactory: return the data factory for the composite in which
+ // this component resides
+ // ==============================================
+ commonj::sdo::DataFactoryPtr ComponentContextImpl::getDataFactory()
+ {
+ LOGENTRY(1, "ComponentContextImpl::getProperties");
+ commonj::sdo::DataFactoryPtr dataFactory = component->getComposite()->getDataFactory();
+
+ LOGEXIT(1, "ComponentContextImpl::getDataFactory");
+ return dataFactory;
+ }
+
+ } // End namespace cpp
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h?rev=438185&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h Tue Aug 29 13:03:17 2006
@@ -0,0 +1,129 @@
+/*
+ *
+ * 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$ */
+
+#ifndef tuscany_sca_cpp_componentcontextimpl_h
+#define tuscany_sca_cpp_componentcontextimpl_h
+
+#include <vector>
+using std::vector;
+
+#include "osoa/sca/ServiceList.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/core/ServiceProxy.h"
+
+using namespace osoa::sca;
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace cpp
+ {
+
+ /**
+ * Contains the actual implementation of a ComponentContext interface.
+ */
+ class ComponentContextImpl : public ComponentContext
+ {
+
+ public:
+ /**
+ * Constructor that takes a Component which represents the runtime
+ * model for this context.
+ */
+ ComponentContextImpl(Component* component);
+
+ /**
+ * Default constructor.
+ */
+ virtual ~ComponentContextImpl();
+
+ /**
+ * See ComponentContext.
+ */
+ virtual void* getService(const char* referenceName);
+
+ /**
+ * See ComponentContext.
+ */
+ virtual ServiceList getServices(const char* referenceName);
+
+ /**
+ * See ComponentContext.
+ */
+ virtual DataObjectPtr getProperties();
+
+ /**
+ * See ComponentContext.
+ */
+ virtual commonj::sdo::DataFactoryPtr getDataFactory();
+
+ /**
+ * Returns the contained Component.
+ * @return The Component to which this context refers.
+ */
+ virtual Component* getComponent() {return component;}
+
+ private:
+ ComponentContextImpl(const ComponentContextImpl&);
+ ComponentContextImpl& operator=(const ComponentContextImpl&);
+
+ /**
+ * Pointer to the runtime model Component to which this
+ * context refers.
+ */
+ Component* component;
+
+ /**
+ * Helper method to return a proxy to a service.
+ * @param serviceReference The source reference.
+ * @param target The target to which this source reference is wired.
+ * @return A pointer to an object which can be cast to the business
+ * class representing the target.
+ */
+ void* getServiceProxy(
+ Reference* serviceReference,
+ Service* target);
+
+ /**
+ * Helper method to return a wrapper for a target service.
+ * @param target The target for which this wrapper is to be created.
+ * @return The service wrapper.
+ */
+ ServiceWrapper* getServiceWrapper(Service* target);
+
+
+ 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 namespaca cpp
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_cpp_componentcontextimpl_h
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/ComponentContextImpl.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org