diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /tags/cpp-0.1.incubating-M1-RC3b/sca/runtime |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tags/cpp-0.1.incubating-M1-RC3b/sca/runtime')
147 files changed, 15164 insertions, 0 deletions
diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/Makefile.am new file mode 100644 index 0000000000..8cd99f1477 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = ws_reference core ws_service diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/Makefile.am new file mode 100644 index 0000000000..b4b5bc3097 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src test diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/Makefile.am new file mode 100644 index 0000000000..305bbe5504 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/Makefile.am @@ -0,0 +1,103 @@ +lib_LTLIBRARIES = libtuscany_sca.la + +nobase_include_HEADERS = \ +osoa/sca/ComponentContext.h \ +osoa/sca/ComponentContextImpl.h \ +osoa/sca/export.h \ +osoa/sca/ModuleContext.h \ +osoa/sca/ModuleContextImpl.h \ +osoa/sca/sca.h \ +osoa/sca/ServiceList.h \ +osoa/sca/ServiceRuntimeException.h \ +tuscany/sca/core/ComponentServiceWrapper.h \ +tuscany/sca/core/ExternalServiceWrapper.h \ +tuscany/sca/core/Operation.h \ +tuscany/sca/core/SCAEntryPoint.h \ +tuscany/sca/core/SCARuntime.h \ +tuscany/sca/core/ServiceProxy.h \ +tuscany/sca/core/ServiceWrapper.h \ +tuscany/sca/core/TuscanyRuntime.h \ +tuscany/sca/model/Binding.h \ +tuscany/sca/model/Component.h \ +tuscany/sca/model/CPPImplementation.h \ +tuscany/sca/model/CPPInterface.h \ +tuscany/sca/model/EntryPoint.h \ +tuscany/sca/model/ExternalService.h \ +tuscany/sca/model/Implementation.h \ +tuscany/sca/model/Interface.h \ +tuscany/sca/model/ModelLoader.h \ +tuscany/sca/model/Module.h \ +tuscany/sca/model/Service.h \ +tuscany/sca/model/ServiceReference.h \ +tuscany/sca/model/Subsystem.h \ +tuscany/sca/model/System.h \ +tuscany/sca/model/Wire.h \ +tuscany/sca/model/WireTarget.h \ +tuscany/sca/model/WSBinding.h \ +tuscany/sca/model/Wsdl.h \ +tuscany/sca/model/WsdlOperation.h \ +tuscany/sca/util/DefaultLogWriter.h \ +tuscany/sca/util/Exceptions.h \ +tuscany/sca/util/File.h \ +tuscany/sca/util/FileLogWriter.h \ +tuscany/sca/util/Library.h \ +tuscany/sca/util/Logger.h \ +tuscany/sca/util/Logging.h \ +tuscany/sca/util/LogWriter.h \ +tuscany/sca/util/Utils.h \ +tuscany/sca/ws/WSServiceWrapper.h \ +tuscany/sca/ws/EntryPointProxy.h + + +libtuscany_sca_la_SOURCES = \ +osoa/sca/ComponentContext.cpp \ +osoa/sca/ComponentContextImpl.cpp \ +osoa/sca/ModuleContext.cpp \ +osoa/sca/ModuleContextImpl.cpp \ +osoa/sca/SCA.cpp \ +osoa/sca/ServiceList.cpp \ +osoa/sca/ServiceRuntimeException.cpp \ +tuscany/sca/util/DefaultLogWriter.cpp \ +tuscany/sca/util/File.cpp \ +tuscany/sca/util/FileLogWriter.cpp \ +tuscany/sca/util/Library.cpp \ +tuscany/sca/util/Logger.cpp \ +tuscany/sca/util/LogWriter.cpp \ +tuscany/sca/util/Utils.cpp \ +tuscany/sca/model/Binding.cpp \ +tuscany/sca/model/Component.cpp \ +tuscany/sca/model/CPPImplementation.cpp \ +tuscany/sca/model/CPPInterface.cpp \ +tuscany/sca/model/EntryPoint.cpp \ +tuscany/sca/model/ExternalService.cpp \ +tuscany/sca/model/Implementation.cpp \ +tuscany/sca/model/Interface.cpp \ +tuscany/sca/model/ModelLoader.cpp \ +tuscany/sca/model/Module.cpp \ +tuscany/sca/model/Service.cpp \ +tuscany/sca/model/ServiceReference.cpp \ +tuscany/sca/model/Subsystem.cpp \ +tuscany/sca/model/System.cpp \ +tuscany/sca/model/Wire.cpp \ +tuscany/sca/model/WireTarget.cpp \ +tuscany/sca/model/WSBinding.cpp \ +tuscany/sca/model/Wsdl.cpp \ +tuscany/sca/model/WsdlOperation.cpp \ +tuscany/sca/core/ComponentServiceWrapper.cpp \ +tuscany/sca/core/ExternalServiceWrapper.cpp \ +tuscany/sca/core/Operation.cpp \ +tuscany/sca/core/SCAEntryPoint.cpp \ +tuscany/sca/core/SCARuntime.cpp \ +tuscany/sca/core/ServiceProxy.cpp \ +tuscany/sca/core/ServiceWrapper.cpp \ +tuscany/sca/core/TuscanyRuntime.cpp \ +tuscany/sca/ws/EntryPointProxy.cpp + +libtuscany_sca_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \ + -L$(top_builddir)/runtime/ws_reference/axis2c/src -ltuscany_sca_ws_reference + +AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContext.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContext.cpp new file mode 100644 index 0000000000..73c3ed2e36 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContext.cpp @@ -0,0 +1,132 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "osoa/sca/ComponentContext.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Exceptions.h" +#include "osoa/sca/ComponentContextImpl.h" +#include "tuscany/sca/core/SCARuntime.h" + +using namespace tuscany::sca; + +namespace osoa +{ + namespace sca + { + + // ======================================================= + // getCurrent: create a context from the current component + // ======================================================= + ComponentContext ComponentContext::getCurrent() + { + LOGENTRY(1, "ComponentContext::getCurrent"); + Component* component = SCARuntime::getInstance()->getCurrentComponent(); + if (!component) + { + throw ComponentContextException("No current component"); + } + ComponentContextImpl* cci = new ComponentContextImpl(component); + LOGEXIT(1, "ComponentContext::constructor"); + return ComponentContext(cci); + } + + // =========== + // Constructor + // =========== + ComponentContext::ComponentContext(ComponentContextImpl* implementation) + : impl(implementation) + { + LOGENTRY(1, "ComponentContext::constructor"); + LOGEXIT(1, "ComponentContext::constructor"); + } + + // ========== + // Destructor + // ========== + ComponentContext::~ComponentContext() + { + LOGENTRY(1, "ComponentContext::destructor"); + delete impl; + LOGEXIT(1, "ComponentContext::destructor"); + } + + // =================================== + // Copy constructor: create a new impl + // =================================== + ComponentContext::ComponentContext(const ComponentContext& ctx) + { + impl = new ComponentContextImpl(impl->getComponent()); + } + + // ============================= + // operator= : create a new impl + // ============================= + ComponentContext& ComponentContext::operator=(const ComponentContext& ctx) + { + if (this != &ctx) + { + impl = new ComponentContextImpl(impl->getComponent()); + } + return *this; + } + + // ========== + // getService + // ========== + void* ComponentContext::getService(const char* referenceName) + { + LOGENTRY(1, "ComponentContext::getService"); + void* service = impl->getService(referenceName); + LOGEXIT(1, "ComponentContext::getService"); + return service; + } + + // =========== + // getServices + // =========== + ServiceList ComponentContext::getServices(const char* referenceName) + { + return impl->getServices(referenceName); + } + + // ============ + // getProperties + // ============= + DataObjectPtr ComponentContext::getProperties() + { + LOGENTRY(1, "ComponentContext::getProperties"); + DataObjectPtr properties = impl->getProperties(); + LOGEXIT(1, "ComponentContext::getProperties"); + return properties; + } + + // ============ + // getDataFactory + // ============= + DataFactoryPtr ComponentContext::getDataFactory() + { + LOGENTRY(1, "ComponentContext::getDataFactory"); + DataFactoryPtr dataFactory = impl->getDataFactory(); + LOGEXIT(1, "ComponentContext::getDataFactory"); + return dataFactory; + } + + + } // End namespace sca +} // End namespace osoa diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContext.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContext.h new file mode 100644 index 0000000000..10d334a936 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContext.h @@ -0,0 +1,105 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#ifndef osoa_sca_componentcontext_h +#define osoa_sca_componentcontext_h + +#include "osoa/sca/export.h" +#include "osoa/sca/ServiceList.h" +#include "commonj/sdo/SDO.h" +namespace osoa +{ + namespace sca + { + class ComponentContextImpl; + + /** + * An SCA component implementation uses the ComponentContext class to + * retrieve information about the configured SCA component. + */ + class SCA_API ComponentContext + { + + public: + /** + * Return a new ComponentContext for the current Component. + */ + static ComponentContext getCurrent(); + + /** + * Resolve a reference name into a single configured service. + * If the component's reference is wired to more than one service + * then theis method will return an exception. + * @param referenceName The reference to be resolved. This must match + * the name of a reference configured in the component type file for + * this component. + */ + void* getService(const char* referenceName); + + /** + * Resolve a reference name into a list of configured services. + * @param referenceName The reference to be resolved. This must match + * the name of a reference configured in the component type file for + * this component. + */ + ServiceList getServices(const char* referenceName); + + /** + * Get the configured properties for the component. + * @return A data object representing all the properties that + * are configured for this component. + */ + commonj::sdo::DataObjectPtr getProperties(); + + /** + * Get an SDO data factory which will allow the component to + * create data objects for all the types configured for this + * component. + * @return A data factory to be used by the component to create + * new data objects. + */ + commonj::sdo::DataFactoryPtr getDataFactory(); + + /** + * Destructor + */ + virtual ~ComponentContext(); + + + ComponentContext(const ComponentContext&); + ComponentContext& operator=(const ComponentContext&); + + private: + /** + * Constructor to create an interface class from the contained + * implementation. + * @param implementation the actual implementation class + */ + ComponentContext(ComponentContextImpl* implementation); + + /** + * Pointer to the class which provides the actual implementation. + */ + ComponentContextImpl* impl; + + }; + } // End namespace sca +} // End namespace osoa + +#endif // osoa_sca_componentcontext_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContextImpl.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContextImpl.cpp new file mode 100644 index 0000000000..436e44d5e1 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContextImpl.cpp @@ -0,0 +1,270 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Exceptions.h" +#include "osoa/sca/ComponentContextImpl.h" +#include "tuscany/sca/model/WireTarget.h" +#include "tuscany/sca/core/ComponentServiceWrapper.h" +#include "tuscany/sca/core/ExternalServiceWrapper.h" +#include "tuscany/sca/model/CPPImplementation.h" +#include "tuscany/sca/model/Module.h" + +using namespace tuscany::sca; +using namespace tuscany::sca::model; + +namespace osoa +{ + namespace sca + { + // =========== + // Constructor + // =========== + ComponentContextImpl::ComponentContextImpl(Component* comp) + : component(comp) + { + LOGENTRY(1, "ComponentContextImpl::constructor"); + LOGEXIT(1, "ComponentContextImpl::constructor"); + } + + // ========== + // Destructor + // ========== + ComponentContextImpl::~ComponentContextImpl() + { + // -------------------------------------------- + // Delete the proxies served up by this context + // -------------------------------------------- + for (PROXIES::iterator iter = proxies.begin(); iter != proxies.end(); iter++) + { + delete (ServiceProxy*)*iter; + } + } + + + // ========================================================================== + // getServices: return a list of Proxies for services wired to this reference + // ========================================================================== + ServiceList ComponentContextImpl::getServices(const char* referenceName) + { + LOGENTRY(1, "ComponentContextImpl::getServices"); + + string message; + + // -------------------------------------------------------------- + // locate reference in the current component and determine target + // -------------------------------------------------------------- + ServiceReference* serviceReference = component->findReference(referenceName); + if (!serviceReference) + { + message = "Reference not defined: "; + message = message + referenceName; + throw ServiceNotFoundException(message.c_str()); + } + + // Get the target services from the ServiceReference + const ServiceReference::TARGETS& targets = serviceReference->getTargets(); + + // -------------------- + // Validate the request + // -------------------- + switch (serviceReference->getMultiplicity()) + { + case ServiceReference::ONE_MANY: + case ServiceReference::ONE_ONE: + { + if (targets.size() == 0) + { + message = "Reference "; + message = message + referenceName + " not wired"; + throw ServiceNotFoundException(message.c_str()); + } + } + default: + { + } + } // end switch + + // ------------------------------ + // Create a proxy for each target + // ------------------------------ + ServiceList services(targets.size()); + for (ServiceReference::TARGETS::const_iterator iter = targets.begin(); + iter!=targets.end(); + iter++) + { + services.addService(getServiceProxy(serviceReference, *iter)); + } + + return services; + + } // End getServices() + + + // =================================================================== + // getService: return a Proxy for the services wired to this reference + // =================================================================== + void* ComponentContextImpl::getService(const char* referenceName) + { + LOGENTRY(1, "ComponentContextImpl::getService"); + + string message; + + // -------------------------------------------------------------- + // locate reference in the current component and determine target + // -------------------------------------------------------------- + ServiceReference* serviceReference = component->findReference(referenceName); + if (!serviceReference) + { + message = "Reference not defined: "; + message = message + referenceName; + throw ServiceNotFoundException(message.c_str()); + } + + // Get the target service from the ServiceReference + const ServiceReference::TARGETS& targets = serviceReference->getTargets(); + + // -------------------- + // Validate the request + // -------------------- + switch (serviceReference->getMultiplicity()) + { + case ServiceReference::ZERO_MANY: + case ServiceReference::ONE_MANY: + { + message = "getService() called for reference with multiplicity >1 :"; + message = message + referenceName; + throw ServiceNotFoundException(message.c_str()); + } + case ServiceReference::ONE_ONE: + { + if (targets.size() == 0) + { + message = "Reference "; + message = message + referenceName + " not wired"; + throw ServiceNotFoundException(message.c_str()); + } + } + default: + { + } + } // end switch + + // Return the proxy + return getServiceProxy(serviceReference, *targets.begin()); + + } // End getService() + + + // ================================================================== + // getServiceProxy: Create and return an instance of the ServiceProxy + // ================================================================== + void* ComponentContextImpl::getServiceProxy( + ServiceReference* serviceReference, + WireTarget* target) + { + // ----------------------------------- + // Get a ServiceWrapper for the target + // ----------------------------------- + ServiceWrapper* serviceWrapper = getServiceWrapper(target); + + // ------------------------------ + // Get a Proxy for this reference + // ------------------------------ + try + { + ServiceProxy* serviceProxy = new ServiceProxy(component, serviceReference->getName(), serviceWrapper); + void* service = serviceProxy->getProxy(); + // service MUST be set here or an exception will have been thrown + proxies.push_back(serviceProxy); + return service; + } + catch (ServiceRuntimeException&) + { + delete serviceWrapper; + throw ; + } + } + + + // ====================================================================== + // getServiceWrapper: Create and return an instance of the ServiceWrapper + // ====================================================================== + ServiceWrapper* ComponentContextImpl::getServiceWrapper(WireTarget* target) + { + // ------------------------- + // Determine type of Service + // ------------------------- + switch (target->getServiceType()) + { + case WireTarget::ExternalServiceType: + { + // ---------------- + // External Service + // ---------------- + return ExternalServiceWrapper::createServiceWrapper((ExternalService*)target); + } + + case WireTarget::ComponentServiceType: + { + // ----------------- + // Component Service + // ----------------- + return ComponentServiceWrapper::createServiceWrapper((Service*)target); + } + + default: + { + string message = "Undefined wire target type for : "; + message = message + target->getName(); + throw ServiceNotFoundException(message.c_str()); + } + } // end switch + } + + + + // ============================================== + // getProperties: return the component properties + // ============================================== + DataObjectPtr ComponentContextImpl::getProperties() + { + LOGENTRY(1, "ComponentContextImpl::getProperties"); + DataObjectPtr properties = component->getProperties(); + + LOGEXIT(1, "ComponentContextImpl::getProperties"); + return properties; + } + + // ============================================== + // getDataFactory: return the data factory for the module in which + // this component resides + // ============================================== + DataFactoryPtr ComponentContextImpl::getDataFactory() + { + LOGENTRY(1, "ComponentContextImpl::getProperties"); + DataFactoryPtr dataFactory = component->getModule()->getDataFactory(); + + LOGEXIT(1, "ComponentContextImpl::getDataFactory"); + return dataFactory; + } + + + } // End namespace sca +} // End namespace osoa diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContextImpl.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContextImpl.h new file mode 100644 index 0000000000..bd3a0d106a --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ComponentContextImpl.h @@ -0,0 +1,120 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#ifndef osoa_sca_componentcontextimpl_h +#define osoa_sca_componentcontextimpl_h + +#include "osoa/sca/ServiceList.h" + +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/core/ServiceProxy.h" +#include "tuscany/sca/model/Service.h" + +using namespace tuscany::sca; +using namespace tuscany::sca::model; + +namespace osoa +{ + namespace sca + { + /** + * Contains the actual implementation of a ComponentContext interface. + */ + class ComponentContextImpl + { + + public: + /** + * Constructor that takes a Component which represents the runtime + * model for this context. + */ + ComponentContextImpl(Component* component); + + /** + * Default constructor. + */ + virtual ~ComponentContextImpl(); + + /** + * See ComponentContext. + */ + void* getService(const char* referenceName); + + /** + * See ComponentContext. + */ + ServiceList getServices(const char* referenceName); + + /** + * See ComponentContext. + */ + DataObjectPtr getProperties(); + + /** + * See ComponentContext. + */ + commonj::sdo::DataFactoryPtr getDataFactory(); + + /** + * Returns the contained Component. + * @return The Component to which this context refers. + */ + Component* getComponent() {return component;} + + private: + ComponentContextImpl(const ComponentContextImpl&); + ComponentContextImpl& operator=(const ComponentContextImpl&); + + /** + * Pointer to the runtime model Component to which this + * context refers. + */ + Component* component; + + /** + * Helper method to return a proxy to a service. + * @param serviceReference The source reference. + * @param target The target to which this source reference is wired. + * @return A pointer to an object which can be cast to the business + * class representing the target. + */ + void* getServiceProxy( + ServiceReference* serviceReference, + WireTarget* target); + + /** + * Helper method to return a wrapper for a target service. + * @param target The target for which this wrapper is to be created. + * @return The service wrapper. + */ + ServiceWrapper* getServiceWrapper(WireTarget* target); + + + typedef vector<ServiceProxy*> PROXIES; + /** + * A vector of the proxies created by this ComponentContext. The + * proxies will be destroyed when the ComponentContext is destroyed. + */ + PROXIES proxies; + }; + } // End namespace sca +} // End namespace osoa + +#endif // osoa_sca_componentcontextimpl_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContext.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContext.cpp new file mode 100644 index 0000000000..93e36b297f --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContext.cpp @@ -0,0 +1,93 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "osoa/sca/ModuleContext.h" +#include "tuscany/sca/util/Logging.h" +#include "osoa/sca/ModuleContextImpl.h" +#include "tuscany/sca/core/SCARuntime.h" + +using namespace tuscany::sca; + +namespace osoa +{ + namespace sca + { + // =========== + // Constructor + // =========== + ModuleContext::ModuleContext(ModuleContextImpl* implementation) + : impl(implementation) + { + } + + // =================================== + // Copy constructor: create a new impl + // =================================== + ModuleContext::ModuleContext(const ModuleContext& ctx) + { + impl = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule()); + } + + // ============================= + // operator= : create a new impl + // ============================= + ModuleContext& ModuleContext::operator=(const ModuleContext& ctx) + { + if (this != &ctx) + { + impl = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule()); + } + return *this; + } + + // ========== + // Destructor + // ========== + ModuleContext::~ModuleContext() + { + LOGENTRY(1, "ModuleContext::destructor"); + delete impl; + LOGEXIT(1, "ModuleContext::destructor"); + } + + // ==================================================== + // getCurrent: create a context from the current module + // ==================================================== + ModuleContext ModuleContext::getCurrent() + { + LOGENTRY(1, "ModuleContext::getCurrent"); + ModuleContextImpl* mci = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule()); + LOGEXIT(1, "ModuleContext::getCurrent"); + return ModuleContext(mci); + } + + // ============= + // locateService + // ============= + void* ModuleContext::locateService(const char* serviceName) + { + LOGENTRY(1, "ModuleContext::locateService"); + void* sp = impl->locateService(serviceName); + LOGEXIT(1, "ModuleContext::locateService"); + return sp; + } + + + } // End namespace sca +} // End namespace osoa diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContext.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContext.h new file mode 100644 index 0000000000..7aacb00123 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContext.h @@ -0,0 +1,80 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#ifndef osoa_sca_modulecontext_h +#define osoa_sca_modulecontext_h + +#include "osoa/sca/export.h" + +namespace osoa +{ + namespace sca + { + class ModuleContextImpl; + + /** + * An SCA component implementation, or a non-SCA client, uses the + * ModuleContext class to retrieve information about the configured + * SCA module. + */ + class SCA_API ModuleContext + { + + public: + /** + * Return a new ModuleContext for the current Component. + */ + static ModuleContext getCurrent(); + + /** + * Resolve a service name into a single component service. + * @param serviceName The name of the service in the form + * "component name"/"service name". The service name is + * optional in the component has one service. + * @return A pointer to an object which can be cast to the + * business interface of the target service. + */ + void* locateService(const char* serviceName); + + /** + * Destructor. + */ + virtual ~ModuleContext(); + + ModuleContext(const ModuleContext&); + ModuleContext& operator=(const ModuleContext&); + + private: + /** + * Constructor to create an interface class from the contained + * implementation. + * @param implementation The actual implementation class. + */ + ModuleContext(ModuleContextImpl* implementation); + + /** + * Pointer to the class which provides the actual implementation. + */ + ModuleContextImpl* impl; + + }; + } // End namespace sca +} // End namespace osoa + +#endif // osoa_sca_modulecontext_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContextImpl.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContextImpl.cpp new file mode 100644 index 0000000000..4d96ee336d --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContextImpl.cpp @@ -0,0 +1,102 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Exceptions.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/CPPImplementation.h" +#include "osoa/sca/ModuleContextImpl.h" +#include "tuscany/sca/core/ComponentServiceWrapper.h" + +using namespace tuscany::sca; +using namespace tuscany::sca::model; + +namespace osoa +{ + namespace sca + { + // =========== + // Constructor + // =========== + ModuleContextImpl::ModuleContextImpl(Module* mod) + : module(mod) + { + } + + // ========== + // Destructor + // ========== + ModuleContextImpl::~ModuleContextImpl() + { + // -------------------------------------------- + // Delete the proxies served up by this context + // -------------------------------------------- + for (PROXIES::iterator iter = proxies.begin(); iter != proxies.end(); iter++) + { + delete (ServiceProxy*)*iter; + } + } + + // =========================================================================== + // locateService: return a proxy connected to a wrapper for the target service + // =========================================================================== + void* ModuleContextImpl::locateService(const char* serviceName) + { + LOGENTRY(1, "ModuleContextImpl::locateService"); + + + // ---------------------------- + // Locate the component service + // ---------------------------- + Service* service = module->findComponentService(serviceName); + string msg; + if (!service) + { + msg = "Service not found: "; + msg = msg + serviceName; + throw ServiceNotFoundException(msg.c_str()); + } + + // ------------------------- + // Create the ServiceWrapper + // ------------------------- + ComponentServiceWrapper* serviceWrapper = ComponentServiceWrapper::createServiceWrapper(service); + + // ---------------------------- + // Get a Proxy for this service + // ---------------------------- + try + { + ServiceProxy* serviceProxy = new ServiceProxy(service->getComponent(), service->getName(), serviceWrapper); + proxies.push_back(serviceProxy); + LOGEXIT(1, "ModuleContextImpl::locateService"); + return serviceProxy->getProxy(); + } + catch (ServiceRuntimeException&) + { + delete serviceWrapper; + throw ; + } + + } + + + + } // End namespace sca +} // End namespace osoa diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContextImpl.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContextImpl.h new file mode 100644 index 0000000000..5950313a06 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ModuleContextImpl.h @@ -0,0 +1,71 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#ifndef osoa_sca_modulecontextimpl_h +#define osoa_sca_modulecontextimpl_h +#include "tuscany/sca/model/Module.h" +#include "tuscany/sca/core/ServiceProxy.h" + +namespace osoa +{ + namespace sca + { + /** + * Contains the actual implementation of a ModuleContext interface. + */ + class ModuleContextImpl + { + + public: + /** + * Constructor that takes a Module which represents the runtime + * model for this context. + */ + ModuleContextImpl(tuscany::sca::model::Module* module); + + /** + * See ModuleContext#locateService. + */ + void* locateService(const char* serviceName); + + /** + * Destructor. + */ + virtual ~ModuleContextImpl(); + private: + ModuleContextImpl(const ModuleContextImpl&); + ModuleContextImpl& operator=(const ModuleContextImpl&); + + /** + * Pointer to the runtime model Module object to which this + * context refers. + */ + tuscany::sca::model::Module* module; + + typedef vector<tuscany::sca::ServiceProxy*> PROXIES; + /** + * Vector of proxies created from calls to the locateService + * method. + */ + PROXIES proxies; + }; + } // End namespace sca +} // End namespace osoa + +#endif // osoa_sca_modulecontextimpl_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/SCA.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/SCA.cpp new file mode 100644 index 0000000000..bcca254028 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/SCA.cpp @@ -0,0 +1,21 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev: $ $Date: $ */ + +#include "osoa/sca/sca.h" + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceList.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceList.cpp new file mode 100644 index 0000000000..ba2b418a7c --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceList.cpp @@ -0,0 +1,105 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "osoa/sca/ServiceList.h" + +#include "osoa/sca/ServiceRuntimeException.h" + +namespace osoa +{ + namespace sca + { + // =========== + // Constructor + // =========== + ServiceList::ServiceList(unsigned int numTargets) + : maxServices(numTargets), numServices(0) + { + services = new void*[numTargets]; + } + + // ========================================== + // Copy comstructor: create new service array + // ========================================== + ServiceList::ServiceList(const ServiceList& sl) + : maxServices(sl.maxServices), numServices(sl.numServices) + { + services = new void*[maxServices]; + for (unsigned int i=0; i<numServices; i++) + { + services[i] = sl.services[i]; + } + } + + // =================================== + // operator=: create new service array + // =================================== + ServiceList& ServiceList::operator=(const ServiceList& sl) + { + if (this != &sl) + { + maxServices = sl.maxServices; + numServices = sl.numServices; + + services = new void*[maxServices]; + for (unsigned int i=0; i<numServices; i++) + { + services[i] = sl.services[i]; + } + } + return *this; + } + + // ========== + // Destructor + // ========== + ServiceList::~ServiceList() + { + delete [] services; + } + + // ================================= + // operator[]: return service at pos + // ================================= + void* ServiceList::operator[] (unsigned int pos) + { + if (pos < numServices) + { + return services[pos]; + } + else + { + throw ServiceRuntimeException("ServiceList: index out of bounds"); + } + } + + // ==================================== + // addService: add service to the array + // ==================================== + void ServiceList::addService(void* service) + { + if (numServices < maxServices) + { + services[numServices] = service; + numServices++; + } + } + + } // End namespace sca +} // End namespace osoa diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceList.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceList.h new file mode 100644 index 0000000000..be6f6c9b1a --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceList.h @@ -0,0 +1,84 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#ifndef osoa_sca_servicelist_h +#define osoa_sca_servicelist_h + +#include "osoa/sca/export.h" + +namespace osoa +{ + namespace sca + { + + /** + * Holds a list of services that can be accessed from an SCA + * component. Each entry can be cast to the business interface + * of the target component. All the entries will be of the + * same type. + */ + class SCA_API ServiceList + { + + public: + /** + * Return the number of services in the list. + * @return Number of services. + */ + unsigned int size() {return numServices;} + + /** + * Return the service at this position. + */ + void* operator[] (unsigned int pos); + + ServiceList(const ServiceList& serviceList); + ServiceList& operator=(const ServiceList& serviceList); + virtual ~ServiceList(); + + private: + friend class ComponentContextImpl; + + /** + * Create a new service list with the known number of + * target services. Once created, the service list can only + * have services added to it up to the number of targets + * specified on this constructor. + * @param numTargets Number of target services to be held in this list. + */ + ServiceList(unsigned int numTargets); + + /** + * Add a service to this list. + */ + void addService(void* service); + + unsigned int maxServices; + unsigned int numServices; + + /** + * Pointer to an array of services. + */ + void** services; + + }; + } // End namespace sca +} // End namespace osoa + +#endif // osoa_sca_servicelist_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp new file mode 100644 index 0000000000..9f275c9c10 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp @@ -0,0 +1,208 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "osoa/sca/ServiceRuntimeException.h" +using namespace std; + +namespace osoa +{ + namespace sca + { + + // ======================================================================== + // Constructor + // ======================================================================== + ServiceRuntimeException :: ServiceRuntimeException(const char* name, + severity_level sev, + const char* msg_text) + : severity(sev), location_set(0) + { + class_name = new char[strlen(name) + 1]; + strcpy(class_name,name); + message_text = new char[strlen(msg_text)+1]; + strcpy(message_text,msg_text); + + } // end ServiceRuntimeException constuctor + + // ======================================================================== + // Constructor + // ======================================================================== + ServiceRuntimeException :: ServiceRuntimeException(const ServiceRuntimeException& c) + : + severity(c.getSeverity()), location_set(c.location_set) + + { + class_name = new char[strlen(c.getEClassName()) + 1]; + strcpy(class_name, c.getEClassName()); + message_text = new char[strlen(c.getMessageText())+1]; + strcpy(message_text,c.getMessageText()); + for (int i=0;i<c.location_set;i++) + { + locations[i].file = new char[strlen(c.locations[i].file) + 1]; + strcpy(locations[i].file,c.locations[i].file); + locations[i].line = c.locations[i].line; + locations[i].function = new char[strlen(c.locations[i].function) + 1]; + strcpy(locations[i].function, c.locations[i].function); + } + } + + // ======================================================================== + // Destructor + // ======================================================================== + ServiceRuntimeException :: ~ServiceRuntimeException() + { + if (class_name) delete class_name; + if (message_text) delete message_text; + for (int i=0;i<location_set;i++) + { + if (locations[i].file) delete locations[i].file; + if (locations[i].function) delete locations[i].function; + } + + } // end ServiceRuntimeException destructor + + // ======================================================================== + // Return class name of this exception + // ======================================================================== + const char* ServiceRuntimeException :: getEClassName() const + { + return class_name; + } // end getClassName() + + // ======================================================================== + // Return severity + // ======================================================================== + ServiceRuntimeException::severity_level ServiceRuntimeException :: getSeverity() const + { + return severity; + } // end getSeverity() + + // ======================================================================== + // Return message text associated with exception + // ======================================================================== + const char* ServiceRuntimeException :: getMessageText() const + { + return message_text; + } // end getMessageText() + + // ======================================================================== + // Return file name where exception was raised + // ======================================================================== + const char* ServiceRuntimeException :: getFileName() const + { + return locations[0].file; + } // end getFileName() + + // ======================================================================== + // Return line number where exception was raised + // ======================================================================== + unsigned long ServiceRuntimeException :: getLineNumber() const + { + return locations[0].line; + } // end getLineNumber() + + // ======================================================================== + // Return function name where exception was raised + // ======================================================================== + const char* ServiceRuntimeException :: getFunctionName() const + { + return locations[0].function; + } // end getFunctionName() + + + // ======================================================================== + // set severity of exception + // ======================================================================== + void ServiceRuntimeException :: setSeverity(severity_level sev) + { + severity = sev; + } // end setSeverity(severity_level sev) const + + // ======================================================================== + // set message text associated with exception + // ======================================================================== + void ServiceRuntimeException :: setMessageText(const char* msg_text) + { + if (message_text != 0) delete message_text; + message_text = new char[strlen(msg_text) + 1]; + strcpy(message_text,msg_text); + } // end setMessageText(const string &msg_text) const + + // ======================================================================== + // set location of most recent throw/handling of the exception + // ======================================================================== + void ServiceRuntimeException :: setLocation(const char* file, + unsigned long line, + const char* function) + { + if (location_set < num_locations) + { + locations[location_set].file = new char[strlen(file) + 1]; + strcpy(locations[location_set].file,file); + locations[location_set].line = line; + locations[location_set].function = new char[strlen(function) + 1]; + strcpy(locations[location_set].function,function); + + location_set++; + } + } // end setLocation() + + + // ======================================================================== + // print self + // ======================================================================== + ostream& ServiceRuntimeException :: PrintSelf(ostream &os) const + { + + os << "Exception object :" << endl; + os << " class: " << class_name << endl; + os << " description: " << message_text << endl; + if (location_set != 0) + { + os << " file name: " << locations[0].file << endl; + char lineNumber[100]; + sprintf(lineNumber, "%lu",locations[0].line); + os << " line number: " << lineNumber << endl; + os << " function: " << locations[0].function << endl; + os << " location history:" << endl; + + int i=1; + while (i < location_set) + { + os << " " << i << ")" << endl; + os << " file: " << locations[i].file << endl; + os << " line: " << locations[i].line << endl; + os << " function: " << locations[i].function << endl; + i++; + } + } + return os; + } // end ostream operator << + + // ======================================================================== + // ostream operator << + // ======================================================================== + SCA_API ostream& operator<< (ostream &os, const ServiceRuntimeException &except) + { + return except.PrintSelf(os); + } // end ostream operator << + + + } // End namespace sca +} // End namespace osoa diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.h new file mode 100644 index 0000000000..7de44f84d7 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.h @@ -0,0 +1,236 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#ifndef osoa_sca_serviceruntimeexception_h +#define osoa_sca_serviceruntimeexception_h + +#include "osoa/sca/export.h" + +#include <ostream> + +namespace osoa +{ + namespace sca + { + + /** + * Top level exception to represent all the exceptions that may be + * thrown by an SCA runtime implementation. + */ + class SCA_API ServiceRuntimeException + { + public: + /** + * Represents the possible severity levels for an exception. + */ + enum severity_level + { + Normal, + Warning, + Error, + Severe + }; + + /** + * Constructor. + * @param name Class name of the exception. + * @param sev Severity level. + * @param msg_text Detailed description of the exception. + */ + ServiceRuntimeException( + const char *name="ServiceRuntimeException", + severity_level sev=Severe, + const char* msg_text=""); + + ServiceRuntimeException(const ServiceRuntimeException& c); + + // Destructor + virtual ~ServiceRuntimeException(); + + /** + * Return class name of this exception. + */ + const char* getEClassName() const; + + /** + * Return severity. + */ + severity_level getSeverity() const; + + /** + * Return message text associated with exception. + */ + const char* getMessageText() const; + + /* + * Return file name where the exception was raised. + */ + const char* getFileName() const; + + /** + * Return line number where the exception was raised. + */ + unsigned long getLineNumber() const; + + /** + * Return function name where the exception was raised. + */ + const char* getFunctionName() const; + + /** + * Set the exception severity. + */ + void setSeverity(severity_level sev); + + /** + * Set the message text associated with exception. + */ + void setMessageText(const char* msg_text); + + /** + * Set the location where the exception was raised. + * @param file Name of the file. + * @param line Line number in the file. + * @param function Name of the function. + */ + void setLocation(const char* file, + unsigned long line, + const char* function=""); + + /** + * Append exception details to ostream. + */ + virtual std::ostream& PrintSelf(std::ostream &os) const; + + /** + * Operator to send exceptions details to a stream. + */ + SCA_API friend std::ostream& operator<< (std::ostream &os, const ServiceRuntimeException &except); + protected: + + private: + /** + * Class name of the exception. + */ + char* class_name; + + /** + * Severity level of the exception. + */ + severity_level severity; + + /** + * Description of the exception. + */ + char* message_text; // Description of exception + + /** + * Location where the exception was thrown or handled and thrown. + */ + class location + { + public: + char* file; // File name (from __FILE__) + unsigned long line; // Line number (from __LINE__) + char* function; // Function name + }; + + + enum {num_locations=5}; + /** + * Array of locations where the exception has been handled and thrown. + */ + location locations[num_locations]; + + /** + * The current location (index into ServiceRuntimeException#location). + */ + int location_set; + + + }; // End ServiceRuntimeException class definition + + + /** + * A remotable service is currently unavailable. It is possible that a retry + * may resolve this exception. + */ + class SCA_API ServiceUnavailableException: public ServiceRuntimeException + { + public: + ServiceUnavailableException(const char* serviceName) + : ServiceRuntimeException("ServiceUnavailableException", Warning, + serviceName) + { + } + private: + }; // End ServiceUnavailableException class definition + + + /** + * The target of a wire cannot be found, or the reference has not been + * configured. + */ + class SCA_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_API ComponentContextException: public ServiceRuntimeException + { + public: + ComponentContextException(const char* msg) + : ServiceRuntimeException("ComponentContextException", Error, + msg) + { + } + private: + }; // End ComponentContextException class definition + + /** + * Unable to find the specified entry point in the module. + */ + class SCA_API EntryPointNotFoundException: public ServiceRuntimeException + { + public: + EntryPointNotFoundException(const char* msg) + : ServiceRuntimeException("EntryPointNotFoundException", Error, + msg) + { + } + private: + }; // End EntryPointNotFoundException class definition + + + + } // End namespace sca +} // End namespace osoa + +#endif // osoa_sca_serviceruntimeexception_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/export.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/export.h new file mode 100644 index 0000000000..6ef7960284 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/export.h @@ -0,0 +1,39 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#ifndef osoa_sca_export_h +#define osoa_sca_export_h + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) + +#ifdef SCA_EXPORTS +#define SCA_API __declspec(dllexport) +#else +#define SCA_API __declspec(dllimport) +#endif + +#else +#include <sys/time.h> +#include <inttypes.h> +#include <stdlib.h> +#define SCA_API +#endif + +#endif // osoa_sca_export_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/sca.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/sca.h new file mode 100644 index 0000000000..528bd91c4a --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/osoa/sca/sca.h @@ -0,0 +1,29 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#ifndef osoa_sca_sca_h +#define osoa_sca_sca_h + +#include "osoa/sca/export.h" +#include "osoa/sca/ModuleContext.h" +#include "osoa/sca/ComponentContext.h" +#include "osoa/sca/ServiceList.h" +#include "osoa/sca/ServiceRuntimeException.h" + +#endif // osoa_sca_sca_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp new file mode 100644 index 0000000000..65d218dc86 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp @@ -0,0 +1,204 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h new file mode 100644 index 0000000000..3a5e990bf0 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h @@ -0,0 +1,156 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp new file mode 100644 index 0000000000..2838bbe4d4 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp @@ -0,0 +1,102 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/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-RC3b/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h new file mode 100644 index 0000000000..b2dcfb3a6b --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h @@ -0,0 +1,81 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/Operation.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/Operation.cpp new file mode 100644 index 0000000000..981f4e6d9e --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/Operation.cpp @@ -0,0 +1,266 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/Operation.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/Operation.h new file mode 100644 index 0000000000..e562dca3c1 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/Operation.h @@ -0,0 +1,177 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp new file mode 100644 index 0000000000..63a7d52e7a --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp @@ -0,0 +1,210 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.h new file mode 100644 index 0000000000..6c1df3e28e --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.h @@ -0,0 +1,122 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp new file mode 100644 index 0000000000..9da3e547e9 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp @@ -0,0 +1,355 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h new file mode 100644 index 0000000000..2b81b2cbcd --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h @@ -0,0 +1,195 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp new file mode 100644 index 0000000000..ef2f2744eb --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp @@ -0,0 +1,121 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h new file mode 100644 index 0000000000..073b379cd7 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h @@ -0,0 +1,89 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp new file mode 100644 index 0000000000..5936f526f1 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp @@ -0,0 +1,55 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h new file mode 100644 index 0000000000..21c162d77f --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h @@ -0,0 +1,73 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp new file mode 100644 index 0000000000..810f810132 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp @@ -0,0 +1,100 @@ +/* + * + * 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-RC3b/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h new file mode 100644 index 0000000000..92da737416 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h @@ -0,0 +1,85 @@ +/* + * + * 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 + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Binding.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Binding.cpp new file mode 100644 index 0000000000..c312d7a077 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Binding.cpp @@ -0,0 +1,44 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/Binding.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + Binding::Binding(const string& uri) : uri(uri) + { + } + + Binding::~Binding() + { + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Binding.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Binding.h new file mode 100644 index 0000000000..ff97990dc6 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Binding.h @@ -0,0 +1,85 @@ +/* + * + * 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_model_binding_h +#define tuscany_sca_model_binding_h +#include <string> +using std::string; + + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Information about the binding for EntryPoint and ExternalService. An + * abstract class which will be extended by classes that hold specific + * information for each type of binding. + */ + class Binding + { + + public: + /** + * Supported binding types. + */ + enum Type + { + WS, + SCA + }; + + /** + * Constructor to create a new binding. + * @param uri The uri specified in the scdl file. + */ + Binding(const string& uri); + + /** + * Destructor. + */ + virtual ~Binding(); + + /** + * Return the enumerated type of binding. + * @return The type of the binding (see Binding#Type). + */ + virtual Type getBindingType() = 0; + + /** + * Return the uri of the binding. + * @return The uri of the binding. + */ + string getUri() {return uri;}; + + private: + /** + * The uri of the binding. + */ + string uri; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_binding_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPImplementation.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPImplementation.cpp new file mode 100644 index 0000000000..7212e777b1 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPImplementation.cpp @@ -0,0 +1,54 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/CPPImplementation.h" +#include "tuscany/sca/util/Utils.h" + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + CPPImplementation::CPPImplementation(const string& dllName, const string& head, const string& classN) + : dll(dllName), header(head), className(classN) + { + // Separate any path element + Utils::rTokeniseString("/", head, headerPath, headerStub); + if (headerPath != "") + { + headerPath += "/"; + } + + // Determine the header stub name + string tmp; + Utils::rTokeniseString(".h", headerStub, headerStub, tmp); + } + + CPPImplementation::~CPPImplementation() + { + } + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPImplementation.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPImplementation.h new file mode 100644 index 0000000000..0294649af7 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPImplementation.h @@ -0,0 +1,125 @@ +/* + * + * 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_model_cppimplementation_h +#define tuscany_sca_model_cppimplementation_h +#include "tuscany/sca/model/Implementation.h" + +#include <map> +using std::map; +#include <string> +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Holds informatio about an SCA implementation written in C++ + */ + class CPPImplementation : public Implementation + { + + public: + /** + * Constructor. + * @param dllName Name of the shared library. + * @param header Name of the header file that contains the class declaring the + * implementation class. + * @param className Name of the class in the header file (could be a blank string + * if this is not specified). + */ + CPPImplementation(const string& dllName, const string& header, const string& className); + + /** + * Destructor + */ + virtual ~CPPImplementation(); + + /** + * Return the implementation type. + * @return Always returns CPP. + */ + virtual Type getImplementationType() {return CPP;} + + /** + * Returns the name of the shared library. + * @return The name of the shared library. + */ + const string& getDll() {return dll;} + + /** + * Get the name of the header file. + * @return Name of the header file. + */ + const string& getHeader() {return header;} + + /** + * Get the header file name without the extension. + * @return The name of the header file without any extension. + */ + const string& getHeaderStub() {return headerStub;} + + /** + * Get the header path. + * @return The pathe element of the header. + */ + const string& getHeaderPath() {return headerPath;} + + /** + * Get the name of the class. + * @return The class name if specified. + */ + const string& getClass() {return className;} + private: + /** + * Name of the shared library. + */ + string dll; + + /** + * Name of the header file describing the interface. + */ + string header; + + /** + * Name of the header file without the extension. + */ + string headerStub; + + /** + * Path element of the header. + */ + string headerPath; + + /** + * Name of the class in the header file declaring the implementation. + * May be an empty string if not set in the SCDL file. + */ + string className; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_cppimplementation_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPInterface.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPInterface.cpp new file mode 100644 index 0000000000..015b54c259 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPInterface.cpp @@ -0,0 +1,67 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/CPPInterface.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + CPPInterface::CPPInterface( + const string& head, + const string& classN, + const string& scop, + bool remote) + : header(head), className(classN), remotable(remote) + { + string::size_type dot = header.rfind(".h"); // this will also find .hpp + if (dot != string::npos) + { + headerStub = header.substr(0, dot); + } + else + { + headerStub = header; + } + + if (scop == "module") + { + scope = MODULE; + } + else + { + scope = STATELESS; + } + } + + CPPInterface::~CPPInterface() + { + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPInterface.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPInterface.h new file mode 100644 index 0000000000..7b37b1892e --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/CPPInterface.h @@ -0,0 +1,143 @@ +/* + * + * 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_model_cppinterface_h +#define tuscany_sca_model_cppinterface_h + +#include "tuscany/sca/model/Interface.h" + + +#include <map> +using std::map; +#include <string> +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Holds information about an interface described using a C++ + * header file. + */ + class CPPInterface : public Interface + { + + public: + /** + * Constuctor. + * @param header Name of the header file containing the class that + * describes the interface. + * @param className Name of the class in the header file that + * describes the interface. + * @param scope The scope of the interface (stateless or module). + * @param remotable True if the interface is remotable. + */ + CPPInterface( + const string& header, + const string& className, + const string& scope, + bool remotable); + + /** + * Destructor. + */ + virtual ~CPPInterface(); + + /** + * Return the type of the interface. + * @return Always returns CPP. + */ + virtual Type getInterfaceType() {return CPP;} + + /** + * Get the name of the header file. + * @return The name of the header file containing the definition of the + * interface. + */ + const string& getHeader() {return header;} + + /** + * Return the name of the header file without the extension. + * @return Header file name without any extension. + */ + const string& getHeaderStub() {return headerStub;} + + /** + * Get the name of the class. + * @return The name of the class defining the interface. + */ + const string& getClass() {return className;} + + /** + * Scope of interface. + */ + enum SCOPE + { + MODULE, + STATELESS + }; + + /** + * Get the scope of the interface. + * @return The scope of the interface. + */ + SCOPE getScope() {return scope;} + + /** + * Return whether the interface is remotable or local. + * @return True if the interface is remotable, otherwise false. + */ + bool getRemotable() {return remotable;} + + private: + /** + * Name of the header file containing the definition of the interface. + */ + string header; + + /** + * Name of the header file without the extension. + */ + string headerStub; + + /** + * Name of the class in the header file. + */ + string className; + + /** + * Scope of the interface. + */ + SCOPE scope; + + /** + * Remotable interface or not. + */ + bool remotable; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_cppinterface_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Component.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Component.cpp new file mode 100644 index 0000000000..4e0cf81c61 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Component.cpp @@ -0,0 +1,305 @@ +/* + * + * 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 $ */ + +// Component.cpp : Represent a loaded Component +// +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Exceptions.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/model/Component.h" + +using namespace commonj::sdo; + +namespace tuscany +{ + namespace sca + { + namespace model + { + // Constructor + Component::Component(const std::string& componentName, Module* module) + : name(componentName), containingModule(module), implementation(0) + { + LOGENTRY(1, "Component::constructor"); + LOGINFO_1(3, "Component::constructor: Component name: %s", name.c_str()); + LOGEXIT(1, "Component::constructor"); + } + + Component::~Component() + { + } + + Service* Component::addService(const std::string& serviceName) + { + Service* service = new Service(serviceName, this); + services[serviceName] = service; + return service; + } + + Service* Component::findService(const std::string& serviceName) + { + // If serviceName is null then return the ONLY service + if (serviceName == "" + && services.size() == 1) + { + return services.begin()->second; + } + else + { + return services[serviceName]; + } + } + + ServiceReference* Component::findReference(const std::string& referenceName) + { + return references[referenceName]; + } + + ServiceReference* Component::addReference(const std::string& referenceName) + { + ServiceReference* serviceReference = references[referenceName]; + if (!serviceReference) + { + references[referenceName] = new ServiceReference(referenceName); + } + return references[referenceName]; + } + + void Component::setImplementation(Implementation* impl) + { + implementation = impl; + } + + void Component::addProperty(const string& name, + const string& type, + bool many, + bool required, + const char* defaultValue) + { + // Create a Type in the Properties dataFactory + DataFactoryPtr factory = getPropertyDataFactory(); + + string typeUri, typeName; + Utils::tokeniseQName(type, typeUri, typeName); + + if (typeUri == "http://www.w3.org/2001/XMLSchema") + { + typeUri = Type::SDOTypeNamespaceURI; + if (typeName == "string") + { + typeName = "String"; + } + else if (typeName == "anyType") + { + typeName = "DataObject"; + } + else if (typeName == "int") + { + typeName = "Integer"; + } + else if (typeName == "integer") + { + typeName = "Integer"; + } + else if (typeName == "negativeInteger") + { + typeName = "Integer"; + } + else if (typeName == "nonNegativeInteger") + { + typeName = "Integer"; + } + else if (typeName == "positiveInteger") + { + typeName = "Integer"; + } + else if (typeName == "nonPositiveInteger") + { + typeName = "Integer"; + } + else if (typeName == "unsignedLong") + { + typeName = "Integer"; + } + else if (typeName == "unsignedShort") + { + typeName = "Integer"; + } + else if (typeName == "unsignedInt") + { + typeName = "Long"; + } + else if (typeName == "long") + { + typeName = "Long"; + } + else if (typeName == "double") + { + typeName = "Double"; + } + else if (typeName == "short") + { + typeName = "Short"; + } + else if (typeName == "unsignedByte") + { + typeName = "Short"; + } + else if (typeName == "float") + { + typeName = "Float"; + } + else if (typeName == "boolean") + { + typeName = "Boolean"; + } + else if (typeName == "byte") + { + typeName = "Byte"; + } + else if (typeName == "base64Binary") + { + typeName = "Bytes"; + } + else if (typeName == "hexBinary") + { + typeName = "Bytes"; + } + else if (typeName == "anyURI") + { + typeName = "URI"; + } + else if (typeName == "QName") + { + typeName = "URI"; + } + else + { + // Default unknown xs: types to string?? + typeName = "String"; + } + } + else + { + // It's not an XML type + } + + + factory->addPropertyToType( + "org/osoa/sca", + "Properties", + name.c_str(), + typeUri.c_str(), + typeName.c_str(), + many, + false, + true); + + // Set the default + + + // Add to list of required properties + if (required) + { + } + } + + DataFactoryPtr Component::getPropertyDataFactory() + { + if (!propertyFactory) + { + propertyFactory = DataFactory::getDataFactory(); + // Add the root type + propertyFactory->addType("org/osoa/sca", "Properties", false, false, false, false); + } + return propertyFactory; + } + + DataObjectPtr Component::getProperties() + { + if (!properties) + { + properties = getPropertyDataFactory()->create("org/osoa/sca", "Properties"); + } + return properties; + } + + void Component::addProperties(DataObjectPtr values) + { + if (!values) + { + return; + } + + DataObjectPtr props = getProperties(); + + PropertyList pl = values->getInstanceProperties(); + for (int i=0; i < pl.size(); i++) + { + if (!values->isSet(i)) + { + continue; + } + + // Add the property value to the component to be resolved later + string propName = pl[i].getName(); + + // Get the property's type + try + { + const Property& propProperty = props->getProperty(pl[i].getName()); + const Type& propType = propProperty.getType(); + + DataObjectList& proplist = values->getList(pl[i]); + for (int proplistI=0; proplistI<proplist.size(); proplistI++) + { + // Get the property value + string propValue = proplist.getDataObject(proplistI)->getSequence()->getCStringValue(0); + if (propType.isDataType()) + { + if (propProperty.isMany()) + { + DataObjectList& dol = props->getList(propProperty); + dol.append(propValue.c_str()); + } + else + { + props->setCString(propProperty, propValue.c_str()); + } + } + else + { + // Create a new instance of the DO + // iterate over properties setting each one + } + } + } + catch (SDOPropertyNotFoundException&) + { + // Configuration error: property is not defined + string message = "Undefined property: " + propName; + throw SystemConfigurationException(message.c_str()); + } + + } + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Component.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Component.h new file mode 100644 index 0000000000..f40690c859 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Component.h @@ -0,0 +1,202 @@ +/* + * + * 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_model_component_h +#define tuscany_sca_model_component_h + +#include <string> +using std::string; + +#include <map> + +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/Implementation.h" +#include "tuscany/sca/model/ServiceReference.h" + +#include "commonj/sdo/SDO.h" +using commonj::sdo::DataObjectPtr; +using commonj::sdo::DataFactoryPtr; + +namespace tuscany +{ + namespace sca + { + namespace model + { + + class Module; + + /** + * Information about an SCA component. + */ + class Component + { + public: + /** + * Constructor + * @param name The name of the component. + * @param module The module containing this component. + */ + Component(const std::string& name, Module* module); + + /** + * Destructor. + */ + virtual ~Component(); + + /** + * Returns the name of the component. + * @return The name of the component. + */ + const string& getName() {return name;} + + /** + * Get the module containing this component. + * @return The containing module. + */ + Module* getModule() {return containingModule;} + + /** + * Add a new service to this component. + * @param serviceName The name of the service to add. + * @return The newly added service. + */ + Service* addService(const std::string& serviceName); + + /** + * Find an existing service on this component. + * @param serviceName The name of the service to find. + * If the serviceName is the zero length string then if there is + * only one service it will be returned. + * @return The found service, or 0 if not found. + */ + Service* findService(const std::string& serviceName); + + /** + * Add a new reference to this component. + * @param referenceName The name of the reference to add. + * @return The newly added reference. + */ + ServiceReference* addReference(const std::string& referenceName); + + /** + * Find an existing reference on this component. + * @param referenceName The name of the reference to find. + * @return The found reference, or 0 if not found. + */ + ServiceReference* findReference(const std::string& referenceName); + + /** + * Set the details of the implementation of this component. + * @param impl The details of the implementation. + */ + void setImplementation(Implementation* impl); + + /** + * Returns the details of the implementation of this component. + * @return The details of the implementation. + */ + Implementation* getImplementation() {return implementation;} + + /** + * Add a new property to this component. Properties are + * added one at a time. The property definitions come from the component + * type file. + * @param name The name of the property. + * @param type The full name of the type (including uri and local name). + * @param many True if this is a many valued property. + * @param required True if this property must have a value set. + * @param defaultValue The default value if the property does not have a + * value set. + */ + void addProperty(const string& name, + const string& type, + bool many, + bool required, + const char* defaultValue = 0); + + /** + * Add the property values to the properties defined on this + * component. The values will come from the sca.module file. + * @param properties A data object representing all the values set + * for this component. + */ + void addProperties(DataObjectPtr properties); + + /** + * Returns a data object from which all the properties and their + * values can be accessed. + * @return A data object holding the property values. + */ + DataObjectPtr getProperties(); + private: + /** + * Name of the component. + */ + string name; + + /** + * Module containing this component for navigating up the tree. + */ + Module* containingModule; + + /** + * Information about the implementation of this component. + */ + Implementation* implementation; + + typedef std::map<std::string, Service*> SERVICE_MAP; + /** + * Map of all the services defined on this component. + */ + SERVICE_MAP services; + + typedef std::map<std::string, ServiceReference*> REFERENCE_MAP; + /** + * Map of all the references defined on this component. + */ + REFERENCE_MAP references; + + /** + * SDO data factory which has all the property types defined from + * the component type file + */ + DataFactoryPtr propertyFactory; + + /** + * Return the SDO data factory which has the property types defined + * in it. + * @return The data factory. + */ + DataFactoryPtr getPropertyDataFactory(); + + /** + * The properties and their values for this component. + */ + DataObjectPtr properties; + + }; + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_component_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/EntryPoint.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/EntryPoint.cpp new file mode 100644 index 0000000000..1c38e31469 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/EntryPoint.cpp @@ -0,0 +1,101 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/EntryPoint.h" +#include "tuscany/sca/util/Exceptions.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + EntryPoint::EntryPoint(const std::string& epName) + : name(epName) + { + LOGENTRY(1, "EntryPoint::constructor"); + LOGINFO_1(2, "EntryPoint::constructor: EntryPoint name: %s", name.c_str()); + LOGEXIT(1, "EntryPoint::constructor"); + } + + EntryPoint::~EntryPoint() + { + } + + void EntryPoint::addTarget(WireTarget* targ) + { + if (multiplicity == ONE_ONE || multiplicity == ZERO_ONE) + { + if (targets.size() > 0) + { + // throw exception + string message = "Duplicate wire for reference: " + name; + throw SystemConfigurationException(message.c_str()); + } + } + + // TODO - must be remotable + + targets.push_back(targ); + } + + void EntryPoint::setMultiplicity(const std::string& multip) + { + if (multip == "0..1") + { + multiplicity = ZERO_ONE; + } + else if (multip == "1..1") + { + multiplicity = ONE_ONE; + } + else if (multip == "0..n") + { + multiplicity = ZERO_MANY; + } + else if (multip == "1..n") + { + multiplicity = ONE_MANY; + } + else + { + string msg = "Invalid multiplicity specified, " + multip + ", for reference: " +name; + throw SystemConfigurationException(msg.c_str()); + } + } + + void EntryPoint::setInterface(Interface* interf) + { + iface = interf; + } + + void EntryPoint::setBinding(Binding* bind) + { + binding = bind; + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/EntryPoint.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/EntryPoint.h new file mode 100644 index 0000000000..9b80a1049f --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/EntryPoint.h @@ -0,0 +1,158 @@ +/* + * + * 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_model_entrypoint_h +#define tuscany_sca_model_entrypoint_h + +#include <string> +using std::string; +#include <vector> +using std::vector; + +#include "tuscany/sca/model/Interface.h" +#include "tuscany/sca/model/Binding.h" +#include "tuscany/sca/model/WireTarget.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Represents the information about an entry point. + */ + class EntryPoint + { + + public: + /** + * Constructor. + * @param name The name of the entry point. + */ + EntryPoint(const std::string& name); + + /** + * Destructor. + */ + virtual ~EntryPoint(); + + /** + * Return the name of the entry point. + * @return The name of the entry point. + */ + const string& getName() {return name;} + + /** + * How many wires can be wired from this entry point. + */ + enum Multiplicity + { + ZERO_ONE, + ONE_ONE, + ZERO_MANY, + ONE_MANY + }; + + /** + * Set the multiplicity of this entry point. + * @param multiplicity One of 0..1, 1..1, 0..n, 1..n + */ + void setMultiplicity(const std::string& multiplicity); + + /** + * Return the multiplicity of this entry point (how + * many wires can be wired from this entry point). + * @return The multiplicity. + */ + Multiplicity getMultiplicity() {return multiplicity;} + + /** + * Set the interface describing this entry point. + * @param iface The interface. + */ + void setInterface(Interface* iface); + + /** + * Get the interface describing this entry point. Use + * Interface#getType to find out the type of interface + * describing this entry point. + * @return iface The interface. + */ + Interface* getInterface() {return iface;} + + /** + * Set the binding connecting this entry point. + * @param binding The Binding. + */ + void setBinding(Binding* binding); + + /** + * Get the binding connecting this entry point. Use + * Binding#getType to find out the type of binding + * connecting this entry point. + * @return binding The binding. + */ + Binding* getBinding() {return binding;} + + /** + * Add a target to the entry point. + * @param target Add a target (derived from a wire) to + * the entry point. + */ + void addTarget(WireTarget* target); + typedef vector<WireTarget*> TARGETS; + + /** + * Get a vector of targets added to this entry point. + */ + const TARGETS& getTargets() {return targets;} + private: + /** + * Name of the entry point. + */ + string name; + + /** + * The interface describing this entry point. + */ + Interface* iface; + + /** + * The binding connecting this entry point. + */ + Binding* binding; + + /** + * The multiplicity of this entry point.. + */ + Multiplicity multiplicity; + + /** + * The vector of targets added to this entry point. + */ + TARGETS targets; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_entrypoint_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ExternalService.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ExternalService.cpp new file mode 100644 index 0000000000..c848c3aafb --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ExternalService.cpp @@ -0,0 +1,55 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/ExternalService.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + ExternalService::ExternalService(const std::string& serviceName, Module *module) + : WireTarget(serviceName), containingModule(module) + { + LOGENTRY(1, "ExternalService::constructor"); + LOGINFO_1(2, "ExternalService::constructor: ExternalService name: %s", getName().c_str()); + LOGEXIT(1, "ExternalService::constructor"); + } + + ExternalService::~ExternalService() + { + delete binding; + } + + void ExternalService::setBinding(Binding* bind) + { + binding = bind; + } + + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ExternalService.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ExternalService.h new file mode 100644 index 0000000000..fe9640d1b8 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ExternalService.h @@ -0,0 +1,97 @@ +/* + * + * 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_model_externalservice_h +#define tuscany_sca_model_externalservice_h + +#include <string> + +#include "tuscany/sca/model/WireTarget.h" +#include "tuscany/sca/model/Binding.h" + +namespace tuscany +{ + namespace sca + { + + namespace model + { + class Module; + + /** + * Information about an external service. + */ + class ExternalService : public WireTarget + { + public: + /** + * Constructor. + * @param name The name of the external service. + * @param module The module containing this external service. + */ + ExternalService(const std::string& name, Module *module); + + /** + * Destructor. + */ + virtual ~ExternalService(); + + /** + * Return the type of service. + * @return Always returns ExternalServiceType + */ + virtual Type getServiceType() {return ExternalServiceType;} + + /** + * Set the binding for this external service. + * @param binding The binding to set. + */ + virtual void setBinding(Binding* binding); + + /** + * Get the binding set for this external service. + * @return The binding. + */ + virtual Binding* getBinding() {return binding;}; + + /** + * Get the module containing this external service. + * @return The containing module. + */ + Module* getContainingModule() {return containingModule;}; + + private: + /** + * The binding for this external service. + */ + Binding* binding; + + /** + * The module containing this external service. + */ + Module* containingModule; + + + }; + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_externalservice_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Implementation.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Implementation.cpp new file mode 100644 index 0000000000..9703d1bab3 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Implementation.cpp @@ -0,0 +1,44 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/Implementation.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + Implementation::Implementation() + { + } + + Implementation::~Implementation() + { + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Implementation.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Implementation.h new file mode 100644 index 0000000000..17414c359b --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Implementation.h @@ -0,0 +1,66 @@ +/* + * + * 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_model_implementation_h +#define tuscany_sca_model_implementation_h + +#include <string> + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Abstract class representing information about an implementation + * of a component. The subtypes will hold information specific to + * the type of implementation. + */ + class Implementation + { + + public: + /** + * Supported types of implementation. + */ + enum Type + { + CPP, + JAVA + }; + + Implementation(); + virtual ~Implementation(); + + /** + * Return the type of the implementation. + * @return Will depend on the subtype. + */ + virtual Type getImplementationType() = 0; + + private: + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_implementation_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Interface.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Interface.cpp new file mode 100644 index 0000000000..9e0aa45889 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Interface.cpp @@ -0,0 +1,44 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/Interface.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + Interface::Interface() + { + } + + Interface::~Interface() + { + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Interface.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Interface.h new file mode 100644 index 0000000000..24bb43224b --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Interface.h @@ -0,0 +1,65 @@ +/* + * + * 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_model_interface_h +#define tuscany_sca_model_interface_h + +#include <string> + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Information about an interface. Subtypes will hold information + * specific to a type of interface. + */ + class Interface + { + + public: + /** + * The supported types of interface. + */ + enum Type + { + CPP, + JAVA + }; + + Interface(); + virtual ~Interface(); + + /** + * Returns the type of the interface. + * @return Will depend on the subtype. + */ + virtual Type getInterfaceType() = 0; + + private: + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_interface_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp new file mode 100644 index 0000000000..32a3ad8d26 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp @@ -0,0 +1,1702 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "osoa/sca/export.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/Exceptions.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/ModelLoader.h" +#include "tuscany/sca/model/CPPImplementation.h" +#include "tuscany/sca/model/CPPInterface.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/model/WSBinding.h" +#include "commonj/sdo/TypeDefinitions.h" + + +using namespace commonj::sdo; + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + // =========== + // Constructor + // =========== + ModelLoader::ModelLoader(System* system) : system(system) + { + LOGENTRY(1, "ModelLoader::constructor"); + + + LOGEXIT(1, "ModelLoader::constructor"); + } + + // ========== + // Destructor + // ========== + ModelLoader::~ModelLoader() + { + } + + // ========================================================= + // load: Load the runtime model from the deployed xml files + // This class has the responsibility for translating from + // the SCA scdl files to the SCA runtime's in memory model. + // ========================================================= + void ModelLoader::load(const string& configurationRoot) + { + LOGENTRY(1, "ModelLoader::load"); + LOGINFO_1(2,"configuration root: %s", configurationRoot.c_str()); + + // The configuration root path will point to a directory structure: + // root/ + // The sca.subsystem files can be located anywhere under this directory + // structure. + loadSubsystems(configurationRoot); + + // sca.module files represent the root of a module, and can occur anywhere + // under the directory structure + loadModules(configurationRoot); + + system->resolveWires(); + LOGEXIT(1, "ModelLoader::load"); + } + + // ======================================================================== + // loadSubsystems: + // Load all the subsystems from any directory below the configuration root. + // Translate the subsystem information to the runtime information + // ======================================================================== + void ModelLoader::loadSubsystems(const string& configurationRoot) + { + // Get all the sca.subsystem files in the module + LOGENTRY(1, "ModelLoader::loadSubsystems"); + Files files(configurationRoot, "sca.subsystem", true); + for (unsigned int i=0; i < files.size(); i++) + { + loadSubsystemFile(files[i]); + } + LOGEXIT(1, "ModelLoader::loadSubsystems"); + } + + + // ===================================================================== + // loadSubsystemFile: + // This method is called for each sca.subsystem file found in the module + // folder structure + // ===================================================================== + void ModelLoader::loadSubsystemFile(const File& file) + { + LOGENTRY(1, "ModelLoader::loadSubsystemFile"); + LOGINFO_1(2, "subsystem filename: %s", file.getFileName().c_str()); + + try + { + string filename = file.getDirectory() + "/" + file.getFileName(); + XMLDocumentPtr subsystemFile = getXMLHelper()->loadFile(filename.c_str()); + if (subsystemFile->getRootDataObject() == 0) + { + LOGERROR_1(0, "ModelLoader::loadSubsystemFile: Unable to load file: %s", filename.c_str()); + } + else + { + //Utils::printDO(subsystemFile->getRootDataObject()); + mapSubsystem(subsystemFile->getRootDataObject()); + } + } catch (SDORuntimeException ex) + { + LOGERROR_1(0, "ModelLoader::loadSubsytemFile: Exception caught: %s", ex.getMessageText()); + } + + LOGEXIT(1, "ModelLoader::loadSubsystemFile"); + } + + // =============== + // mapSubsystem: + // =============== + void ModelLoader::mapSubsystem(DataObjectPtr root) + { + LOGENTRY(1, "ModelLoader::mapSubsystem"); + + LOGINFO_1(2, "ModelLoader::mapSubsystem: Loaded subsystem: %s", root->getCString("name")); + + Subsystem* subsystem; + subsystem = system->addSubsystem(root->getCString("name")); + + DataObjectList& Modules = root->getList("moduleComponent"); + LOGINFO_1(2, "ModelLoader::mapSubsystem: number of module components: %d", Modules.size()); + + // Iterate over module components + for (int i=0; i<Modules.size(); i++) + { + // Add each module component to the subsystem + Module* Module; + Module = subsystem->addModuleComponent(Modules[i]->getCString("name"), Modules[i]->getCString("module")); + } + + + /// @todo Add external services and entry points + + + LOGEXIT(1, "ModelLoader::mapSubsystem"); + } + + + // ===================================================================== + // loadModules: + // Load all the modules from any directory below the configuration root. + // Translate the module information to the runtime information + // ===================================================================== + void ModelLoader::loadModules(const string& configurationRoot) + { + // Get all the sca.module files in the module + LOGENTRY(1, "ModelLoader::loadModules"); + Files files(configurationRoot, "sca.module", true); + for (unsigned int i=0; i < files.size(); i++) + { + loadModuleFile(files[i]); + } + LOGEXIT(1, "ModelLoader::loadModules"); + } + + + // ==================================================================== + // loadModuleFile: + // This method is called for each sca.module file found in the module + // folder structure + // The location of this module file will indicate the root of a module + // ==================================================================== + void ModelLoader::loadModuleFile(const File& file) + { + LOGENTRY(1, "ModelLoader::loadModuleFile"); + LOGINFO_1(2, "module filename: %s", file.getFileName().c_str()); + + try + { + string filename = file.getDirectory() + "/" + file.getFileName(); + + XMLDocumentPtr moduleFile = getXMLHelper()->loadFile(filename.c_str()); + if (moduleFile->getRootDataObject() == 0) + { + LOGERROR_1(0, "ModelLoader::loadModuleFile: Unable to load file: %s", filename.c_str()); + } + else + { + string moduleName = moduleFile->getRootDataObject()->getCString("name"); + mapModule(moduleName, moduleFile->getRootDataObject(), file.getDirectory()); + + // -------------------------------------------------------------- + // Load any module Fragments in the same folder as the sca.module + // -------------------------------------------------------------- + Files files(file.getDirectory(), "*.fragment", false); + for (unsigned int i=0; i < files.size(); i++) + { + filename = file.getDirectory() + "/" + files[i].getFileName(); + moduleFile = getXMLHelper()->loadFile(filename.c_str()); + if (moduleFile->getRootDataObject() == 0) + { + LOGERROR_1(0, "ModelLoader::loadModuleFile: Unable to load file: %s", filename.c_str()); + } + else + { + mapModule(moduleName, moduleFile->getRootDataObject(), file.getDirectory()); + } + } + + // Load the xsd types and wsdl files in the module + loadModuleConfig(file.getDirectory(), moduleName); + } + + } catch (SDORuntimeException ex) + { + LOGERROR_1(0, "ModelLoader::loadModuleFile: Exception caught: %s", ex.getMessageText()); + } + + LOGEXIT(1, "ModelLoader::loadModuleFile"); + } + + // =========== + // mapModule + // =========== + void ModelLoader::mapModule(const string& moduleName, DataObjectPtr root, string moduleRootDir) + { + LOGENTRY(1, "ModelLoader::mapModule"); + + LOGINFO_2(2, "ModelLoader::mapModule: Loading module: %s, root Dir: %s", moduleName.c_str(), moduleRootDir.c_str()); + + // Find the ModuleComponent(s) that refer to this module. If a ModuleComponent does not refer to this + // module then ignore it + MODULE_LIST moduleList = system->findModules(moduleName); + MODULE_LIST::iterator moduleIter; + + for (moduleIter = moduleList.begin(); + moduleIter != moduleList.end(); + moduleIter++ ) + { + LOGINFO_1(2, "ModelLoader::mapModule: Loading module details for module component: %s", (*moduleIter)->getName().c_str()); + + string message; // for exceptions + // Set module root + (*moduleIter)->setRoot(moduleRootDir); + + // ---------------------------- + // Add components to the module + // ---------------------------- + DataObjectList& componentList = root->getList("component"); + int i; + for (i=0; i < componentList.size(); i++) + { + addComponent(*moduleIter, componentList[i]); + } + + // ------------ + // Entry points + // ------------ + DataObjectList& entryPointList = root->getList("entryPoint"); + for (i=0; i < entryPointList.size(); i++) + { + addEntryPoint(*moduleIter, entryPointList[i]); + } + + + // ----------------- + // External services + // ----------------- + DataObjectList& externalServiceList = root->getList("externalService"); + for (i=0; i < externalServiceList.size(); i++) + { + addExternalService(*moduleIter, externalServiceList[i]); + } + + // ----- + // Wires + // ----- + DataObjectList& wireList = root->getList("wire"); + for (int l=0; l < wireList.size(); l++) + { + string source = wireList[l]->getCString("sourceUri"); + string target = wireList[l]->getCString("targetUri"); + (*moduleIter)->addWire(source, target); + } + + } + + LOGEXIT(1, "ModelLoader::mapModule"); + } + + // ================================= + // addComponent: + // ================================= + void ModelLoader::addComponent(Module* module, DataObjectPtr componentDO) + { + Component* component = module->addComponent(componentDO->getCString("name")); + + string message; + + // ------------------- + // Implementation type + // ------------------- + DataObjectPtr impl = componentDO->getDataObject("implementation"); + if (!impl) + { + message = "No implementation for component: "; + message = message + componentDO->getCString("name"); + throw SystemConfigurationException(message.c_str()); + } + // Determine the type + string componentTypeName; + string componentTypePath; + string implType = impl->getType().getName(); + if (implType == "CPPImplementation") + { + string dll = impl->getCString("dll"); + string header = impl->getCString("header"); + string className = impl->getCString("class"); + CPPImplementation* cppImpl = new CPPImplementation(dll, header, className); + componentTypePath = cppImpl->getHeaderPath(); + componentTypeName = cppImpl->getHeaderStub(); + component->setImplementation(cppImpl); + + } + else if (implType == "JavaImplementation") + { + } + + // ----------------------- + // Load the .componentType + // ----------------------- + string typeFileName = module->getRoot() + "/" + componentTypePath + componentTypeName + ".componentType"; + try + { + XMLDocumentPtr componentTypeFile = getXMLHelper()->loadFile(typeFileName.c_str()); + if (componentTypeFile->getRootDataObject() == 0) + { + LOGERROR_1(0, "ModelLoader::mapModule: Unable to load file: %s", typeFileName.c_str()); + } + else + { + //Utils::printDO(componentTypeFile->getRootDataObject()); + //commonj::sdo::SDOUtils::printDataObject(componentTypeFile->getRootDataObject()); + addServices(component, componentTypeFile->getRootDataObject()); + addReferences(component, componentTypeFile->getRootDataObject()); + addProperties(component, componentTypeFile->getRootDataObject()); + } + } catch (SDORuntimeException& ex) + { + LOGERROR_1(0, "ModelLoader::mapModule: Exception caught: %s", ex.getMessageText()); + throw SystemConfigurationException(ex.getMessageText()); + } + + // ---------- + // Properties + // ---------- + DataObjectPtr props = componentDO->getDataObject("properties"); + component->addProperties(props); + + // ---------- + // References + // ---------- + DataObjectPtr refs = componentDO->getDataObject("references"); + if (refs) + { + PropertyList pl = refs->getInstanceProperties(); + for (int refI=0; refI < pl.size(); refI++) + { + // ---------------------------------------------------------- + // Add the reference to the module wires to be resolved later + // ---------------------------------------------------------- + string refName = pl[refI].getName(); + if (!component->findReference(pl[refI].getName())) + { + // Configuration error: reference is not defined + message = "Undefined reference: " + refName; + throw SystemConfigurationException(message.c_str()); + } + + string src = component->getName() + "/" + refName; + + // The reflist below is a list of open data objects + DataObjectList& reflist = refs->getList(pl[refI]); + for (int refslistI=0; refslistI<reflist.size(); refslistI++) + { + // Get the reference value + string refValue = reflist.getDataObject(refslistI)->getSequence()->getCStringValue(0); + module->addWire(src, refValue); + } + } + } + } + + + // ===================================================================== + // addServices: add the services from the componentType to the component + // ===================================================================== + void ModelLoader::addServices(Component* component, DataObjectPtr componentType) + { + DataObjectList& services = componentType->getList("service"); + for (int i=0; i<services.size(); i++) + { + Service* service = component->addService(services[i]->getCString("name")); + service->setInterface(getInterface(services[i])); + } + } + + // =================================================== + // addReferences: add the references to the component + // =================================================== + void ModelLoader::addReferences(Component* component, DataObjectPtr componentType) + { + DataObjectList& refs = componentType->getList("reference"); + for (int i=0; i<refs.size(); i++) + { + ServiceReference* serviceRef = component->addReference(refs[i]->getCString("name")); + string multiplicity = "1..1"; + if (refs[i]->isSet("multiplicity")) + { + multiplicity = refs[i]->getCString("multiplicity"); + } + serviceRef->setMultiplicity(multiplicity); + serviceRef->setInterface(getInterface(refs[i])); + } + } + + + // ============== + // getInterface + // ============== + Interface* ModelLoader::getInterface(DataObjectPtr obj) + { + // ----------------- + // get the interface + // ----------------- + DataObjectPtr iface = obj->getDataObject("interface"); + if (!iface) + { + string message = "No interface for: "; + message = message + obj->getCString("name"); + throw SystemConfigurationException(message.c_str()); + } + + // Determine the type + string componentTypeName; + string ifType = iface->getType().getName(); + if (ifType == "CPPInterface") + { + string header = iface->getCString("header"); + string className = iface->getCString("class"); + string scope = iface->getCString("scope"); + bool remotable = iface->getBoolean("remotable"); + + return new CPPInterface(header, className, scope, remotable); + } + else + { + // Error? + return 0; + } + } + + // ============================================== + // addProperties: add Properties to the component + // ============================================== + void ModelLoader::addProperties(Component* component, DataObjectPtr componentType) + { + DataObjectList& props = componentType->getList("property"); + for (int i=0; i<props.size(); i++) + { + string name = props[i]->getCString("name"); + string type = props[i]->getCString("type"); + bool many=false; + if (props[i]->isSet("many")) + { + many = props[i]->getBoolean("many"); + } + + bool required=false; + if (props[i]->isSet("required")) + { + many = props[i]->getBoolean("required"); + } + + const char* defaultValue = 0; + if (props[i]->isSet("default")) + { + defaultValue = props[i]->getCString("default"); + } + + component->addProperty(name, type, many, required, defaultValue); + } + } + + // =============================================== + // addEntryPoint: add an EntryPoint to the module + // =============================================== + void ModelLoader::addEntryPoint(Module* module, DataObjectPtr entryPointDO) + { + string message; + + //Utils::printDO(entryPointDO); + EntryPoint* entryPoint = module->addEntryPoint(entryPointDO->getCString("name")); + + string multiplicity = "1..1"; + if (entryPointDO->isSet("multiplicity")) + { + multiplicity = entryPointDO->getCString("multiplicity"); + } + + entryPoint->setMultiplicity(multiplicity); + entryPoint->setInterface(getInterface(entryPointDO)); + + DataObjectList& refs = entryPointDO->getList("reference"); + for (int i=0; i<refs.size(); i++) + { + // ---------------------------------------------------------- + // Add the reference to the module wires to be resolved later + // ---------------------------------------------------------- + string targ = refs.getCString(i); + module->addWire(entryPoint->getName(), targ); + } + + // Get binding, it will be the first and only binding + DataObjectPtr binding = entryPointDO->getList("binding")[0]; + if (!binding) + { + message = "No binding for entryPoint: "; + message = message + entryPointDO->getCString("name"); + throw SystemConfigurationException(message.c_str()); + } + + // Utils::printDO(binding); + + string uri = binding->getCString("uri"); + + // Determine the binding type + string bindingType = binding->getType().getName(); + if (bindingType == "WebServiceBinding") + { + string port = binding->getCString("port"); + + WSBinding* wsBinding = new WSBinding(uri,port); + + entryPoint->setBinding(wsBinding); + + } + else if (bindingType == "SCABinding") + { + message = "SCA binding not yet implemented. Binding is for entryPoint: "; + message = message + entryPointDO->getCString("name"); + throw SystemConfigurationException(message.c_str()); + } + } + + + // ========================================================= + // addExternalService: add an ExternalService to the module + // ========================================================= + void ModelLoader::addExternalService(Module* module, DataObjectPtr externalServiceDO) + { + string message; + + ExternalService* externalService = module->addExternalService(externalServiceDO->getCString("name")); + // Add the interface + externalService->setInterface(getInterface(externalServiceDO)); + + // Get binding, it will be the first and only binding + DataObjectPtr binding = externalServiceDO->getList("binding")[0]; + if (!binding) + { + message = "No binding for externalService: "; + message = message + externalServiceDO->getCString("name"); + throw SystemConfigurationException(message.c_str()); + } + + //Utils::printDO(binding); + + string uri = binding->getCString("uri"); + + // Determine the binding type + string bindingType = binding->getType().getName(); + if (bindingType == "WebServiceBinding") + { + string port = binding->getCString("port"); + + WSBinding* wsBinding = new WSBinding(uri,port); + + externalService->setBinding(wsBinding); + + } + else if (bindingType == "SCABinding") + { + } + } + + + + /// + /// Use the Tuscany-model.config file in the module root directory to + /// determine which xsds and wsdls to load into a dataFactory. + /// + void ModelLoader::loadModuleConfig(const string &moduleRootDir, const string &moduleName) + { + LOGENTRY(1, "ModelLoader::loadModuleConfig"); + + // Load the "Tuscany-model.config" file, if it exists + Files files(moduleRootDir, "Tuscany-model.config", false); + for (unsigned int i=0; i < files.size(); i++) + { + string filename = moduleRootDir + "/" + files[i].getFileName(); + XMLDocumentPtr moduleConfigFile = getXMLHelper()->loadFile(filename.c_str()); + if (moduleConfigFile->getRootDataObject() == 0) + { + LOGERROR_1(0, "ModelLoader::loadModuleConfig: Unable to load file: %s", filename.c_str()); + } + else + { + LOGINFO_2(2, "ModelLoader::loadModuleConfig: Loading module config for: %s, root Dir: %s", moduleName.c_str(), moduleRootDir.c_str()); + + if(moduleConfigFile->getRootDataObject()->isSet("xsd")) + { + DataObjectList& xsds = moduleConfigFile->getRootDataObject()->getList("xsd/file"); + + for (int i=0; i<xsds.size(); i++) + { + if(xsds[i]->isSet("name")) + { + // Load a xsd file -> set the types in the moduleComponents data factory file + string xsdName = moduleRootDir + "/" +xsds[i]->getCString("name"); + loadTypes(xsdName.c_str(), moduleName); + } + } + } + + + if( moduleConfigFile->getRootDataObject()->isSet("wsdl")) + { + DataObjectList& wsdls = moduleConfigFile->getRootDataObject()->getList("wsdl/file"); + for (int j=0; j<wsdls.size(); j++) + { + if(wsdls[i]->isSet("name")) + { + string wsdlName = moduleRootDir + "/" +wsdls[j]->getCString("name"); + // Load a wsdl file -> get the types, then the contents of the wsdl + loadTypes(wsdlName.c_str(), moduleName); + + // Load the contents of the wsdl files + loadWsdl(wsdlName.c_str(), moduleName); + } + } + } + } + } + + + LOGEXIT(1, "ModelLoader::loadModuleConfig"); + } + + + /// + /// Use the types from an xsd or wsdl file + /// + void ModelLoader::loadTypes(const char *fileName, const string &moduleName) + { + LOGENTRY(1, "ModelLoader::loadTypes"); + + // Load a xsd file -> set the types in the moduleComponents data factory file + + MODULE_LIST moduleList = system->findModules(moduleName); + MODULE_LIST::iterator moduleIter; + + for (moduleIter = moduleList.begin(); + moduleIter != moduleList.end(); + moduleIter++ ) + { + try { + (*moduleIter)->getXSDHelper()->defineFile(fileName); + //Utils::printTypes((*moduleIter)->getXSDHelper()->getDataFactory()); + + } catch (SDOTypeNotFoundException ex) + { + LOGERROR_1(0, "ModuleLoader: Exception caught: %s", ex.getMessageText()); + throw ex; + } + } + LOGEXIT(1, "ModelLoader::loadTypes"); + } + + /// + /// Load the web services definition from a wsdl + /// + void ModelLoader::loadWsdl(const char *fileName, const string &moduleName) + { + LOGENTRY(1, "ModelLoader::loadWsdl"); + + try { + // Load the wsdl file + XMLDocumentPtr doc = getXMLHelper()->loadFile(fileName); + + if (doc!=0 && doc->getRootDataObject()!=0) + { + //Utils::printDO(doc->getRootDataObject()); + MODULE_LIST moduleList = system->findModules(moduleName); + MODULE_LIST::iterator moduleIter; + + for (moduleIter = moduleList.begin(); + moduleIter != moduleList.end(); + moduleIter++ ) + { + // Add the root object to the module + (*moduleIter)->addWsdl(doc->getRootDataObject()); + + } + + } + else + { + LOGERROR_1(0, "ModuleLoader: Unable to load or parse WSDL %s", fileName); + } + + } catch (SDOTypeNotFoundException ex) + { + LOGERROR_1(0, "ModelLoader: SDOTypeNotFoundException caught: %s", ex.getMessageText()); + throw ex; + } + catch (SDONullPointerException ex) + { + LOGERROR_1(0, "ModelLoader: SDONullPointerException caught: %s", ex.getMessageText()); + throw ex; + } + LOGEXIT(1, "ModelLoader::loadWsdl"); + + } + + ////////////////////////////////////////////////////////////////////////////// + // Methods used to load the model into memory + ////////////////////////////////////////////////////////////////////////////// + + /// + /// Get an XSDHelper that has the appropriate XSDs already loaded + /// + const XSDHelperPtr ModelLoader::getXSDHelper() + { + if (myXSDHelper == 0) + { + + // Create an xsd helper + myXSDHelper = HelperProvider::getXSDHelper(); + + // Now add to it some xsd files + try { + string root = SCARuntime::getInstance()->getInstallRoot(); + string filename = root + "/xsd/sca.xsd"; + + myXSDHelper->defineFile(filename.c_str()); + + // Tuscany specific xsd for config files + filename = root + "/xsd/tuscany.xsd"; + myXSDHelper->defineFile(filename.c_str()); + + loadWSDLTypes(myXSDHelper); + + } catch (SDOTypeNotFoundException ex) + { + LOGERROR_1(0, "ModuleLoader: Exception caught: %s", ex.getMessageText()); + throw ex; + } + } + + + return myXSDHelper; + } + + + /// + /// Get an XMLHelper to load files + /// + const XMLHelperPtr ModelLoader::getXMLHelper() + { + if (myXMLHelper == 0) { + + // Create an xml helper + myXMLHelper = HelperProvider::getXMLHelper(getXSDHelper()->getDataFactory()); + + } + + return myXMLHelper; + } + + void ModelLoader::loadWSDLTypes(XSDHelperPtr xsdHelper) + { + DataFactoryPtr dataFactory = xsdHelper->getDataFactory(); + + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tBinding", + false, true, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationFault", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationMessage", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tDocumentation", + true, true, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tDocumented", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement", + false, false, true); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented", + false, true, true); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented", + false, true, true); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tFault", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tImport", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tMessage", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tOperation", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tParam", + false, false, false); + + + TypeDefinition tpart; + tpart.setUri("http://schemas.xmlsoap.org/wsdl/"); + tpart.setName("tPart"); + tpart.setParentType("http://schemas.xmlsoap.org/wsdl/", + "tExtensibleAttributesDocumented", false); + PropertyDefinition propdef; + propdef.setName("name"); + propdef.setLocalName("name"); + propdef.setType("commonj.sdo", "String"); + propdef.setIsContainment(true); + tpart.addPropertyDefinition(propdef); + propdef.setName("element"); + propdef.setLocalName("element"); + propdef.setIsQName(true); + tpart.addPropertyDefinition(propdef); + propdef.setName("type"); + propdef.setLocalName("type"); + tpart.addPropertyDefinition(propdef); + TypeDefinitions typedefs; + typedefs.addTypeDefinition(tpart); + xsdHelper->defineTypes(typedefs); + + //Utils::printTypes(dataFactory); + /*dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tPart", + false, false, false);*/ + + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tPort", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tPortType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tService", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/", "tTypes", + false, false, false); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "definitions", + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "import", + "http://schemas.xmlsoap.org/wsdl/", "tImport", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "types", + "http://schemas.xmlsoap.org/wsdl/", "tTypes", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "message", + "http://schemas.xmlsoap.org/wsdl/", "tMessage", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "portType", + "http://schemas.xmlsoap.org/wsdl/", "tPortType", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "binding", + "http://schemas.xmlsoap.org/wsdl/", "tBinding", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "service", + "http://schemas.xmlsoap.org/wsdl/", "tService", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "input", + "http://schemas.xmlsoap.org/wsdl/", "tParam", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "output", + "http://schemas.xmlsoap.org/wsdl/", "tParam", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "fault", + "http://schemas.xmlsoap.org/wsdl/", "tFault", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "output", + "http://schemas.xmlsoap.org/wsdl/", "tParam", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "input", + "http://schemas.xmlsoap.org/wsdl/", "tParam", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "fault", + "http://schemas.xmlsoap.org/wsdl/", "tFault", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "arrayType", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "RootType", + "required", + "commonj.sdo", "Boolean", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tBinding", + "operation", + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tBinding", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tBinding", + "type", + "commonj.sdo", "URI", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation", + "input", + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationMessage", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation", + "output", + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationMessage", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation", + "fault", + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationFault", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperation", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationFault", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationFault", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationMessage", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tBindingOperationMessage", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + "import", + "http://schemas.xmlsoap.org/wsdl/", "tImport", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + "types", + "http://schemas.xmlsoap.org/wsdl/", "tTypes", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + "message", + "http://schemas.xmlsoap.org/wsdl/", "tMessage", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + "portType", + "http://schemas.xmlsoap.org/wsdl/", "tPortType", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + "binding", + "http://schemas.xmlsoap.org/wsdl/", "tBinding", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + "service", + "http://schemas.xmlsoap.org/wsdl/", "tService", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + "targetNamespace", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tDefinitions", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tDocumented", + "documentation", + "http://schemas.xmlsoap.org/wsdl/", "tDocumentation", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement", + "required", + "commonj.sdo", "Boolean", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented", + "http://schemas.xmlsoap.org/wsdl/", "tDocumented"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented", + "http://schemas.xmlsoap.org/wsdl/", "tDocumented"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tFault", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tFault", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tFault", + "message", + "commonj.sdo", "URI", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tImport", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tImport", + "namespace", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tImport", + "location", + "commonj.sdo", "URI", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tMessage", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tMessage", + "part", + "http://schemas.xmlsoap.org/wsdl/", "tPart", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tMessage", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tOperation", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tOperation", + "input", + "http://schemas.xmlsoap.org/wsdl/", "tParam", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tOperation", + "output", + "http://schemas.xmlsoap.org/wsdl/", "tParam", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tOperation", + "fault", + "http://schemas.xmlsoap.org/wsdl/", "tFault", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tOperation", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tOperation", + "parameterOrder", + "commonj.sdo", "String", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tParam", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tParam", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tParam", + "message", + "commonj.sdo", "URI", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tPart", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented"); + /*dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tPart", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tPart", + "element", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tPart", + "type", + "commonj.sdo", "URI", + false, false, true);*/ + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tPort", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tPort", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tPort", + "binding", + "commonj.sdo", "URI", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tPortType", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleAttributesDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tPortType", + "operation", + "http://schemas.xmlsoap.org/wsdl/", "tOperation", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tPortType", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tService", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tService", + "port", + "http://schemas.xmlsoap.org/wsdl/", "tPort", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/", "tService", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/", "tTypes", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibleDocumented"); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tAddress", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tBinding", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tBody", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tFault", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes", + false, false, true); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tOperation", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tStyleChoice", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice", + false, false, false); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "binding", + "http://schemas.xmlsoap.org/wsdl/soap/", "tBinding", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "operation", + "http://schemas.xmlsoap.org/wsdl/soap/", "tOperation", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "body", + "http://schemas.xmlsoap.org/wsdl/soap/", "tBody", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "encodingStyle", + "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "use", + "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "namespace", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "fault", + "http://schemas.xmlsoap.org/wsdl/soap/", "tFault", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "header", + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "message", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "part", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "use", + "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "encodingStyle", + "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "namespace", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "headerfault", + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "RootType", + "address", + "http://schemas.xmlsoap.org/wsdl/soap/", "tAddress", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tAddress", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tAddress", + "location", + "commonj.sdo", "URI", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tBinding", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tBinding", + "transport", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tBinding", + "style", + "http://schemas.xmlsoap.org/wsdl/soap/", "tStyleChoice", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tBody", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tBody", + "parts", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tBody", + "encodingStyle", + "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tBody", + "use", + "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tBody", + "namespace", + "commonj.sdo", "URI", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tFault", + "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tFault", + "name", + "commonj.sdo", "String", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes", + "http://schemas.xmlsoap.org/wsdl/soap/", "tBody"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes", + "required", + "commonj.sdo", "Boolean", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes", + "parts", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes", + "encodingStyle", + "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes", + "use", + "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tFaultRes", + "namespace", + "commonj.sdo", "URI", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader", + "headerfault", + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault", + true, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader", + "message", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader", + "part", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader", + "use", + "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader", + "encodingStyle", + "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeader", + "namespace", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault", + "message", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault", + "part", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault", + "use", + "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault", + "encodingStyle", + "http://schemas.xmlsoap.org/wsdl/soap/", "encodingStyle", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tHeaderFault", + "namespace", + "commonj.sdo", "URI", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tOperation", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tOperation", + "soapAction", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tOperation", + "style", + "http://schemas.xmlsoap.org/wsdl/soap/", "tStyleChoice", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap/", "tStyleChoice", + "commonj.sdo", "String"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap/", "useChoice", + "commonj.sdo", "String"); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/http/", "RootType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/http/", "addressType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/http/", "bindingType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/http/", "operationType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/http/", "urlEncoded", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/http/", "urlReplacement", + false, false, false); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/http/", "RootType", + "address", + "http://schemas.xmlsoap.org/wsdl/http/", "addressType", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/http/", "RootType", + "binding", + "http://schemas.xmlsoap.org/wsdl/http/", "bindingType", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/http/", "RootType", + "operation", + "http://schemas.xmlsoap.org/wsdl/http/", "operationType", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/http/", "RootType", + "urlEncoded", + "http://schemas.xmlsoap.org/wsdl/http/", "urlEncoded", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/http/", "RootType", + "urlReplacement", + "http://schemas.xmlsoap.org/wsdl/http/", "urlReplacement", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/http/", "addressType", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/http/", "addressType", + "location", + "commonj.sdo", "URI", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/http/", "bindingType", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/http/", "bindingType", + "verb", + "commonj.sdo", "String", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/http/", "operationType", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/http/", "operationType", + "location", + "commonj.sdo", "URI", + false, false, true); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/mime/", "RootType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/mime/", "contentType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/mime/", "multipartRelatedType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/mime/", "tMimeXml", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/mime/", "tPart", + false, true, false); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/mime/", "RootType", + "content", + "http://schemas.xmlsoap.org/wsdl/mime/", "contentType", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/mime/", "RootType", + "multipartRelated", + "http://schemas.xmlsoap.org/wsdl/mime/", "multipartRelatedType", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/mime/", "RootType", + "mimeXml", + "http://schemas.xmlsoap.org/wsdl/mime/", "tMimeXml", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/mime/", "contentType", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/mime/", "contentType", + "type", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/mime/", "contentType", + "part", + "commonj.sdo", "String", + false, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/mime/", "multipartRelatedType", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/mime/", "multipartRelatedType", + "part", + "http://schemas.xmlsoap.org/wsdl/mime/", "tPart", + true, false, true); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/mime/", "tMimeXml", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/mime/", "tMimeXml", + "part", + "commonj.sdo", "String", + false, false, true); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/wsdl/mime/", "tPart", + "name", + "commonj.sdo", "String", + false, false, true); + + + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "RootType", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tAddress", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tBinding", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tBody", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs", + false, true, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tFault", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tFaultRes", + false, false, true); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tHeader", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tHeaderFault", + false, true, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tOperation", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tParts", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tStyleChoice", + false, false, false); + dataFactory->addType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "useChoice", + false, false, false); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tAddress", + "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tBinding", + "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tBody", + "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs", + "http://schemas.xmlsoap.org/wsdl/", "tExtensibilityElement"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tFault", + "http://schemas.xmlsoap.org/wsdl/soap12/", "tFaultRes"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tFaultRes", + "http://schemas.xmlsoap.org/wsdl/soap12/", "tBody"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tHeader", + "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tOperation", + "http://schemas.xmlsoap.org/wsdl/soap12/", "tExtensibilityElementOpenAttrs"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "tStyleChoice", + "commonj.sdo", "String"); + dataFactory->setBaseType( + "http://schemas.xmlsoap.org/wsdl/soap12/", "useChoice", + "commonj.sdo", "String"); + } + + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h new file mode 100644 index 0000000000..97478748e9 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h @@ -0,0 +1,105 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#ifndef tuscany_sca_model_modelloader_h +#define tuscany_sca_model_modelloader_h + +#include "osoa/sca/export.h" +#include "commonj/sdo/SDO.h" +using commonj::sdo::DataObjectPtr; +using commonj::sdo::DataFactoryPtr; +using commonj::sdo::XSDHelperPtr; + +#include "tuscany/sca/model/System.h" +#include "tuscany/sca/model/Subsystem.h" + +#include "tuscany/sca/util/File.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Provides methods to load the runtime model from the SCDL file. + */ + class ModelLoader { + public: + /** + * Constructor. + * @param system The SCA system to load. + */ + ModelLoader(System* system); + + /** + * Destructor. + */ + virtual ~ModelLoader(); + + /** + * Load the model from the configuration information. + * @param configurationRoot The location of the deployed SCA + * modules and subsystems. + */ + void load(const string& configurationRoot); + + private: + System* system; + void loadModule(const char *moduleRoot); + + + commonj::sdo::XMLHelperPtr myXMLHelper; // Used to load scdl files + commonj::sdo::XSDHelperPtr myXSDHelper; // Used to load xsds + const commonj::sdo::XSDHelperPtr getXSDHelper(void); + const commonj::sdo::XMLHelperPtr getXMLHelper(void); + + void loadSubsystems(const string& configurationRoot); + void loadSubsystemFile(const File& file); + void mapSubsystem(commonj::sdo::DataObjectPtr rootDO); + + void loadModules(const string& configurationRoot); + void loadModuleFile(const File& file); + void mapModule(const string& moduleName, commonj::sdo::DataObjectPtr rootDO, std::string moduleRootDir); + + void addComponent(Module* module, DataObjectPtr componentDO); + void addEntryPoint(Module* module, DataObjectPtr entryPointDO); + void addExternalService(Module* module, DataObjectPtr externalServiceDO); + + void addServices(Component* component, DataObjectPtr componentType); + void addReferences(Component* component, DataObjectPtr componentType); + void addProperties(Component* component, DataObjectPtr componentType); + + + void loadModuleConfig(const string &moduleRootDir, const string &moduleName); + void loadTypes(const char *fileName, const string &moduleName); + void loadWsdl(const char *fileName, const string &moduleName); + + void loadWSDLTypes(XSDHelperPtr xsdHelper); + + Interface* getInterface(DataObjectPtr obj); + + + }; + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_modelloader_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Module.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Module.cpp new file mode 100644 index 0000000000..fc8b6b1eb8 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Module.cpp @@ -0,0 +1,235 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/model/Module.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + Module::Module(const std::string& moduleName) + : name(moduleName) + { + LOGENTRY(1, "Module::constructor"); + LOGEXIT(1, "Module::constructor"); + } + + Module::~Module() + { + } + + void Module::setRoot(const std::string& rootDirectory) + { + moduleRoot = rootDirectory; + } + + + /// + /// Add a new component to the module component + /// + Component* Module::addComponent(const std::string& name) + { + LOGENTRY(1, "Module::addComponent"); + Component* newComponent = new Component(name, this); + components[name] = newComponent; + LOGEXIT(1, "Module::addComponent"); + return newComponent; + } + + Component* Module::findComponent(const std::string& name) + { + LOGENTRY(1, "Module::findComponent"); + Component* foundComponent = components[name]; + LOGEXIT(1, "Module::findComponent"); + return foundComponent; + } + + Service* Module::findComponentService(const std::string& name) + { + LOGENTRY(1, "Module::findComponentService"); + + Service* service = 0; + + string componentName; + string serviceName; + Utils::tokeniseUri(name, componentName, serviceName); + + // Locate the component + Component* foundComponent = components[componentName]; + if (foundComponent) + { + // Locate the service + service = foundComponent->findService(serviceName); + } + LOGEXIT(1, "Module::findComponentService"); + return service; + } + + ExternalService* Module::findExternalService(const std::string& name) + { + LOGENTRY(1, "Module::findExternalService"); + ExternalService* foundService = externalServices[name]; + LOGEXIT(1, "Module::findExternalService"); + return foundService; + } + + + EntryPoint* Module::addEntryPoint(const std::string& name) + { + LOGENTRY(1, "Module::addEntryPoint"); + EntryPoint* ep = new EntryPoint(name); + entryPoints[name] = ep; + LOGEXIT(1, "Module::addEntryPoint"); + return findEntryPoint(name); + } + + EntryPoint* Module::findEntryPoint(const std::string& name) + { + return entryPoints[name]; + } + + + ExternalService* Module::addExternalService(const std::string& name) + { + LOGENTRY(1, "Module::addExternalService"); + ExternalService* es = new ExternalService(name, this); + externalServices[name] = es; + LOGEXIT(1, "Module::addExternalService"); + return es; + } + + void Module::addWire(const std::string& source, const std::string& target) + { + LOGENTRY(1, "Module::addWire"); + wires.push_back(Wire(source, target)); + LOGEXIT(1, "Module::addWire"); + } + + + void Module::resolveWires() + { + LOGENTRY(1, "Module::resolveWires"); + for (WIRES::iterator iter = wires.begin(); + iter != wires.end(); + iter++) + { + // ----------------- + // Locate the target + // ----------------- + WireTarget* target = findComponentService(iter->getTarget()); + if (!target) + { + target = findExternalService(iter->getTarget()); + } + if (!target) + { + LOGERROR_1(0, "Module::resolveWires: Wire target %s not found", iter->getTarget().c_str()); + } + else + { + EntryPoint* entrypoint = findEntryPoint(iter->getSourceComponent()); + if (entrypoint) + { + entrypoint->addTarget(target); + } + else + { + Component* component = findComponent(iter->getSourceComponent()); + if (component) + { + ServiceReference* serviceReference = component->findReference(iter->getSourceReference()); + if (serviceReference) + { + serviceReference->addTarget(target); + } + else + { + LOGERROR_1(0, "Module::resolveWires: Wire source reference %s not found", iter->getSourceReference().c_str()); + } + } + else + { + LOGERROR_1(0, "Module::resolveWires: Wire source %s not found", iter->getSourceComponent().c_str()); + } + } + } + } + + LOGEXIT(1, "Module::resolveWires"); + } + + + + void Module::addWsdl(commonj::sdo::DataObjectPtr wsdlModel) + { + LOGENTRY(1, "Module::addWsdl"); + Wsdl* wsdl = new Wsdl(wsdlModel); + wsdls[wsdl->getNamespace()] = wsdl; + LOGEXIT(1, "Module::addWsdl"); + + } + + Wsdl* Module::findWsdl(const std::string& wsdlNamespace ) + { + return wsdls[wsdlNamespace]; + + } + + + // Get an XSDHelper - one will be created for each module + commonj::sdo::XSDHelperPtr Module::getXSDHelper() + { + if (xsdHelper == 0) + { + xsdHelper = commonj::sdo::HelperProvider::getXSDHelper(); + } + + return xsdHelper; + } + + // Get an XMLHelper - one will be created for each module + commonj::sdo::XMLHelperPtr Module::getXMLHelper() + { + if (xmlHelper == 0) + { + xmlHelper = commonj::sdo::HelperProvider::getXMLHelper(getXSDHelper()->getDataFactory()); + } + + return xmlHelper; + } + + + // Get a data factory - the one in the xsd/xml helper + commonj::sdo::DataFactoryPtr Module::getDataFactory() + { + return getXSDHelper()->getDataFactory(); + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Module.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Module.h new file mode 100644 index 0000000000..f73f1d36bc --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Module.h @@ -0,0 +1,235 @@ +/* + * + * 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_model_module_h +#define tuscany_sca_model_module_h + +#include <string> +using std::string; + +#include <map> +using std::map; +#include <vector> +using std::vector; + +#include "commonj/sdo/SDO.h" + + +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/ExternalService.h" +#include "tuscany/sca/model/EntryPoint.h" +#include "tuscany/sca/model/Wire.h" +#include "tuscany/sca/model/Wsdl.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + /** + * Information about a module. + */ + class Module + { + public: + /** + * Constructor. + * @param name the name of the module. + */ + Module(const std::string& name); + + /** + * Destructor. + */ + virtual ~Module(); + + /** + * Set the root directory of the module information. + * @param rootDirectory The root of the module in the file system. + */ + void setRoot(const std::string& rootDirectory); + + /** + * Get the root directory of the module. + * @return The root of the module in the file system. + */ + const std::string& getRoot() {return moduleRoot;} + + /** + * Return the name of the module. + * @return Name of the module. + */ + const std::string& getName() {return name;} + + /** + * Add a new component to the module. + * @param componentName The name of the new component. + * @return The Component added to the module. + */ + Component* addComponent(const std::string& componentName); + + /** + * Add a new entry point to the module. + * @param name The name of the new entry point. + * @return The entry point added to the module. + */ + EntryPoint* addEntryPoint(const std::string& name); + + /** + * Find an entry point by name. + * @param name The name of the entry point to be found. + * @return The entry point that was found, or 0 if not found. + */ + EntryPoint* findEntryPoint(const std::string& name); + + /** + * Add a new external service to the module. + * @param name The name of the new external service. + * @return The external service added to the module. + */ + ExternalService* addExternalService(const std::string& name); + + /** + * Add a wire to the model. + * @param source The source location. Either the source component and + * reference (optional), or an entry point. + * @param target The target location. Either the target component and + * service (optional), or an external service. + */ + void addWire(const std::string& source, const std::string& target); + + /** + * Find a component by name. + * @param componentName The name of the component to be found. + * @return The component that was found, or 0 if not found. + */ + Component* findComponent(const std::string& componentName); + + /** + * Find a component and service by name. + * @param componentServiceName A string of the form + * "componentName"/"serviceName" where the service name is optional + * if there is only one service on the component. + * @return The Service that was found, or 0 if not found. + */ + Service* findComponentService(const std::string& componentServiceName); + + /** + * Find an external service by name. + * @param serviceName The name of the external service to be found. + * @return The external service that was found, or 0 if not found. + */ + ExternalService* findExternalService(const std::string& serviceName); + + /** + * Add a WSDL definition to the module. + * @param wsdlModel A data object holding all the information about + * the WSDL definition from a WSDL file. + */ + void addWsdl(commonj::sdo::DataObjectPtr wsdlModel); + + /** + * Find a WSDL definition by target namespace. + * @param wsdlNamespace The namespace of the WSDL definitions to find. + */ + Wsdl* findWsdl(const std::string& wsdlNamespace); + + /** + * Return a cached SDO XSDHelper. + */ + commonj::sdo::XSDHelperPtr getXSDHelper(void); + + /** + * Return a cached SDO XMLHelper. + */ + commonj::sdo::XMLHelperPtr getXMLHelper(void); + + /** + * Return a data factory which has all the types defined in XSDs and + * WSDL files configured for this module. + * @return The data factory for this module. + */ + commonj::sdo::DataFactoryPtr getDataFactory(void); + + /** + * Work through the list of wires and connect the source and target uris. + */ + void resolveWires(); + + private: + /** + * Name of the module. + */ + string name; + + /** + * Directory of the root of the module. + */ + string moduleRoot; + + /** + * Cached XSDHelper. + */ + commonj::sdo::XSDHelperPtr xsdHelper; + + /** + * Cached XMLHelper. + */ + commonj::sdo::XMLHelperPtr xmlHelper; + + typedef map<std::string, Component*> COMPONENT_MAP; + /** + * Map (by name) of all the components in this module. + */ + COMPONENT_MAP components; + + typedef map<std::string, ExternalService*> EXTERNALSERVICE_MAP; + /** + * Map (by name) of all the external services in this module. + */ + EXTERNALSERVICE_MAP externalServices; + + typedef map<std::string, EntryPoint*> ENTRYPOINT_MAP; + /** + * Map (by name) of all the entry points in this module. + */ + ENTRYPOINT_MAP entryPoints; + + typedef vector<Wire> WIRES; + /** + * Vector of all the wires in this module. + */ + WIRES wires; + + typedef map<std::string, Wsdl*> WSDL_MAP; + /** + * Map by namespace of all the wsdl definitions in this module. + */ + WSDL_MAP wsdls; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // SCA_ModuleComponent_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Service.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Service.cpp new file mode 100644 index 0000000000..42ccecbc99 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Service.cpp @@ -0,0 +1,47 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/Service.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + + + // Constructor + Service::Service(const std::string& serviceName, Component* comp) + : WireTarget(serviceName), + component(comp) + { + LOGENTRY(1, "Service::constructor (Component)"); + LOGINFO_1(3, "Service::constructor: Service name: %s", serviceName.c_str()); + LOGEXIT(1, "Service::constructor"); + } + + Service::~Service() + { + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Service.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Service.h new file mode 100644 index 0000000000..6c37dabb3e --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Service.h @@ -0,0 +1,81 @@ +/* + * + * 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_model_service_h +#define tuscany_sca_model_service_h + +#include <string> +using std::string; + +#include "tuscany/sca/model/WireTarget.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + class Component; + + /** + * Information about a service defined on a component. + */ + class Service : public WireTarget + { + public: + /** + * Destructor. + */ + virtual ~Service(); + + /** + * Return the type of the wire target. + * @return Always returns ComponentServiceType. + */ + virtual Type getServiceType() {return ComponentServiceType;} + + /** + * Get the component on which this service is defined. + * @return The component on which this service is defined. + */ + Component* getComponent() {return component;} + + + private: + friend class Component; + /** + * Constructor. + * @param name The name of the service. + * @param component The component on which this service is defined. + */ + Service(const std::string& name, Component* component); + + /** + * The component on which this service is defined. + */ + Component* component; + + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_service_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ServiceReference.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ServiceReference.cpp new file mode 100644 index 0000000000..cada38dec2 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ServiceReference.cpp @@ -0,0 +1,89 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Exceptions.h" +#include "tuscany/sca/model/ServiceReference.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + + + // Constructor + ServiceReference::ServiceReference(const std::string& referenceName) + : name(referenceName), multiplicity(ONE_ONE) + { + } + + ServiceReference::~ServiceReference() + { + } + + void ServiceReference::addTarget(WireTarget* targ) + { + if (multiplicity == ONE_ONE || multiplicity == ZERO_ONE) + { + if (targets.size() > 0) + { + // throw exception + string message = "Duplicate wire for reference: " + name; + throw SystemConfigurationException(message.c_str()); + } + } + + targets.push_back(targ); + } + + void ServiceReference::setMultiplicity(const std::string& multip) + { + if (multip == "0..1") + { + multiplicity = ZERO_ONE; + } + else if (multip == "1..1") + { + multiplicity = ONE_ONE; + } + else if (multip == "0..n") + { + multiplicity = ZERO_MANY; + } + else if (multip == "1..n") + { + multiplicity = ONE_MANY; + } + else + { + string msg = "Invalid multiplicity specified, " + multip + ", for reference: " +name; + throw SystemConfigurationException(msg.c_str()); + } + } + + void ServiceReference::setInterface(Interface* interf) + { + iface = interf; + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ServiceReference.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ServiceReference.h new file mode 100644 index 0000000000..062d7a4c19 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/ServiceReference.h @@ -0,0 +1,136 @@ +/* + * + * 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_model_servicereference_h +#define tuscany_sca_model_servicereference_h + +#include <string> +using std::string; +#include <vector> +using std::vector; + +#include "tuscany/sca/model/Interface.h" +#include "tuscany/sca/model/WireTarget.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Information about a reference on a serivce. + */ + class ServiceReference + { + public: + /** + * Constructor. + * @param name The name of the reference. + */ + ServiceReference(const std::string& name) + + /** + * Destructor. + */; + virtual ~ServiceReference(); + + /** + * Get the name of the service. + * @return The name of the service. + */ + const std::string& getName() {return name;} + + /** + * Multiplicity (how many wires can be attached to this + * reference as their source) + */ + enum Multiplicity + { + ZERO_ONE, + ONE_ONE, + ZERO_MANY, + ONE_MANY + }; + + /** + * Set the multiplicity of this reference. + * @param multiplicity One of "0..1", "1..1", "0..n", "1..n" + */ + void setMultiplicity(const std::string& multiplicity); + + /** + * Get the multiplicity of this reference. + * @return The multiplicity. + */ + Multiplicity getMultiplicity() {return multiplicity;} + + /** + * Set the interface required by this reference. + * @param iface The interface. + */ + void setInterface(Interface* iface); + + /** + * Get the interface. + * @return The interface. + */ + Interface* getInterface() {return iface;} + + /** + * Add a target for a reference. There may be more than + * one if the multiplicity is 0..n or 1..n. + * @param target The target for a wire. + */ + void addTarget(WireTarget* target); + typedef vector<WireTarget*> TARGETS; + + /** + * Get a vector of all the targets from this reference. + * @return The targets of this reference. + */ + const TARGETS& getTargets() {return targets;} + private: + /** + * Name of this reference. + */ + string name; + + /** + * The interface defining this reference. + */ + Interface* iface; + + /** + * The multiplicity of this reference. + */ + Multiplicity multiplicity; + + /** + * Vector of all the targets wired from this reference. + */ + TARGETS targets; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_servicereference_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Subsystem.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Subsystem.cpp new file mode 100644 index 0000000000..08ef0dde49 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Subsystem.cpp @@ -0,0 +1,122 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/Subsystem.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + + // Constructor + Subsystem::Subsystem(const std::string& subsystemName) : name(subsystemName) + { + LOGENTRY(1, "Subsystem::constructor"); + + + LOGEXIT(1, "Subsystem::constructor"); + } + + Subsystem::~Subsystem() + { + } + + /// + /// Add a new module component + /// + Module* Subsystem::addModuleComponent(const std::string& name, const std::string& moduleName) + { + LOGENTRY(1, "Subsystem::addModuleComponent"); + + Module* newModule = new Module(moduleName); + + // TODO: Should check for duplicates and throw exception + moduleComponents[name] = newModule; + + LOGEXIT(1, "Subsystem::addModuleComponent"); + + return newModule; + } + + Module* Subsystem::findModule(const std::string& moduleName) + { + for (MODULECOMPONENT_MAP::iterator moduleComponentIter = moduleComponents.begin(); + moduleComponentIter != moduleComponents.end(); + moduleComponentIter++) + { + if (moduleName == moduleComponentIter->second->getName()) + { + return (Module*)moduleComponentIter->second; + } + } + return 0; + } + + Module* Subsystem::findModuleByComponentName(const std::string& moduleComponentName) + { + return moduleComponents[moduleComponentName]; + } + + Module* Subsystem::getDefaultModule() + { + if (moduleComponents.size() == 1) + { + MODULECOMPONENT_MAP::iterator moduleComponentIter = moduleComponents.begin(); + return moduleComponentIter->second; + } + return 0; + } + + /// + /// Add a new entrypoint + /// + EntryPoint* Subsystem::addEntryPoint(const std::string& name) + { + LOGENTRY(1, "Subsystem::addEntryPoint"); + + EntryPoint* newEntryPoint = new EntryPoint(name); + entryPoints[name] = newEntryPoint; + LOGEXIT(1, "Subsystem::addEntryPoint"); + return findEntryPoint(name); + } + + EntryPoint* Subsystem::findEntryPoint(const std::string& name) + { + return entryPoints[name]; + } + + void Subsystem::resolveWires() + { + for (MODULECOMPONENT_MAP::iterator moduleComponentIter = moduleComponents.begin(); + moduleComponentIter != moduleComponents.end(); + moduleComponentIter++) + { + moduleComponentIter->second->resolveWires(); + } + + // Resolve EntryPoint wires + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Subsystem.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Subsystem.h new file mode 100644 index 0000000000..b3c59898eb --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Subsystem.h @@ -0,0 +1,131 @@ +/* + * + * 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_model_h +#define tuscany_sca_model_h + +#include <string> +using std::string; +#include <map> +using std::map; + +#include "tuscany/sca/model/Module.h" +#include "tuscany/sca/model/EntryPoint.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Information about a subsystem. + */ + class Subsystem { + public: + /** + * Constructor. + * @param name The name of the subsystem. + */ + Subsystem(const std::string& name); + + /** + * Destructor. + */ + virtual ~Subsystem(); + + /** + * Add a new module component to the subsystem. + * @param name The name of the module component. + * @param moduleName The name of the module. + * @return The new Module added to the subsystem. + */ + Module* addModuleComponent(const std::string& name, const std::string& moduleName); + + /** + * Find a module by module name. + * @param moduleName The name of the module to be found. + * @return The Module that was found, or 0 if not found. + */ + Module* findModule(const std::string& moduleName); + + /** + * Find a module by the module component name. + * @param moduleComponentName The module component name to be used to find + * the module. + * @return The Module that was found, or 0 if not found. + */ + Module* findModuleByComponentName(const std::string& moduleComponentName); + + /** + * Get the default module set for this subsystem. + * @return The default module. + */ + Module* getDefaultModule(); + + /** + * Add an new entry point to the subsystem. + * @param name The name of the entry point. + * @return The new EntryPoint added to the subsystem. + */ + EntryPoint* addEntryPoint(const std::string& name); + + /** + * Find an entry point by name. + * @param name The name of the entry point to be found. + * @return The EntryPoint that was found, or 0 if not found. + */ + EntryPoint* findEntryPoint(const std::string& name); + + /** + * Return the name of the subsystem. + * @return The name. + */ + const std::string& getName() {return name;} + + /** + * Resolve all the wires configured in all the modules in this + * subsystem. + */ + void resolveWires(); + + private: + /** + * The name of the subsystem. + */ + std::string name; + + typedef std::map<std::string, Module*> MODULECOMPONENT_MAP; + /** + * A map by module component name of modules. + */ + MODULECOMPONENT_MAP moduleComponents; + + typedef map<string, EntryPoint*> ENTRYPOINT_MAP; + /** + * A map of entry points defined in this subsystem. + */ + ENTRYPOINT_MAP entryPoints; + }; + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/System.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/System.cpp new file mode 100644 index 0000000000..dfc4a21b1c --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/System.cpp @@ -0,0 +1,118 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/System.h" + + +namespace tuscany +{ + namespace sca + { + namespace model + { + + // ============ + // Constructor + // ============ + System::System() + { + LOGENTRY(1, "System::constructor"); + + + LOGEXIT(1, "System::constructor"); + } + + System::~System() + { + SUBSYSTEM_MAP::iterator subsystemsIter; + for (subsystemsIter = subsystemMap.begin(); + subsystemsIter != subsystemMap.end(); + subsystemsIter++ ) + { + delete subsystemsIter->second; + } + } + + // ================================= + // Add a new subsystem to the system + // ================================= + Subsystem* System::addSubsystem(const std::string& name) + { + LOGENTRY(1, "System::addSubsystem"); + + Subsystem* newSubsystem = new Subsystem(name); + + subsystemMap[name] = newSubsystem; + + LOGEXIT(1, "System::addSubsystem"); + + return newSubsystem; + } + + // ==================================================================== + // Get a map of all the moduleComponents that use a particular module + // ==================================================================== + MODULE_LIST System::findModules(const std::string& name) + { + LOGENTRY(1, "System::findModules"); + MODULE_LIST foundModules; + + SUBSYSTEM_MAP::iterator subsystemsIter; + for (subsystemsIter = subsystemMap.begin(); + subsystemsIter != subsystemMap.end(); subsystemsIter++ ) { + LOGINFO_1(2, "System::findModules: Found subsystem: %s", subsystemsIter->second->getName().c_str()); + // In each subsystem, find module components with this module defined + + Module* module = subsystemsIter->second->findModule(name); + if (module) + { + LOGINFO_1(2, "System::findModules: Found module: %s", module->getName().c_str()); + foundModules.push_back(module); + } + } + LOGEXIT(1, "System::findModules"); + + return foundModules; + } + + + // ==================================================================== + // Get a map of all the moduleComponents that use a particular module + // ==================================================================== + Subsystem* System::findSubsystem(const std::string& subsystem) + { + return subsystemMap[subsystem]; + } + + void System::resolveWires() + { + SUBSYSTEM_MAP::iterator subsystemsIter; + for (subsystemsIter = subsystemMap.begin(); + subsystemsIter != subsystemMap.end(); + subsystemsIter++ ) + { + subsystemsIter->second->resolveWires(); + } + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/System.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/System.h new file mode 100644 index 0000000000..a0f62ce67a --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/System.h @@ -0,0 +1,89 @@ +/* + * + * 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_model_system_h +#define tuscany_sca_model_system_h + +#include <map> +#include <string> +#include <vector> + +#include "tuscany/sca/model/Subsystem.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + typedef std::vector<Module*> MODULE_LIST; + + /** + * The root of the runtime model supported by a Tuscany runtime. + */ + class System { + public: + System(); + virtual ~System(); + + /** + * Add a new subsystem to the system. + * @param subsystemName The name of the new subsystem to add. + * @return The new Subsystem added to the system. + */ + Subsystem* addSubsystem(const std::string& subsystemName); + + /** + * Find subsystem by name. + * @param subsystemName The name of the subsystem to be found. + * @return The Subsystem found, or 0 if not found. + */ + Subsystem* findSubsystem(const std::string& subsystemName); + + typedef std::vector<Module*> MODULE_LIST; + + /** + * Return a vector of all the modules with a given module name. + * @param moduleName The name of the module to find + * @return A vector of all the times the module appears in the + * system. It can be more than once because the same module name + * is used by more than one module component. + */ + MODULE_LIST findModules(const std::string& moduleName); + + /** + * Resolve all the wires defined in the system. + */ + void resolveWires(); + + private: + + typedef std::map<std::string, Subsystem*> SUBSYSTEM_MAP; + + /** + * Map by name of subsystems. + */ + SUBSYSTEM_MAP subsystemMap; + }; + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_system_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WSBinding.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WSBinding.cpp new file mode 100644 index 0000000000..85cb7482bd --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WSBinding.cpp @@ -0,0 +1,127 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/WSBinding.h" + + +namespace tuscany +{ + namespace sca + { + + namespace model + { + + // Constructor + WSBinding::WSBinding(const string& uri, const string& port) + : Binding(uri), port(port) + { + + // Port is of the form: <wsdl-namepace-uri>#wsdl.endpoint(<service-name>/<port-name>) + string::size_type hash = port.find("#"); + if (hash != string::npos) + { + // Found a hash + + // Namepace is the part before the # + wsdlNamespaceURL = port.substr(0, hash); + + + if ( (hash+1) < port.length()) + { + // Check the next part is wsdl.endpoint( + int ending = hash+15; + string check = port.substr(hash+1, 14); + if (check.compare("wsdl.endpoint(") == 0) + { + // Find the matching ) + int endBracket = port.find(")",ending); + if (endBracket-1 > ending+1) + { + string serviceAndPort = port.substr(ending, endBracket-ending); + // Look for a '/' + string::size_type slash = serviceAndPort.find("/"); + if (slash != string::npos) + { + serviceName = serviceAndPort.substr(0, slash); + + if ( (slash+1) < serviceAndPort.length()) + { + portName = serviceAndPort.substr(slash+1); + } + else + { + portName = ""; + } + + } + else + { + // No '/' so all of it is the service name + serviceName = serviceAndPort; + portName = ""; + + } + } + else + { + // Nothing between the () + serviceName = ""; + portName = ""; + } + } + else + { + // not the correct characters after the #, ignore the rest + serviceName = ""; + portName = ""; + } + + } + else + { + // Nothing after the hash + serviceName = ""; + portName = ""; + } + } + else + { + // No hash at all + wsdlNamespaceURL = port; + serviceName = ""; + portName = ""; + } + + + + + + + } + + WSBinding::~WSBinding() + { + } + + } // End namespace model + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WSBinding.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WSBinding.h new file mode 100644 index 0000000000..e7963d205b --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WSBinding.h @@ -0,0 +1,106 @@ +/* + * + * 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_model_wsbinding_h +#define tuscany_sca_model_wsbinding_h + +#include "tuscany/sca/model/Binding.h" + +#include <string> + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Information about a web service binding for an entry point or an + * external service. + */ + class WSBinding : public Binding + { + public: + /** + * Constructor. + * @param uri The uri of the binding. + * @param port The definition of the port to which the entrypoint + * or external service is to be bound. This is of the form + * "namespace"#endpoint("service"/"port") + */ + WSBinding(const string&uri, const string& port); + + /** + * Destructor. + */ + virtual ~WSBinding(); + + /** + * Return the type of the binding. + * @return Always returns WS. + */ + virtual Type getBindingType() {return WS;}; + + /** + * Return the part of the port definition describing the wsdl + * namespace. + * @return The wsdl namespace. + */ + string getWSDLNamespaceURL() {return wsdlNamespaceURL;}; + + /** + * Return the service part of the port definition. + * @return The service to use. + */ + string getServiceName() {return serviceName;}; + + /** + * Return the port name part of the port definition. + * @return The port name to use. + */ + string getPortName() {return portName;}; + + private: + /** + * The full port string. + */ + string port; + + /** + * Namespace from the port. + */ + string wsdlNamespaceURL; + + /** + * Service name from the port. + */ + string serviceName; + + /** + * Port name from the port. + */ + string portName; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_wsbinding_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wire.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wire.cpp new file mode 100644 index 0000000000..6c1b14940f --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wire.cpp @@ -0,0 +1,46 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/model/Wire.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + + // Constructor + Wire::Wire(const std::string& source, const std::string& targ) + { + Utils::tokeniseUri(source, sourceComponent, sourceReference); + target = targ; + } + + Wire::~Wire() + { + } + + } // End namespace model + + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wire.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wire.h new file mode 100644 index 0000000000..b126137118 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wire.h @@ -0,0 +1,91 @@ +/* + * + * 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_model_wire_h +#define tuscany_sca_model_wire_h + +#include <string> +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Information about a wire in the model. + */ + class Wire + { + public: + /** + * Constructor. + * @param source The source of the wire. Either the component and + * reference name (optional) or an entry point. + * @param target The target of the wire. Either a component and service + * service name (optional) or an external sevice. + */ + Wire(const std::string& source, const std::string& target); + + /** + * Destructor. + */ + virtual ~Wire(); + + /** + * Get the component name defined by the source of the wire. + * @return The component name which is the source of the wire. + */ + const std::string& getSourceComponent() {return sourceComponent;} + + /** + * Get the reference name defined by the source of the wire. + * @return The reference name which is the source of the wire. + */ + const std::string& getSourceReference() {return sourceReference;} + + /** + * Get the target uri defined by the target of the wire. + * @return The target uri which is the source of the wire. + */ + const std::string& getTarget() {return target;} + private: + /** + * The source component of the wire. + */ + string sourceComponent; + + /** + * The source reference of the wire. + */ + string sourceReference; + + /** + * The target uri of the wire. + */ + string target; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_wire_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WireTarget.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WireTarget.cpp new file mode 100644 index 0000000000..a35b07f5fe --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WireTarget.cpp @@ -0,0 +1,49 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/WireTarget.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + + // Constructor + WireTarget::WireTarget(const std::string& targetName) + : name(targetName) + { + } + + WireTarget::~WireTarget() + { + } + + void WireTarget::setInterface(Interface* interf) + { + iface = interf; + } + + } // End namespace model + + + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WireTarget.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WireTarget.h new file mode 100644 index 0000000000..312d20a704 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WireTarget.h @@ -0,0 +1,106 @@ +/* + * + * 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_model_wiretarget_h +#define tuscany_sca_model_wiretarget_h + +#include <string> +using std::string; + +#include "tuscany/sca/model/Interface.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + /** + * Represents the target of a wire. This could be a service on a + * component or an external service. + */ + class WireTarget + { + public: + /** + * Supported types of wire target. + */ + enum Type + { + ComponentServiceType, + ExternalServiceType + }; + + /** + * Constructor. + * @param name The name of the wire target. + */ + WireTarget(const std::string& name); + + /** + * Destructor. + */ + virtual ~WireTarget(); + + /** + * Return the name of the wire target. + */ + string getName() {return name;} + + /** + * Get the type of the wire target. + * @return Depends on the type of the wire target. + */ + virtual Type getServiceType() = 0; + + /** + * Set the interface describing the wire target. + * @param iface The interface. + */ + void setInterface(Interface* iface); + + /** + * Get the interface describing the wire target. + * @return The interface. + */ + Interface* getInterface() {return iface;} + + private: + /** + * Name of the wire target (service name or external service name) + */ + string name; + + /** + * Type of the service. + */ + Type serviceType; + + /** + * Interface describing the wire target. + */ + Interface* iface; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_wiretarget_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wsdl.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wsdl.cpp new file mode 100644 index 0000000000..d2ca9e96c1 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wsdl.cpp @@ -0,0 +1,356 @@ +/* + * + * 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/model/Wsdl.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/Exceptions.h" + +using namespace tuscany::sca; + +using namespace commonj::sdo; + +namespace tuscany +{ + namespace sca + { + namespace model + { + + + // Constructor + Wsdl::Wsdl(DataObjectPtr wsdlModel) + : wsdlModel(wsdlModel) + { + LOGENTRY(1, "Wsdl::constructor"); + + // Trace + //Utils::printDO(wsdlModel); + + + + LOGEXIT(1, "Wsdl::constructor"); + } + + Wsdl::~Wsdl() + { + } + + + /// + /// The namespace of the service and other definitions defined in this wsdl definition + string Wsdl::getNamespace() + { + + return wsdlModel->getCString("targetNamespace"); + + } + + /// + /// Find the operation defined in this wsdl + /// + const WsdlOperation& Wsdl::findOperation(const string& serviceName, + const string& portName, + const string& operationName) + { + string message; + + string operationKey = serviceName+"#"+portName+"#"+operationName; + OperationMap::iterator iter = operationMap.find(operationKey); + if (iter != operationMap.end()) + { + return iter->second; + } + + // Find the service + DataObjectPtr service = findService(serviceName); + if (!service) + { + // Service not found + message = "Unable to find service "; + message = message + serviceName; + message = message + " in the WSDL definition"; + throw SystemConfigurationException(message.c_str()); + } + else + { + + + // Found the service + DataObjectList& portList = service->getList("port"); + for (int j=0; j<portList.size();j++) + { + string portListName(portList[j]->getCString("name")); + if (portListName.compare(portName) == 0) + { + // found port + // Add address at this point + string targetAddress(portList[j]->getCString("address/location")); + + // find operation by traversing the binding, portType then operation + string wsBindingName(portList[j]->getCString("binding")); + + DataObjectPtr wsBinding = findBinding(wsBindingName); + if (!wsBinding) + { + message = "Unable to find binding "; + message = message + wsBindingName; + message = message + " in the WSDL definition"; + throw SystemConfigurationException(message.c_str()); + } + + + string soapAction; + bool documentStyle = false; + bool useEncoded = false; + WsdlOperation::soapVersion soapVer = WsdlOperation::SOAP11; + + // Find the binding operation + DataObjectList& bindingOperationList = wsBinding->getList("operation"); + for (int i=0; i<bindingOperationList.size(); i++) + { + string name(bindingOperationList[i]->getCString("name")); + + if (name.compare(operationName) == 0) + { + DataObjectPtr op = bindingOperationList[i]->getDataObject("operation"); + string opType = op->getType().getURI(); + if (opType == "http://schemas.xmlsoap.org/wsdl/soap12/") + { + soapVer = WsdlOperation::SOAP12; + } + // Get the soapAction + soapAction = bindingOperationList[i]->getCString("operation/soapAction"); + + // Get the style + string style = bindingOperationList[i]->getCString("operation/style"); + if (style == "") + { + style = wsBinding->getCString("binding/style"); + } + if (style == "document") + { + documentStyle = true; + } + + // get the use + string use = bindingOperationList[i]->getCString("input/body/use"); + if (style == "encoded") + { + useEncoded = true; + } + } + } + + + // TODO - get the style from the binding or operation???? + + // Found the binding, get the portType + string wsPortTypeName(wsBinding->getCString("type")); + DataObjectPtr wsPortType = findPortType(wsPortTypeName); + if (!wsPortType) + { + message = "Unable to find PortType "; + message = message + wsPortTypeName; + message = message + " in the WSDL definition"; + throw SystemConfigurationException(message.c_str()); + } + + //Utils::printDO(wsPortType); + + // Found the portType, find the operation + DataObjectList& operationList = wsPortType->getList("operation"); + for (int k=0; k< operationList.size(); k++) + { + string opName(operationList[k]->getCString("name")); + if( opName.compare(operationName) == 0) + { + // Found the operation + + // Find the type of the request message + string inputMessageType = string(operationList[k]->getCString("input/message")); + + DataObjectPtr wsMessageIn = findMessage(inputMessageType); + if (!wsMessageIn) + { + message = "Unable to find message "; + message = message + inputMessageType; + message = message + " in the WSDL definition"; + throw SystemConfigurationException(message.c_str()); + } + + string requestType(wsMessageIn->getList("part")[0]->getCString("element")); + + // Find the type of the response message + string outputMessageType = string(operationList[k]->getCString("output/message")); + + DataObjectPtr wsMessageOut = findMessage(outputMessageType); + if (!wsMessageOut) + { + message = "Unable to find message "; + message = message + outputMessageType; + message = message + " in the WSDL definition"; + throw SystemConfigurationException(message.c_str()); + } + + string responseType(wsMessageOut->getList("part")[0]->getCString("element")); + + WsdlOperation& wsdlOp = operationMap[operationKey]; + wsdlOp.setOperationName(operationName); + wsdlOp.setSoapAction(soapAction); + wsdlOp.setEndpoint(targetAddress); + wsdlOp.setSoapVersion(soapVer); + wsdlOp.setDocumentStyle(documentStyle); + wsdlOp.setEncoded(useEncoded); + wsdlOp.setInputType(requestType); + wsdlOp.setOutputType(responseType); + return wsdlOp; + } + + } + + message = "Unable to find Operation "; + message = message + operationName; + message = message + " in the WSDL definition"; + throw SystemConfigurationException(message.c_str()); + } + } + // cannot find the port + message = "Unable to find port "; + message = message + portName; + message = message + " in the WSDL definition"; + throw SystemConfigurationException(message.c_str()); + } + + } + + /// + /// Find a service + /// + DataObjectPtr Wsdl::findService(const string& serviceName) + { + DataObjectPtr service = 0; + + + // Find the binding + DataObjectList& serviceList = wsdlModel->getList("service"); + for (int i=0; i<serviceList.size(); i++) + { + string name(serviceList[i]->getCString("name")); + + if (name.compare(serviceName) == 0) + { + return serviceList[i]; + } + } + + return service; + } + + + /// + /// Find a named binding + /// + DataObjectPtr Wsdl::findBinding(const string& bindingName) + { + DataObjectPtr binding = 0; + string uri; + string name; + + + //Utils::tokeniseQName(bindingName, uri, name); + Utils::rTokeniseString(":", bindingName, uri, name); + + + // Find the binding + DataObjectList& bindingList = wsdlModel->getList("binding"); + for (int i=0; i<bindingList.size(); i++) + { + string nameBinding(bindingList[i]->getCString("name")); + + if (nameBinding.compare(name) == 0) + { + return bindingList[i]; + } + } + + return binding; + } + + /// + /// Find a named portType + /// + DataObjectPtr Wsdl::findPortType(const string& portTypeName) + { + DataObjectPtr portType = 0; + string uri; + string name; + + + // Utils::tokeniseQName(portTypeName, uri, name); + Utils::rTokeniseString(":", portTypeName, uri, name); + + + // Find the binding + DataObjectList& portTypeList = wsdlModel->getList("portType"); + for (int i=0; i<portTypeList.size(); i++) + { + string namePortType(portTypeList[i]->getCString("name")); + + if (namePortType.compare(name) == 0) + { + return portTypeList[i]; + } + } + + return portType; + } + + /// + /// Find a named message + /// + DataObjectPtr Wsdl::findMessage(const string& messageName) + { + DataObjectPtr message = 0; + string uri; + string name; + + + // Utils::tokeniseQName(messageName, uri, name); + Utils::rTokeniseString(":", messageName, uri, name); + + + // Find the binding + DataObjectList& messageList = wsdlModel->getList("message"); + for (int i=0; i<messageList.size(); i++) + { + string nameMessage(messageList[i]->getCString("name")); + + if (nameMessage.compare(name) == 0) + { + return messageList[i]; + } + } + + return message; + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wsdl.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wsdl.h new file mode 100644 index 0000000000..70a07996cc --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/Wsdl.h @@ -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: 2005/12/22 11:33:21 $ */ + +#ifndef tuscany_sca_model_wsdl_h +#define tuscany_sca_model_wsdl_h + +#include "osoa/sca/export.h" +#include <string> +using std::string; + +#include "tuscany/sca/model/WsdlOperation.h" + +#include "commonj/sdo/SDO.h" +using commonj::sdo::DataObjectPtr; + +#include <map> +using std::map; + +namespace tuscany +{ + namespace sca + { + namespace model + { + + /** + * Holds information about a WSDL definition loaded into the runtime. + */ + class Wsdl + { + public: + /** + * Constructor. + * @param wsdlModel The data object representing the WSDL document + * defining a web service. + */ + Wsdl(DataObjectPtr wsdlModel); + + /** + * Destructor. + */ + ~Wsdl(); + + + /** + * Returns the target namespace of the WSDL definitions. + * @return The target namespace. + */ + string getNamespace(void); + + /** + * Find an operation in the WSDL definitions. + * @param serviceName The name of the service on which this + * operation is defined. + * @param portName The name of the port in the service to + * use. + * @param operationName The name of the operation to find. + * @return The operation if found. Exception thrown if not found. + */ + const WsdlOperation& findOperation(const string& serviceName, + const string& portName, + const string& operationName); + + private: + + /** + * Find a service in the wsdl definition. + * @param serviceName The name of the service. + * @return A data object describing the service if found, otherwise + * a 0 if not found. + */ + DataObjectPtr findService(const string& serviceName); + + /** + * Find a binding in the wsdl definition. + * @param bindingName The name of the binding to find. + * @return A data object describing the binding if found, otherwise + * a 0 if not found. + */ + DataObjectPtr findBinding(const string& bindingName); + + /** + * Find a portType in the wsdl definition. + * @param portTypeName The name of the portType. + * @return A data object describing the portType if found, otherwise + * a 0 if not found. + */ + DataObjectPtr findPortType(const string& portTypeName); + + /** + * Find a message in the wsdl definition. + * @param messageName The name of the message. + * @return A data object describing the message if found, otherwise + * a 0 if not found. + */ + DataObjectPtr findMessage(const string& messageName); + + + /** + * The data object representation of the WSDL document. + */ + DataObjectPtr wsdlModel; + + typedef map<string, WsdlOperation> OperationMap; + OperationMap operationMap; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_wsdl_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WsdlOperation.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WsdlOperation.cpp new file mode 100644 index 0000000000..40964ea20e --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WsdlOperation.cpp @@ -0,0 +1,56 @@ +/* + * + * 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/model/WsdlOperation.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" + +namespace tuscany +{ + namespace sca + { + namespace model + { + + + // Constructor + WsdlOperation::WsdlOperation() + { + LOGENTRY(1, "WsdlOperation::constructor"); + LOGEXIT(1, "WsdlOperation::constructor"); + } + + WsdlOperation::~WsdlOperation() + { + } + + + void WsdlOperation::setInputType(const string& inputType) + { + Utils::tokeniseQName(inputType, inputTypeUri, inputTypeName); + } + + void WsdlOperation::setOutputType(const string& outputType) + { + Utils::tokeniseQName(outputType, outputTypeUri, outputTypeName); + } + + } // End namespace model + } // End namespace sca +} // End namespace tuscany diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WsdlOperation.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WsdlOperation.h new file mode 100644 index 0000000000..9fe22b6f57 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/model/WsdlOperation.h @@ -0,0 +1,141 @@ +/* + * + * 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_model_wsdlOperation_h +#define tuscany_sca_model_wsdlOperation_h +#include "osoa/sca/export.h" +#include <string> +using std::string; + + +#include "commonj/sdo/SDO.h" +using commonj::sdo::DataObjectPtr; + +namespace tuscany +{ + namespace sca + { + namespace model + { + + /** + * Represents a single.,bound WSDL defined operation. + * This class includes information from the soapBinding + * in addition to the WSDL definition of the operation. + */ + class WsdlOperation + { + public: + /** + * Constructor. + * @param operation The name of the operation. + * @param soapAction The soapAction associated with this operation + * in the SOAP binding of the operation. + * @param endpoint The endpoint address of the operation. + * @param responseName The name of the response message. + */ + WsdlOperation(); + + /** + * Destructor. + */ + ~WsdlOperation(); + + /** + * Return the name of the operation for use when serializing an + * outgoing message. + * @return The name of the element in the request message. + */ + const string& getOperationName() const {return operationName;} + void setOperationName(const string& opName) {operationName = opName;} + + /** + * The soap action string for this operation. + * @return The soap action. + */ + const string& getSoapAction() const {return soapAction;} + void setSoapAction(const string& soapAct) {soapAction = soapAct;} + + /** + * Return the endpoint address for the target web service. + * @return The endpoint address. + */ + const string& getEndpoint() const {return endpoint;} + void setEndpoint(const string& ep) {endpoint = ep;} + + enum soapVersion + { + SOAP11, + SOAP12 + }; + + void setSoapVersion(soapVersion ver) {soapVer = ver;} + soapVersion getSoapVersion() const {return soapVer;} + + void setDocumentStyle(bool docStyle) {documentStyle = docStyle;} + bool isDocumentStyle() const {return documentStyle;} + + void setEncoded(bool enc) {encoded = enc;} + bool isEncoded() const {return encoded;} + + + void setInputType(const string& inputType); + const string& getInputTypeUri() const {return inputTypeUri;} + const string& getInputTypeName() const {return inputTypeName;} + void setOutputType(const string& outputType); + const string& getOutputTypeUri() const {return outputTypeUri;} + const string& getOutputTypeName() const {return outputTypeName;} + + private: + /** + * The name of the operation for use when serializing an + * outgoing message. + */ + string operationName; + + /** + * The soap action string for this operation. + */ + string soapAction; + + /** + * The endpoint address of the target web service. + */ + string endpoint; + + bool documentStyle; + bool encoded; + soapVersion soapVer; + + string inputTypeUri; + string inputTypeName; + + string outputTypeUri; + string outputTypeName; + + DataObjectPtr inputMessage; + DataObjectPtr outputMessage; + }; + + } // End namespace model + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_model_wsdlOperation_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp new file mode 100644 index 0000000000..3ea2212f7c --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp @@ -0,0 +1,43 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/DefaultLogWriter.h" +#include <iostream> +using namespace std; + +namespace tuscany +{ + namespace sca + { + DefaultLogWriter::~DefaultLogWriter() + { + } + + void DefaultLogWriter::log(int level, const char* msg) + { + for (int i=0; i < level; i++) + { + cout << " "; + } + cout << msg <<endl; + } + + } // End namespace sca +} // End namespace tuscany + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h new file mode 100644 index 0000000000..4d45579907 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h @@ -0,0 +1,46 @@ +/* + * + * 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_util_defaultlogwriter_h +#define tuscany_sca_util_defaultlogwriter_h + +#include "tuscany/sca/util/LogWriter.h" + +namespace tuscany +{ + namespace sca + { + /** + * Log writer to write out to standard out. + */ + class DefaultLogWriter : public LogWriter + { + public: + virtual ~DefaultLogWriter(); + + /** + * Will write to the console. + * See LogWriter#log. + */ + virtual void log(int level, const char* msg); + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_defaultlogwriter_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Exceptions.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Exceptions.h new file mode 100644 index 0000000000..daad31f59f --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Exceptions.h @@ -0,0 +1,48 @@ +/* + * + * 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_util_exceptions_h +#define tuscany_sca_util_exceptions_h + +#include "osoa/sca/ServiceRuntimeException.h" +using osoa::sca::ServiceRuntimeException; + +namespace tuscany +{ + namespace sca + { + /** + * Indicates a problem in the consistency of the SCA model provided to the + * Tuscany runtime. + */ + class SCA_API SystemConfigurationException: public ServiceRuntimeException + { + public: + SystemConfigurationException(const char* msg) + : ServiceRuntimeException("SystemConfigurationException", Severe, + msg) + { + } + private: + }; + + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_exceptions_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/File.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/File.cpp new file mode 100644 index 0000000000..33e33d1aad --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/File.cpp @@ -0,0 +1,221 @@ +/* + * + * 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 $ */ +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "tuscany/sca/util/File.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/Exceptions.h" +#include <iostream> + +#include <string> +#include <iostream> +using namespace std; + +#if defined(WIN32) || defined (_WINDOWS) +#include <windows.h> +#else +#include <unistd.h> +#include <sys/stat.h> +#include <dirent.h> +#endif + +namespace tuscany +{ + namespace sca + { + File::File(const string& dir, const string& file) + : directory(dir), fileName(file) + { + } + File::~File() + { + } + + + Files::Files(const string& rootDir, const string& pattern, bool subdirectories) + : rootDirectory(rootDir) + { + findFiles(rootDirectory, pattern, subdirectories); + } + + Files::~Files() + { + } + + unsigned int Files::size() + { + return files.size(); + } + + const File& Files::operator[] (unsigned int index) + { + if (size() <= index) + { + throw ServiceRuntimeException("Files::operator[] index out of bounds"); + } + + FILES::iterator iter = files.begin(); + for (unsigned int i=0; i<index; i++) + { + iter++; + } + + return *iter; + } + + + void Files::findFiles(const string& rootDir, const string& pattern, bool subdirectories) + { + +#if defined(WIN32) || defined (_WINDOWS) + char currentDir[ _MAX_FNAME]; + + + GetCurrentDirectory(_MAX_FNAME, currentDir); + + // Set current directory, from which to search. + if (!SetCurrentDirectory(rootDir.c_str())) + { + cout << "Unable to set current directory to: " << rootDir.c_str() << endl; + return; + } + char fullDirname[ _MAX_FNAME]; + GetCurrentDirectory(_MAX_FNAME, fullDirname); + + // First, look for all files in this directory that meet the pattern + char search[ _MAX_FNAME]; + strcpy(search, pattern.c_str()); + + // Find the first file in the directory + WIN32_FIND_DATA data; + HANDLE searchHandle = FindFirstFile(search, &data); + + int more = TRUE; + if (searchHandle != INVALID_HANDLE_VALUE) + { + // Found some matching files, so call the function with the details of each one + while (more) + { + // Skip over directories + if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + // Add the file to our list + files.push_back(File(fullDirname, data.cFileName)); + } + + more = FindNextFile(searchHandle, &data); + } + } + + + if (!subdirectories) + return; + + // Now recurse down all the directories + // Find the first file in the directory + searchHandle = FindFirstFile( "*.*", &data); + more = TRUE; + + if (searchHandle != INVALID_HANDLE_VALUE) + { + // Found some files in the directory. + while (more) + { + // If directory + if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + // Skip over '.' and '..' + if ((strcmp(data.cFileName, ".")) && (strcmp("..", data.cFileName))) + { + // Recurse + findFiles(data.cFileName, pattern, subdirectories); + } + } + + more = FindNextFile(searchHandle, &data); + } + } + SetCurrentDirectory(currentDir); +#else + // Linux + //char fullDirname[MAX_PATH]; + //getcwd(fullDirname, MAX_PATH); + + DIR* root = opendir(rootDir.c_str()); + if (!root) + { + cout << "Unable to open directory: " << rootDir.c_str() << endl; + return; + } + + bool exactMatch = true; + string token1, token2; + if (pattern.find('*') != string::npos) + { + exactMatch = false; + Utils::tokeniseString("*", pattern, token1, token2); + } + + struct dirent *entry=0; + while ((entry = readdir(root))) + { + string entryName = rootDir + "/" + entry->d_name; + struct stat statbuf; + if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + continue; + if (stat(entryName.c_str(), &statbuf) != 0) + { + perror("stat"); + } + else + { + if (S_ISDIR(statbuf.st_mode)) + { + if (subdirectories) + { + findFiles(entryName, pattern, subdirectories); + } + } + else if (S_ISREG(statbuf.st_mode)) + { + string filename = entry->d_name; + + if ((exactMatch && filename == pattern) || + (!exactMatch && + ((filename.find(token1) == 0) + && (filename.length() >= token2.length()) + && (filename.rfind(token2) == (filename.length() - token2.length())) ))) + { + // Add the file to our list + files.push_back(File(rootDir, filename)); + } + } + } + } + closedir(root); +#endif + } + + + } // End namespace sca +} // End namespace tuscany + + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/File.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/File.h new file mode 100644 index 0000000000..f177401442 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/File.h @@ -0,0 +1,133 @@ +/* + * + * 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_util_file_h +#define tuscany_sca_util_file_h + +#include <string> +using std::string; +#include <vector> +using std::vector; + +namespace tuscany +{ + namespace sca + { + /** + * File access methods. Provides platform independent + * access to files. + */ + class File + { + public: + /** + * Constructor. + * @param directory Name of the directory in which this file is located. + * Either / or \ can be used interchangeably for separating directory elements. + * @param fileName Name of the file in the dirctory. + */ + File(const string& directory, const string& fileName); + + /** + * Destructor. + */ + virtual ~File(); + + /** + * Return the directory in which this file is located. + * @return Name of the directory. + */ + const string& getDirectory() const {return directory;} + + /** + * Name of the file. + * @return Name of the file. + */ + const string& getFileName() const {return fileName;} + private: + /** + * Name of the directory. + */ + string directory; + + /** + * Name of the file. + */ + string fileName; + }; + + /** + * Collection of File to provide platform independent access + * to files and directories. + */ + class Files + { + public: + /** + * Constructor which will search a given directory with a pattern and return a + * new instance of this collection class. + * @param rootDirectory The directory in which to search. + * @param pattern A pattern for matching file names. Can include * and ?. + * @param subdirectories Whether subdirectories should be searched too. + */ + Files(const string& rootDirectory, const string& pattern, bool subdirectories = false); + + /** + * Destructor. + */ + virtual ~Files(); + + /** + * Return the number of files found. + * @return The number of files found. + */ + unsigned int size(); + + /** + * Return a File at this position in the collection. + * @param index The index into the collection. + * @return The File at this index in the collection. + */ + const File& operator[] (unsigned int index); + + private: + /** + * Search the given directory and pattern for matching files. + * @param rootDirectory The directory in which to search. + * @param pattern A pattern for matching file names. Can include * and ?. + * @param subdirectories Whether subdirectories should be searched too. + */ + void findFiles(const string& rootDirectory, const string& pattern, bool subdirectories); + + /** + * The top level directory to search. + */ + string rootDirectory; + + typedef vector<File> FILES; + + /** + * Vector of File. + */ + FILES files; + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_file_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp new file mode 100644 index 0000000000..c3749c1be2 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp @@ -0,0 +1,49 @@ +/* + * + * 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/FileLogWriter.h" +#include <iostream> +using namespace std; + +namespace tuscany +{ + namespace sca + { + FileLogWriter::FileLogWriter(const char* logfile) + { + logFile.open(logfile, ios_base::app); + } + + FileLogWriter::~FileLogWriter() + { + logFile.close(); + } + + void FileLogWriter::log(int level, const char* msg) + { + for (int i=0; i < level; i++) + { + logFile << " "; + } + logFile << msg <<endl; + } + + } // End namespace sca +} // End namespace tuscany + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.h new file mode 100644 index 0000000000..4f230a8f0b --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/FileLogWriter.h @@ -0,0 +1,53 @@ +/* + * + * 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_util_filelogwriter_h +#define tuscany_sca_util_filelogwriter_h + +#include "tuscany/sca/util/LogWriter.h" +#include <iostream> +#include <fstream> +using std::ofstream; + +namespace tuscany +{ + namespace sca + { + /** + * Log writer to write out to standard out. + */ + class FileLogWriter : public LogWriter + { + public: + FileLogWriter(const char* logfile); + + virtual ~FileLogWriter(); + + /** + * Will write to the console. + * See LogWriter#log. + */ + virtual void log(int level, const char* msg); + private: + ofstream logFile; + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_defaultlogwriter_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Library.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Library.cpp new file mode 100644 index 0000000000..0a50f396c7 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Library.cpp @@ -0,0 +1,122 @@ +/* + * + * 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 $ */ +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "tuscany/sca/util/Library.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/Exceptions.h" +#include "tuscany/sca/util/Logging.h" +using namespace osoa::sca; + +namespace tuscany +{ + namespace sca + { + Library::Library() + : hDLL(NULL) + { + } + + Library::Library(const string& libraryName) + : name(libraryName), hDLL(NULL) + { + LOGINFO_1(3, "Library::construcor : %s", name.c_str()); + load(); + } + + Library::Library(const Library& lib) + : name(lib.name), hDLL(NULL) + { + LOGINFO_1(3, "Library::copy constructor : %s", name.c_str()); + if (lib.hDLL) + { + load(); + } + } + + Library& Library::operator=(const Library& lib) + { + LOGINFO_1(3, "Library::operator= : %s", name.c_str()); + if (&lib != this) + { + unload(); + name = lib.name; + load(); + } + return *this; + } + + Library::~Library() + { + LOGINFO_1(3, "Library::destructor: %s", name.c_str()); + unload(); + } + + + void Library::load() + { + LOGINFO_1(3, "Library::load : %s", name.c_str()); + string msg; +#if defined(WIN32) || defined (_WINDOWS) + hDLL = LoadLibrary(name.c_str()); +#else + hDLL = dlopen(name.c_str(), RTLD_NOW); +#endif + if (hDLL == NULL) + { + LOGERROR_1(1, "Library::load: Unable to load library %s", name.c_str()); + msg = "Unable to load dll: " + name; + throw ServiceRuntimeException(msg.c_str()); + } + } + + void Library::unload() + { + if (hDLL != NULL) + { + LOGINFO_1(3, "Library::unload : %s", name.c_str()); +#if defined(WIN32) || defined (_WINDOWS) + FreeLibrary(hDLL); +#else + dlclose(hDLL); +#endif + hDLL = NULL; + } + } + + void* Library::getSymbol(const string& symbol) + { + LOGINFO_1(3, "Library::getSymbol : %s", symbol.c_str()); + if (!hDLL) + { + return 0; + } +#if defined(WIN32) || defined (_WINDOWS) + return GetProcAddress(hDLL, symbol.c_str()); +#else + return dlsym(hDLL, symbol.c_str()); +#endif + } + + } // End namespace sca +} // End namespace tuscany + + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Library.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Library.h new file mode 100644 index 0000000000..69b2f5352a --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Library.h @@ -0,0 +1,97 @@ +/* + * + * 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_util_library_h +#define tuscany_sca_util_library_h + + +#if defined(WIN32) || defined (_WINDOWS) +#include <windows.h> +#else +#include <unistd.h> +#include <dlfcn.h> +#endif + +#include <string> +using std::string; + +namespace tuscany +{ + namespace sca + { + /** + * Information about shared libraries and methods to + * access these shared libraries. + */ + class Library + { + public: + Library(); + + /** + * Constructor. Will load the library. + * @param libraryName Fully qualified name of the library. + */ + Library(const string& libraryName); + + /** + * Destructor. Will unload the library. + */ + virtual ~Library(); + + Library(const Library& lib); + Library& operator=(const Library& lib); + + /** + * Find an externalized symbol in the library. + * @param symbol The name of the symbol to be found. + * @return The pointer to the symbol if found, otherwise 0. + */ + void* getSymbol(const string& symbol); + private: + /** + * Name of the library. + */ + string name; + + /** + * Handle to the loaded library. + */ +#if defined(WIN32) || defined (_WINDOWS) + HINSTANCE hDLL; +#else + void* hDLL; +#endif + + /** + * Load the library. + */ + void load(); + + /** + * Unload the library, if successfully loaded. + */ + void unload(); + + }; + + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_util_library_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp new file mode 100644 index 0000000000..d77d1e4bfd --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/LogWriter.cpp @@ -0,0 +1,32 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/LogWriter.h" + +namespace tuscany +{ + namespace sca + { + LogWriter::~LogWriter() + { + } + + } // End namespace sca +} // End namespace tuscany + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/LogWriter.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/LogWriter.h new file mode 100644 index 0000000000..edb07c3684 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/LogWriter.h @@ -0,0 +1,47 @@ +/* + * + * 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_util_logwriter_h +#define tuscany_sca_util_logwriter_h + +#include "osoa/sca/export.h" + +namespace tuscany +{ + namespace sca + { + /** + * Abstract class for extending logging to other destinations. + */ + class SCA_API LogWriter + { + public: + virtual ~LogWriter(); + + /** + * Log a message. + * @param level The level of logging for this message. + * @param msg The message to log. + */ + virtual void log(int level, const char* msg) = 0; + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_logwriter_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Logger.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Logger.cpp new file mode 100644 index 0000000000..0a888a69ef --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Logger.cpp @@ -0,0 +1,107 @@ +/* + * + * 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 <iostream> +#include <stdarg.h> + +#include "tuscany/sca/util/Logger.h" +#include "tuscany/sca/util/DefaultLogWriter.h" +#include "tuscany/sca/util/FileLogWriter.h" + +using namespace std; + +namespace tuscany +{ + namespace sca + { + LogWriter* Logger::logWriter = getLogWriter(); + + LogWriter* Logger::getLogWriter() + { + if (logWriter == 0) + { + setLogWriter(0); + } + return logWriter; + } + + void Logger::setLogWriter(LogWriter* writer) + { + if (logWriter != writer + && logWriter != 0) + { + delete logWriter; + } + + if (writer == 0) + { + char* loggingVar = 0; + loggingVar = getenv("TUSCANY_SCACPP_LOG"); + if (loggingVar == 0) + logWriter = new DefaultLogWriter; + else + logWriter = new FileLogWriter(loggingVar); + } + else + { + logWriter = writer; + } + } + + int Logger::loggingLevel = setLogging(); + + int Logger::setLogging() + { + char* loggingVar = 0; + loggingVar = getenv("TUSCANY_SCACPP_LOGGING"); + if (loggingVar == 0) + return 0; + else + return atoi(loggingVar); + } + + void Logger::setLogging(int level) + { + loggingLevel = level; + } + + void Logger::log(int level, const char* msg) + { + if (level <= loggingLevel) + { + logWriter->log(level, msg); + } + } + + void Logger::logArgs(int level, const char* msg, ...) + { + if (level <= loggingLevel) + { + va_list variableArguments; + va_start(variableArguments, msg); + char messageBuffer[1024]; + vsprintf(messageBuffer, msg, variableArguments); + logWriter->log(level, messageBuffer); + va_end(variableArguments); + } + } + + } // End namespace sca +} // End namespace tuscany + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Logger.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Logger.h new file mode 100644 index 0000000000..be5e47e02a --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Logger.h @@ -0,0 +1,89 @@ +/* + * + * 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_util_logger_h +#define tuscany_sca_util_logger_h + +#include "osoa/sca/export.h" +#include "tuscany/sca/util/LogWriter.h" +namespace tuscany +{ + namespace sca + { + /** + * Provide a logging interface. + */ + class Logger { + + public: + /** + * Set the log writer to use. + * @param writer The writer to use for all subsequent logging. + */ + SCA_API static void setLogWriter(LogWriter* writer); + + /** + * Set or reset the logging level. Any message with a higher logging + * level than this value will be filtered (i.e. not shown). + * @param level The level of logging to use for all subsequent logging. + */ + SCA_API static void setLogging(int level); + + /** + * Log a message. + * @param level The log level of this message. + * @param msg The message to be logged. + */ + SCA_API static void log(int level, const char* msg); + + /** + * Log a message with variable arguments. + * @param level The log level of this message. + * @param msg The message to be logged. Must include template + * characters as described in printf. + * @param ... Variable arguments. + */ + SCA_API static void logArgs(int level, const char* msg, ...); + + /** + * The currently set logging level + */ + SCA_API static int loggingLevel; + + private: + /** + * The current log writer. + */ + static LogWriter* logWriter; + + /** + * Get the current log writer. + * @return The current log writer. + */ + static LogWriter* getLogWriter(); + + /** + * Retrieves the logging level set as an environment variable. + */ + static int setLogging(); + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_logger_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Logging.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Logging.h new file mode 100644 index 0000000000..7e3a1a84ab --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Logging.h @@ -0,0 +1,57 @@ +/* + * + * 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_util_logging_h +#define tuscany_sca_util_logging_h + +#include "tuscany/sca/util/Logger.h" + +#define LOGENTRY(level, methodName) \ +if (Logger::loggingLevel >= level) \ +Logger::log(level, "Entering: " methodName); + +#define LOGEXIT(level, methodName) \ +if (Logger::loggingLevel >= level) \ +Logger::log(level, "Exiting: " methodName); + +#define LOGINFO(level, message) \ +if (Logger::loggingLevel >= level) \ +Logger::log(level, message); + +#define LOGINFO_1(level, message, arg1) \ +if (Logger::loggingLevel >= level) \ +Logger::logArgs(level, message, arg1); + +#define LOGINFO_2(level, message, arg1, arg2) \ +if (Logger::loggingLevel >= level) \ +Logger::logArgs(level, message, arg1, arg2); + +#define LOGERROR(level, message) \ +if (Logger::loggingLevel >= level) \ +Logger::log(level, message); + +#define LOGERROR_1(level, message, arg1) \ +if (Logger::loggingLevel >= level) \ +Logger::logArgs(level, message, arg1); + +#define LOGERROR_2(level, message, arg1, arg2) \ +if (Logger::loggingLevel >= level) \ +Logger::logArgs(level, message, arg1, arg2); + +#endif // tuscany_sca_util_logging_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Utils.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Utils.cpp new file mode 100644 index 0000000000..6417ed3da4 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Utils.cpp @@ -0,0 +1,215 @@ +/* + * + * 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 $ */ +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "tuscany/sca/util/Utils.h" + +using namespace std; +using namespace commonj::sdo; +namespace tuscany +{ + namespace sca + { + void Utils::tokeniseUri(const string& uri, string& token1, string& token2) + { + tokeniseString("/", uri, token1, token2); + } + + void Utils::tokeniseQName(const string& qname, string& uri, string& name) + { + tokeniseString("#", qname, uri, name); + if (name == "") + { + name = uri; + uri = ""; + } + } + + void Utils::tokeniseString( + const string& separator, + const string& str, + string& token1, + string& token2) + { + string::size_type sep = str.find(separator); + if (sep != string::npos) + { + token1 = str.substr(0, sep); + if ( (sep+1) < str.length()) + { + token2 = str.substr(sep+1); + } + else + { + token2 = ""; + } + } + else + { + token1 = str; + token2 = ""; + } + } + + void Utils::rTokeniseString( + const string& separator, + const string& str, + string& token1, + string& token2) + { + string::size_type sep = str.rfind(separator); + if (sep != string::npos) + { + token1 = str.substr(0, sep); + if ( (sep+1) < str.length()) + { + token2 = str.substr(sep+1); + } + else + { + token2 = ""; + } + } + else + { + token1 = ""; + token2 = str; + } + } + + ////////////////////////////////////////////////////////////////////////// + // Print a DatObject tree + ////////////////////////////////////////////////////////////////////////// + void Utils::tabs(int inc) + { + for (int ind=0; ind <inc; ind++) + { + cout << " "; + } + } + + void Utils::printDO(DataObjectPtr dataObject, int increment) + { + int inc=increment; + if (!dataObject) + return; + const Type& dataObjectType = dataObject->getType(); + tabs(inc); + cout << "DataObject type: " << dataObjectType.getURI()<< "#" << dataObjectType.getName() << endl; + inc++; + + ////////////////////////////////////////////////////////////////////////// + // Iterate over all the properties + ////////////////////////////////////////////////////////////////////////// + PropertyList pl = dataObject->getInstanceProperties(); + for (int i = 0; i < pl.size(); i++) + { + tabs(inc); + cout << "Property: " << pl[i].getName() << endl; + + const Type& propertyType = pl[i].getType(); + + tabs(inc); + cout << "Property Type: " << propertyType.getURI()<< "#" << propertyType.getName() << endl; + + if (dataObject->isSet(pl[i])) + { + + ////////////////////////////////////////////////////////////////////// + // For a many-valued property get the list of values + ////////////////////////////////////////////////////////////////////// + if (pl[i].isMany()) + { + inc++; + DataObjectList& dol = dataObject->getList(pl[i]); + for (int j = 0; j <dol.size(); j++) + { + tabs(inc); + cout << "Value " << j <<endl; + inc++; + + if (propertyType.isDataType()) + { + tabs(inc); + cout<< "Property Value: " << dol.getCString(j) <<endl ; + } + else + printDO(dol[j], inc); + inc--; + } + inc--; + } // end IsMany + + + ////////////////////////////////////////////////////////////////////// + // For a primitive data type print the value + ////////////////////////////////////////////////////////////////////// + else if (propertyType.isDataType()) + { + tabs(inc); + cout<< "Property Value: " << dataObject->getCString(pl[i]) <<endl ; + } + + ////////////////////////////////////////////////////////////////////// + // For a dataobject print the do + ////////////////////////////////////////////////////////////////////// + else + { + inc++; + printDO(dataObject->getDataObject(pl[i]), inc); + inc--; + } + } + else + { + tabs(inc); + cout<< "Property Value: not set" <<endl ; + } + + } + inc--; + } + + void Utils::printTypes(DataFactoryPtr df) + { + ////////////////////////////////////////////////////////////////////////// + // Retrieve the DataFactory from the mediator + // get the list of Types in the DataFactory and list them + ////////////////////////////////////////////////////////////////////////// + TypeList tl = df->getTypes(); + for (int i = 0; i < tl.size(); i++) + { + cout << "Type: " << tl[i].getURI()<< "#" << tl[i].getName() << endl; + PropertyList pl = tl[i].getProperties(); + for (int j = 0; j < pl.size(); j++) + { + cout << "\tProperty: " << pl[j].getName() + << " type: " <<pl[j].getType().getURI()<<"#"<<pl[j].getType().getName()<< endl; + + } + } + + } + + + } // End namespace sca +} // End namespace tuscany + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Utils.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Utils.h new file mode 100644 index 0000000000..184bcd3dad --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/util/Utils.h @@ -0,0 +1,61 @@ +/* + * + * 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_util_utils_h +#define tuscany_sca_util_utils_h +#include <string> +using std::string; +#include "commonj/sdo/SDO.h" + +#include "osoa/sca/export.h" + +namespace tuscany +{ + namespace sca + { + /** + * Utility methods to parse strings and provide debugging information. + */ + class Utils { + + public: + static void tokeniseUri(const string& uri, string& token1, string& token2); + static void tokeniseQName(const string& sdoname, string& uri, string& name); + static void tokeniseString( + const string& separator, + const string& str, + string& token1, + string& token2); + + static void rTokeniseString( + const string& separator, + const string& str, + string& token1, + string& token2); + + SCA_API static void printDO(commonj::sdo::DataObjectPtr dataObject, int increment=0); + SCA_API static void printTypes(commonj::sdo::DataFactoryPtr df); + + private: + static void tabs(int increment=0); + }; + + } // End namespace sca +} // End namespace tuscany +#endif // tuscany_sca_util_utils_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/ws/EntryPointProxy.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/ws/EntryPointProxy.cpp new file mode 100644 index 0000000000..dcf974623d --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/ws/EntryPointProxy.cpp @@ -0,0 +1,677 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * 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. + */ +#include "tuscany/sca/ws/EntryPointProxy.h" + +using namespace tuscany::sca; + +#include "tuscany/sca/util/Exceptions.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/core/SCARuntime.h" + +#include "tuscany/sca/model/WSBinding.h" + +#include "commonj/sdo/SDO.h" +using namespace commonj::sdo; + +using namespace tuscany::sca::ws; + + +// Singleton pattern +EntryPointProxy* EntryPointProxy::entryPointProxyInstance = new EntryPointProxy(); + +EntryPointProxy* EntryPointProxy::getInstance() +{ + return entryPointProxyInstance; +} + +EntryPointProxy::EntryPointProxy() +{ + LOGENTRY(1,"EntryPointProxy::constructor"); + tuscanyRuntime = NULL; + scaEntryPoint = NULL; + entryPointName = ""; + systemRoot = ""; + moduleComponent = ""; + LOGEXIT(1,"EntryPointProxy::constructor"); +} + +EntryPointProxy::~EntryPointProxy() +{ + LOGENTRY(1,"EntryPointProxy::destructor"); + + if(tuscanyRuntime != NULL) + { + tuscanyRuntime->stop(); + delete tuscanyRuntime; + tuscanyRuntime = NULL; + } + if(scaEntryPoint != NULL) + { + delete scaEntryPoint; + } + LOGEXIT(1,"EntryPointProxy::destructor"); +} + +void EntryPointProxy::init(const char* systemRootPath, const char* fullEntryPointName) +{ + LOGENTRY(1,"EntryPointProxy::init"); + + try + { + + // fullEntryPointName is of the form "subsystem name"/"module component name"/"entry point name" + // Get the "subsystem name"/"module component name" part for setDefaultModuleComponent + // Keep the "entry point name" part for use in invoke + string subsystemAndComponentName, epName; + Utils::rTokeniseString("/", fullEntryPointName, subsystemAndComponentName, epName); + + bool newInitParams = false; + + if(systemRoot.length() != 0 && systemRoot != systemRootPath) + { + systemRoot = systemRootPath; + newInitParams = true; + } + + if(moduleComponent.length() != 0 && moduleComponent != subsystemAndComponentName) + { + moduleComponent = subsystemAndComponentName; + newInitParams = true; + } + + if(entryPointName.length() != 0 && entryPointName != epName) + { + entryPointName = epName; + newInitParams = true; + } + + + if(tuscanyRuntime == NULL) + { + LOGINFO(4, "Creating new TuscanyRuntime"); + moduleComponent = subsystemAndComponentName; + systemRoot = systemRootPath; + entryPointName = epName; + tuscanyRuntime = new TuscanyRuntime(moduleComponent, systemRoot); + tuscanyRuntime->start(); + } + else if(tuscanyRuntime != NULL && newInitParams) + { + LOGINFO(4, "Restarting TuscanyRuntime with new SystemRoot or DefaultModule"); + tuscanyRuntime->stop(); + tuscanyRuntime->setDefaultModuleComponent(moduleComponent); + tuscanyRuntime->setSystemRoot(systemRoot); + tuscanyRuntime->start(); + } + + if(scaEntryPoint == NULL) + { + scaEntryPoint = new SCAEntryPoint(fullEntryPointName); + } + else + { + if(newInitParams) + { + delete scaEntryPoint; + scaEntryPoint = NULL; + scaEntryPoint = new SCAEntryPoint(fullEntryPointName); + } + } + } + catch(SystemConfigurationException &ex) + { + LOGERROR_1(0, "SystemConfigurationException has been caught: %s\n", ex.getMessageText()); + scaEntryPoint = 0; + } + catch(ServiceRuntimeException &ex) + { + LOGERROR_2(0, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText()); + scaEntryPoint = 0; + } + LOGEXIT(1,"EntryPointProxy::init"); +} + +DataFactoryPtr EntryPointProxy::getDataFactory() +{ + if (scaEntryPoint == 0) return 0; + return scaEntryPoint->getDataFactory(); +} + +/// +/// This method will be called when an EntryPoint needs to be invoked. +/// +DataObjectPtr EntryPointProxy::invoke(const char* operationName, DataObjectPtr inputDataObject) +{ + LOGENTRY(1,"EntryPointProxy::invoke"); + + if (scaEntryPoint == 0) + { + LOGINFO(4, "EntryPointProxy has not got an sca EntryPoint\n"); + return NULL; + } + + DataFactoryPtr dataFactoryPtr = scaEntryPoint->getDataFactory(); + + DataObjectPtr outputDataObject = NULL; + SCARuntime* runtime = SCARuntime::getInstance(); + + Module* module = runtime->getCurrentModule(); + + EntryPoint* entryPoint = module->findEntryPoint(entryPointName); + + Binding* binding = entryPoint->getBinding(); + if(binding->getBindingType() == Binding::SCA) + { + LOGINFO_1(4, "EntryPointProxy has got SCA binding: %s\n", binding->getUri().c_str()); + LOGERROR(0, "EntryPoints with SCA bindings are not yet supported"); + return NULL; + } + else if(binding->getBindingType() == Binding::WS) + { + WSBinding* wsBinding = (WSBinding*) binding; + + string wsdlNamespace = wsBinding->getWSDLNamespaceURL(); + string wsdlPort = wsBinding->getPortName(); + string wsdlService = wsBinding->getServiceName(); + + Wsdl* wsdl = module->findWsdl(wsdlNamespace); + if (wsdl == 0) + { + LOGINFO_1(0, "WSDL description %s not found\n", wsdlNamespace.c_str()); + return NULL; + } + + WsdlOperation operation; + try + { + operation = wsdl->findOperation(wsdlService, wsdlPort, operationName); + } + catch(SystemConfigurationException &ex) + { + LOGERROR_1(0, "SystemConfigurationException has been caught: %s\n", ex.getMessageText()); + return NULL; + } + + LOGINFO_2(4, "EntryPointProxy has got WsdlOperation with inputType: %s#%s", + operation.getInputTypeUri().c_str(), + operation.getInputTypeName().c_str()); + LOGINFO_2(4, "EntryPointProxy has got WsdlOperation with outputType: %s#%s", + operation.getOutputTypeUri().c_str(), + operation.getOutputTypeName().c_str()); + LOGINFO_2(4, "EntryPointProxy has got WsdlOperation with documentStyle=%d and encoded=%d", + operation.isDocumentStyle(), + operation.isEncoded()); + + if(operation.isDocumentStyle()) + { + // Document style + outputDataObject = dataFactoryPtr->create(operation.getOutputTypeUri().c_str(), operation.getOutputTypeName().c_str()); + + //printf("outputDataObject %s#%s\n", outputDataObject->getType().getURI(), outputDataObject->getType().getName()); + //Utils::printDO(outputDataObject); + } + else + { + // RPC style + LOGERROR(0, "EntryPoints with RPC style WSDL Operations are not yet supported"); + return NULL; + } + } + + // Create new Operation object and set parameters and return value + Operation operation(operationName); + + // Go through input data object to set the operation parameters + PropertyList pl = inputDataObject->getInstanceProperties(); + + for(int i=0; i<pl.size(); i++) + { + const char* name = pl[i].getName(); + + switch (pl[i].getTypeEnum()) + { + case Type::BooleanType: + { + bool* boolData = new bool; + *boolData = inputDataObject->getBoolean(pl[i]); + //printf("inputDataObject has BooleanType named %s with value %d\n", name, boolData); + operation.addParameter(boolData); + } + break; + case Type::ByteType: + { + char* byteData = new char; + //printf("inputDataObject has ByteType named %s\n", name); + *byteData = inputDataObject->getByte(pl[i]); + operation.addParameter(byteData); + } + break; + case Type::BytesType: + { + int len = inputDataObject->getLength(pl[i]); + char* bytesData = new char[len+1]; + int bytesWritten = inputDataObject->getBytes(pl[i], bytesData, len); + // Ensure the bytes end with the null char. Not sure if this is neccessary + if(bytesWritten <= len) + { + bytesData[bytesWritten] = 0; + } + else + { + bytesData[len] = 0; + } + //printf("inputDataObject has BytesType named %s with length %d\n", name, bytesWritten); + operation.addParameter(&bytesData); + } + break; + case Type::CharacterType: + { + // This code should work but won't be used as there is no mapping from an XSD type to the SDO CharacterType + wchar_t* charData = new wchar_t; + //printf("inputDataObject has CharacterType named %s\n", name); + *charData = inputDataObject->getCharacter(pl[i]); + operation.addParameter(charData); + } + break; + case Type::DoubleType: + { + long double* doubleData = new long double; + *doubleData = inputDataObject->getDouble(pl[i]); + //printf("inputDataObject has DoubleType named %s\n", name); + operation.addParameter(doubleData); + } + break; + case Type::FloatType: + { + float* floatData = new float; + *floatData = inputDataObject->getFloat(pl[i]); + //printf("inputDataObject has FloatType named %s with value %f\n", name, *floatData); + operation.addParameter(floatData); + } + break; + case Type::IntegerType: + { + long* intData = new long; + //printf("inputDataObject has IntegerType named %s\n", name); + *intData = inputDataObject->getInteger(pl[i]); + operation.addParameter(intData); + } + break; + case Type::ShortType: + { + short* shortData = new short; + //printf("inputDataObject has ShortType named %s\n", name); + *shortData = inputDataObject->getShort(pl[i]); + operation.addParameter(shortData); + } + break; + case Type::StringType: + { + const char* stringData = inputDataObject->getCString(pl[i]); + //printf("inputDataObject has StringType named %s with value %s\n", name, stringData); + operation.addParameter(&stringData); + } + break; + case Type::DataObjectType: + { + DataObjectPtr dataObjectData = inputDataObject->getDataObject(pl[i]); + //printf("inputDataObject has DataObjectType named %s (#%d)\n", name, dataObjectData); + + if(!dataObjectData) + { + LOGINFO_1(4, "SDO DataObject parameter named %s was null", name); + } + operation.addParameter(&dataObjectData); + } + break; + case Type::OpenDataObjectType: + { + /* + * This code deals with xsd:any element parameters + * Get each element as a DataObject and add in to the parameter list + */ + + //printf("inputDataObject has OpenDataObjectType named %s\n", name); + DataObjectList& dataObjectList = inputDataObject->getList(pl[i]); + + for(int j=0; j<dataObjectList.size(); j++) + { + DataObjectPtr dataObjectData = dataObjectList[j]; + if(!dataObjectData) + { + LOGINFO_2(4, "SDO OpenDataObject parameter named %s[%d] was null", name, j); + } + operation.addParameter(&dataObjectData); + //Utils::printDO(dataObjectData); + } + } + break; + case Type::DateType: + LOGERROR_1(0, "SDO DateType parameters are not yet supported (%s)", name); + return NULL; + case Type::LongType: + LOGERROR_1(0, "SDO LongType (int64_t) parameters are not yet supported (%s)", name); + return NULL; + break; + case Type::UriType: + LOGERROR_1(0, "SDO UriType parameters are not yet supported (%s)", name); + return NULL; + break; + case Type::BigDecimalType: + LOGERROR_1(0, "SDO BigDecimalType parameters are not yet supported (%s)", name); + return NULL; + break; + case Type::BigIntegerType: + LOGERROR_1(0, "SDO BigIntegerType parameters are not yet supported (%s)", name); + return NULL; + break; + default: + LOGERROR_1(0, "Unknown SDO type parameter named %s has been found. Unknown types are not yet supported", name); + return NULL; + } + } + + // Now go through outputDataObject to set the return value + pl = outputDataObject->getInstanceProperties(); + + // Set up the possible return value pointers + bool boolData = 0; + char byteData = 0; + wchar_t charData = 0; + long double doubleData = 0; + float floatData = 0; + long intData = 0; + short shortData = 0; + const char* stringData; + DataObjectPtr dataObjectData; + + + // There should only be one return value, but go through any list anyway? + if(pl.size() > 1) + { + LOGINFO(4, "More than one return value is defined in the WSDL, just defining the first"); + } + else if(pl.size() == 0) + { + if(outputDataObject->getType().isOpenType() && outputDataObject->getType().isDataObjectType()) + { + /* + * This code deals with returning xsd:any elements + * Return as a DataObject set within the outputDataObject + */ + + // An OpenDataObject for the data to return in + operation.setReturnValue(&dataObjectData); + } + else + { + LOGINFO(4, "No return values are defined in the WSDL"); + } + + } + + if(pl.size() > 0) + { + const char* name = pl[0].getName(); + + switch (pl[0].getTypeEnum()) + { + case Type::BooleanType: + { + //printf("outputDataObject has BooleanType named %s\n", name); + operation.setReturnValue(&boolData); + } + break; + case Type::ByteType: + { + //printf("outputDataObject has ByteType named %s\n", name); + operation.setReturnValue(&byteData); + } + break; + case Type::CharacterType: + { + //printf("outputDataObject has CharacterType named %s\n", name); + operation.setReturnValue(&charData); + } + break; + case Type::DoubleType: + { + //printf("outputDataObject has DoubleType named %s\n", name); + operation.setReturnValue((long double*) &doubleData); + } + break; + case Type::FloatType: + { + //printf("outputDataObject has FloatType named %s\n", name); + operation.setReturnValue(&floatData); + } + break; + case Type::IntegerType: + { + //printf("outputDataObject has IntegerType named %s\n", name); + operation.setReturnValue(&intData); + } + break; + case Type::ShortType: + { + //printf("outputDataObject has ShortType named %s\n", name); + operation.setReturnValue(&shortData); + } + break; + case Type::StringType: + case Type::BytesType: + { + //printf("outputDataObject has StringType or BytesType named %s\n", name); + operation.setReturnValue((const char**) &stringData); + } + break; + case Type::DataObjectType: + { + // printf("outputDataObject has DataObjectType named %s with type %s # %s\n", name, pl[0].getType().getURI(), pl[0].getType().getName()); + operation.setReturnValue(&dataObjectData); + } + break; + case Type::DateType: + LOGERROR_1(0, "SDO DateType return values are not yet supported (%s)", name); + return NULL; + case Type::LongType: + LOGERROR_1(0, "SDO LongType (int64_t) return values are not yet supported (%s)", name); + return NULL; + case Type::UriType: + LOGERROR_1(0, "SDO UriType return values are not yet supported (%s)", name); + return NULL; + case Type::BigDecimalType: + LOGERROR_1(0, "SDO BigDecimalType return values are not yet supported (%s)", name); + return NULL; + case Type::BigIntegerType: + LOGERROR_1(0, "SDO BigIntegerType return values are not yet supported (%s)", name); + return NULL; + default: + LOGERROR_1(0, "Unknown SDO type return value named %s has been found. Unknown types are not yet supported", name); + return NULL; + } + } + + try + { + // Call into the wired module + scaEntryPoint->invoke(operation); + + // Set the data in the outputDataObject to be returned + setOutputData(operation, outputDataObject); + } + catch(SDORuntimeException &ex) + { + // TODO: Return more error information than just a null DataObject + LOGERROR_2(0, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText()); + return NULL; + } + catch(ServiceRuntimeException &ex) + { + // TODO: Return more error information than just a null DataObject + LOGERROR_2(0, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText()); + return NULL; + } + + LOGEXIT(1,"EntryPointProxy::invoke"); + + return outputDataObject; +} + + +void EntryPointProxy::setOutputData(Operation operation, DataObjectPtr outputDataObject) +{ + // Go through data object to set the return value + PropertyList pl = outputDataObject->getInstanceProperties(); + + if(pl.size() == 0) + { + if(outputDataObject->getType().isOpenType() && outputDataObject->getType().isDataObjectType()) + { + /* + * This code deals with returning xsd:any elements + * Return as a DataObject set within the outputDataObject + */ + + DataObjectPtr* dataObjectData = (DataObjectPtr*) operation.getReturnValue(); + //Utils::printDO(*dataObjectData); + + // Need to provide a name for the dataobject being returned, use the containment property name if there is one. + const char* rootName = "OpenDataObject"; + try + { + const Property& prop = (*dataObjectData)->getContainmentProperty(); + rootName = prop.getName(); + (*dataObjectData)->detach(); + } + catch(SDOPropertyNotFoundException&) + { + // DataObject has no containment property - use default rootName + } + outputDataObject->setDataObject(rootName, *dataObjectData); + } + else + { + LOGINFO(4, "No return values are defined in the WSDL"); + } + + } + + // Should only be one return value.. This goes through all return values + for(int i=0; i<pl.size(); i++) + { + const char* name = pl[i].getName(); + + switch (pl[i].getTypeEnum()) + { + case Type::BooleanType: + { + bool* boolData = (bool*)operation.getReturnValue(); + //printf("outputDataObject has BooleanType named %s with value %d\n", name, *boolData); + outputDataObject->setBoolean(pl[i], *boolData); + } + break; + case Type::ByteType: + { + char* byteData = (char*) operation.getReturnValue(); + //printf("outputDataObject has ByteType named %s with value %c (#%d)\n", name, *byteData, *byteData); + outputDataObject->setByte(pl[i], *byteData); + } + break; + case Type::BytesType: + { + const char** bytesData = (const char**) operation.getReturnValue(); + // TODO This looks for the first NULL byte - this may not be the full length of the data... + int len = 0; + while((*bytesData)[len] != 0) + { + len++; + } + //printf("outputDataObject has BytesType named %s with value %s and length %d\n", name, *bytesData, len); + outputDataObject->setBytes(pl[i], *bytesData, len); + } + break; + case Type::CharacterType: + { + wchar_t* charData = (wchar_t*) operation.getReturnValue(); + //printf("outputDataObject has CharacterType named %s with value %s\n", name, charData); + outputDataObject->setCharacter(pl[i], *charData); + } + break; + case Type::DoubleType: + { + long double* doubleData = (long double*) operation.getReturnValue(); + //printf("outputDataObject has DoubleType named %s with value %f\n", name, *doubleData); + outputDataObject->setDouble(pl[i], *doubleData); + } + break; + case Type::FloatType: + { + float* floatData = (float*) operation.getReturnValue(); + //printf("outputDataObject has FloatType named %s with value %f \n", name, *floatData); + outputDataObject->setFloat(pl[i], *floatData); + } + break; + case Type::IntegerType: + { + long* intData = (long*) operation.getReturnValue(); + //printf("outputDataObject has IntegerType named %s with value %d\n", name, *intData); + outputDataObject->setInteger(pl[i], *intData); + } + break; + case Type::ShortType: + { + short* shortData = (short*) operation.getReturnValue(); + //printf("outputDataObject has ShortType named %s with value %d\n", name, *shortData); + outputDataObject->setShort(pl[i], *shortData); + } + break; + case Type::StringType: + { + const char** stringData = (const char**) operation.getReturnValue(); + //printf("outputDataObject has StringType named %s with value %s\n", name, *stringData); + outputDataObject->setCString(pl[i], *stringData); + } + break; + case Type::DataObjectType: + { + DataObjectPtr* dataObjectData = (DataObjectPtr*) operation.getReturnValue(); + //printf("outputDataObject has DataObjectType named %s with value (%d)\n", name, (*dataObjectData)); + outputDataObject->setDataObject(pl[i], *dataObjectData); + } + break; + case Type::DateType: + LOGERROR_1(0, "SDO DateType return values are not yet supported (%s)", name); + break; + case Type::LongType: + LOGERROR_1(0, "SDO LongType (int64_t) return values are not yet supported (%s)", name); + break; + case Type::UriType: + LOGERROR_1(0, "SDO UriType return values are not yet supported (%s)", name); + break; + case Type::BigDecimalType: + LOGERROR_1(0, "SDO BigDecimalType return values are not yet supported (%s)", name); + break; + case Type::BigIntegerType: + LOGERROR_1(0, "SDO BigIntegerType return values are not yet supported (%s)", name); + break; + default: + LOGERROR_1(0, "Unknown SDO type return value named %s has been found. Unknown types are not yet supported", name); + } + } +} + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/ws/EntryPointProxy.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/ws/EntryPointProxy.h new file mode 100644 index 0000000000..959a5ee07c --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/ws/EntryPointProxy.h @@ -0,0 +1,63 @@ +/* + * + * Copyright 2006 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. + */ + +#ifndef tuscany_sca_ws_entrypointproxy_h +#define tuscany_sca_ws_entrypointproxy_h + +#include "osoa/sca/export.h" + +#include "commonj/sdo/SDO.h" +using commonj::sdo::DataObjectPtr; + +#include "tuscany/sca/core/SCAEntryPoint.h" +using tuscany::sca::SCAEntryPoint; + +#include "tuscany/sca/core/TuscanyRuntime.h" +using tuscany::sca::TuscanyRuntime; + +#include <string> +using std::string; + +namespace tuscany +{ + namespace sca + { + namespace ws + { + class SCA_API EntryPointProxy + { + public: + static EntryPointProxy* getInstance(); + virtual ~EntryPointProxy(); + virtual void init(const char* systemRoot, const char* entryPointName); + virtual DataFactoryPtr getDataFactory(void); + virtual DataObjectPtr invoke(const char* operationName, DataObjectPtr inputDataObject); + private: + EntryPointProxy(); + static EntryPointProxy* entryPointProxyInstance; + virtual void setOutputData(Operation operation, DataObjectPtr outputDataObject); + string entryPointName; + string systemRoot; + string moduleComponent; + SCAEntryPoint* scaEntryPoint; + TuscanyRuntime* tuscanyRuntime; + }; + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_ws_entrypointproxy_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.h new file mode 100644 index 0000000000..713c575735 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/src/tuscany/sca/ws/WSServiceWrapper.h @@ -0,0 +1,47 @@ +/* + * + * 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_ws_wsservicewrapper_h +#define tuscany_sca_ws_wsservicewrapper_h +#include "osoa/sca/export.h" + +#include "tuscany/sca/core/ExternalServiceWrapper.h" +#include "tuscany/sca/model/ExternalService.h" +#include "tuscany/sca/core/Operation.h" + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + class SCA_API WSServiceWrapper : public tuscany::sca::ExternalServiceWrapper + { + public: + WSServiceWrapper(tuscany::sca::model::WireTarget* target); + virtual ~WSServiceWrapper(); + + virtual void invoke(Operation& operation); + }; + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_ws_wsservicewrapper_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.cdtbuild b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.cdtbuild new file mode 100644 index 0000000000..ed308ead8d --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.cdtbuild @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?fileVersion 3.0.0?>
+
+<ManagedProjectBuildInfo>
+<project id="tuscany_sca_test_CustomerInfo.cdt.managedbuild.target.gnu.so.1305856867" name="Shared Library (Gnu)" projectType="cdt.managedbuild.target.gnu.so">
+<configuration artifactExtension="so" artifactName="CustomerInfo" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.so.debug.180210457" name="Debug" parent="cdt.managedbuild.config.gnu.so.debug">
+<toolChain id="cdt.managedbuild.toolchain.gnu.so.debug.150489083" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.so.debug">
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.compiler.so.debug.744339895" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.debug"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug.773936698" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug">
+<option id="gnu.cpp.compiler.option.preprocessor.def.1937348866" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+<listOptionValue builtIn="false" value="_DEBUG"/>
+</option>
+<option id="gnu.cpp.compiler.option.include.paths.1481017815" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/src"/>
+<listOptionValue builtIn="false" value="${SDO4CPP}/include"/>
+</option>
+</tool>
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.linker.so.debug.2091259285" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.debug"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.so.debug.509296678" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.debug"/>
+<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.so.debug.187343736" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.debug"/>
+<macros/>
+</toolChain>
+</configuration>
+<configuration artifactExtension="so" artifactName="CustomerInfo" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.so.release.954607388" name="Release" parent="cdt.managedbuild.config.gnu.so.release">
+<toolChain id="cdt.managedbuild.toolchain.gnu.so.release.1899157892" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.so.release">
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.compiler.so.release.1905763267" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.release"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.so.release.91975924" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.release">
+<option id="gnu.cpp.compiler.option.include.paths.695258843" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/src"/>
+<listOptionValue builtIn="false" value="${SDO4CPP}/include"/>
+</option>
+</tool>
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.linker.so.release.749931234" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.release"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.so.release.636362934" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.release"/>
+<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.so.release.1971799783" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.release"/>
+<macros/>
+</toolChain>
+</configuration>
+<macros/>
+</project>
+</ManagedProjectBuildInfo>
diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.cdtproject b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.cdtproject new file mode 100644 index 0000000000..48a12e6664 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.cdtproject @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse-cdt version="2.0"?>
+
+<cdtproject id="org.eclipse.cdt.managedbuilder.core.managedMake">
+<extension id="org.eclipse.cdt.managedbuilder.core.ManagedBuildManager" point="org.eclipse.cdt.core.ScannerInfoProvider"/>
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>
+<data>
+<item id="org.eclipse.cdt.core.pathentry">
+<pathentry kind="src" path=""/>
+<pathentry kind="out" path=""/>
+<pathentry kind="con" path="org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"/>
+</item>
+</data>
+</cdtproject>
diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.project b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.project new file mode 100644 index 0000000000..60a0a75176 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.project @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>tuscany_sca_test_CustomerInfo</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + </natures> +</projectDescription> diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 0000000000..691a33706a --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,9 @@ +#Tue Nov 29 15:05:50 GMT 2005
+eclipse.preferences.version=1
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.so.debug.180210457=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.so.release.954607388=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.so.debug.180210457=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.so.release.954607388=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/project=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.so.debug.180210457=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.so.release.954607388=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfo.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfo.h new file mode 100644 index 0000000000..6372a5a45a --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfo.h @@ -0,0 +1,30 @@ +/* + * + * 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 CustomerInfo_h +#define CustomerInfo_h + +class CustomerInfo +{ +public: + virtual const char* getCustomerInformation(const char* customerID) = 0; + +}; + +#endif diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl.cpp new file mode 100644 index 0000000000..371ab74f14 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl.cpp @@ -0,0 +1,80 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "CustomerInfoImpl.h" +#include <ostream> +#include <string.h> +#include "osoa/sca/sca.h" +#include "commonj/sdo/DataObjectInstance.h" +using namespace osoa::sca; +using namespace commonj::sdo; +using namespace std; + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CustomerInfoImpl::CustomerInfoImpl() +{ + cout << "Construct CustomerInfoImpl" << endl; + +} + +CustomerInfoImpl::~CustomerInfoImpl() +{ + cout << "Destroy CustomerInfoImpl" << endl; +} + +////////////////////////////////////////////////////////////////////// +// Other methods +////////////////////////////////////////////////////////////////////// +const char* CustomerInfoImpl::getCustomerInformation(const char* customerID) +{ + cout << "In getCustomerInformation with customerid: " << customerID << endl; + + + + ComponentContext myContext = ComponentContext::getCurrent(); + + DataObjectInstance properties = myContext.getProperties(); + DataObjectInstance props2 = properties; + if (properties) + { + const char* fredVal = properties->getCString("Fred"); + cout << "Property Fred value: " << fredVal <<endl; + + + DataObjectList& joeList = properties->getList("Joe"); + for (int i=0; i<joeList.size();i++) + { + cout << "Property Joe value " << i << ": " << joeList.getInteger(i) <<endl; + } + } + + if (!strcmp("12345", customerID)) + { + return "xzderg"; + } + else + { + throw "Wobbler"; + } + + +} diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl.h new file mode 100644 index 0000000000..7f70664f68 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl.h @@ -0,0 +1,36 @@ +/* + * + * 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 CustomerInfoImpl_h +#define CustomerInfoImpl_h + +#include "CustomerInfo.h" + + + +class CustomerInfoImpl : public CustomerInfo +{ +public: + CustomerInfoImpl(); + virtual ~CustomerInfoImpl(); + virtual const char* getCustomerInformation(const char* customerID); + +}; + +#endif diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Proxy.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Proxy.cpp new file mode 100644 index 0000000000..e6cb3b3426 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Proxy.cpp @@ -0,0 +1,63 @@ +/* + * 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. + */ + +#include "CustomerInfoImpl_CustomerInfoService_Proxy.h" + +#include "osoa/sca/sca.h" +using namespace osoa::sca; +using namespace tuscany::sca; + +extern "C" +{ + + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + CustomerInfoImpl_CustomerInfoService_Proxy* CustomerInfoImpl_CustomerInfoService_Proxy_Factory(ServiceWrapper* target) + { + return new CustomerInfoImpl_CustomerInfoService_Proxy(target); + } + + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void CustomerInfoImpl_CustomerInfoService_Proxy_Destructor(void* proxy) + { + delete (CustomerInfoImpl_CustomerInfoService_Proxy*)proxy; + } +} + +CustomerInfoImpl_CustomerInfoService_Proxy::CustomerInfoImpl_CustomerInfoService_Proxy(ServiceWrapper* targ) : target(targ) +{ +} + +CustomerInfoImpl_CustomerInfoService_Proxy::~CustomerInfoImpl_CustomerInfoService_Proxy() +{ + if (target) + delete target; +} + +const char* CustomerInfoImpl_CustomerInfoService_Proxy::getCustomerInformation(const char* arg0) +{ + Operation operation("getCustomerInformation"); + operation.addParameter(&arg0); + const char* ret; + operation.setReturnValue(&ret); + target->invoke(operation); + return ret; +} + + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Proxy.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Proxy.h new file mode 100644 index 0000000000..7173dacd34 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Proxy.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#ifndef CustomerInfoImpl_CustomerInfoService_Proxy_h +#define CustomerInfoImpl_CustomerInfoService_Proxy_h + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "CustomerInfo.h" +#include "tuscany/sca/core/ServiceWrapper.h" + +class CustomerInfoImpl_CustomerInfoService_Proxy : public CustomerInfo +{ +public: + CustomerInfoImpl_CustomerInfoService_Proxy(tuscany::sca::ServiceWrapper*); + virtual ~CustomerInfoImpl_CustomerInfoService_Proxy(); + virtual const char* getCustomerInformation(const char* customerID); +private: + tuscany::sca::ServiceWrapper* target; +}; + +#endif // CustomerInfoImpl_CustomerInfoService_Proxy_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Wrapper.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Wrapper.cpp new file mode 100644 index 0000000000..1f28bf5715 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Wrapper.cpp @@ -0,0 +1,72 @@ +/* + * 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. + */ + +#include "CustomerInfoImpl_CustomerInfoService_Wrapper.h" + +#include "osoa/sca/sca.h" +using namespace osoa::sca; +using namespace tuscany::sca; + + + +extern "C" +{ + + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + CustomerInfoImpl_CustomerInfoService_Wrapper* CustomerInfoImpl_CustomerInfoService_Wrapper_Factory(tuscany::sca::model::Service* target) + { + return new CustomerInfoImpl_CustomerInfoService_Wrapper(target); + } +} + +CustomerInfoImpl_CustomerInfoService_Wrapper::CustomerInfoImpl_CustomerInfoService_Wrapper(Service* target) : ComponentServiceWrapper(target) +{ + impl = (CustomerInfoImpl*)getImplementation(); +} + +CustomerInfoImpl_CustomerInfoService_Wrapper::~CustomerInfoImpl_CustomerInfoService_Wrapper() +{ + releaseImplementation(); +} + +void* CustomerInfoImpl_CustomerInfoService_Wrapper::newImplementation() +{ + return new CustomerInfoImpl; +} + +void CustomerInfoImpl_CustomerInfoService_Wrapper::deleteImplementation() +{ + delete impl; +} + +void CustomerInfoImpl_CustomerInfoService_Wrapper::invokeService(Operation& operation) +{ + const string& operationName = operation.getName(); + + if (operationName == "getCustomerInformation") + { + const char* p0 = *(const char**)operation.getParameterValue(0); + *(const char**)operation.getReturnValue() = impl->getCustomerInformation(p0); + return; + } + + + throw ServiceRuntimeException("Invalid operation"); + +} + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Wrapper.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Wrapper.h new file mode 100644 index 0000000000..5fb82c4295 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/CustomerInfoImpl_CustomerInfoService_Wrapper.h @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#ifndef CustomerInfoImpl_CustomerInfoService_Wrapper_h +#define CustomerInfoImpl_CustomerInfoService_Wrapper_h + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "CustomerInfoImpl.h" +#include "tuscany/sca/core/ComponentServiceWrapper.h" + +class CustomerInfoImpl_CustomerInfoService_Wrapper : public tuscany::sca::ComponentServiceWrapper +{ +public: + CustomerInfoImpl_CustomerInfoService_Wrapper(tuscany::sca::model::Service* target); + virtual ~CustomerInfoImpl_CustomerInfoService_Wrapper(); + virtual void invokeService(tuscany::sca::Operation& operation); + virtual void* newImplementation(); + virtual void deleteImplementation(); +private: + CustomerInfoImpl* impl; +}; + +#endif // CustomerInfoImpl_CustomerInfoService_Wrapper_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/Makefile.am new file mode 100644 index 0000000000..baf839d51a --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/CustomerInfo/Makefile.am @@ -0,0 +1,15 @@ +lib_LTLIBRARIES = libCustomerInfo.la + +libCustomerInfo_la_SOURCES = \ +CustomerInfoImpl.cpp \ +CustomerInfoImpl_CustomerInfoService_Proxy.cpp \ +CustomerInfoImpl_CustomerInfoService_Wrapper.cpp + +noinst_HEADERS = *.h + +libCustomerInfo_la_LIBADD = + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include + +install:
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/Makefile.am new file mode 100644 index 0000000000..52ea80e3fb --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/Makefile.am @@ -0,0 +1,28 @@ +SUBDIRS = CustomerInfo MyValue src + +EXTRA_DIST = testSCASystem/subsystems \ +testSCASystem/modules/MyValueServiceModule/sca.module \ +testSCASystem/modules/MyValueServiceModule/*.fragment \ +testSCASystem/modules/MyValueServiceModule/*.componentType \ +testSCASystem/modules/MyValueServiceModule/*.wsdl \ +testSCASystem/modules/MyValueServiceModule/*.xsd \ +testSCASystem/modules/MyValueServiceModule/*.config + + +BUILT_SOURCES = scagen + +scagen: + cp ./MyValue/MyValue.h ./testSCASystem/modules/MyValueServiceModule + cp ./MyValue/MyValueImpl.h ./testSCASystem/modules/MyValueServiceModule + cp ./MyValue/StockQuoteService.h ./testSCASystem/modules/MyValueServiceModule + cp ./CustomerInfo/CustomerInfo.h ./testSCASystem/modules/MyValueServiceModule + cp ./CustomerInfo/CustomerInfoImpl.h ./testSCASystem/modules/MyValueServiceModule + java -jar $(top_builddir)/tools/scagen/bld/scagen.jar -dir testSCASystem/modules/MyValueServiceModule -output tmp + cp tmp/CustomerInfoImpl*.* CustomerInfo + cp tmp/MyValueImpl*.* MyValue + + +install-exec-local: + cp CustomerInfo/.libs/libCustomerInfo.so testSCASystem/modules/MyValueServiceModule + cp MyValue/.libs/libMyValue.so testSCASystem/modules/MyValueServiceModule +
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.cdtbuild b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.cdtbuild new file mode 100644 index 0000000000..acc65c20f2 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.cdtbuild @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?fileVersion 3.0.0?>
+
+<ManagedProjectBuildInfo>
+<project id="tuscany_sca_test_MyValue.cdt.managedbuild.target.gnu.so.757075771" name="Shared Library (Gnu)" projectType="cdt.managedbuild.target.gnu.so">
+<configuration artifactExtension="so" artifactName="MyValue" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.so.debug.903609302" name="Debug" parent="cdt.managedbuild.config.gnu.so.debug">
+<toolChain id="cdt.managedbuild.toolchain.gnu.so.debug.255326897" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.so.debug">
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.compiler.so.debug.1055337069" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.debug"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug.1856329612" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug">
+<option id="gnu.cpp.compiler.option.preprocessor.def.1031467482" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+<listOptionValue builtIn="false" value="_DEBUG"/>
+</option>
+<option id="gnu.cpp.compiler.option.include.paths.571240659" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/src"/>
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/test/CustomerInfo"/>
+<listOptionValue builtIn="false" value="${SDO4CPP}/include"/>
+</option>
+</tool>
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.linker.so.debug.1169623816" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.debug"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.so.debug.578216644" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.debug"/>
+<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.so.debug.1431997590" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.debug"/>
+<macros/>
+</toolChain>
+</configuration>
+<configuration artifactExtension="so" artifactName="MyValue" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.so.release.1558347965" name="Release" parent="cdt.managedbuild.config.gnu.so.release">
+<toolChain id="cdt.managedbuild.toolchain.gnu.so.release.957726846" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.so.release">
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.compiler.so.release.625045304" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.release"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.so.release.1998422811" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.release">
+<option id="gnu.cpp.compiler.option.include.paths.687314264" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/src"/>
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/test/CustomerInfo"/>
+<listOptionValue builtIn="false" value="${SDO4CPP}/include"/>
+</option>
+</tool>
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.linker.so.release.1598091246" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.release"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.so.release.1373242294" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.release"/>
+<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.so.release.1820024298" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.release"/>
+<macros/>
+</toolChain>
+</configuration>
+<macros/>
+</project>
+</ManagedProjectBuildInfo>
diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.cdtproject b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.cdtproject new file mode 100644 index 0000000000..48a12e6664 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.cdtproject @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse-cdt version="2.0"?>
+
+<cdtproject id="org.eclipse.cdt.managedbuilder.core.managedMake">
+<extension id="org.eclipse.cdt.managedbuilder.core.ManagedBuildManager" point="org.eclipse.cdt.core.ScannerInfoProvider"/>
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>
+<data>
+<item id="org.eclipse.cdt.core.pathentry">
+<pathentry kind="src" path=""/>
+<pathentry kind="out" path=""/>
+<pathentry kind="con" path="org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"/>
+</item>
+</data>
+</cdtproject>
diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.project b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.project new file mode 100644 index 0000000000..113442bfd8 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.project @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>tuscany_sca_test_MyValue</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + </natures> +</projectDescription> diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 0000000000..4c585d5bb1 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,9 @@ +#Tue Nov 29 15:11:39 GMT 2005
+eclipse.preferences.version=1
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.so.debug.903609302=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.so.release.1558347965=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.so.debug.903609302=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.so.release.1558347965=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/project=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.so.debug.903609302=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.so.release.1558347965=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/Makefile.am new file mode 100644 index 0000000000..0eb5f89ad3 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/Makefile.am @@ -0,0 +1,18 @@ +lib_LTLIBRARIES = libMyValue.la + +noinst_HEADERS = *.h + +libMyValue_la_SOURCES = \ +MyValueImpl.cpp \ +MyValueImpl_customerInfo_Proxy.cpp \ +MyValueImpl_MyValueService_Proxy.cpp \ +MyValueImpl_MyValueService_Wrapper.cpp \ +MyValueImpl_stockQuote_Proxy.cpp + +libMyValue_la_LIBADD = + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include \ + -I../CustomerInfo + +install:
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValue.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValue.h new file mode 100644 index 0000000000..710910f08c --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValue.h @@ -0,0 +1,34 @@ +/* + * + * 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 MyValue_h +#define MyValue_h +#include <string> +using std::string; +class MyValue +{ +public: + virtual float getMyValue(const char* customerID) = 0; + virtual float getMyValueS(const string& customerID) = 0; + virtual string getCustname(string& customerID) = 0; + virtual const string& getCustnamecs(string customerID) = 0; + +}; + +#endif diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl.cpp new file mode 100644 index 0000000000..a6e10384e4 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl.cpp @@ -0,0 +1,150 @@ +/* + * + * 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 $ */ + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "MyValueImpl.h" +#include "CustomerInfo.h" +#include "StockQuoteService.h" +#include <iostream> +using namespace std; + +#include "osoa/sca/sca.h" +#include "commonj/sdo/SDO.h" + +using namespace osoa::sca; +using namespace commonj::sdo; + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +MyValueImpl::MyValueImpl() +{ + cout << "Construct MyValueImpl" << endl; + +} + +MyValueImpl::~MyValueImpl() +{ + cout << "Destroy MyValueImpl" << endl; +} + +////////////////////////////////////////////////////////////////////// +// Other methods +////////////////////////////////////////////////////////////////////// +float MyValueImpl::getMyValue(const char *customerID) +{ + cout << "In getMyValue with customerid: " << customerID << endl; + + + ComponentContext myContext = ComponentContext::getCurrent(); + CustomerInfo* customerInfoService = (CustomerInfo*)myContext.getService("customerInfo"); + + if (customerInfoService == 0) + { + cout << "unable to find customer info service" << endl; + + return 0.0f; + } + + const char * stock; + try + { + stock = customerInfoService->getCustomerInformation(customerID); + } + catch(const char* x) + { + cout << "Exception caught: " << x <<endl; + throw; + } + + ServiceList serviceList = myContext.getServices("customerInfo"); + + for (unsigned int i=0; i<serviceList.size();i++) + { + CustomerInfo* service = (CustomerInfo*)(serviceList[i]); + stock = service->getCustomerInformation(customerID); + cout << "Stock from getServices " << i << " : " << stock <<endl; + + } + + // Use a second SCA reference to get the stock price + StockQuoteService* stockQuoteService = (StockQuoteService*)myContext.getService("stockQuote"); + + if (stockQuoteService == 0) + { + cout << "unable to find stock quote service" << endl; + + return 0.1f; + } + + // Create a data object representing the requests (use dynamic API until static is available) + DataObjectPtr requestDO; + + + // Invoke the service + string result = stockQuoteService->GetQuote("IBM"); + + cout << result<<endl; + float stockPrice = 0.0f; + + try + { + XMLHelperPtr xmlHelper = HelperProvider::getXMLHelper(myContext.getDataFactory()); + XMLDocumentPtr stockDoc = xmlHelper->load(result.c_str()); + if (stockDoc->getRootDataObject()) + { + stockPrice=stockDoc->getRootDataObject()->getFloat("Stock.0/Last"); + } + + } + catch (SDORuntimeException e) + { + cout << e; + throw; + } + + return stockPrice; +} + +float MyValueImpl::getMyValueS(const string& customerID) +{ + cout << "In getMyValueS with customerid: " << customerID.c_str() << endl; + return 87.35f; +} + +string MyValueImpl::getCustname(string& customerID) +{ + cout << "In getCustname with customerid: " << customerID.c_str() << endl; + customerID = "FRED"; + cout << "setting customer name to " << customerID.c_str() <<endl; + return "done"; +} + +static string fred("FEREDDEYY"); +const string& MyValueImpl::getCustnamecs(string customerID) +{ + cout << "In getCustname with customerid: " << customerID.c_str() << endl; + customerID = "FRED"; + cout << "setting customer name to " << customerID.c_str() <<endl; + return fred; +} diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl.h new file mode 100644 index 0000000000..fa4053692e --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl.h @@ -0,0 +1,39 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#ifndef MyValueImpl_h +#define MyValueImpl_h + +#include "MyValue.h" + + + +class MyValueImpl : public MyValue +{ +public: + MyValueImpl(); + virtual ~MyValueImpl(); + virtual float getMyValue(const char* customerID); + virtual float getMyValueS(const string& customerID); + virtual string getCustname(string& customerID); + virtual const string& getCustnamecs(string customerID); + +}; + +#endif diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Proxy.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Proxy.cpp new file mode 100644 index 0000000000..d34b63ea14 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Proxy.cpp @@ -0,0 +1,91 @@ +/* + * 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. + */ + +#include "MyValueImpl_MyValueService_Proxy.h" + +#include "osoa/sca/sca.h" +using namespace osoa::sca; +using namespace tuscany::sca; + +extern "C" +{ + + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + MyValueImpl_MyValueService_Proxy* MyValueImpl_MyValueService_Proxy_Factory(ServiceWrapper* target) + { + return new MyValueImpl_MyValueService_Proxy(target); + } + + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void MyValueImpl_MyValueService_Proxy_Destructor(void* proxy) + { + delete (MyValueImpl_MyValueService_Proxy*)proxy; + } +} + +MyValueImpl_MyValueService_Proxy::MyValueImpl_MyValueService_Proxy(ServiceWrapper* targ) : target(targ) +{ +} + +MyValueImpl_MyValueService_Proxy::~MyValueImpl_MyValueService_Proxy() +{ + if (target) + delete target; +} + +float MyValueImpl_MyValueService_Proxy::getMyValue(const char* arg0) +{ + Operation operation("getMyValue"); + operation.addParameter(&arg0); + float ret; + operation.setReturnValue(&ret); + target->invoke(operation); + return ret; +} + +float MyValueImpl_MyValueService_Proxy::getMyValueS(const string& arg0) +{ + Operation operation("getMyValueS"); + operation.addParameter(&arg0); + float ret; + operation.setReturnValue(&ret); + target->invoke(operation); + return ret; +} + +string MyValueImpl_MyValueService_Proxy::getCustname( string& arg0) +{ + Operation operation("getCustname"); + operation.addParameter(&arg0); + string ret; + operation.setReturnValue(&ret); + target->invoke(operation); + return ret; +} + +const string& MyValueImpl_MyValueService_Proxy::getCustnamecs( string arg0) +{ + Operation operation("getCustnamecs"); + operation.addParameter(&arg0); + target->invoke(operation); + return *(const string*)operation.getReturnValue(); +} + + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Proxy.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Proxy.h new file mode 100644 index 0000000000..742947ca69 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Proxy.h @@ -0,0 +1,41 @@ +/* + * 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. + */ + +#ifndef MyValueImpl_MyValueService_Proxy_h +#define MyValueImpl_MyValueService_Proxy_h + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "MyValue.h" +#include "tuscany/sca/core/ServiceWrapper.h" + +class MyValueImpl_MyValueService_Proxy : public MyValue +{ +public: + MyValueImpl_MyValueService_Proxy(tuscany::sca::ServiceWrapper*); + virtual ~MyValueImpl_MyValueService_Proxy(); + virtual float getMyValue(const char* customerID); + virtual float getMyValueS(const string& customerID); + virtual string getCustname( string& customerID); + virtual const string& getCustnamecs( string customerID); +private: + tuscany::sca::ServiceWrapper* target; +}; + +#endif // MyValueImpl_MyValueService_Proxy_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Wrapper.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Wrapper.cpp new file mode 100644 index 0000000000..da60e4c1e3 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Wrapper.cpp @@ -0,0 +1,91 @@ +/* + * 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. + */ + +#include "MyValueImpl_MyValueService_Wrapper.h" + +#include "osoa/sca/sca.h" +using namespace osoa::sca; +using namespace tuscany::sca; + + + +extern "C" +{ + + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + MyValueImpl_MyValueService_Wrapper* MyValueImpl_MyValueService_Wrapper_Factory(tuscany::sca::model::Service* target) + { + return new MyValueImpl_MyValueService_Wrapper(target); + } +} + +MyValueImpl_MyValueService_Wrapper::MyValueImpl_MyValueService_Wrapper(Service* target) : ComponentServiceWrapper(target) +{ + impl = (MyValueImpl*)getImplementation(); +} + +MyValueImpl_MyValueService_Wrapper::~MyValueImpl_MyValueService_Wrapper() +{ + releaseImplementation(); +} + +void* MyValueImpl_MyValueService_Wrapper::newImplementation() +{ + return new MyValueImpl; +} + +void MyValueImpl_MyValueService_Wrapper::deleteImplementation() +{ + delete impl; +} + +void MyValueImpl_MyValueService_Wrapper::invokeService(Operation& operation) +{ + const string& operationName = operation.getName(); + + if (operationName == "getMyValue") + { + const char* p0 = *(const char**)operation.getParameterValue(0); + *(float*)operation.getReturnValue() = impl->getMyValue(p0); + return; + } + if (operationName == "getMyValueS") + { + string& p0 = *(string*)operation.getParameterValue(0); + *(float*)operation.getReturnValue() = impl->getMyValueS(p0); + return; + } + if (operationName == "getCustname") + { + string& p0 = *(string*)operation.getParameterValue(0); + *(string*)operation.getReturnValue() = impl->getCustname(p0); + return; + } + if (operationName == "getCustnamecs") + { + string& p0 = *( string*)operation.getParameterValue(0); + const string& ret = impl->getCustnamecs(p0); + operation.setReturnValue(&ret); + return; + } + + + throw ServiceRuntimeException("Invalid operation"); + +} + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Wrapper.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Wrapper.h new file mode 100644 index 0000000000..82fbcf76cc --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_MyValueService_Wrapper.h @@ -0,0 +1,40 @@ +/* + * 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. + */ + +#ifndef MyValueImpl_MyValueService_Wrapper_h +#define MyValueImpl_MyValueService_Wrapper_h + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "MyValueImpl.h" +#include "tuscany/sca/core/ComponentServiceWrapper.h" + +class MyValueImpl_MyValueService_Wrapper : public tuscany::sca::ComponentServiceWrapper +{ +public: + MyValueImpl_MyValueService_Wrapper(tuscany::sca::model::Service* target); + virtual ~MyValueImpl_MyValueService_Wrapper(); + virtual void invokeService(tuscany::sca::Operation& operation); + virtual void* newImplementation(); + virtual void deleteImplementation(); +private: + MyValueImpl* impl; +}; + +#endif // MyValueImpl_MyValueService_Wrapper_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_customerInfo_Proxy.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_customerInfo_Proxy.cpp new file mode 100644 index 0000000000..cda55a99c8 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_customerInfo_Proxy.cpp @@ -0,0 +1,63 @@ +/* + * 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. + */ + +#include "MyValueImpl_customerInfo_Proxy.h" + +#include "osoa/sca/sca.h" +using namespace osoa::sca; +using namespace tuscany::sca; + +extern "C" +{ + + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + MyValueImpl_customerInfo_Proxy* MyValueImpl_customerInfo_Proxy_Factory(ServiceWrapper* target) + { + return new MyValueImpl_customerInfo_Proxy(target); + } + + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void MyValueImpl_customerInfo_Proxy_Destructor(void* proxy) + { + delete (MyValueImpl_customerInfo_Proxy*)proxy; + } +} + +MyValueImpl_customerInfo_Proxy::MyValueImpl_customerInfo_Proxy(ServiceWrapper* targ) : target(targ) +{ +} + +MyValueImpl_customerInfo_Proxy::~MyValueImpl_customerInfo_Proxy() +{ + if (target) + delete target; +} + +const char* MyValueImpl_customerInfo_Proxy::getCustomerInformation(const char* arg0) +{ + Operation operation("getCustomerInformation"); + operation.addParameter(&arg0); + const char* ret; + operation.setReturnValue(&ret); + target->invoke(operation); + return ret; +} + + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_customerInfo_Proxy.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_customerInfo_Proxy.h new file mode 100644 index 0000000000..6ac33b4ef6 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_customerInfo_Proxy.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#ifndef MyValueImpl_customerInfo_Proxy_h +#define MyValueImpl_customerInfo_Proxy_h + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "CustomerInfo.h" +#include "tuscany/sca/core/ServiceWrapper.h" + +class MyValueImpl_customerInfo_Proxy : public CustomerInfo +{ +public: + MyValueImpl_customerInfo_Proxy(tuscany::sca::ServiceWrapper*); + virtual ~MyValueImpl_customerInfo_Proxy(); + virtual const char* getCustomerInformation(const char* customerID); +private: + tuscany::sca::ServiceWrapper* target; +}; + +#endif // MyValueImpl_customerInfo_Proxy_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_stockQuote_Proxy.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_stockQuote_Proxy.cpp new file mode 100644 index 0000000000..6b0e4df2d5 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_stockQuote_Proxy.cpp @@ -0,0 +1,63 @@ +/* + * 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. + */ + +#include "MyValueImpl_stockQuote_Proxy.h" + +#include "osoa/sca/sca.h" +using namespace osoa::sca; +using namespace tuscany::sca; + +extern "C" +{ + + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + MyValueImpl_stockQuote_Proxy* MyValueImpl_stockQuote_Proxy_Factory(ServiceWrapper* target) + { + return new MyValueImpl_stockQuote_Proxy(target); + } + + #if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) + #endif + void MyValueImpl_stockQuote_Proxy_Destructor(void* proxy) + { + delete (MyValueImpl_stockQuote_Proxy*)proxy; + } +} + +MyValueImpl_stockQuote_Proxy::MyValueImpl_stockQuote_Proxy(ServiceWrapper* targ) : target(targ) +{ +} + +MyValueImpl_stockQuote_Proxy::~MyValueImpl_stockQuote_Proxy() +{ + if (target) + delete target; +} + +string MyValueImpl_stockQuote_Proxy::GetQuote(const char* arg0) +{ + Operation operation("GetQuote"); + operation.addParameter(&arg0); + string ret; + operation.setReturnValue(&ret); + target->invoke(operation); + return ret; +} + + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_stockQuote_Proxy.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_stockQuote_Proxy.h new file mode 100644 index 0000000000..54b70fd684 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/MyValueImpl_stockQuote_Proxy.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#ifndef MyValueImpl_stockQuote_Proxy_h +#define MyValueImpl_stockQuote_Proxy_h + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#endif + +#include "StockQuoteService.h" +#include "tuscany/sca/core/ServiceWrapper.h" + +class MyValueImpl_stockQuote_Proxy : public StockQuoteService +{ +public: + MyValueImpl_stockQuote_Proxy(tuscany::sca::ServiceWrapper*); + virtual ~MyValueImpl_stockQuote_Proxy(); + virtual string GetQuote(const char* request); +private: + tuscany::sca::ServiceWrapper* target; +}; + +#endif // MyValueImpl_stockQuote_Proxy_h + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/StockQuoteService.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/StockQuoteService.h new file mode 100644 index 0000000000..e53f41c736 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/MyValue/StockQuoteService.h @@ -0,0 +1,32 @@ +/* + * + * 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 StockQuoteService_h +#define StockQuoteService_h +#include <string> +#include "commonj/sdo/SDO.h" +using std::string; +class StockQuoteService +{ +public: + virtual string GetQuote(const char* request) = 0; + +}; + +#endif // StockQuoteService_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.cdtbuild b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.cdtbuild new file mode 100644 index 0000000000..73f28e14fd --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.cdtbuild @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?fileVersion 3.0.0?>
+
+<ManagedProjectBuildInfo>
+<project id="tuscany_sca_test.cdt.managedbuild.target.gnu.exe.2075572137" name="Executable (Gnu)" projectType="cdt.managedbuild.target.gnu.exe">
+<configuration artifactName="tuscany_sca_test" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.exe.debug.961609061" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug">
+<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1940833295" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1305113089" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.526049094" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
+<option id="gnu.cpp.compiler.option.preprocessor.def.257257608" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+<listOptionValue builtIn="false" value="_DEBUG"/>
+</option>
+<option id="gnu.cpp.compiler.option.include.paths.2142231807" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/src"/>
+<listOptionValue builtIn="false" value="${SDO4CPP}/include"/>
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/test/MyValue"/>
+</option>
+</tool>
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.966487740" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1717129068" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
+<option id="gnu.cpp.link.option.libs.111258106" superClass="gnu.cpp.link.option.libs" valueType="libs">
+<listOptionValue builtIn="false" value="tuscany_sca"/>
+<listOptionValue builtIn="false" value="axis_clientC"/>
+<listOptionValue builtIn="false" value="axis_client"/>
+<listOptionValue builtIn="false" value="tuscany_sdo"/>
+<listOptionValue builtIn="false" value="xml2"/>
+</option>
+<option id="gnu.cpp.link.option.paths.746681481" superClass="gnu.cpp.link.option.paths" valueType="stringList">
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/src/Debug"/>
+<listOptionValue builtIn="false" value="${AXISCPP_DEPLOY}/lib"/>
+<listOptionValue builtIn="false" value="${SDO4CPP}/lib"/>
+</option>
+</tool>
+<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.exe.debug.888159856" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug"/>
+<macros/>
+</toolChain>
+</configuration>
+<configuration artifactName="tuscany_sca_test" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.exe.release.278641057" name="Release" parent="cdt.managedbuild.config.gnu.exe.release">
+<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.204044209" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.822246239" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1002800488" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
+<option id="gnu.cpp.compiler.option.include.paths.454857737" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/src"/>
+<listOptionValue builtIn="false" value="${SDO4CPP}/include"/>
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/test/MyValue"/>
+</option>
+</tool>
+<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1733957415" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"/>
+<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1578655729" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
+<option id="gnu.cpp.link.option.libs.18758324" superClass="gnu.cpp.link.option.libs" valueType="libs">
+<listOptionValue builtIn="false" value="xml2"/>
+<listOptionValue builtIn="false" value="tuscany_sca"/>
+<listOptionValue builtIn="false" value="tuscany_sdo"/>
+<listOptionValue builtIn="false" value="axis_clientC"/>
+<listOptionValue builtIn="false" value="axis_client"/>
+</option>
+<option id="gnu.cpp.link.option.paths.1663707007" superClass="gnu.cpp.link.option.paths" valueType="stringList">
+<listOptionValue builtIn="false" value="${SCA4CPP_HOME}/runtime/core/src/Release"/>
+<listOptionValue builtIn="false" value="${SDO4CPP}/lib"/>
+<listOptionValue builtIn="false" value="${AXISCPP_DEPLOY}/lib"/>
+</option>
+</tool>
+<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.exe.release.464104013" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release"/>
+<macros/>
+</toolChain>
+</configuration>
+<macros/>
+</project>
+</ManagedProjectBuildInfo>
diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.cdtproject b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.cdtproject new file mode 100644 index 0000000000..48a12e6664 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.cdtproject @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse-cdt version="2.0"?>
+
+<cdtproject id="org.eclipse.cdt.managedbuilder.core.managedMake">
+<extension id="org.eclipse.cdt.managedbuilder.core.ManagedBuildManager" point="org.eclipse.cdt.core.ScannerInfoProvider"/>
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>
+<data>
+<item id="org.eclipse.cdt.core.pathentry">
+<pathentry kind="src" path=""/>
+<pathentry kind="out" path=""/>
+<pathentry kind="con" path="org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"/>
+</item>
+</data>
+</cdtproject>
diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.project b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.project new file mode 100644 index 0000000000..5e5b12e9d8 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.project @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>tuscany_sca_test</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + </natures> +</projectDescription> diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 0000000000..fe629d7d5b --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,9 @@ +#Tue Nov 29 17:30:33 GMT 2005
+eclipse.preferences.version=1
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.961609061=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.278641057=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.961609061=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.278641057=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/project=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.exe.debug.961609061=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.exe.release.278641057=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/Makefile.am new file mode 100644 index 0000000000..e9a449aaf0 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/Makefile.am @@ -0,0 +1,12 @@ +prgbindir=$(prefix)/bin/test +prgbin_PROGRAMS = tuscany_sca_test +SUBDIRS = +AM_CPPFLAGS = $(CPPFLAGS) +tuscany_sca_test_SOURCES = TestSCA.cpp + +tuscany_sca_test_LDADD = -L$(top_builddir)/runtime/core/src -ltuscany_sca \ + -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo + +INCLUDES = -I$(top_builddir)/runtime/core/test/MyValue \ + -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/TestSCA.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/TestSCA.cpp new file mode 100644 index 0000000000..489fdab622 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/src/TestSCA.cpp @@ -0,0 +1,86 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "tuscany/sca/util/Logger.h" +#include "commonj/sdo/Logger.h" +#include "osoa/sca/sca.h" +#include <iostream> +using namespace std; + +using namespace osoa::sca; +#include "tuscany/sca/core/TuscanyRuntime.h" +using namespace tuscany::sca; +#include "MyValue.h" + +int main(int argc, char* argv[]) +{ + tuscany::sca::Logger::setLogging(4); + commonj::sdo::Logger::setLogging(20); + cout << "Start of SCA test" << endl; + + // Set default module + TuscanyRuntime runtime("SubSystem1"); + + try + { + runtime.start(); + + // Locate a service + ModuleContext myContext = ModuleContext::getCurrent(); + ModuleContext myContext2 = myContext; + + MyValue* myService = (MyValue*) myContext.locateService("MyValueServiceComponent"); + if (myService == 0) + { + cout << "Unable to find service" << endl; + } + else + { + + try + { + float value = myService->getMyValue("12345"); + cout << "My value is: " << value << endl; + value = myService->getMyValueS("12345"); + cout << "My valueSS is: " << value << endl; + string custid = "fred"; + string name = myService->getCustname(custid); + cout << "Returned string: " << name.c_str() << " custid now: " << custid.c_str() <<endl; + custid = "fred"; + const string& csname = myService->getCustnamecs(custid); + cout << "Returned string: " << csname.c_str() << " custid now: " << custid.c_str() <<endl; + //value = myService->getMyValue("999"); + cout << "My value is: " << value << endl; + } + catch (char* x) + { + cout << "Exception caught: " << x << endl; + } + } + cout << "End of SCA test" << endl; + + } + catch (ServiceRuntimeException& ex) + { + cout << ex << endl; + } + + runtime.stop(); + return 0; +} diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/CustomerInfo.fragment b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/CustomerInfo.fragment new file mode 100644 index 0000000000..f473f59748 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/CustomerInfo.fragment @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ 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.
+ -->
+
+<moduleFragment xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:mvs="http://www.myvalue.org/MyValueService/"
+ name="CustomerInfoComponent">
+
+
+ <component name="CustomerInfoComponent">
+ <implementation.cpp dll="libCustomerInfo.so" header="CustomerInfoImpl.h"></implementation.cpp>
+ <properties>
+ <v:Fred>x</v:Fred>
+ <v:Joe>23</v:Joe>
+ <Joe>42</Joe>
+ </properties>
+ <references>
+ </references>
+ </component>
+
+</moduleFragment>
+
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/CustomerInfoImpl.componentType b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/CustomerInfoImpl.componentType new file mode 100644 index 0000000000..48651b63fe --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/CustomerInfoImpl.componentType @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ 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.
+ -->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <service name="CustomerInfoService">
+ <interface.cpp header="CustomerInfo.h">
+ </interface.cpp>
+ </service>
+
+ <property name="Fred" type="xs:string"/>
+ <property name="Joe" type="xs:integer" many="true"/>
+
+</componentType>
+
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/MyValueImpl.componentType b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/MyValueImpl.componentType new file mode 100644 index 0000000000..ace4154966 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/MyValueImpl.componentType @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ 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.
+ -->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/0.9">
+
+ <service name="MyValueService">
+ <interface.cpp header="MyValue.h">
+ </interface.cpp>
+ </service>
+
+ <reference name="customerInfo">
+ <interface.cpp header="CustomerInfo.h">
+ </interface.cpp>
+ </reference>
+
+ <reference name="stockQuote">
+ <interface.cpp header="StockQuoteService.h">
+ </interface.cpp>
+ </reference>
+
+</componentType>
+
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/StockQuoteService.wsdl b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/StockQuoteService.wsdl new file mode 100644 index 0000000000..5bce10d2f9 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/StockQuoteService.wsdl @@ -0,0 +1,135 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2006 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.
+ -->
+<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.webserviceX.NET/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://www.webserviceX.NET/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <s:schema elementFormDefault="qualified" targetNamespace="http://www.webserviceX.NET/">
+ <s:element name="GetQuote">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="symbol" type="s:string" />
+ </s:sequence>
+ </s:complexType>
+
+ </s:element>
+ <s:element name="GetQuoteResponse">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="GetQuoteResult" type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="string" nillable="true" type="s:string" />
+
+ </s:schema>
+ </wsdl:types>
+ <wsdl:message name="GetQuoteSoapIn">
+ <wsdl:part name="parameters" element="tns:GetQuote" />
+ </wsdl:message>
+ <wsdl:message name="GetQuoteSoapOut">
+ <wsdl:part name="parameters" element="tns:GetQuoteResponse" />
+ </wsdl:message>
+ <wsdl:message name="GetQuoteHttpGetIn">
+
+ <wsdl:part name="symbol" type="s:string" />
+ </wsdl:message>
+ <wsdl:message name="GetQuoteHttpGetOut">
+ <wsdl:part name="Body" element="tns:string" />
+ </wsdl:message>
+ <wsdl:message name="GetQuoteHttpPostIn">
+ <wsdl:part name="symbol" type="s:string" />
+ </wsdl:message>
+ <wsdl:message name="GetQuoteHttpPostOut">
+
+ <wsdl:part name="Body" element="tns:string" />
+ </wsdl:message>
+ <wsdl:portType name="StockQuoteSoap">
+ <wsdl:operation name="GetQuote">
+ <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</documentation>
+ <wsdl:input message="tns:GetQuoteSoapIn" />
+ <wsdl:output message="tns:GetQuoteSoapOut" />
+ </wsdl:operation>
+
+ </wsdl:portType>
+ <wsdl:portType name="StockQuoteHttpGet">
+ <wsdl:operation name="GetQuote">
+ <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</documentation>
+ <wsdl:input message="tns:GetQuoteHttpGetIn" />
+ <wsdl:output message="tns:GetQuoteHttpGetOut" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:portType name="StockQuoteHttpPost">
+ <wsdl:operation name="GetQuote">
+ <documentation xmlns="http://schemas.xmlsoap.org/wsdl/">Get Stock quote for a company Symbol</documentation>
+ <wsdl:input message="tns:GetQuoteHttpPostIn" />
+ <wsdl:output message="tns:GetQuoteHttpPostOut" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="StockQuoteSoap" type="tns:StockQuoteSoap">
+
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
+ <wsdl:operation name="GetQuote">
+ <soap:operation soapAction="http://www.webserviceX.NET/GetQuote" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="StockQuoteHttpGet" type="tns:StockQuoteHttpGet">
+ <http:binding verb="GET" />
+ <wsdl:operation name="GetQuote">
+ <http:operation location="/GetQuote" />
+ <wsdl:input>
+ <http:urlEncoded />
+ </wsdl:input>
+
+ <wsdl:output>
+ <mime:mimeXml part="Body" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="StockQuoteHttpPost" type="tns:StockQuoteHttpPost">
+ <http:binding verb="POST" />
+ <wsdl:operation name="GetQuote">
+ <http:operation location="/GetQuote" />
+
+ <wsdl:input>
+ <mime:content type="application/x-www-form-urlencoded" />
+ </wsdl:input>
+ <wsdl:output>
+ <mime:mimeXml part="Body" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="StockQuote">
+
+ <wsdl:port name="StockQuoteSoap" binding="tns:StockQuoteSoap">
+ <soap:address location="http://www.webservicex.net/stockquote.asmx" />
+ </wsdl:port>
+ <wsdl:port name="StockQuoteHttpGet" binding="tns:StockQuoteHttpGet">
+ <http:address location="http://www.webservicex.net/stockquote.asmx" />
+ </wsdl:port>
+ <wsdl:port name="StockQuoteHttpPost" binding="tns:StockQuoteHttpPost">
+ <http:address location="http://www.webservicex.net/stockquote.asmx" />
+ </wsdl:port>
+
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/StockQuoteTypes.xsd b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/StockQuoteTypes.xsd new file mode 100644 index 0000000000..5bce3a63dc --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/StockQuoteTypes.xsd @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + Copyright 2006 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. + --> + +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:element name="StockQuotes" type="tStockQuotes"/> + <xs:complexType name="tStockQuotes"> + <xs:sequence> + <xs:element name="Stock" type="tStock" minOccurs="0" maxOccurs="unbounded"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:anyAttribute namespace="##any" processContents="lax"/> + </xs:complexType> + + <xs:complexType name="tStock"> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="1" name="Symbol" type="xs:string"/> + <xs:element minOccurs="0" maxOccurs="1" name="Last" type="xs:float"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:anyAttribute namespace="##any" processContents="lax"/> + </xs:complexType> +</xs:schema>
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/Tuscany-model.config b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/Tuscany-model.config new file mode 100644 index 0000000000..cba35b444b --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/Tuscany-model.config @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ 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.
+ -->
+
+<tuscany-model xmlns="http://org.apache.tuscany/xmlns/cpp/1.0">
+ <wsdl>
+ <file name="StockQuoteService.wsdl"/>
+ </wsdl>
+ <xsd>
+ <file name="StockQuoteTypes.xsd"/>
+ </xsd>
+</tuscany-model>
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/sca.module b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/sca.module new file mode 100644 index 0000000000..b9b9b51036 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/modules/MyValueServiceModule/sca.module @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ 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.
+ -->
+
+<module xmlns="http://www.osoa.org/xmlns/sca/0.9"
+ xmlns:v="http://www.osoa.org/xmlns/sca/values/0.9"
+ xmlns:mvs="http://www.myvalue.org/MyValueService/"
+ name="MyValueServiceModule">
+
+ <!-- Expose as a web service -->
+ <entryPoint name="MyValueServiceExport" multiplicity="1..1">
+ <interface.wsdl interface="" callbackInterface=""></interface.wsdl>
+ <binding.ws port="mvs:MyValueServiceSOAP"></binding.ws>
+ <reference>MyValueServiceComponent</reference>
+ </entryPoint>
+
+ <component name="MyValueServiceComponent">
+ <implementation.cpp dll="libMyValue.so" header="MyValueImpl.h"></implementation.cpp>
+ <properties>
+ </properties>
+ <references>
+ <stockQuote>StockQuoteService</stockQuote>
+ </references>
+ </component>
+
+ <externalService name="StockQuoteService">
+ <interface.cpp header="StockQuoteService.h"/>
+ <binding.ws port="http://www.webserviceX.NET/#wsdl.endpoint(StockQuote/StockQuoteSoap)"/>
+ </externalService>
+
+ <wire>
+ <source.uri>MyValueServiceComponent/customerInfo</source.uri>
+ <target.uri>CustomerInfoComponent</target.uri>
+ </wire>
+
+</module>
+
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/subsystems/SubSystem1/sca.subsystem b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/subsystems/SubSystem1/sca.subsystem new file mode 100644 index 0000000000..1b32bf8a93 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/core/test/testSCASystem/subsystems/SubSystem1/sca.subsystem @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="ASCII"?>
+<!--
+ 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.
+ -->
+
+<subsystem xmlns="http://www.osoa.org/xmlns/sca/0.9"
+
+ name="SubSystem1">
+
+ <moduleComponent name="MyValue" module="MyValueServiceModule">
+
+ </moduleComponent>
+
+</subsystem>
+
\ No newline at end of file diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/Makefile.am new file mode 100644 index 0000000000..f3ba006041 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = axis2c diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/Makefile.am new file mode 100644 index 0000000000..af437a64d6 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/Axis2Client.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/Axis2Client.cpp new file mode 100644 index 0000000000..4064235062 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/Axis2Client.cpp @@ -0,0 +1,362 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * 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. + */ + +#include "osoa/sca/export.h" +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4091) +#endif + +#include <axis2_client.h> + +#include <axis2_error_default.h> +#include <axis2_log_default.h> +#include <axis2_defines.h> +#include <axiom_soap_const.h> +#include <platforms/axis2_platform_auto_sense.h> + +#include <sdo_axiom.h> +#include "Axis2Client.h" + + +#include <osoa/sca/sca.h> +using namespace osoa::sca; +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/model/WSBinding.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/Exceptions.h" + +using namespace tuscany::sca::ws; + + +using namespace commonj::sdo; +using namespace commonj::sdo_axiom; + +Axis2Client::Axis2Client(ExternalService* extService) + : externalService(extService) +{ +} + +Axis2Client::~Axis2Client() +{ +} + +void Axis2Client::invoke(tuscany::sca::Operation& operation) +{ + LOGENTRY(1, "Axis2Client::invoke"); + + // From the external service ws-binding, get the namespace of the wsdl endpoint + WSBinding* binding = (WSBinding *)externalService->getBinding(); + // TODO check 0 throw + + string portNamespace = binding->getWSDLNamespaceURL(); + + // Lookup the wsdl model from the module, keyed on the namespace + // (the wsdl will have been loaded at startup, based on the information in the config file) + Wsdl* wsdlDefinition = externalService->getContainingModule()->findWsdl(portNamespace); + if (wsdlDefinition == 0) + { + string msg = "WSDL not found for " + portNamespace; + throw SystemConfigurationException(msg.c_str()); + } + + const string& operationName = operation.getName(); + + // Match the operation in Operation to the operation in the wsdl port type. + const WsdlOperation& wsdlOperation = wsdlDefinition->findOperation( + binding->getServiceName(), + binding->getPortName(), + operationName); + + // Initialize Axis2 stuff + axis2_allocator_t *allocator = axis2_allocator_init (NULL); + axis2_log_t *log = axis2_log_create(allocator, NULL, "tuscany_client.log"); + axis2_error_t *error = axis2_error_create(allocator); + axis2_env_t *env = axis2_env_create_with_error_log(allocator, error, log); + env->log->level = AXIS2_LOG_LEVEL_TRACE; + axis2_error_init(); + + axis2_char_t* address = (axis2_char_t*)wsdlOperation.getEndpoint().c_str(); + axis2_char_t* opName = (axis2_char_t*)operationName.c_str(); + axis2_char_t* soap_action = (axis2_char_t*)wsdlOperation.getSoapAction().c_str(); + axis2_char_t* serviceName = (axis2_char_t*)binding->getServiceName().c_str(); + + // create OM from Operation and wsdlOperation + axiom_node_t* payload = createPayload(operation, wsdlOperation, env); + + /* Create EPR with given address */ + axis2_endpoint_ref_t* endpoint_ref = axis2_endpoint_ref_create(env, address); + + /* Setup options */ + axis2_options_t* options = axis2_options_create(env); + AXIS2_OPTIONS_SET_TO(options, env, endpoint_ref); + int soap_version = AXIOM_SOAP11; + if (wsdlOperation.getSoapVersion() == WsdlOperation::SOAP12) + { + soap_version = AXIOM_SOAP12; + } + + AXIS2_OPTIONS_SET_SOAP_VERSION(options, env, soap_version); + AXIS2_OPTIONS_SET_ACTION(options, env, soap_action); + + /* Create service client */ + + axis2_char_t* client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + { + throw SystemConfigurationException("Environment error: AXIS2C_HOME not set"); + } + axis2_svc_client_t* svc_client = axis2_svc_client_create(env, client_home); + if (!svc_client) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "invoke FAILED: Error code:" + " %d :: %s", env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + + throw ServiceRuntimeException("Axis2Client: axis2_svc_client_create failed"); + } + + /* Set service client options */ + AXIS2_SVC_CLIENT_SET_OPTIONS(svc_client, env, options); + + /* Send request */ + axiom_node_t* ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE(svc_client, env, payload); + if(ret_node) + { + setReturn(ret_node, operation, wsdlOperation, env); + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invoke failed: Error code:" + " %d :: %s", env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + throw ServiceRuntimeException("Axis2Client: Invoke failed"); + } + + if (svc_client) + { + AXIS2_SVC_CLIENT_FREE(svc_client, env); + svc_client = NULL; + } + + LOGEXIT(1, "Axis2Client::invoke"); +} + +axiom_node_t* Axis2Client::createPayload(Operation& operation, + const WsdlOperation& wsdlOp, + axis2_env_t* env) +{ + LOGENTRY(1, "Axis2Client::createPayload"); + axiom_node_t* requestOM = NULL; + + // map the operation request to the wsdl + if (wsdlOp.isDocumentStyle()) + { + // Document style + // only support single part messages - WS-I compliant + + // Build up the payload as an SDO + + // Get the data factory for the module (it will already have the typecreates loaded for the xsds) + DataFactoryPtr dataFactory = externalService->getContainingModule()->getDataFactory(); + DataObjectPtr requestDO = dataFactory->create(wsdlOp.getInputTypeUri().c_str(), + wsdlOp.getInputTypeName().c_str()); + + // Each parameter in the operation should be a property on the request dataobject + for (int i=0; i<operation.getNParms(); i++) + { + Operation::Parameter& parm = operation.getParameter(i); + switch(parm.getType()) + { + case Operation::BOOL: + { + requestDO->setBoolean(i, *(bool*)parm.getValue()); + break; + } + case Operation::SHORT: + { + requestDO->setShort(i, *(short*)parm.getValue()); + break; + } + case Operation::LONG: + { + requestDO->setLong(i, *(long*)parm.getValue()); + break; + } + case Operation::USHORT: + { + requestDO->setInteger(i, *(unsigned short*)parm.getValue()); + break; + } + case Operation::ULONG: + { + requestDO->setInteger(i, *(unsigned long*)parm.getValue()); + break; + } + case Operation::FLOAT: + { + requestDO->setFloat(i, *(float*)parm.getValue()); + break; + } + case Operation::DOUBLE: + { + requestDO->setDouble(i, *(double*)parm.getValue()); + break; + } + case Operation::LONGDOUBLE: + { + requestDO->setDouble(i, *(long double*)parm.getValue()); + break; + } + case Operation::CHARS: + { + requestDO->setCString(i, *(char**)parm.getValue()); + break; + } + case Operation::STRING: + { + requestDO->setCString(i, (*(string*)parm.getValue()).c_str()); + break; + } + case Operation::DATAOBJECT: + { + requestDO->setDataObject(i, *(DataObjectPtr*)parm.getValue()); + break; + } + default: throw "unsupported parameter type"; + } + } + + // Create the Axiom object from the request dataobject + AxiomHelper myHelper; + requestOM = myHelper.toAxiomNode(requestDO); + } + else + { + // RPC + } + + // Logging start + axiom_xml_writer_t* xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE, AXIS2_XML_PARSER_TYPE_BUFFER); + axiom_output_t* om_output = axiom_output_create( env, xml_writer); + + AXIOM_NODE_SERIALIZE(requestOM, env, om_output); + axis2_char_t* buffer = (axis2_char_t*)AXIOM_XML_WRITER_GET_XML(xml_writer, env); + LOGINFO_1(3, "Sending this OM node in XML : %s \n", buffer); + AXIOM_OUTPUT_FREE(om_output, env); + AXIS2_FREE((env)->allocator, buffer); + // Logging end + + return requestOM; + + LOGEXIT(1, "Axis2Client::createPayload"); +} + +void Axis2Client::setReturn(axiom_node_t* ret_node, + Operation& operation, + const WsdlOperation& wsdlOp, + axis2_env_t* env) +{ + LOGENTRY(1, "Axis2Client::setReturn"); + /* Get the response value from the SOAP message */ + + // logging start + axiom_xml_writer_t* writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, AXIS2_XML_PARSER_TYPE_BUFFER); + axiom_output_t* om_output = axiom_output_create (env, writer); + AXIOM_NODE_SERIALIZE (ret_node, env, om_output); + axis2_char_t* buffer = (axis2_char_t*)AXIOM_XML_WRITER_GET_XML(writer, env); + LOGINFO_1(3,"Received OM node in XML : %s\n", buffer); + AXIOM_OUTPUT_FREE(om_output, env); + AXIS2_FREE((env)->allocator, buffer); + // Logging end + + + if (wsdlOp.isDocumentStyle()) + { + // Document style + + DataFactoryPtr dataFactory = externalService->getContainingModule()->getDataFactory(); + AxiomHelper myHelper; + DataObjectPtr returnDO = myHelper.toSdo(ret_node, dataFactory); + + unsigned int index = 0; + switch(operation.getReturnType()) + { + case Operation::BOOL: + { + *(bool*)operation.getReturnValue() = returnDO->getBoolean(index); + break; + } + case Operation::SHORT: + { + *(short*)operation.getReturnValue() = returnDO->getShort(index); + break; + } + case Operation::LONG: + { + *(long*)operation.getReturnValue() = returnDO->getLong(index); + break; + } + case Operation::USHORT: + { + *(unsigned short*)operation.getReturnValue() = (unsigned short)returnDO->getInteger(index); + break; + } + case Operation::ULONG: + { + *(unsigned long*)operation.getReturnValue() = (unsigned long)returnDO->getInteger(index); + break; + } + case Operation::FLOAT: + { + *(float*)operation.getReturnValue() = returnDO->getFloat(index); + break; + } + case Operation::DOUBLE: + { + *(double*)operation.getReturnValue() = returnDO->getDouble(index); + break; + } + case Operation::LONGDOUBLE: + { + *(long double*)operation.getReturnValue() = returnDO->getDouble(index); + break; + } + case Operation::CHARS: + { + *(char**)operation.getReturnValue() = strdup(returnDO->getCString(index)); + break; + } + case Operation::STRING: + { + *(string*)operation.getReturnValue() = returnDO->getCString(index); + break; + } + case Operation::DATAOBJECT: + { + *(DataObjectPtr*)operation.getReturnValue() = returnDO->getDataObject(index); + break; + } + default:; + } + } + else + { + // RPC + } + LOGEXIT(1, "Axis2Client::setReturn"); +} + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/Axis2Client.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/Axis2Client.h new file mode 100644 index 0000000000..c07e1fee4e --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/Axis2Client.h @@ -0,0 +1,68 @@ +/* + * + * 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. + */ + +#ifndef tuscany_sca_ws_axis2client_h +#define tuscany_sca_ws_axis2client_h + +#include "osoa/sca/export.h" + +#include <axiom.h> + +#include <osoa/sca/export.h> + +#include "tuscany/sca/core/ExternalServiceWrapper.h" +#include "tuscany/sca/model/ExternalService.h" + +#include "tuscany/sca/model/Wsdl.h" +#include "tuscany/sca/core/Operation.h" +using namespace tuscany::sca; +using namespace tuscany::sca::model; + + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + class SCA_API Axis2Client + { + public: + Axis2Client(tuscany::sca::model::ExternalService* externalService); + virtual ~Axis2Client(); + + virtual void invoke(tuscany::sca::Operation& operation); + + private: + tuscany::sca::model::ExternalService* externalService; + + axiom_node_t* createPayload(Operation& operation, + const WsdlOperation& wsdlOp, + axis2_env_t* env); + + void setReturn(axiom_node_t* returnNode, + Operation& operation, + const WsdlOperation& wsdlOp, + axis2_env_t* env); + + }; + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_ws_axis2client_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/Makefile.am new file mode 100644 index 0000000000..60678dd31b --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/Makefile.am @@ -0,0 +1,26 @@ +lib_LTLIBRARIES = libtuscany_sca_ws_reference.la + +libtuscany_sca_ws_reference_la_SOURCES = WSServiceWrapper.cpp Axis2Client.cpp + +noinst_HEADERS = *.h + +AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG + +libtuscany_sca_ws_reference_la_LIBADD = \ + -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -ltuscany_sdo_axiom \ + -L$(AXIS2C_HOME)/lib \ + -laxis2_util \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -laxis2_parser \ + -laxis2_minizip \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver + + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include \ + -I${AXIS2C_HOME}/include + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/WSServiceWrapper.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/WSServiceWrapper.cpp new file mode 100644 index 0000000000..2a4d6a1d8d --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_reference/axis2c/src/WSServiceWrapper.cpp @@ -0,0 +1,71 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date$ */ +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4091) +#endif + +#include "tuscany/sca/ws/WSServiceWrapper.h" + +#include "Axis2Client.h" + +#include "osoa/sca/sca.h" +using namespace osoa::sca; + +#include "tuscany/sca/util/Logging.h" +using namespace tuscany::sca; +using namespace tuscany::sca::ws; + + + + +WSServiceWrapper::WSServiceWrapper(tuscany::sca::model::WireTarget* target) : ExternalServiceWrapper(target) +{ + +} + +WSServiceWrapper::~WSServiceWrapper() +{ + +} + +/// +/// This method will be called when a web service call needs to be made. +/// +void WSServiceWrapper::invoke(Operation& operation) +{ + LOGENTRY(1, "WSServiceWrapper::invoke"); + + const string& operationName = operation.getName(); + + LOGINFO_2(2,"External service: %s, Operation: %s", getTarget()->getName().c_str() , operationName.c_str()); + + for (unsigned int i=0; i<operation.getNParms(); i++) + { + LOGINFO_2(2, "Parameter %p, Type %u", operation.getParameterValue(i),(int) operation.getParameterType(i)); + } + + // From the external service ws-binding, get the namespace of the wsdl endpoint + ExternalService* externalService = getExternalService(); + + Axis2Client client(externalService); + client.invoke(operation); + + LOGEXIT(1, "WSServiceWrapper::invoke"); +} + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/Makefile.am new file mode 100644 index 0000000000..f3ba006041 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = axis2c diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/Makefile.am new file mode 100644 index 0000000000..af437a64d6 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Axis2EntryPointService_skeleton.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Axis2EntryPointService_skeleton.cpp new file mode 100644 index 0000000000..c2a06e05c0 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Axis2EntryPointService_skeleton.cpp @@ -0,0 +1,253 @@ +/* + * Copyright 2006 The Apache Software Foundation. + * + * 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. + */ +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#pragma warning(disable: 4091) +#endif + +#include <axis2_svc_skeleton.h> +#include <axis2_array_list.h> +#include <axis2_log_default.h> +#include <axis2_error_default.h> +#include <axiom.h> +#include <stdio.h> + +#include <sdo_axiom.h> +using namespace commonj::sdo; +using namespace commonj::sdo_axiom; + +#include "tuscany/sca/util/Utils.h" +using namespace tuscany::sca; + +#include "tuscany/sca/ws/EntryPointProxy.h" +#include "Axis2Utils.h" +using namespace tuscany::sca::ws; + + +int AXIS2_CALL +Axis2EntryPointService_free(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env); + +/* + * This method invokes the right service method + */ +axiom_node_t* AXIS2_CALL +Axis2EntryPointService_invoke(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env, + axiom_node_t *node, + axis2_msg_ctx_t *msg_ctx); + +int AXIS2_CALL Axis2EntryPointService_init(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env); + +EntryPointProxy* entryPointProxy = NULL; + +axis2_svc_skeleton_t * +axis2_Axis2EntryPointService_create(axis2_env_t *env) +{ + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = (axis2_svc_skeleton_t *) AXIS2_MALLOC((env)->allocator, + sizeof(axis2_svc_skeleton_t)); + + + svc_skeleton->ops = (axis2_svc_skeleton_ops_t *) AXIS2_MALLOC( + (env)->allocator, sizeof(axis2_svc_skeleton_ops_t)); + + svc_skeleton->func_array = NULL; + + svc_skeleton->ops->free = Axis2EntryPointService_free; + svc_skeleton->ops->init = Axis2EntryPointService_init; + svc_skeleton->ops->invoke = Axis2EntryPointService_invoke; + /*svc_skeleton->ops->on_fault = Axis2Service_on_fault;*/ + + if(entryPointProxy == NULL) + { + entryPointProxy = EntryPointProxy::getInstance(); + } + + return svc_skeleton; +} + +int AXIS2_CALL +Axis2EntryPointService_init(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env) +{ + // This method never seems to be called - an old Axis2C artifact? + + svc_skeleton->func_array = axis2_array_list_create(env, 0); + return AXIS2_SUCCESS; +} + +int AXIS2_CALL +Axis2EntryPointService_free(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env) +{ + /*if(svc_skeleton->func_array) + { + AXIS2_ARRAY_LIST_FREE(svc_skeleton->func_array, env); + svc_skeleton->func_array = NULL; + }*/ + + if(svc_skeleton->ops) + { + AXIS2_FREE((env)->allocator, svc_skeleton->ops); + svc_skeleton->ops = NULL; + } + + if(svc_skeleton) + { + AXIS2_FREE((env)->allocator, svc_skeleton); + svc_skeleton = NULL; + } + return AXIS2_SUCCESS; +} + +/* + * This method invokes the right service method + */ +axiom_node_t* AXIS2_CALL +Axis2EntryPointService_invoke(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env, + axiom_node_t *node, + axis2_msg_ctx_t *msg_ctx) +{ + axiom_node_t *returnNode = node; + + /* Depending on the function name invoke the + * corresponding Axis2Service method + */ + if (node) + { + if (AXIOM_NODE_GET_NODE_TYPE(node, env) == AXIOM_ELEMENT) + { + axiom_element_t *element = NULL; + element = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env); + if (element) + { + // This gets the operation name from the root element name - this is correct for DocLit Wrapped style + axis2_char_t *op_name = AXIOM_ELEMENT_GET_LOCALNAME(element, env); + if (op_name) + { + char* systemRoot = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanySystemRoot"); + char* fullEntryPointName = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyEntryPoint"); + + AXIS2_LOG_INFO((env)->log, "Axis2EntryPointService invoke called with system root: %s entrypoint name: %s operation name: %s", systemRoot, fullEntryPointName, op_name); + + //LOGINFO_2(4, "Axis2EntryPointService invoke called with system root: %s and entrypoint name: %s", systemRoot, fullEntryPointName); + //LOGINFO_1(4, "Axis2EntryPointService invoke called with operation", op_name); + entryPointProxy->init(systemRoot, fullEntryPointName); + + //Utils::printTypes(entryPointProxy->getDataFactory()); + + AxiomHelper* axiomHelper = AxiomHelper::getHelper(); + if (entryPointProxy->getDataFactory() == 0) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2EntryPointService_invoke: EntryPoint has no SCA implementation"); + return 0; + } + + char* om_str = NULL; + om_str = AXIOM_NODE_TO_STRING(node, env); + if (om_str) + { + AXIS2_LOG_INFO((env)->log, "Axis2EntryPointService invoke has request OM: %s\n", om_str); + } + + DataObjectPtr inputDataObject = axiomHelper->toSdo(node, entryPointProxy->getDataFactory()); + + //printf("Axis2EntryPoint inputDataObject: (%d)\n", inputDataObject); + + if(!inputDataObject) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2EntryPointService_invoke: Could not convert received Axiom node to SDO"); + //LOGERROR(0, "Axis2EntryPointService_invoke: Failure whilst invoking EntryPoint"); + /** TODO: return a SOAP fault here */ + return 0; + } + //Utils::printDO(inputDataObject); + + DataObjectPtr outputDataObject = entryPointProxy->invoke(op_name, inputDataObject); + + //printf("Axis2EntryPoint outputDataObject: %d\n", outputDataObject); + //Utils::printDO(outputDataObject); + //printf("Axis2EntryPoint outputDataObject printed\n"); + if(!outputDataObject) + { + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2EntryPointService_invoke: Failure whilst invoking EntryPoint"); + //LOGERROR(0, "Axis2EntryPointService_invoke: Failure whilst invoking EntryPoint"); + /** TODO: return a SOAP fault here */ + return 0; + } + + returnNode = axiomHelper->toAxiomNode(outputDataObject); + + om_str = NULL; + om_str = AXIOM_NODE_TO_STRING(returnNode, env); + if (om_str) + { + AXIS2_LOG_INFO((env)->log, "Axis2EntryPointService invoke has response OM : %s\n", om_str); + } + + AxiomHelper::releaseHelper(axiomHelper); + + //LOGEXIT(1, "Axis2EntryPointService_invoke"); + return returnNode; + } + } + } + } + + AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2EntryPointService_invoke: invalid OM parameters in request"); + //LOGERROR(0, "Axis2Service service ERROR: invalid OM parameters in request\n"); + + /** TODO: return a SOAP fault here */ + return node; +} + + +extern "C" +{ +/** + * Following block distinguish the exposed part of the dll. + */ + +AXIS2_EXPORT int axis2_get_instance(axis2_svc_skeleton **inst, + axis2_env_t *env) +{ + *inst = axis2_Axis2EntryPointService_create(env); + /*if(NULL != *inst) + { + status = *inst->init(); + }*/ + if(!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int axis2_remove_instance(axis2_svc_skeleton_t *inst, + axis2_env_t *env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; +} +} diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Axis2Utils.cpp b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Axis2Utils.cpp new file mode 100644 index 0000000000..7007e71c96 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Axis2Utils.cpp @@ -0,0 +1,66 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * 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. + */ +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#pragma warning(disable: 4091) +#endif +#include "Axis2Utils.h" + +#include <axis2_svc_ctx.h> +#include <axis2_defines.h> + +#include "tuscany/sca/util/Logging.h" + +using namespace tuscany::sca; +using namespace tuscany::sca::ws; + + +/* Static utility method to retrieve service parameters from the service.xml file + * Get an odd linking error if this method (or the header's it requires) are in + * a different class. + */ +char* Axis2Utils::getAxisServiceParameterValue(const axis2_env_t *env, axis2_msg_ctx_t *msg_ctx, char* parameterName) +{ + struct axis2_svc *svc = NULL; + struct axis2_op_ctx *op_ctx = NULL; + struct axis2_svc_ctx *svc_ctx = NULL; + axis2_param_t *param = NULL; + char* paramValue = NULL; + + LOGENTRY(1, "Axis2Utils::getAxisServiceParameterValue"); + + op_ctx = AXIS2_MSG_CTX_GET_OP_CTX(msg_ctx, env); + svc_ctx = AXIS2_OP_CTX_GET_PARENT(op_ctx, env); + svc = AXIS2_SVC_CTX_GET_SVC(svc_ctx, env); + if(NULL == svc) + { + return NULL; + } + + param = AXIS2_SVC_GET_PARAM(svc, env, parameterName); + if(!param) + { + LOGERROR_1(0,"Axis parameter %s cannot be found", parameterName); + } + else + { + paramValue = (char*) AXIS2_PARAM_GET_VALUE(param, env); + } + + LOGEXIT(1, "Axis2Utils::getAxisServiceParameterValue"); + return paramValue; +} + diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Axis2Utils.h b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Axis2Utils.h new file mode 100644 index 0000000000..a998ed8682 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Axis2Utils.h @@ -0,0 +1,41 @@ +/* + * + * 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. + */ + +#ifndef tuscany_sca_ws_axis2utils_h +#define tuscany_sca_ws_axis2utils_h + +#include <axis2_env.h> +#include <axis2_msg_ctx.h> + + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + class Axis2Utils + { + public: + static char* getAxisServiceParameterValue(const axis2_env_t *env, axis2_msg_ctx_t *msg_ctx, char* parameterName); + }; + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_ws_axis2utils_h diff --git a/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Makefile.am b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Makefile.am new file mode 100644 index 0000000000..22bf2f2276 --- /dev/null +++ b/tags/cpp-0.1.incubating-M1-RC3b/sca/runtime/ws_service/axis2c/src/Makefile.am @@ -0,0 +1,27 @@ +lib_LTLIBRARIES = libtuscany_sca_ws_service.la + +libtuscany_sca_ws_service_la_SOURCES = Axis2EntryPointService_skeleton.cpp Axis2Utils.cpp + +noinst_HEADERS = *.h + +AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG + +libtuscany_sca_ws_service_la_LIBADD = \ + -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -ltuscany_sdo_axiom \ + -L$(top_builddir)/runtime/core/src -ltuscany_sca \ + -L$(AXIS2C_HOME)/lib \ + -laxis2_util \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -laxis2_parser \ + -lpthread \ + -laxis2_minizip \ + -laxis2_http_sender \ + -laxis2_http_receiver + + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include \ + -I${AXIS2C_HOME}/include + |