diff options
Diffstat (limited to 'tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core')
16 files changed, 0 insertions, 2391 deletions
diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp deleted file mode 100644 index 65d218dc86..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#include "tuscany/sca/core/ComponentServiceWrapper.h" - -#include "tuscany/sca/util/Exceptions.h" -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/core/SCARuntime.h" -#include "tuscany/sca/model/CPPImplementation.h" -using namespace osoa::sca; - -namespace tuscany -{ - namespace sca - { - // =================== - // Static data members - // =================== - void* ComponentServiceWrapper::staticImpl = 0; - - // =========== - // Constructor - // =========== - ComponentServiceWrapper::ComponentServiceWrapper(Service* target) - : ServiceWrapper(target), service(target) - { - LOGENTRY(1,"ComponentServiceWrapper::constructor"); - if (target->getServiceType() != WireTarget::ComponentServiceType) - { - throw ServiceRuntimeException("ComponentServiceWrapper: target is not a component service"); - } - - component = target->getComponent(); - interf = (CPPInterface*)target->getInterface(); - - remotable = interf->getRemotable(); - - - LOGEXIT(1,"ComponentServiceWrapper::constructor"); - - } - - // ========== - // Destructor - // ========== - ComponentServiceWrapper::~ComponentServiceWrapper() - { - LOGENTRY(1,"ComponentServiceWrapper::destructor"); - LOGEXIT(1,"ComponentServiceWrapper::destructor"); - } - - - // ====================================================================== - // getImplementation: get an implementation for this scope - // ====================================================================== - void* ComponentServiceWrapper::getImplementation() - { - CPPInterface::SCOPE scope = interf->getScope(); - if (scope == CPPInterface::MODULE) - { - if (!staticImpl) - { - staticImpl = newImplementation(); - } - return staticImpl; - } - else // (scope == CPPInterface::STATELESS) - { - return newImplementation(); - } - } - - // ====================================================================== - // releaseImplementation: release the implementation for this scope - // ====================================================================== - void ComponentServiceWrapper::releaseImplementation() - { - CPPInterface::SCOPE scope = interf->getScope(); - if (scope == CPPInterface::STATELESS) - { - deleteImplementation(); - } - } - - // ====================================================================== - // invoke: wrapper call to service with setting the component context - // ====================================================================== - void ComponentServiceWrapper::invoke(Operation& operation) - { - LOGENTRY(1,"ComponentServiceWrapper::invoke"); - - SCARuntime* runtime = SCARuntime::getInstance(); - runtime->setCurrentComponent(component); - - try - { - invokeService(operation); - } - catch (...) - { - runtime->unsetCurrentComponent(); - throw; - } - runtime->unsetCurrentComponent(); - LOGEXIT(1,"ComponentServiceWrapper::invoke"); - - } - - void ComponentServiceWrapper::setLibrary(Library* lib) - { - wrapperLibrary = lib; - } - - // ====================================================================== - // createServiceWrapper: create a wrapper for the target ComponentService - // ====================================================================== - ComponentServiceWrapper* ComponentServiceWrapper::createServiceWrapper(Service* service) - { - string msg; - ComponentServiceWrapper* serviceWrapper = 0; - - // ----------------------------------------------- - // Get the implementation for the target component - // ----------------------------------------------- - Component* targetComponent = service->getComponent(); - Implementation* impl = targetComponent->getImplementation(); - if (!impl) - { - msg = "Component " + targetComponent->getName() + " has no implementation defined"; - throw ServiceNotFoundException(msg.c_str()); - } - - // TODO: This only handle CPP implementation for now - if (impl->getImplementationType() == Implementation::CPP) - { - // ---------------------------------------------------- - // Get implementation dll name and wrapper factory name - // ---------------------------------------------------- - string dllName = ((CPPImplementation*)impl)->getDll(); - string wrapperFactoryName = ((CPPImplementation*)impl)->getHeaderStub() - + "_" + service->getName() + "_Wrapper_Factory"; - - // ------------ - // Load the dll - // ------------ - string fullDllName = targetComponent->getModule()->getRoot() + "/" + dllName; - typedef ComponentServiceWrapper* (* WRAPPERFACTORY) (Service*); - Library* wrapperLib = new Library(fullDllName); - - // ------------------------- - // Locate the factory method - // ------------------------- - WRAPPERFACTORY wrapperFactory = (WRAPPERFACTORY)wrapperLib->getSymbol(wrapperFactoryName); - if (!wrapperFactory) - { - LOGERROR_2(1, "ComponentServiceWrapper::createServiceWrapper: Unable to locate %s in library %s", - wrapperFactoryName.c_str(), fullDllName.c_str()); - msg = "Unable to locate " + wrapperFactoryName + " in library " + fullDllName; - throw ServiceNotFoundException(msg.c_str()); - } - - // ------------------------------------- - // Now create an instance of the wrapper - // ------------------------------------- - serviceWrapper = wrapperFactory(service); - if (!serviceWrapper) - { - LOGERROR_2(1, "ComponentServiceWrapper::createServiceWrapper: Factory method %s in library %s returned null", - wrapperFactoryName.c_str(), fullDllName.c_str()); - msg = "Factory method " + wrapperFactoryName + " in library " + fullDllName + " returned null"; - throw ServiceNotFoundException(msg.c_str()); - } - serviceWrapper->setLibrary(wrapperLib); - } - else - { - // ---------------------- - // Non CPP Implementation - // ---------------------- - msg = "Unsupported implementation type for service: " + service->getName(); - throw ServiceNotFoundException(msg.c_str()); - } - - return serviceWrapper; - } - - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h deleted file mode 100644 index 3a5e990bf0..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#ifndef tuscany_sca_core_componentservicewrapper_h -#define tuscany_sca_core_componentservicewrapper_h - -#include "osoa/sca/export.h" -#include "tuscany/sca/core/ServiceWrapper.h" -#include "tuscany/sca/model/Component.h" -#include "tuscany/sca/core/Operation.h" -#include "tuscany/sca/model/CPPInterface.h" -#include "tuscany/sca/util/Library.h" - -using namespace tuscany::sca::model; - -namespace tuscany -{ - namespace sca - { - /** - * 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 ComponentServiceWrapper : public ServiceWrapper - { - public: - /** - * Factory method to create a new ComponentServiceWrapper 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 SCA_API ComponentServiceWrapper* createServiceWrapper(Service* target); - - /** - * Constructor. - * @param target The component service to which this wrapper refers. - */ - SCA_API ComponentServiceWrapper(Service* target); - - /** - * Destructor. - */ - SCA_API virtual ~ComponentServiceWrapper(); - - /** - * 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. - */ - SCA_API virtual void invoke(Operation& operation); - - /** - * Return the loaded shared library for the target component. - */ - Library* getLibrary() {return wrapperLibrary;} - protected: - /** - * Delegated method to invoke the correct method on the target component. - * Implemented by the subtype. - */ - SCA_API 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. - */ - SCA_API virtual void* newImplementation() = 0; - - /** - * Delegated method to delete the current instance of the component - * implementation. - * Implemented by the subtype. - */ - SCA_API virtual void deleteImplementation() = 0; - - /** - * Return the current instance of the component implementation. - * @return A pointer to an instance of the component implementation class. - */ - SCA_API virtual void* getImplementation(); - - /** - * Indicates that the current instance of the component implementation - * has been finished with. - * Will call ComponentServiceWrapper#deleteImplementation if the - * implementation is stateless (so that a new instance is returned - * for each call). - */ - SCA_API virtual void releaseImplementation(); - - private: - /** - * Holds an implementation instance if the scope is set to module. - */ - static void* staticImpl; - - /** - * The component to which this wrapper refers. - */ - Component* component; - - /** - * The service on the component to which this wrapper refers. - */ - Service* service; - - /** - * 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 sca -} // End namespace tuscany - -#endif // tuscany_sca_core_componentservicewrapper_h diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp deleted file mode 100644 index 2838bbe4d4..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#include "tuscany/sca/core/ExternalServiceWrapper.h" -#include <stdarg.h> - -#include "tuscany/sca/util/Exceptions.h" -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/core/SCARuntime.h" - -#include "tuscany/sca/ws/WSServiceWrapper.h" -using tuscany::sca::ws::WSServiceWrapper; - -using namespace osoa::sca; - - -namespace tuscany -{ - namespace sca - { - - ////////////////////////////////////////////////////////////////////// - // Construction/Destruction - ////////////////////////////////////////////////////////////////////// - - ExternalServiceWrapper::ExternalServiceWrapper(tuscany::sca::model::WireTarget* target) - : ServiceWrapper(target) - { - LOGENTRY(1,"ExternalServiceWrapper::constructor"); - if (target->getServiceType() != WireTarget::ExternalServiceType) - { - throw ServiceRuntimeException("ExternalServiceWrapper: target is not an ExternalService"); - } - - LOGEXIT(1,"ExternalServiceWrapper::constructor"); - - } - - ExternalServiceWrapper::~ExternalServiceWrapper() - { - LOGENTRY(1,"ExternalServiceWrapper::destructor"); - LOGEXIT(1,"ExternalServiceWrapper::destructor"); - } - - // ====================================================================== - // createServiceWrapper: create a wrapper for the target ExternalService - // ====================================================================== - ExternalServiceWrapper* ExternalServiceWrapper::createServiceWrapper(ExternalService* service) - { - string msg; - ExternalServiceWrapper* serviceWrapper = 0; - - // ----------------------------------------------- - // Get the binding for the target component - // ----------------------------------------------- - Binding* targetBinding = service->getBinding(); - if (!targetBinding) - { - msg = "External service " + service->getName() + " has no binding defined"; - throw ServiceNotFoundException(msg.c_str()); - } - - // TODO: This only handles ws implementation for now - if (targetBinding->getBindingType() == Binding::WS) - { - // ------------------------------------- - // Create an instance of the wrapper - // ------------------------------------- - serviceWrapper = new WSServiceWrapper(service); - - } - else - { - // ---------------------- - // Non WS Binding - // ---------------------- - msg = "Unsupported binding type for externalService: " + service->getName(); - throw ServiceNotFoundException(msg.c_str()); - } - - return serviceWrapper; - } - - - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h deleted file mode 100644 index b2dcfb3a6b..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#ifndef tuscany_sca_core_externalservicewrapper_h -#define tuscany_sca_core_externalservicewrapper_h - -#include "osoa/sca/export.h" -#include "tuscany/sca/core/ServiceWrapper.h" -#include "tuscany/sca/core/Operation.h" -#include "tuscany/sca/model/ExternalService.h" -using tuscany::sca::model::ExternalService; - -namespace tuscany -{ - namespace sca - { - - /** - * Wraps an SCA external service so that it can be called by a - * proxy. - * This abstract class will be extended by a class which supports - * a specific external service binding (for example, the web services binding). - */ - class SCA_API ExternalServiceWrapper : public ServiceWrapper - { - public: - /** - * Factory method to create a new ExternaServiceWrapper for a given - * external service described in the SCA module. - */ - static ExternalServiceWrapper* createServiceWrapper(ExternalService* service); - - /** - * Constructor. - * @param target The target external service for which this wrapper is to be - * created. - * @return A wrapper that references the given target. - */ - ExternalServiceWrapper(tuscany::sca::model::WireTarget* target); - - /** - * Destructor. - */ - virtual ~ExternalServiceWrapper(); - - /** - * Return the external service (in the runtime model) that is wrapped by - * the instance of this class. - */ - virtual ExternalService* getExternalService() {return (ExternalService*)getTarget();}; - - /** - * All business method calls to the external service go through the invoke method. - * This is a delegated method which will be implemented by the subclass. - * @param operation The details of the method, paramaters and return value for the - * business method to be called on the external service. - */ - virtual void invoke(Operation& operation) = 0; - private: - - }; - } // End namespace sca -} // End namespace tuscany - -#endif // tuscany_sca_core_externalservicewrapper_h diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/Operation.cpp b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/Operation.cpp deleted file mode 100644 index 981f4e6d9e..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/Operation.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#include "tuscany/sca/core/Operation.h" -#include <stdarg.h> - -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/core/SCARuntime.h" - - - -namespace tuscany -{ - namespace sca - { - // =========== - // Constructor - // =========== - Operation::Operation(const char* operationName) - { - LOGENTRY(1,"Operation::constructor"); - - if (operationName != 0) - { - name = operationName; - } - - LOGEXIT(1,"Operation::constructor"); - } - - // ========== - // Destructor - // ========== - Operation::~Operation() - { - LOGENTRY(1,"Operation::destructor"); - LOGEXIT(1,"Operation::destructor"); - } - - - // ============================================== - // getParameter: return parameter at position pos - // ============================================== - void* Operation::getParameterValue(unsigned int pos) - { - if (pos < parameters.size()) - { - return parameters[pos].getValue(); - } - - return 0; - } - - // ============================================== - // getParameter: return of parameter - // ============================================== - Operation::Parameter& Operation::getParameter(unsigned int pos) - { - if (pos < parameters.size()) - { - return parameters[pos]; - } - - throw "index out of range"; - } - - - // ============================================== - // getParameterType: return type of parameter - // ============================================== - Operation::ParameterType Operation::getParameterType(unsigned int pos) - { - if (pos < parameters.size()) - { - return parameters[pos].getType(); - } - - return VOID_TYPE; - } - - // =========================================== - // addParameter: set parameter at position pos - // =========================================== - void Operation::addParameter(const void *parm) - { - LOGINFO(4, "Operation::addParameter(void*)"); - parameters.insert(parameters.end(), Parameter((void*)parm, VOID_TYPE)); - } - - void Operation::addParameter(const bool *parm) - { - LOGINFO(4, "Operation::addParameter(bool)"); - parameters.insert(parameters.end(), Parameter((void*)parm, BOOL)); - } - - void Operation::addParameter(const short *parm) - { - LOGINFO(4, "Operation::addParameter(short)"); - parameters.insert(parameters.end(), Parameter((void*)parm, SHORT)); - } - - void Operation::addParameter(const long *parm) - { - LOGINFO(4, "Operation::addParameter(long)"); - parameters.insert(parameters.end(), Parameter((void*)parm, LONG)); - } - - void Operation::addParameter(const unsigned short *parm) - { - LOGINFO(4, "Operation::addParameter(unsigned short)"); - parameters.insert(parameters.end(), Parameter((void*)parm, USHORT)); - } - - void Operation::addParameter(const unsigned long *parm) - { - LOGINFO(4, "Operation::addParameter(unsigned long)"); - parameters.insert(parameters.end(), Parameter((void*)parm, ULONG)); - } - - void Operation::addParameter(const float *parm) - { - LOGINFO(4, "Operation::addParameter(float)"); - parameters.insert(parameters.end(), Parameter((void*)parm, FLOAT)); - } - - void Operation::addParameter(const double *parm) - { - LOGINFO(4, "Operation::addParameter(double)"); - parameters.insert(parameters.end(), Parameter((void*)parm, DOUBLE)); - } - - void Operation::addParameter(const long double *parm) - { - LOGINFO(4, "Operation::addParameter(long double)"); - parameters.insert(parameters.end(), Parameter((void*)parm, LONGDOUBLE)); - } - - void Operation::addParameter(const char* *parm) - { - LOGINFO(4, "Operation::addParameter(char*)"); - parameters.insert(parameters.end(), Parameter((void*)parm, CHARS)); - } - - void Operation::addParameter(const char *parm) - { - LOGINFO(4, "Operation::addParameter(char)"); - parameters.insert(parameters.end(), Parameter((void*)parm, CHAR)); - } - - void Operation::addParameter(const string *parm) - { - LOGINFO(4, "Operation::addParameter(string)"); - parameters.insert(parameters.end(), Parameter((void*)parm, STRING)); - } - - void Operation::addParameter(const DataObjectPtr *parm) - { - LOGINFO(4, "Operation::addParameter(DataObjectPtr)"); - parameters.insert(parameters.end(), Parameter((void*)parm, DATAOBJECT)); - } - - Operation::Parameter::Parameter(void* val, Operation::ParameterType typ) - : value(val), type(typ) - { - } - - // =========================================== - // setReturnValue - // =========================================== - void Operation::setReturnValue(const void *parm) - { - LOGINFO(4, "Operation::setReturnValue(void*)"); - returnValue = Parameter((void*)parm, VOID_TYPE); - } - - void Operation::setReturnValue(const bool *parm) - { - LOGINFO(4, "Operation::setReturnValue(bool*)"); - returnValue = Parameter((void*)parm, BOOL); - } - - void Operation::setReturnValue(const short *parm) - { - LOGINFO(4, "Operation::setReturnValue(short*)"); - returnValue = Parameter((void*)parm, SHORT); - } - - void Operation::setReturnValue(const long *parm) - { - LOGINFO(4, "Operation::setReturnValue(long*)"); - returnValue = Parameter((void*)parm, LONG); - } - - void Operation::setReturnValue(const unsigned short *parm) - { - LOGINFO(4, "Operation::setReturnValue(unsigned short*)"); - returnValue = Parameter((void*)parm, USHORT); - } - - void Operation::setReturnValue(const unsigned long *parm) - { - LOGINFO(4, "Operation::setReturnValue(unsigned long*)"); - returnValue = Parameter((void*)parm, ULONG); - } - - void Operation::setReturnValue(const float *parm) - { - LOGINFO(4, "Operation::setReturnValue(float*)"); - returnValue = Parameter((void*)parm, FLOAT); - } - - void Operation::setReturnValue(const double *parm) - { - LOGINFO(4, "Operation::setReturnValue(double*)"); - returnValue = Parameter((void*)parm, DOUBLE); - } - - void Operation::setReturnValue(const long double *parm) - { - LOGINFO(4, "Operation::setReturnValue(long double*)"); - returnValue = Parameter((void*)parm, LONGDOUBLE); - } - - void Operation::setReturnValue(const char *parm) - { - LOGINFO(4, "Operation::setReturnValue(char)"); - returnValue = Parameter((void*)parm, CHAR); - } - - void Operation::setReturnValue(const char* *parm) - { - LOGINFO(4, "Operation::setReturnValue(char*)"); - returnValue = Parameter((void*)parm, CHARS); - } - - void Operation::setReturnValue(const string *parm) - { - LOGINFO(4, "Operation::setReturnValue(string*)"); - returnValue = Parameter((void*)parm, STRING); - } - - void Operation::setReturnValue(const DataObjectPtr *parm) - { - LOGINFO(4, "Operation::setReturnValue(DataObjectPtr*)"); - returnValue = Parameter((void*)parm, DATAOBJECT); - } - - - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/Operation.h b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/Operation.h deleted file mode 100644 index e562dca3c1..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/Operation.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#ifndef tuscany_sca_core_operation_h -#define tuscany_sca_core_operation_h -#include "osoa/sca/export.h" -#include "commonj/sdo/SDO.h" -using commonj::sdo::DataObjectPtr; -#include <string> -using std::string; -#include <vector> -using std::vector; - -namespace tuscany -{ - namespace sca - { - /** - * Holds the details of a single invocation of a business method. - * This class is used to pass the parameters and operation name from the - * client to a service. It will also hold the return value on the - * return from the business method. - */ - class Operation - { - public: - /** - * Create a new operation. - * @param operationName The method name of the business method to be invoked. - * @param numParameters The number of parameters to be passed. - */ - SCA_API Operation(const char* operationName = 0); - - /** - * Destructor. - */ - SCA_API virtual ~Operation(); - - /** - * Return the operation name. - * @return The name of the operation. - */ - SCA_API const string& getName() {return name;} - - - enum ParameterType - { - UNSET = 0, - VOID_TYPE, - BOOL, - SHORT, - LONG, - USHORT, - ULONG, - FLOAT, - DOUBLE, - LONGDOUBLE, - CHARS, - CHAR, - STRING, - DATAOBJECT - }; - - class Parameter - { - public: - SCA_API Parameter(void* value = NULL, ParameterType type = VOID_TYPE); - SCA_API void* getValue() {return value;} - SCA_API ParameterType getType() {return type;} - - private: - void* value; - ParameterType type; - }; - - /** - * Set a return value for the operation. - * @param retVal Pointer to the return value. - */ - SCA_API void setReturnValue(const void *retVal); - SCA_API void setReturnValue(const bool *retVal); - SCA_API void setReturnValue(const short *retVal); - SCA_API void setReturnValue(const long *retVal); - SCA_API void setReturnValue(const unsigned short *retVal); - SCA_API void setReturnValue(const unsigned long *retVal); - SCA_API void setReturnValue(const float *retVal); - SCA_API void setReturnValue(const double *retVal); - SCA_API void setReturnValue(const long double *retVal); - SCA_API void setReturnValue(const char *retVal); - SCA_API void setReturnValue(const char* *retVal); - SCA_API void setReturnValue(const string *retVal); - SCA_API void setReturnValue(const DataObjectPtr *retVal); - - /** - * Set a parameter on the operation. - * @param pos The position of the parameter in the parameter list. - * @param parm Pointer to the parameter to be passed. - */ - SCA_API void addParameter(const void *parm); - SCA_API void addParameter(const bool *parm); - SCA_API void addParameter(const short *parm); - SCA_API void addParameter(const long *parm); - SCA_API void addParameter(const unsigned short *parm); - SCA_API void addParameter(const unsigned long *parm); - SCA_API void addParameter(const float *parm); - SCA_API void addParameter(const double *parm); - SCA_API void addParameter(const long double *parm); - SCA_API void addParameter(const char *parm); - SCA_API void addParameter(const char* *parm); - SCA_API void addParameter(const string *parm); - SCA_API void addParameter(const DataObjectPtr *parm); - - SCA_API unsigned int getNParms() {return parameters.size();} - - /** - * Get a parameter from the operation. - * @param pos The position of the parameter in the parameter list. - * @return Pointer to the paramter at the given postion. Should be - * cast to the appropriate type. - */ - SCA_API Parameter& getParameter(unsigned int pos); - - /** - * Get a parameter type from the operation. - * @param pos The position of the parameter in the parameter list. - * @return Pointer to the paramter at the given postion. Should be - * cast to the appropriate type. - */ - SCA_API ParameterType getParameterType(unsigned int pos); - - /** - * Get a parameter from the operation. - * @param pos The position of the parameter in the parameter list. - * @return Pointer to the paramter at the given postion. Should be - * cast to the appropriate type. - */ - SCA_API void* getParameterValue(unsigned int pos); - - SCA_API ParameterType getReturnType() {return returnValue.getType();} - SCA_API void* getReturnValue() {return returnValue.getValue();} - - private: - /** - * Operation name (method name). - */ - string name; - - /** - * Array of parameters. - */ - typedef std::vector<Parameter> PARAMETER_VECTOR; - - PARAMETER_VECTOR parameters; - - Parameter returnValue; - - }; - } // End namespace sca -} // End namespace tuscany - -#endif // tuscany_sca_core_operation_h diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp deleted file mode 100644 index 63a7d52e7a..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#include "tuscany/sca/core/SCAEntryPoint.h" - -#include "tuscany/sca/util/Exceptions.h" -#include "tuscany/sca/util/Utils.h" -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/core/SCARuntime.h" -#include "tuscany/sca/core/ComponentServiceWrapper.h" -#include "tuscany/sca/core/ExternalServiceWrapper.h" -using namespace osoa::sca; - -namespace tuscany -{ - namespace sca - { - // =========== - // Constructor - // =========== - SCAEntryPoint::SCAEntryPoint(const char* epName) - : subsystem(0), entrypoint(0), module(0) - { - LOGENTRY(1,"SCAEntryPoint::constructor"); - string message; - - // initialize the system if necessary - System* system = SCARuntime::getInstance()->getSystem(); - - string subsystemName; - string entrypointName; - - Utils::tokeniseUri(epName, subsystemName, entrypointName); - - // -------------------- - // locate the Subsystem - // -------------------- - subsystem = system->findSubsystem(subsystemName); - if (!subsystem) - { - throw EntryPointNotFoundException(epName); - } - - // --------------------- - // locate the EntryPoint - // --------------------- - entrypoint = subsystem->findEntryPoint(entrypointName); - if (entrypoint) - { - // found Subsystem EntryPoint - throw EntryPointNotFoundException("Subsystem EntryPoint not yet supported"); - } - else - { - // ----------------------------------- - // locate the EntryPoint in the Module - // ----------------------------------- - string moduleComponentName; - Utils::tokeniseUri(entrypointName, moduleComponentName, entrypointName); - module = subsystem->findModuleByComponentName(moduleComponentName); - if (module) - { - dataFactory = module->getDataFactory(); - entrypoint = module->findEntryPoint(entrypointName); - } - } - - if (!entrypoint) - { - throw EntryPointNotFoundException(epName); - } - - // --------------------------------- - // Get Wrappers for each wire target - // --------------------------------- - - // Get the target services from the EntryPoint - const EntryPoint::TARGETS& targets = entrypoint->getTargets(); - - // -------------------- - // Validate the request - // -------------------- - switch (entrypoint->getMultiplicity()) - { - case EntryPoint::ONE_MANY: - case EntryPoint::ONE_ONE: - { - if (targets.size() == 0) - { - message = "EntryPoint " + entrypoint->getName() + " not wired"; - throw ServiceNotFoundException(message.c_str()); - } - } - default: - { - } - } // end switch - - for (EntryPoint::TARGETS::const_iterator iter = targets.begin(); - iter!=targets.end(); - iter++) - { - ServiceWrapper* service = getServiceWrapper(*iter); - if (service) - { - services.push_back(service); - } - } - - LOGEXIT(1,"SCAEntryPoint::constructor"); - } - - // ========== - // Destructor - // ========== - SCAEntryPoint::~SCAEntryPoint() - { - LOGENTRY(1,"SCAEntryPoint::destructor"); - - // Delete any ServiceWrappers - for (SERVICES::iterator iter = services.begin(); iter < services.end(); iter++) - { - delete (*iter); - } - LOGEXIT(1,"SCAEntryPoint::destructor"); - } - - - // ====================================================================== - // invoke: - // ====================================================================== - SCA_API void SCAEntryPoint::invoke(Operation& operation) - { - LOGENTRY(1,"SCAEntryPoint::invoke"); - string message; - - // -------------------- - // Validate the request - // -------------------- - if (services.size() == 0) - { - message = "EntryPoint " + entrypoint->getName() + " not wired"; - throw ServiceNotFoundException(message.c_str()); - } - - // ------------------- - // Invoke each target - // ------------------- - for (SERVICES::iterator iter = services.begin(); iter < services.end(); iter++) - { - (*iter)->invoke(operation); - } - LOGEXIT(1,"SCAEntryPoint::invoke"); - } - - - // ====================================================================== - // getServiceWrapper: Create and return an instance of the ServiceWrapper - // ====================================================================== - ServiceWrapper* SCAEntryPoint::getServiceWrapper(WireTarget* target) - { - // ------------------------- - // Determine type of Service - // ------------------------- - switch (target->getServiceType()) - { - case WireTarget::ExternalServiceType: - { - // ---------------- - // External Service - // ---------------- - return ExternalServiceWrapper::createServiceWrapper((ExternalService*)target); - } - - case WireTarget::ComponentServiceType: - { - // ----------------- - // Component Service - // ----------------- - return ComponentServiceWrapper::createServiceWrapper((Service*)target); - } - - default: - { - string message = "Undefined wire target type for : "; - message = message + target->getName(); - throw ServiceNotFoundException(message.c_str()); - } - } // end switch - } - - - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.h b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.h deleted file mode 100644 index 6c1df3e28e..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#ifndef tuscany_sca_core_scaentrypoint_h -#define tuscany_sca_core_scaentrypoint_h - -#include "osoa/sca/export.h" - -#include <vector> -using std::vector; -#include "tuscany/sca/core/ServiceWrapper.h" -#include "tuscany/sca/model/WireTarget.h" -#include "tuscany/sca/model/Subsystem.h" -#include "tuscany/sca/model/EntryPoint.h" -#include "tuscany/sca/model/Module.h" -using namespace tuscany::sca::model; -#include "commonj/sdo/SDO.h" -using commonj::sdo::DataObjectPtr; -using commonj::sdo::DataFactoryPtr; - -namespace tuscany -{ - namespace sca - { - /** - * A runtime class which is used by external bindings to provide the entry - * point into the SCA runtime. An entry point will be defined in an SCA - * module, and a binding class will be provided to service the - * communication between the external binding (e.g. for web services the - * SOAP/HTTP communication) and the SCA runtime. The binding class will - * use SCAEntryPoint to call into the SCA runtime. - */ - class SCAEntryPoint - { - public: - /** - * Constructor to create a new instance which will be associated with - * a given entry point in an SCA module. - * @param entryPointName The qualified name of the entry point in an - * SCA module. It is of the form - * "subsystem name"/"module component name"/"entry point name". - */ - SCA_API SCAEntryPoint(const char* entryPointName); - - /** - * Destructor. - */ - SCA_API virtual ~SCAEntryPoint(); - - /** - * Invokes an operation on the component to which the SCA entry point - * is wired in the SCA module. - * @param operation. The operation request - */ - SCA_API virtual void invoke(Operation& operation); - - /** - * Returns a SDO data factory from which all the types associated with the entry point - * and module can be created. - */ - SCA_API DataFactoryPtr getDataFactory() {return dataFactory;} - - protected: - - private: - /** - * The subsystem in which this entry point is found. - */ - Subsystem* subsystem; - - /** - * The entry point in the module. - */ - EntryPoint* entrypoint; - - /** - * The module component in the subsystem. - */ - Module* module; - - /** - * Cached data factory which has all the types defined for the module in which - * this entry point is found. - */ - DataFactoryPtr dataFactory; - - typedef vector<ServiceWrapper*> SERVICES; - /** - * Vector of all the service wrappers created for this entry point. - * Used to destroy the wrappers when this class is destroyed. - */ - SERVICES services; - - /** - * Creates and returns the service wrapper for a given target. - * @param target The target of the wire for which a service wrapper is - * to be created. - * @return A service wrapper to be used for invoking the target implementation. - */ - ServiceWrapper* getServiceWrapper(WireTarget* target); - - }; - } // End namespace sca -} // End namespace tuscany - -#endif // tuscany_sca_core_scaentrypoint_h diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp deleted file mode 100644 index 9da3e547e9..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp +++ /dev/null @@ -1,355 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#include "tuscany/sca/core/SCARuntime.h" -#include "tuscany/sca/core/ComponentServiceWrapper.h" -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/util/Utils.h" -#include "tuscany/sca/util/Exceptions.h" - -#include "tuscany/sca/model/System.h" -#include "tuscany/sca/model/Subsystem.h" -#include "tuscany/sca/model/ModelLoader.h" - -#if defined(WIN32) || defined (_WINDOWS) -#include <windows.h> -#endif - -namespace tuscany -{ - namespace sca - { - /** - * Environment variable names - */ - static const char* TUSCANY_SCACPP = "TUSCANY_SCACPP"; - static const char* TUSCANY_SCACPP_SYSTEM_ROOT = "TUSCANY_SCACPP_SYSTEM_ROOT"; - static const char* TUSCANY_SCACPP_DEFAULT_MODULE = "TUSCANY_SCACPP_DEFAULT_MODULE"; - - - // ========================================================== - // Initialize static class member to not pointing at anything - // ========================================================== - SCARuntime* SCARuntime::instance = 0; - string SCARuntime::systemRoot = ""; - string SCARuntime::defaultModuleName = ""; - - - // ========================================================== - // Set the system configuration root - // ========================================================== - void SCARuntime::setSystemRoot(const string& root) - { - LOGENTRY(1, "SCARuntime::"); - systemRoot = root; - LOGINFO_1(3, "SCARuntime::setSystemRoot - set to %s", root.c_str()); - LOGEXIT(1, "SCARuntime::setSystemRoot"); - } - - // ========================================================== - // Set the default ModuleComponent name - // ========================================================== - void SCARuntime::setDefaultModuleComponent(const string& moduleComponent) - { - LOGENTRY(1, "SCARuntime::setDefaultModuleComponent"); - defaultModuleName = moduleComponent; - LOGINFO_1(3, "SCARuntime::setDefaultModuleComponent - set to %s", moduleComponent.c_str()); - LOGEXIT(1, "SCARuntime::setDefaultModuleComponent"); - } - - // =================================================================== - // Constructor for the SCARuntime class. This will be a singleton that - // holds all the information about the current runtime. - // =================================================================== - SCARuntime::SCARuntime() : system(new System()), defaultModule(0) - { - LOGENTRY(1, "SCARuntime::constructor"); - - // Locate the SCA install root - char* root = 0; - root = getenv(TUSCANY_SCACPP); - if (root == 0) - { - string msg = TUSCANY_SCACPP; - msg += " environment variable not set"; - throw SystemConfigurationException(msg.c_str()); - } - else - { - SCARoot = root; - } - - LOGEXIT(1, "SCARuntime::constructor"); - } - - // =================================================================== - // Destructor for the SCARuntime class. - // =================================================================== - SCARuntime::~SCARuntime() - { - LOGENTRY(1, "SCARuntime::destructor"); - - if (system) - { - delete system; - } - - LOGEXIT(1, "SCARuntime::destructor"); - } - - // ============================================================= - // Get the instance of the runtime, creates it if does not exist - // static method - // ============================================================= - SCARuntime* SCARuntime::getInstance() - { - LOGENTRY(1, "SCARuntime::getInstance"); - - if (instance == NULL) - { - instance = new SCARuntime(); - - if (systemRoot == "") - { - - // Load the runtime - // Get root from environment variable TUSCANY_SCACPP_SYSTEM_ROOT - char* systemRootEnv = getenv(TUSCANY_SCACPP_SYSTEM_ROOT); - if (systemRootEnv == 0) - { - string msg = TUSCANY_SCACPP_SYSTEM_ROOT; - msg += " environment variable not set"; - throw SystemConfigurationException(msg.c_str()); - } - - systemRoot = systemRootEnv; - } - - instance->load(systemRoot); - } - - LOGEXIT(1, "SCARuntime::getInstance"); - - return instance; - - } - - - // ============================================================= - // Release the instance of the runtime. - // ============================================================= - void SCARuntime::releaseInstance() - { - LOGENTRY(1, "SCARuntime::releaseInstance"); - - if (instance) - { - delete instance; - instance = 0; - systemRoot = ""; - defaultModuleName = ""; - } - - LOGEXIT(1, "SCARuntime::releaseInstance"); - } - - // ====================================== - // Load up all the details of the runtime - // ====================================== - void SCARuntime::load(const string& configurationRoot) - { - LOGENTRY(1, "SCARuntime::load"); - - LOGINFO_1(2,"configuration root: %s", configurationRoot.c_str()); - - ModelLoader loader(system); - // Load details of the module - loader.load(configurationRoot); - - LOGEXIT(1, "SCARuntime::load"); - } - - - // =================================== - // Return the top of the runtime model - // =================================== - System* SCARuntime::getSystem() - { - return system; - } - - - // =================================================== - // setCurrentComponent: push component for this thread - // =================================================== - void SCARuntime::setCurrentComponent(Component* component) - { - -#if defined(WIN32) || defined (_WINDOWS) - DWORD currentThreadId = GetCurrentThreadId(); -#else - pthread_t currentThreadId = pthread_self(); -#endif - COMPONENTS_MAP::iterator iter = components.find(currentThreadId); - if (iter == components.end()) - { - components[currentThreadId] = COMPONENT_STACK(); - iter = components.find(currentThreadId); - } - - COMPONENT_STACK& compStack = iter->second; - compStack.push(component); - } - - - // ==================================================== - // unsetCurrentComponent: pop component for this thread - // ==================================================== - Component* SCARuntime::unsetCurrentComponent() - { -#if defined(WIN32) || defined (_WINDOWS) - DWORD currentThreadId = GetCurrentThreadId(); -#else - pthread_t currentThreadId = pthread_self(); -#endif - - COMPONENTS_MAP::iterator iter = components.find(currentThreadId); - if (iter != components.end()) - { - COMPONENT_STACK& compStack = iter->second; - if (compStack.size() > 0) - { - Component* component = compStack.top(); - compStack.pop(); - return component; - } - } - - return 0; - } - - // ============================================================= - // getCurrentComponent: return current component for this thread - // ============================================================= - Component* SCARuntime::getCurrentComponent() - { -#if defined(WIN32) || defined (_WINDOWS) - DWORD currentThreadId = GetCurrentThreadId(); -#else - pthread_t currentThreadId = pthread_self(); -#endif - - COMPONENTS_MAP::iterator iter = components.find(currentThreadId); - if (iter == components.end()) - { - components[currentThreadId] = COMPONENT_STACK(); - iter = components.find(currentThreadId); - } - - COMPONENT_STACK& compStack = iter->second; - if (compStack.size() > 0) - { - return compStack.top(); - } - else - { - return 0; - } - - } - - - // =========================================== - // getCurrentModule: return the current module - // =========================================== - Module* SCARuntime::getCurrentModule() - { - // --------------------------------------------- - // Get module from current component if possible - // --------------------------------------------- - Component* comp = getCurrentComponent(); - if (comp != 0) - { - return comp->getModule(); - } - - // ---------------------- - // Get the default Module - // ---------------------- - string message; - if (!defaultModule) - { - // ------------------------------------------- - // Get the default module from the environment - // ------------------------------------------- - if (defaultModuleName == "") - { - const char* defMod = getenv(TUSCANY_SCACPP_DEFAULT_MODULE); - if (!defMod) - { - message = TUSCANY_SCACPP_DEFAULT_MODULE; - message += " environment variable not set"; - throw SystemConfigurationException(message.c_str()); - } - defaultModuleName = defMod; - } - string subsystemName, moduleName; - Utils::tokeniseUri(defaultModuleName, subsystemName, moduleName); - - // --------------------------- - // Subsystem must be specified - // --------------------------- - Subsystem* subsystem = system->findSubsystem(subsystemName); - if (!subsystem) - { - message = "Default subsystem \'" + subsystemName + "\' not found"; - throw SystemConfigurationException(message.c_str()); - } - - // -------------------------------------------------------------------------- - // If module is not specified then get the default module for this subsystem. - // This will be the ONLY module for this subsystem - // -------------------------------------------------------------------------- - if (moduleName == "") - { - defaultModule = subsystem->getDefaultModule(); - if (!defaultModule) - { - message = "Default module not found for subsystem \'" + subsystemName + "\'"; - throw SystemConfigurationException(message.c_str()); - } - } - else - { - // ----------------------------- - // get the named ModuleComponent - // ----------------------------- - defaultModule = subsystem->findModuleByComponentName(moduleName); - if (!defaultModule) - { - message = "Default module \'" + moduleName + "\' not found in subsystem \'" + subsystemName +"\'"; - throw SystemConfigurationException(message.c_str()); - } - } - } - return defaultModule; - } - - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h deleted file mode 100644 index 2b81b2cbcd..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#ifndef tuscany_sca_core_scaruntime_h -#define tuscany_sca_core_scaruntime_h - -#include "osoa/sca/export.h" - -#include "osoa/sca/ComponentContext.h" -using osoa::sca::ComponentContext; - -#include "tuscany/sca/core/ServiceWrapper.h" -#include "tuscany/sca/model/System.h" -using namespace tuscany::sca::model; - -#if defined(WIN32) || defined (_WINDOWS) -#include <windows.h> -#else -#include <pthread.h> -#endif - -#include <stack> -#include <string> -#include <map> -using namespace std; - -namespace tuscany -{ - namespace sca - { - - /** - * A singleton which represents the executing SCA runtime. - */ - class SCARuntime { - public: - /** - * Get the single instance. - * @return The single instance of the runtime. - */ - SCA_API static SCARuntime* getInstance(); - - /** - * Release the single instance. - */ - SCA_API static void releaseInstance(); - - /** - * Set the system root - * @param root The path to the deployed system. - */ - static void setSystemRoot(const string& root); - - /** - * Set the default ModuleComponent for the system - * @param moduleComponent The name of the default moduleComponent. - */ - static void setDefaultModuleComponent(const string& moduleComponent); - - /** - * Set the current component for the current thread. - * @param component The current component. - */ - SCA_API void setCurrentComponent(Component* component); - - /** - * Remove the current component from this thread, and return - * to the previous component (if there was one). - * @return The previous component. - */ - SCA_API Component* unsetCurrentComponent(); - - /** - * Get a pointer to the configured SCA system which this - * SCA runtime represents. - * The rest of the SCA configuration can be navigated from - * the System. - * @return The configured SCA system. - */ - System* getSystem(); - - /** - * The directory in which the Tuscany runtime has been installed. - */ - const string& getInstallRoot() {return SCARoot;} - - /** - * Return the current component for this thread. - * @return The current component for this thread. - */ - Component* getCurrentComponent(); - - /** - * Get the current module. The current module will either - * be the module in which the current component for this thread - * is defined, or it will be the default module if there is no current - * component. There will not be a current component if a client of - * the SCA runtime is making a call into the SCA runtime. - */ - Module* getCurrentModule(); - - private: - /** - * Default constructor is private to prevent more than one instance. - */ - SCARuntime(); - - virtual ~SCARuntime(); - - /** - * Load the SCA configuration from the scdl files (sca.module, - * *.fragment, etc). - * This will create the runtime model from which the SCA runtime - * will operate. - * @param configurationRoot The path to the configuration of the - * SCA runtime. Under this root will be the subsystems and modules - * directories. - */ - void load(const string& configurationRoot); - - /** - * The single instance of this class. - */ - static SCARuntime* instance; - - /** - * Pointer to the top of the runtime model. - */ - System* system; - - /** - * The installed path of the Tuscany runtime. - */ - string SCARoot; - - /** - * The path to the system root - */ - static string systemRoot; - - /** - * The default ModuleComponent. - */ - static string defaultModuleName; - - /** - * Get the default module set for this runtime. - * @return The default module. - */ - Module* getDefaultModule() {return defaultModule;} - - /** - * The default module set for this runtime. - */ - Module* defaultModule; - - - typedef stack<Component*> COMPONENT_STACK; -#if defined(WIN32) || defined (_WINDOWS) - typedef map<DWORD, COMPONENT_STACK> COMPONENTS_MAP; -#else - typedef map<pthread_t, COMPONENT_STACK> COMPONENTS_MAP; -#endif - - /** - * A map of threads to components. - */ - COMPONENTS_MAP components; - }; - - - } // End namespace sca -} // End namespace tuscany - - - - -#endif // tuscany_sca_core_scaruntime_h - diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp deleted file mode 100644 index ef2f2744eb..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#include "tuscany/sca/core/ServiceProxy.h" - -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/util/Exceptions.h" -#include "tuscany/sca/core/SCARuntime.h" -#include "tuscany/sca/model/CPPImplementation.h" - -using namespace osoa::sca; - -namespace tuscany -{ - namespace sca - { - // ============================ - // Constructor: Create a proxy - // ============================ - ServiceProxy::ServiceProxy(Component* component, const string& name, ServiceWrapper* target) - { - LOGENTRY(1,"ServiceProxy::constructor"); - string msg; - - // ---------------------- - // Get the implementation - // ---------------------- - Implementation* impl = component->getImplementation(); - if (!impl) - { - msg = "Component " + component->getName() + " has no implementation defined"; - throw ServiceNotFoundException(msg.c_str()); - } - - // TODO: This only handle CPP implementation for now - if (impl->getImplementationType() == Implementation::CPP) - { - // ---------------------------------------------------- - // Get implementation dll name and service factory name - // ---------------------------------------------------- - string dllName = ((CPPImplementation*)impl)->getDll(); - string headerStub = ((CPPImplementation*)impl)->getHeaderStub(); - - string fullDllName = component->getModule()->getRoot() + "/" + dllName; - string proxyFactoryName = headerStub + "_" + name + "_Proxy_Factory"; - string proxyDestructorName = headerStub + "_" + name + "_Proxy_Destructor"; - typedef void* (* PROXYFACTORY) (ServiceWrapper*); - - // ------------ - // Load the dll - // ------------ - proxyLibrary = Library(fullDllName); - - // ------------------------- - // Locate the factory method - // ------------------------- - PROXYFACTORY proxyFactory = (PROXYFACTORY)proxyLibrary.getSymbol(proxyFactoryName); - if (!proxyFactory) - { - LOGERROR_2(1, "ComponentContextImpl::getServiceProxy: Unable to locate %s in library %s", - proxyFactoryName.c_str(), fullDllName.c_str()); - msg = "Unable to locate " + proxyFactoryName + " in library " + fullDllName; - throw ServiceNotFoundException(msg.c_str()); - } - - // ----------------------------------- - // Now create an instance of the proxy - // ----------------------------------- - proxy = proxyFactory(target); - if (!proxy) - { - LOGERROR_2(1, "ComponentContextImpl::getServiceProxy: Factory method %s in library %s returned null", - proxyFactoryName.c_str(), fullDllName.c_str()); - msg = "Factory method " + proxyFactoryName + " in library " + fullDllName + " returned null"; - throw ServiceNotFoundException(msg.c_str()); - } - - // ------------------------- - // Get the destructor method - // ------------------------- - destructor = (PROXYDESTRUCTOR)proxyLibrary.getSymbol(proxyDestructorName); - } - - LOGEXIT(1,"ServiceProxy::constructor"); - - } - - // ========== - // Destructor - // ========== - ServiceProxy::~ServiceProxy() - { - LOGENTRY(1,"ServiceProxy::destructor"); - - // Delete the proxy - if (destructor) - { - destructor(proxy); - } - LOGEXIT(1,"ServiceProxy::destructor"); - } - - - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h deleted file mode 100644 index 073b379cd7..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#ifndef tuscany_sca_core_serviceproxy_h -#define tuscany_sca_core_serviceproxy_h - -#include "osoa/sca/export.h" - -#include "tuscany/sca/core/ServiceWrapper.h" -#include "tuscany/sca/model/Component.h" -#include "tuscany/sca/util/Library.h" - -using namespace tuscany::sca::model; - -namespace tuscany -{ - namespace sca - { - /** - * 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 ServiceProxy - { - public: - /** - * Create a new service proxy for a given component and reference name. The - * create proxy will contain a pointer to the target ServiceWrapper. - * @param component The component for which this proxy will be created (the - * source component). - * @param name The name of the reference on the component. - * @param target The wrapper of the component which is wired to this component and - * reference. - */ - ServiceProxy(Component* component, const string& name, ServiceWrapper* target); - - /** - * Destructor. - */ - virtual ~ServiceProxy(); - - /** - * Return an instance of the proxy created for this particular component and reference. - * @return The proxy. - */ - void* getProxy() {return proxy;} - - - private: - /** - * Holds the instance of the code generated proxy. - */ - void* proxy; - - typedef void (* PROXYDESTRUCTOR) (void*); - - /** - * A function pointer to the destructor of the proxy. - */ - PROXYDESTRUCTOR destructor; - - /** - * The library which contains the code for the proxy. - */ - Library proxyLibrary; - - }; - } // End namespace sca -} // End namespace tuscany - -#endif // tuscany_sca_core_serviceproxy_h diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp deleted file mode 100644 index 5936f526f1..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#include "tuscany/sca/core/ServiceWrapper.h" -#include <stdarg.h> - -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/core/SCARuntime.h" - - - -namespace tuscany -{ - namespace sca - { - - // =========== - // Constructor - // =========== - ServiceWrapper::ServiceWrapper(WireTarget* targ) - : target(targ) - { - LOGENTRY(1,"ServiceWrapper::constructor"); - - LOGEXIT(1,"ServiceWrapper::constructor"); - - } - - // ========== - // Destructor - // ========== - ServiceWrapper::~ServiceWrapper() - { - LOGENTRY(1,"ServiceWrapper::destructor"); - LOGEXIT(1,"ServiceWrapper::destructor"); - } - - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h deleted file mode 100644 index 21c162d77f..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#ifndef tuscany_sca_core_servicewrapper_h -#define tuscany_sca_core_servicewrapper_h - -#include "osoa/sca/export.h" - -#include "tuscany/sca/core/Operation.h" -#include "tuscany/sca/model/WireTarget.h" -using tuscany::sca::model::WireTarget; - -namespace tuscany -{ - namespace sca - { - /** - * An abstract class that wraps a component implementation or an external - * service. - */ - class SCA_API ServiceWrapper - { - public: - /** - * Constructor. - * @param target The service wrapper wraps the target of a wire. - */ - ServiceWrapper(WireTarget* target); - - /** - * Destructor. - */ - virtual ~ServiceWrapper(); - - /** - * Get the target represented by this wrapper. - * @return The target represented by this wrapper. - */ - virtual WireTarget* getTarget() {return target;} - - /** - * All business method calls on the target service are performed through - * this invoke method. - * @param operation The details of the method, paramaters and return value for the - * business method to be called on the target service. - */ - virtual void invoke(Operation& operation) = 0; - private: - /** - * The target represented by this wrapper. - */ - WireTarget* target; - }; - } // End namespace sca -} // End namespace tuscany - -#endif // tuscany_sca_core_servicewrapper_h diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp deleted file mode 100644 index 810f810132..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#include "tuscany/sca/core/TuscanyRuntime.h" -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/util/Utils.h" -#include "tuscany/sca/util/Exceptions.h" -#include "tuscany/sca/core/SCARuntime.h" - -#include "tuscany/sca/model/System.h" - -namespace tuscany -{ - namespace sca - { - - // ========================================================== - // Set the default ModuleComponent name - // ========================================================== - void TuscanyRuntime::setSystemRoot(const string& root) - { - LOGENTRY(1, "TuscanyRuntime::setSystemRoot"); - systemRoot = root; - LOGINFO_1(3, "TuscanyRuntime::setSystemRoot - set to %s", root.c_str()); - LOGEXIT(1, "TuscanyRuntime::setSystemRoot"); - } - - // ========================================================== - // Set the default ModuleComponent name - // ========================================================== - void TuscanyRuntime::setDefaultModuleComponent(const string& moduleComponent) - { - LOGENTRY(1, "TuscanyRuntime::setDefaultModuleComponent"); - defaultModuleComponent = moduleComponent; - LOGINFO_1(3, "TuscanyRuntime::setDefaultModuleComponent - set to %s", moduleComponent.c_str()); - LOGEXIT(1, "TuscanyRuntime::setDefaultModuleComponent"); - } - - // =================================================================== - // Constructor for the TuscanyRuntime class. - // =================================================================== - TuscanyRuntime::TuscanyRuntime(const string& moduleComponent, const string& root) - { - LOGENTRY(1, "TuscanyRuntime::constructor"); - setSystemRoot(root); - setDefaultModuleComponent(moduleComponent); - LOGEXIT(1, "TuscanyRuntime::constructor"); - } - - // =================================================================== - // Destructor for the TuscanyRuntime class. - // =================================================================== - TuscanyRuntime::~TuscanyRuntime() - { - LOGENTRY(1, "TuscanyRuntime::destructor");; - LOGEXIT(1, "TuscanyRuntime::destructor"); - } - - // =================================================================== - // Start the runtime. - // =================================================================== - void TuscanyRuntime::start() - { - LOGENTRY(1, "TuscanyRuntime::start"); - SCARuntime::setSystemRoot(systemRoot); - SCARuntime::setDefaultModuleComponent(defaultModuleComponent); - SCARuntime::getInstance(); - LOGEXIT(1, "TuscanyRuntime::start"); - } - - // =================================================================== - // Stop the runtime. - // =================================================================== - void TuscanyRuntime::stop() - { - LOGENTRY(1, "TuscanyRuntime::stop"); - SCARuntime::releaseInstance(); - LOGEXIT(1, "TuscanyRuntime::stop"); - } - - - - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h b/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h deleted file mode 100644 index 92da737416..0000000000 --- a/tags/cpp-0.1.incubating-M1-final/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ - -#ifndef tuscany_sca_core_tuscanyruntime_h -#define tuscany_sca_core_tuscanyruntime_h - -#include "osoa/sca/export.h" -#include <string> -using std::string; - -namespace tuscany -{ - namespace sca - { - - /** - * A singleton which represents the executing SCA runtime. - */ - class SCA_API TuscanyRuntime - { - public: - /** - * Default constructor - */ - TuscanyRuntime(const string& moduleComponent = "", const string& root = ""); - - /** - * Destructor - */ - virtual ~TuscanyRuntime(); - - - /** - * Set the system root - * @param root The path to the deployed system. - */ - void setSystemRoot(const string& root); - - /** - * Set the default ModuleComponent for the system - * @param moduleComponent The name of the default moduleComponent. - */ - void setDefaultModuleComponent(const string& moduleComponent); - - /** - * start the runtime - */ - void start(); - - /** - * stop the runtime - */ - void stop(); - - - private: - string systemRoot; - string defaultModuleComponent; - }; - - - } // End namespace sca -} // End namespace tuscany - - - - -#endif // tuscany_sca_core_tuscanyruntime_h - |