You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2006/08/28 12:42:20 UTC
svn commit: r437637 [4/8] - in /incubator/tuscany/cpp/sca: runtime/core/src/
runtime/core/src/osoa/sca/ runtime/core/src/tuscany/sca/core/
runtime/core/src/tuscany/sca/cpp/ runtime/core/src/tuscany/sca/extension/
runtime/core/src/tuscany/sca/model/ run...
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp Mon Aug 28 03:42:10 2006
@@ -22,13 +22,26 @@
#include "tuscany/sca/util/Exceptions.h"
#include "tuscany/sca/util/Logging.h"
#include "tuscany/sca/model/ModelLoader.h"
-#include "tuscany/sca/model/CPPInterface.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/CompositeService.h"
+#include "tuscany/sca/model/CompositeReference.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/ReferenceType.h"
#include "tuscany/sca/core/SCARuntime.h"
-#include "tuscany/sca/model/WSBinding.h"
+#include "tuscany/sca/ws/WSServiceBinding.h"
+#include "tuscany/sca/ws/WSReferenceBinding.h"
#include "commonj/sdo/TypeDefinitions.h"
+#include "tuscany/sca/util/File.h"
using namespace commonj::sdo;
+using namespace tuscany::sca;
+
+using tuscany::sca::ws::WSServiceBinding;
+using tuscany::sca::ws::WSReferenceBinding;
namespace tuscany
@@ -41,9 +54,10 @@
// ===========
// Constructor
// ===========
- ModelLoader::ModelLoader(System* system) : system(system)
+ ModelLoader::ModelLoader(Composite* system) : system(system)
{
LOGENTRY(1, "ModelLoader::constructor");
+
runtime = SCARuntime::getInstance();
LOGEXIT(1, "ModelLoader::constructor");
@@ -59,23 +73,24 @@
// =========================================================
// 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.
+ // the SCDL files to the SCA runtime's in memory model.
// =========================================================
- void ModelLoader::load(const string& configurationRoot)
+ void ModelLoader::load(const string& systemRoot)
{
LOGENTRY(1, "ModelLoader::load");
- LOGINFO_1(2,"configuration root: %s", configurationRoot.c_str());
+ LOGINFO_1(2,"system root: %s", systemRoot.c_str());
// The configuration root path will point to a directory structure.
+ // Implementation packages can occur anywhere under the packages directory
+ loadPackages(systemRoot+"/packages");
+
// The composite files representing the configuration of the system can be located
// anywhere under the configuration directory.
- loadConfiguration(configurationRoot+"/configuration");
-
- // implementations can occur anywhere under the packages directory
- loadComposites(configurationRoot+"/packages");
+ loadConfiguration(systemRoot+"/configuration");
system->resolveWires();
+
LOGEXIT(1, "ModelLoader::load");
}
@@ -91,7 +106,10 @@
Files files(configurationRoot, "*.composite", true);
for (unsigned int i=0; i < files.size(); i++)
{
- loadConfigurationFile(files[i]);
+ Composite* include = loadConfigurationCompositeFile(files[i]);
+
+ // Include each composite in the system composite
+ system->addInclude(include);
}
LOGEXIT(1, "ModelLoader::loadConfiguration");
}
@@ -102,46 +120,48 @@
// This method is called for each composite file found in the configuration
// folder structure
// =====================================================================
- void ModelLoader::loadConfigurationFile(const File& file)
+ Composite* ModelLoader::loadConfigurationCompositeFile(const File& file)
{
- LOGENTRY(1, "ModelLoader::loadConfigurationFile");
+ LOGENTRY(1, "ModelLoader::loadConfigurationCompositeFile");
LOGINFO_1(2, "configuration filename: %s", file.getFileName().c_str());
+ Composite* include;
try
{
string filename = file.getDirectory() + "/" + file.getFileName();
XMLDocumentPtr configurationFile = getXMLHelper()->loadFile(filename.c_str());
if (configurationFile->getRootDataObject() == 0)
{
- LOGERROR_1(0, "ModelLoader::loadConfigurationFile: Unable to load file: %s", filename.c_str());
+ LOGERROR_1(0, "ModelLoader::loadConfigurationCompositeFile: Unable to load file: %s", filename.c_str());
}
else
{
//Utils::printDO(configurationFile->getRootDataObject());
- mapConfiguration(configurationFile->getRootDataObject());
+ include = mapConfigurationComposite(configurationFile->getRootDataObject(), file.getDirectory());
}
} catch (SDORuntimeException ex)
{
- LOGERROR_1(0, "ModelLoader::loadSubsytemFile: Exception caught: %s", ex.getMessageText());
+ LOGERROR_1(0, "ModelLoader::loadConfigurationCompositeFile: Exception caught: %s", ex.getMessageText());
}
- LOGEXIT(1, "ModelLoader::loadConfigurationFile");
+ LOGEXIT(1, "ModelLoader::loadConfigurationCompositeFile");
+ return include;
}
// ===============
// mapConfiguration:
// ===============
- void ModelLoader::mapConfiguration(DataObjectPtr root)
+ Composite* ModelLoader::mapConfigurationComposite(DataObjectPtr root, string compositeRootDir)
{
- LOGENTRY(1, "ModelLoader::mapConfiguration");
-
- LOGINFO_1(2, "ModelLoader::mapConfiguration: Loaded configuration: %s", root->getCString("name"));
+ LOGENTRY(1, "ModelLoader::mapConfigurationComposite");
- Subsystem* subsystem;
- subsystem = system->addSubsystem(root->getCString("name"));
+ LOGINFO_1(2, "ModelLoader::mapConfigurationComposite: Loaded configuration: %s", root->getCString("name"));
+
+ // Create a composite and include it in the system
+ Composite* include = new Composite(root->getCString("name"), compositeRootDir);
DataObjectList& componentDOs = root->getList("component");
- LOGINFO_1(2, "ModelLoader::mapConfiguration: number of composite components: %d", componentDOs.size());
+ LOGINFO_1(2, "ModelLoader::mapConfigurationComposite: number of composite components: %d", componentDOs.size());
// Iterate over components
for (int i=0; i<componentDOs.size(); i++)
@@ -156,16 +176,27 @@
}
// Determine the implementation type
- string implType = impl->getType().getName();
- if (implType == "SCAImplementation")
+ string implementationType = impl->getType().getName();
+ if (implementationType == "SCAImplementation")
{
- // Add each composite component to the subsystem
- Composite* composite;
- composite = subsystem->addCompositeComponent(componentDOs[i]->getCString("name"), impl->getCString("name"));
+ // Add each composite component to the include
+
+ Composite* composite = packages[impl->getCString("name")];
+ if (!composite)
+ {
+ string message = "Composite not found: ";
+ message = message + impl->getCString("name");
+ throw SystemConfigurationException(message.c_str());
+ }
+ else
+ {
+ Component* component = new Component(include, componentDOs[i]->getCString("name"), composite);
+ include->addComponent(component);
+ }
}
else
{
- string message = "Atomic component implementation not yet supported in a subsystem: ";
+ string message = "Atomic component implementation not yet supported in a system include: ";
message = message + componentDOs[i]->getCString("name");
throw SystemConfigurationException(message.c_str());
}
@@ -173,164 +204,123 @@
//TODO Add composite services and references
- LOGEXIT(1, "ModelLoader::mapConfiguration");
+ LOGEXIT(1, "ModelLoader::mapConfigurationComposite");
+ return include;
}
// =====================================================================
- // loadComposites:
- // Load all the composites from any directory below the configuration root.
+ // loadPackages:
+ // Load all the composites from any directory below the packages root.
// Translate the composite information to the runtime information
// =====================================================================
- void ModelLoader::loadComposites(const string& configurationRoot)
+ void ModelLoader::loadPackages(const string& installRoot)
{
- // Get all the main composite files (named like the directory that contains them)
- LOGENTRY(1, "ModelLoader::loadComposites");
- Files files(configurationRoot, "*.composite", true);
+ // Get all the composite files
+ LOGENTRY(1, "ModelLoader::loadPackages");
+ Files files(installRoot, "*.composite", true);
for (unsigned int i=0; i < files.size(); i++)
{
- /*string directoryName = files[i].getDirectory();
- string fileName = files[i].getFileName();
- int fl = fileName.length()-10;
- string compositeName = "/" + fileName.substr(0, fl);
- fl++;
- int dl = directoryName.length();
- if (dl>fl && directoryName.substr(dl-fl, fl) == compositeName)
- {*/
- loadCompositeFile(files[i]);
- //}
+ loadPackageCompositeFile(files[i]);
}
- LOGEXIT(1, "ModelLoader::loadComposites");
+ LOGEXIT(1, "ModelLoader::loadPackages");
}
// ====================================================================
- // loadCompositeFile:
- // This method is called for each sca.composite file found in the composite
+ // loadPackageCompositeFile:
+ // This method is called for each .composite file found in the packages
// folder structure
// The location of this composite file will indicate the root of a composite
// ====================================================================
- void ModelLoader::loadCompositeFile(const File& file)
+ Composite* ModelLoader::loadPackageCompositeFile(const File& file)
{
- LOGENTRY(1, "ModelLoader::loadCompositeFile");
+ LOGENTRY(1, "ModelLoader::loadPackageCompositeFile");
LOGINFO_1(2, "composite filename: %s", file.getFileName().c_str());
-
+
+ Composite* composite = NULL;
try
{
- string mainFileName = file.getDirectory() + "/" + file.getFileName();
-
- XMLDocumentPtr compositeFile = getXMLHelper()->loadFile(mainFileName.c_str());
- if (compositeFile->getRootDataObject() == 0)
+ string fileName = file.getDirectory() + "/" + file.getFileName();
+ XMLDocumentPtr compositeFile = getXMLHelper()->loadFile(fileName.c_str());
+ if (compositeFile->getRootDataObject() == NULL)
{
- LOGERROR_1(0, "ModelLoader::loadCompositeFile: Unable to load file: %s", mainFileName.c_str());
+ LOGERROR_1(0, "ModelLoader::loadPackageCompositeFile: Unable to load file: %s", fileName.c_str());
}
else
{
- string compositeName = compositeFile->getRootDataObject()->getCString("name");
- mapComposite(compositeName, compositeFile->getRootDataObject(), file.getDirectory());
-
- // --------------------------------------------------------------
- // Load any other composites in the same folder as the main composite
- // --------------------------------------------------------------
- Files files(file.getDirectory(), "*.composite", false);
- for (unsigned int i=0; i < files.size(); i++)
- {
- string filename = file.getDirectory() + "/" + files[i].getFileName();
-
- // Skip the main composite file
- if (filename == mainFileName)
- continue;
-
- compositeFile = getXMLHelper()->loadFile(filename.c_str());
- if (compositeFile->getRootDataObject() == 0)
- {
- LOGERROR_1(0, "ModelLoader::loadCompositeFile: Unable to load file: %s", filename.c_str());
- }
- else
- {
- mapComposite(compositeName, compositeFile->getRootDataObject(), file.getDirectory());
- }
- }
+ // Map the SCDL
+ composite = mapPackageComposite(compositeFile->getRootDataObject(), file.getDirectory());
// Load the xsd types and wsdl files in the composite
- loadCompositeConfig(file.getDirectory(), compositeName);
+ loadTypeMetadata(composite, file.getDirectory());
}
} catch (SDORuntimeException ex)
{
- LOGERROR_1(0, "ModelLoader::loadCompositeFile: Exception caught: %s", ex.getMessageText());
+ LOGERROR_1(0, "ModelLoader::loadPackageCompositeFile: Exception caught: %s", ex.getMessageText());
}
- LOGEXIT(1, "ModelLoader::loadCompositeFile");
+ LOGEXIT(1, "ModelLoader::loadPackageCompositeFile");
+ return composite;
}
// ===========
- // mapComposite
+ // mapPackageComposite
// ===========
- void ModelLoader::mapComposite(const string& compositeName, DataObjectPtr root, string compositeRootDir)
+ Composite* ModelLoader::mapPackageComposite(DataObjectPtr root, string compositeRootDir)
{
- LOGENTRY(1, "ModelLoader::mapComposite");
+ LOGENTRY(1, "ModelLoader::mapPackageComposite");
- LOGINFO_2(2, "ModelLoader::mapComposite: Loading composite: %s, root Dir: %s", compositeName.c_str(), compositeRootDir.c_str());
+ string compositeName = root->getCString("name");
+ LOGINFO_2(2, "ModelLoader::mapPackageComposite: Loading composite: %s, root Dir: %s", compositeName.c_str(), compositeRootDir.c_str());
- // Find the CompositeComponent(s) that refer to this composite. If a CompositeComponent does not refer to this
- // composite then ignore it
- COMPOSITE_LIST compositeList = system->findComposites(compositeName);
- COMPOSITE_LIST::iterator compositeIter;
+ Composite* composite = new Composite(compositeName, compositeRootDir);
+ packages[compositeName] = composite;
- for (compositeIter = compositeList.begin();
- compositeIter != compositeList.end();
- compositeIter++ )
+ // ----------------------------
+ // Add components to the composite
+ // ----------------------------
+ DataObjectList& componentList = root->getList("component");
+ int i;
+ for (i=0; i < componentList.size(); i++)
{
- LOGINFO_1(2, "ModelLoader::mapComposite: Loading composite details for composite component: %s", (*compositeIter)->getName().c_str());
-
- string message; // for exceptions
- // Set composite root
- (*compositeIter)->setRoot(compositeRootDir);
-
- // ----------------------------
- // Add components to the composite
- // ----------------------------
- DataObjectList& componentList = root->getList("component");
- int i;
- for (i=0; i < componentList.size(); i++)
- {
- addComponent(*compositeIter, componentList[i]);
- }
+ addComponent(composite, componentList[i]);
+ }
- // ------------
- // Entry points
- // ------------
- DataObjectList& compositeServiceList = root->getList("service");
- for (i=0; i < compositeServiceList.size(); i++)
- {
- addCompositeServiceType(*compositeIter, compositeServiceList[i]);
- }
-
+ // ------------
+ // Composite services
+ // ------------
+ DataObjectList& compositeServiceList = root->getList("service");
+ for (i=0; i < compositeServiceList.size(); i++)
+ {
+ addCompositeService(composite, compositeServiceList[i]);
+ }
- // -----------------
- // External services
- // -----------------
- DataObjectList& compositeReferenceTypeList = root->getList("reference");
- for (i=0; i < compositeReferenceTypeList.size(); i++)
- {
- addCompositeReferenceType(*compositeIter, compositeReferenceTypeList[i]);
- }
+ // -----------------
+ // Composite references
+ // -----------------
+ DataObjectList& compositeReferenceList = root->getList("reference");
+ for (i=0; i < compositeReferenceList.size(); i++)
+ {
+ addCompositeReference(composite, compositeReferenceList[i]);
+ }
- // -----
- // Wires
- // -----
- DataObjectList& wireList = root->getList("wire");
- for (int l=0; l < wireList.size(); l++)
- {
- string source = wireList[l]->getCString("source");
- string target = wireList[l]->getCString("target");
- (*compositeIter)->addWire(source, target);
- }
-
+ // -----
+ // Wires
+ // -----
+ DataObjectList& wireList = root->getList("wire");
+ for (int l=0; l < wireList.size(); l++)
+ {
+ string source = wireList[l]->getCString("source");
+ string target = wireList[l]->getCString("target");
+ composite->addWire(source, target);
}
+
+ composite->resolveWires();
- LOGEXIT(1, "ModelLoader::mapComposite");
+ LOGEXIT(1, "ModelLoader::mapPackageComposite");
+ return composite;
}
// =================================
@@ -338,21 +328,23 @@
// =================================
void ModelLoader::addComponent(Composite* composite, DataObjectPtr componentDO)
{
- Component* component = composite->addComponent(componentDO->getCString("name"));
-
- string message;
-
// -------------------
- // Implementation type
+ // Get the component implementation
// -------------------
DataObjectPtr impl = componentDO->getDataObject("implementation");
if (!impl)
{
- message = "No implementation for component: ";
+ string message = "No implementation for component: ";
message = message + componentDO->getCString("name");
throw SystemConfigurationException(message.c_str());
}
+ // Create the component type
+ ComponentType* componentType;
+ string componentTypeName;
+ string componentTypePath;
+ string implementationType = impl->getType().getName();
+
string implTypeQname = impl->getType().getURI();
implTypeQname += "#";
implTypeQname += impl->getType().getName();
@@ -361,45 +353,46 @@
ImplementationExtension* implExtension = runtime->getImplementationExtension(implTypeQname);
if (implExtension)
{
- component->setImplementation(implExtension->getImplementation(impl));
+ componentType = implExtension->getImplementation(composite, impl);
+
+ // -----------------------
+ // Load the .componentType
+ // -----------------------
+ string typeFileName = composite->getRoot() + "/" + componentType->getName() + ".componentType";
+ try
+ {
+ XMLDocumentPtr componentTypeFile = getXMLHelper()->loadFile(typeFileName.c_str());
+ if (!componentTypeFile || componentTypeFile->getRootDataObject() == 0)
+ {
+ LOGERROR_1(0, "ModelLoader::addComponent: Unable to load file: %s", typeFileName.c_str());
+ }
+ else
+ {
+ //Utils::printDO(componentTypeFile->getRootDataObject());
+ //commonj::sdo::SDOUtils::printDataObject(componentTypeFile->getRootDataObject());
+ addServiceTypes(composite, componentType, componentTypeFile->getRootDataObject());
+ addReferenceTypes(composite, componentType, componentTypeFile->getRootDataObject());
+ addPropertyTypes(componentType, componentTypeFile->getRootDataObject());
+ }
+ } catch (SDORuntimeException& ex)
+ {
+ LOGERROR_2(0, "ModelLoader::addComponent (%s): Exception caught: %s",
+ typeFileName.c_str(), ex.getMessageText());
+ throw SystemConfigurationException(ex.getMessageText());
+ }
}
else
{
LOGERROR_1(0, "ModelLoader::addComponent: Unsupported implementation type: %s", implTypeQname.c_str());
+
+ string message = "Implementation type not supported: ";
+ message = message + implTypeQname;
+ throw SystemConfigurationException(message.c_str());
}
- // -----------------------
- // Load the .componentType
- // -----------------------
- Implementation* theImpl = component->getImplementation();
- if (theImpl)
- {
- string componentTypeFileName = theImpl->getComponentTypeFileName();
- if (componentTypeFileName != "")
- {
- string typeFileName = composite->getRoot() + "/" + componentTypeFileName + ".componentType";
- try
- {
- XMLDocumentPtr componentTypeFile = getXMLHelper()->loadFile(typeFileName.c_str());
- if (!componentTypeFile || componentTypeFile->getRootDataObject() == 0)
- {
- LOGERROR_1(0, "ModelLoader::addComponent: Unable to load file: %s", typeFileName.c_str());
- }
- else
- {
- addServices(component, componentTypeFile->getRootDataObject());
- addReferences(component, componentTypeFile->getRootDataObject());
- addProperties(component, componentTypeFile->getRootDataObject());
- }
- } catch (SDORuntimeException& ex)
- {
- LOGERROR_2(0, "ModelLoader::addComponent (%s): Exception caught: %s",
- typeFileName.c_str(), ex.getMessageText());
- throw SystemConfigurationException(ex.getMessageText());
- }
- }
- }
-
+ // Create the component
+ Component* component = new Component(composite, componentDO->getCString("name"), componentType);
+ composite->addComponent(component);
// ----------
// Properties
@@ -426,7 +419,7 @@
if (!component->findReference(refName))
{
// Configuration error: reference is not defined
- message = "Undefined reference: " + refName;
+ string message = "Undefined reference: " + refName;
throw SystemConfigurationException(message.c_str());
}
@@ -439,36 +432,46 @@
}
}
-
// =====================================================================
- // addServices: add the services from the componentType to the component
+ // addServiceTypes: add the services to the component type
// =====================================================================
- void ModelLoader::addServices(Component* component, DataObjectPtr componentType)
+ void ModelLoader::addServiceTypes(Composite* composite, ComponentType* componentType, DataObjectPtr componentTypeDO)
{
- DataObjectList& services = componentType->getList("service");
- for (int i=0; i<services.size(); i++)
+ DataObjectList& serviceTypes = componentTypeDO->getList("service");
+ for (int i=0; i<serviceTypes.size(); i++)
{
- Service* service = component->addService(services[i]->getCString("name"));
- service->setInterface(getInterface(services[i]));
+ Interface* interface = getInterface(composite, serviceTypes[i]);
+ ServiceType* serviceType = new ServiceType(
+ componentType, serviceTypes[i]->getCString("name"), interface, NULL, false);
+ componentType->addServiceType(serviceType);
}
}
// ===================================================
- // addReferences: add the references to the component
+ // addReferenceTypes: add the references to the component type
// ===================================================
- void ModelLoader::addReferences(Component* component, DataObjectPtr componentType)
+ void ModelLoader::addReferenceTypes(Composite* composite, ComponentType* componentType, DataObjectPtr componentTypeDO)
{
- DataObjectList& refs = componentType->getList("reference");
+ DataObjectList& refs = componentTypeDO->getList("reference");
for (int i=0; i<refs.size(); i++)
{
- ServiceReference* serviceRef = component->addReference(refs[i]->getCString("name"));
- string multiplicity = "1..1";
+ ReferenceType::Multiplicity multiplicity;
if (refs[i]->isSet("multiplicity"))
{
- multiplicity = refs[i]->getCString("multiplicity");
+ string s = refs[i]->getCString("multiplicity");
+ multiplicity = ReferenceType::getMultiplicityFromString(s);
+ }
+ else
+ {
+ multiplicity = ReferenceType::ONE_ONE;
}
- serviceRef->setMultiplicity(multiplicity);
- serviceRef->setInterface(getInterface(refs[i]));
+
+ Interface* interface = getInterface(composite, refs[i]);
+
+ ReferenceType* referenceType = new ReferenceType(
+ componentType, refs[i]->getCString("name"), interface, NULL, false, multiplicity);
+ componentType->addReferenceType(referenceType);
+
}
}
@@ -476,7 +479,7 @@
// ==============
// getInterface
// ==============
- Interface* ModelLoader::getInterface(DataObjectPtr obj)
+ Interface* ModelLoader::getInterface(Composite* composite, DataObjectPtr obj)
{
// -----------------
// get the interface
@@ -497,7 +500,7 @@
InterfaceExtension* ifaceExtension = runtime->getInterfaceExtension(typeQname);
if (ifaceExtension)
{
- return ifaceExtension->getInterface(iface);
+ return ifaceExtension->getInterface(composite, iface);
}
else
{
@@ -509,11 +512,11 @@
}
// ==============================================
- // addProperties: add Properties to the component
+ // addProperties: add properties to the component type
// ==============================================
- void ModelLoader::addProperties(Component* component, DataObjectPtr componentType)
+ void ModelLoader::addPropertyTypes(ComponentType* componentType, DataObjectPtr componentTypeDO)
{
- DataObjectList& props = componentType->getList("property");
+ DataObjectList& props = componentTypeDO->getList("property");
for (int i=0; i<props.size(); i++)
{
//cout << "Property " << props[i];
@@ -527,34 +530,42 @@
}
//TODO need to add support for complex properties, need the SDO
- // folks to shed some light on how to do this...
+ // folks to help understand how to do this...
DataObjectPtr defaultValue;
if (props[i]->isSet("value")) {
defaultValue = props[i]->getDataObject("value");
}
- component->addProperty(name, type, many, defaultValue);
+ componentType->addPropertyType(name, type, many, defaultValue);
}
}
// ===============================================
- // addCompositeServiceType: add an CompositeServiceType to the composite
+ // addCompositeService: add an CompositeService to the composite
// ===============================================
- void ModelLoader::addCompositeServiceType(Composite* composite, DataObjectPtr compositeServiceDO)
+ void ModelLoader::addCompositeService(Composite* composite, DataObjectPtr compositeServiceDO)
{
- string message;
//Utils::printDO(compositeServiceDO);
- CompositeServiceType* compositeServiceType = composite->addCompositeServiceType(compositeServiceDO->getCString("name"));
-
- string multiplicity = "1..1";
- if (compositeServiceDO->isSet("multiplicity"))
- {
- multiplicity = compositeServiceDO->getCString("multiplicity");
- }
+ string compositeServiceName = compositeServiceDO->getCString("name");
+
+ Interface* interface = getInterface(composite, compositeServiceDO);
+
+ ReferenceType::Multiplicity multiplicity;
+ if (compositeServiceDO->isSet("multiplicity"))
+ {
+ string s = compositeServiceDO->getCString("multiplicity");
+ multiplicity = ReferenceType::getMultiplicityFromString(s);
+ }
+ else
+ {
+ multiplicity = ReferenceType::ONE_ONE;
+ }
- compositeServiceType->setMultiplicity(multiplicity);
- compositeServiceType->setInterface(getInterface(compositeServiceDO));
+ CompositeService* compositeService = new CompositeService(
+ composite, compositeServiceName, interface, NULL, false, multiplicity);
+
+ composite->addComponent(compositeService);
DataObjectList& refs = compositeServiceDO->getList("reference");
for (int i=0; i<refs.size(); i++)
@@ -563,14 +574,14 @@
// Add the reference to the composite wires to be resolved later
// ----------------------------------------------------------
string targ = refs.getCString(i);
- composite->addWire(compositeServiceType->getName(), targ);
+ composite->addWire(compositeServiceName, targ);
}
// Get binding, it will be the first and only binding
DataObjectList& bindings = compositeServiceDO->getList("binding");
if (bindings.size()==0)
{
- message = "No binding for compositeService: ";
+ string message = "No binding for compositeService: ";
message = message + compositeServiceDO->getCString("name");
throw SystemConfigurationException(message.c_str());
}
@@ -586,14 +597,15 @@
{
string port = binding->getCString("port");
- WSBinding* wsBinding = new WSBinding(uri,port);
+ Reference* reference = compositeService->getReference();
+ WSReferenceBinding* wsBinding = new WSReferenceBinding(reference, uri, port);
- compositeServiceType->setBinding(wsBinding);
+ reference->setBinding(wsBinding);
}
- else if (bindingType == "SCABinding")
+ else
{
- message = "SCA binding not yet implemented. Binding is for compositeService: ";
+ string message = "Binding type not yet implemented. Binding is for compositeService: ";
message = message + compositeServiceDO->getCString("name");
throw SystemConfigurationException(message.c_str());
}
@@ -601,23 +613,25 @@
// =========================================================
- // addCompositeReferenceType: add an CompositeReferenceType to the composite
+ // addCompositeReference: add a CompositeReference to the composite
// =========================================================
- void ModelLoader::addCompositeReferenceType(Composite* composite, DataObjectPtr compositeReferenceTypeDO)
+ void ModelLoader::addCompositeReference(Composite* composite, DataObjectPtr compositeReferenceDO)
{
- string message;
-
- CompositeReferenceType* compositeReferenceType = composite->addCompositeReferenceType(compositeReferenceTypeDO->getCString("name"));
-
- // Add the interface
- compositeReferenceType->setInterface(getInterface(compositeReferenceTypeDO));
+ string compositeReferenceName = compositeReferenceDO->getCString("name");
+ Interface* interface = getInterface(composite, compositeReferenceDO);
+
+ CompositeReference* compositeReference = new CompositeReference(
+ composite, compositeReferenceName, interface, NULL, false, ReferenceType::ONE_ONE);
+
+ composite->addComponent(compositeReference);
+
// Get binding, it will be the first and only binding
- DataObjectList& bindings = compositeReferenceTypeDO->getList("binding");
+ DataObjectList& bindings = compositeReferenceDO->getList("binding");
if (bindings.size()==0)
{
- message = "No binding for compositeReferenceType: ";
- message = message + compositeReferenceTypeDO->getCString("name");
+ string message = "No binding for compositeReference: ";
+ message = message + compositeReferenceDO->getCString("name");
throw SystemConfigurationException(message.c_str());
}
DataObjectPtr binding = bindings[0];
@@ -632,25 +646,28 @@
{
string port = binding->getCString("port");
- WSBinding* wsBinding = new WSBinding(uri,port);
+ Service* service = compositeReference->getService();
+ WSServiceBinding* wsBinding = new WSServiceBinding(service, uri,port);
- compositeReferenceType->setBinding(wsBinding);
+ service->setBinding(wsBinding);
}
- else if (bindingType == "SCABinding")
+ else
{
+ string message = "Binding type not yet implemented. Binding is for compositeReference: ";
+ message = message + compositeReferenceDO->getCString("name");
+ throw SystemConfigurationException(message.c_str());
}
}
-
///
/// Use the Tuscany-model.config file in the composite root directory to
/// determine which xsds and wsdls to load into a dataFactory.
///
- void ModelLoader::loadCompositeConfig(const string &compositeRootDir, const string &compositeName)
+ void ModelLoader::loadTypeMetadata(Composite* composite, const string &compositeRootDir)
{
- LOGENTRY(1, "ModelLoader::loadCompositeConfig");
+ LOGENTRY(1, "ModelLoader::loadTypeMetadata");
// Load the "Tuscany-model.config" file, if it exists
Files files(compositeRootDir, "Tuscany-model.config", false);
@@ -660,11 +677,11 @@
XMLDocumentPtr compositeConfigFile = getXMLHelper()->loadFile(filename.c_str());
if (compositeConfigFile->getRootDataObject() == 0)
{
- LOGERROR_1(0, "ModelLoader::loadCompositeConfig: Unable to load file: %s", filename.c_str());
+ LOGERROR_1(0, "ModelLoader::loadTypeMetadata: Unable to load file: %s", filename.c_str());
}
else
{
- LOGINFO_2(2, "ModelLoader::loadCompositeConfig: Loading composite config for: %s, root Dir: %s", compositeName.c_str(), compositeRootDir.c_str());
+ LOGINFO_2(2, "ModelLoader::loadTypeMetadata: Loading composite config for: %s, root Dir: %s", composite->getName().c_str(), compositeRootDir.c_str());
if(compositeConfigFile->getRootDataObject()->isSet("xsd"))
{
@@ -676,7 +693,7 @@
{
// Load a xsd file -> set the types in the compositeComponents data factory file
string xsdName = compositeRootDir + "/" +xsds[i]->getCString("name");
- loadTypes(xsdName.c_str(), compositeName);
+ loadXMLSchema(composite, xsdName.c_str());
}
}
}
@@ -691,10 +708,10 @@
{
string wsdlName = compositeRootDir + "/" +wsdls[j]->getCString("name");
// Load a wsdl file -> get the types, then the contents of the wsdl
- loadTypes(wsdlName.c_str(), compositeName);
+ loadXMLSchema(composite, wsdlName.c_str());
// Load the contents of the wsdl files
- loadWsdl(wsdlName.c_str(), compositeName);
+ loadWSDLDefinition(composite, wsdlName.c_str());
}
}
}
@@ -702,45 +719,37 @@
}
- LOGEXIT(1, "ModelLoader::loadCompositeConfig");
+ LOGEXIT(1, "ModelLoader::loadTypeMetadata");
}
///
/// Use the types from an xsd or wsdl file
///
- void ModelLoader::loadTypes(const char *fileName, const string &compositeName)
+ void ModelLoader::loadXMLSchema(Composite* composite, const char *fileName)
{
- LOGENTRY(1, "ModelLoader::loadTypes");
+ LOGENTRY(1, "ModelLoader::loadXMLSchema");
- // Load a xsd file -> set the types in the compositeComponents data factory file
-
- COMPOSITE_LIST compositeList = system->findComposites(compositeName);
- COMPOSITE_LIST::iterator compositeIter;
-
- for (compositeIter = compositeList.begin();
- compositeIter != compositeList.end();
- compositeIter++ )
+ // Load a xsd file -> set the types in the data factory associated with
+ // the composite
+ try {
+ composite->getXSDHelper()->defineFile(fileName);
+ //Utils::printTypes((*compositeIter)->getXSDHelper()->getDataFactory());
+
+ } catch (SDOTypeNotFoundException ex)
{
- try {
- (*compositeIter)->getXSDHelper()->defineFile(fileName);
- //Utils::printTypes((*compositeIter)->getXSDHelper()->getDataFactory());
-
- } catch (SDOTypeNotFoundException ex)
- {
- LOGERROR_1(0, "CompositeLoader: Exception caught: %s", ex.getMessageText());
- throw ex;
- }
+ LOGERROR_1(0, "ModelLoader: Exception caught: %s", ex.getMessageText());
+ throw ex;
}
- LOGEXIT(1, "ModelLoader::loadTypes");
+ LOGEXIT(1, "ModelLoader::loadXMLSchema");
}
///
/// Load the web services definition from a wsdl
///
- void ModelLoader::loadWsdl(const char *fileName, const string &compositeName)
+ void ModelLoader::loadWSDLDefinition(Composite* composite, const char *fileName)
{
- LOGENTRY(1, "ModelLoader::loadWsdl");
+ LOGENTRY(1, "ModelLoader::loadWSDLDefinition");
try {
// Load the wsdl file
@@ -749,22 +758,14 @@
if (doc!=0 && doc->getRootDataObject()!=0)
{
//Utils::printDO(doc->getRootDataObject());
- COMPOSITE_LIST compositeList = system->findComposites(compositeName);
- COMPOSITE_LIST::iterator compositeIter;
- for (compositeIter = compositeList.begin();
- compositeIter != compositeList.end();
- compositeIter++ )
- {
- // Add the root object to the composite
- (*compositeIter)->addWsdl(doc->getRootDataObject());
-
- }
+ // Add the root WSDL object to the composite
+ composite->addWSDLDefinition(doc->getRootDataObject());
}
else
{
- LOGERROR_1(0, "CompositeLoader: Unable to load or parse WSDL %s", fileName);
+ LOGERROR_1(0, "ModelLoader: Unable to load or parse WSDL %s", fileName);
}
} catch (SDOTypeNotFoundException ex)
@@ -777,7 +778,7 @@
LOGERROR_1(0, "ModelLoader: SDONullPointerException caught: %s", ex.getMessageText());
throw ex;
}
- LOGEXIT(1, "ModelLoader::loadWsdl");
+ LOGEXIT(1, "ModelLoader::loadWSDLDefinition");
}
@@ -808,7 +809,7 @@
filename = root + "/xsd/tuscany.xsd";
myXSDHelper->defineFile(filename.c_str());
- loadWSDLTypes(myXSDHelper);
+ initializeWSDLModel(myXSDHelper);
// Load any schema from the extensions directory
string extensionsRoot = root + "/extensions";
@@ -823,7 +824,7 @@
} catch (SDOTypeNotFoundException ex)
{
- LOGERROR_1(0, "CompositeLoader: Exception caught: %s", ex.getMessageText());
+ LOGERROR_1(0, "ModelLoader: Exception caught: %s", ex.getMessageText());
throw ex;
}
}
@@ -849,7 +850,7 @@
return myXMLHelper;
}
- void ModelLoader::loadWSDLTypes(XSDHelperPtr xsdHelper)
+ void ModelLoader::initializeWSDLModel(XSDHelperPtr xsdHelper)
{
DataFactoryPtr dataFactory = xsdHelper->getDataFactory();
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h Mon Aug 28 03:42:10 2006
@@ -22,32 +22,39 @@
#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/core/SCARuntime.h"
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
#include "tuscany/sca/util/File.h"
-#include "tuscany/sca/core/SCARuntime.h"
+#include <map>
+using std::map;
+
+using namespace commonj::sdo;
+using namespace tuscany::sca;
+
+
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);
+ ModelLoader(Composite* system);
/**
* Destructor.
@@ -59,43 +66,55 @@
* @param configurationRoot The location of the deployed SCA
* packages and configuration.
*/
- void load(const string& configurationRoot);
+ void load(const string& systemRoot);
private:
- SCARuntime* runtime;
- System* system;
void loadComposite(const char *compositeRoot);
-
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 loadConfiguration(const string& configurationRoot);
- void loadConfigurationFile(const File& file);
- void mapConfiguration(commonj::sdo::DataObjectPtr rootDO);
+ Composite* loadConfigurationCompositeFile(const File& file);
+ Composite* mapConfigurationComposite(DataObjectPtr rootDO, const string compositeRootDir);
- void loadComposites(const string& configurationRoot);
- void loadCompositeFile(const File& file);
- void mapComposite(const string& compositeName, commonj::sdo::DataObjectPtr rootDO, std::string compositeRootDir);
+ void loadPackages(const string& installRoot);
+ Composite* loadPackageCompositeFile(const File& file);
+ Composite* mapPackageComposite(DataObjectPtr rootDO, const string compositeRootDir);
void addComponent(Composite* composite, DataObjectPtr componentDO);
- void addCompositeServiceType(Composite* composite, DataObjectPtr compositeServiceDO);
- void addCompositeReferenceType(Composite* composite, DataObjectPtr externalServiceDO);
-
- void addServices(Component* component, DataObjectPtr componentType);
- void addReferences(Component* component, DataObjectPtr componentType);
- void addProperties(Component* component, DataObjectPtr componentType);
+ void addCompositeService(Composite* composite, DataObjectPtr compositeServiceDO);
+ void addCompositeReference(Composite* composite, DataObjectPtr referenceServiceDO);
+ void addServiceTypes(Composite* composite, ComponentType* componentType, DataObjectPtr componentTypeDO);
+ void addReferenceTypes(Composite* composite, ComponentType* componentType, DataObjectPtr componentTypeDO);
+ void addPropertyTypes(ComponentType* componentType, DataObjectPtr componentTypeDO);
+
+ void loadTypeMetadata(Composite* composite, const string &compositeRootDir);
+
+ void loadXMLSchema(Composite* composite, const char *fileName);
+ void loadWSDLDefinition(Composite* composite, const char *fileName);
+ void initializeWSDLModel(XSDHelperPtr xsdHelper);
+
+ Interface* getInterface(Composite* composite, DataObjectPtr obj);
- void loadCompositeConfig(const string &compositeRootDir, const string &compositeName);
- void loadTypes(const char *fileName, const string &compositeName);
- void loadWsdl(const char *fileName, const string &compositeName);
+ SCARuntime* runtime;
- void loadWSDLTypes(XSDHelperPtr xsdHelper);
-
- Interface* getInterface(DataObjectPtr obj);
+ /**
+ * The composite describing the composition of the system
+ * All the composites under the configuration root directory are
+ * included in the system composite.
+ */
+ Composite* system;
+
+ /**
+ * Map of all the package composites installed on the system.
+ */
+ typedef map<string, Composite*> PACKAGES;
+ PACKAGES packages;
};
} // End namespace model
Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.cpp?rev=437637&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.cpp Mon Aug 28 03:42:10 2006
@@ -0,0 +1,70 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+ // Constructor
+ Reference::Reference(Component* component, ReferenceType* referenceType)
+ : component(component), type(referenceType), binding(0)
+ {
+ }
+
+ // Destructor
+ Reference::~Reference()
+ {
+ }
+
+ void Reference::setBinding(ReferenceBinding* binding)
+ {
+ this->binding = binding;
+ }
+
+ ReferenceBinding* Reference::getBinding() const
+ {
+ return binding;
+ }
+
+ void Reference::addTarget(Service* target)
+ {
+ if (type->getMultiplicity() == ReferenceType::ONE_ONE || type->getMultiplicity() == ReferenceType::ZERO_ONE)
+ {
+ if (targets.size() > 0)
+ {
+ // throw exception
+ string message = "Duplicate wire for reference: " + type->getName();
+ throw SystemConfigurationException(message.c_str());
+ }
+ }
+
+ targets.push_back(target);
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.h?rev=437637&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.h Mon Aug 28 03:42:10 2006
@@ -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$ */
+
+#ifndef tuscany_sca_model_reference_h
+#define tuscany_sca_model_reference_h
+
+#include <string>
+using std::string;
+#include <vector>
+using std::vector;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ class Component;
+ class ReferenceType;
+ class ReferenceBinding;
+ class Service;
+
+ /**
+ * An addressable instance of a reference type associated with a particular component.
+ * Each reference represents a configured version of a logical
+ * reference type defined in the component type. If the logical reference
+ * has a multiplicity greater than 1 (0..n or 1..n) then the configured
+ * reference many have multiple targets.
+ */
+ class Reference
+ {
+ public:
+ /**
+ * Constructor.
+ * @param component The component on which the reference is defined.
+ * @param referenceType The reference type defining the characteristics of the reference.
+ */
+ Reference(Component* component, ReferenceType* referenceType);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Reference();
+
+ /**
+ * Returns the component on which this reference is defined.
+ * @return The component on which this reference is defined.
+ */
+ Component* getComponent() const { return component; }
+
+ /**
+ * Returns the reference type defining the characteristics of the reference.
+ * @return The reference type defining the characteristics of the reference.
+ */
+ ReferenceType* getType() const { return type; }
+
+ /**
+ * Returns the binding supported by the reference.
+ * @return The binding supported by the reference.
+ */
+ ReferenceBinding* getBinding() const;
+
+ /**
+ * Sets the binding supported by the reference.
+ * @param binding The binding supported by the reference.
+ */
+ void setBinding(ReferenceBinding* binding);
+
+ /**
+ * Add a target for this reference. There may be more than
+ * one if the multiplicity is 0..n or 1..n.
+ * @param target The target of the reference.
+ */
+ void addTarget(Service* target);
+
+ typedef vector<Service*> TARGETS;
+
+ /**
+ * Get a vector of all the targets from this reference.
+ * @return The targets of this reference.
+ */
+ const TARGETS& getTargets() const { return targets; }
+
+ private:
+
+ /**
+ * The component on which this reference is defined.
+ */
+ Component* component;
+
+ /**
+ * The reference type defining the characteristics of the reference.
+ */
+ ReferenceType* type;
+
+ /**
+ * The binding supported by this reference
+ */
+ ReferenceBinding* binding;
+
+ /**
+ * Vector of all the targets wired from this reference.
+ */
+ TARGETS targets;
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_reference_h
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Reference.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp?rev=437637&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp Mon Aug 28 03:42:10 2006
@@ -0,0 +1,45 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ ReferenceBinding::ReferenceBinding(Reference *reference, const string& uri) :
+ Binding(uri), reference(reference)
+ {
+ }
+
+ // Destructor
+ ReferenceBinding::~ReferenceBinding()
+ {
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h?rev=437637&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h Mon Aug 28 03:42:10 2006
@@ -0,0 +1,94 @@
+/*
+ *
+ * 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_model_referencebinding_h
+#define tuscany_sca_model_referencebinding_h
+#include <string>
+using std::string;
+
+#include "tuscany/sca/model/Binding.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ class ServiceProxy;
+
+ using namespace tuscany::sca;
+
+ namespace model
+ {
+ class Reference;
+ class ServiceBinding;
+
+ /**
+ * Represents a reference binding.
+ * Bindings are used by services and references. References use bindings
+ * to describe the access mechanism used to call an external service (which can
+ * be a service provided by another SCA composite). Services use bindings to describe
+ * the access mechanism that clients (which can be a client from another SCA composite)
+ * have to use to call the service.
+ * This interface will typically be extended by binding implementations to allow
+ * specification of binding/transport specific information.
+ */
+ class ReferenceBinding : public Binding
+ {
+ public:
+
+ /**
+ * Constructor to create a new binding.
+ */
+ ReferenceBinding(Reference* reference, const string& uri);
+
+ /**
+ * Destructor.
+ */
+ virtual ~ReferenceBinding();
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ virtual ServiceProxy* getServiceProxy() = 0;
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ virtual void configure(ServiceBinding* serviceBinding) = 0;
+
+ /**
+ * Returns the reference.
+ * @return The reference.
+ */
+ Reference* getReference() const { return reference; };
+
+ private:
+
+ /**
+ * The reference configured with the binding.
+ */
+ Reference* reference;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_referencebinding_h
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.cpp?rev=437637&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.cpp Mon Aug 28 03:42:10 2006
@@ -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$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/model/ReferenceType.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+
+
+ // Constructor
+ ReferenceType::ReferenceType(ComponentType* componentType, const string& name,
+ Interface* interface, Interface* callbackInterface, bool conversational, Multiplicity multiplicity)
+ : Contract(interface, callbackInterface, conversational),
+ componentType(componentType), name(name), multiplicity(multiplicity)
+ {
+ }
+
+ ReferenceType::~ReferenceType()
+ {
+ }
+
+ ReferenceType::Multiplicity ReferenceType::getMultiplicityFromString(const string& multip)
+ {
+ if (multip == "0..1")
+ {
+ return ReferenceType::ZERO_ONE;
+ }
+ else if (multip == "1..1")
+ {
+ return ReferenceType::ONE_ONE;
+ }
+ else if (multip == "0..n")
+ {
+ return ReferenceType::ZERO_MANY;
+ }
+ else if (multip == "1..n")
+ {
+ return ReferenceType::ONE_MANY;
+ }
+ else
+ {
+ return ReferenceType::UNKNOWN;
+ }
+ }
+
+ void ReferenceType::setBinding(Binding* binding)
+ {
+ this->binding = binding;
+ }
+
+ Binding* ReferenceType::getBinding() const
+ {
+ return binding;
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.h?rev=437637&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.h Mon Aug 28 03:42:10 2006
@@ -0,0 +1,137 @@
+/*
+ *
+ * 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_model_referencetype_h
+#define tuscany_sca_model_referencetype_h
+
+#include <string>
+using std::string;
+
+#include "tuscany/sca/model/Contract.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace model
+ {
+ class ComponentType;
+ class Interface;
+ class Binding;
+
+ /**
+ * Represents an SCA reference. SCA references within an implementation represent
+ * links to services that the implementation uses that must be provided by other components
+ * in the SCA system.
+ */
+ class ReferenceType : public Contract
+ {
+ public:
+
+ /**
+ * Multiplicity (how many wires can be connected to this
+ * reference)
+ */
+ enum Multiplicity
+ {
+ ZERO_ONE = 1,
+ ONE_ONE = 2,
+ ZERO_MANY = 3,
+ ONE_MANY = 4,
+ UNKNOWN = 0,
+ };
+
+ /**
+ * Constructor.
+ * @param name The name of the reference.
+ */
+ ReferenceType(ComponentType* componentType, const string& name,
+ Interface* interface, Interface* callbackInterface, bool conversational, Multiplicity multiplicity);
+
+ /**
+ * Destructor.
+ */;
+ virtual ~ReferenceType();
+
+ /**
+ * Returns the component type on which this reference is defined.
+ * @return The component type on which this reference is defined.
+ */
+ ComponentType* getComponentType() const { return componentType; }
+
+ /**
+ * Returns the name of the reference.
+ * @return The name of the reference.
+ */
+ const string& getName() const { return name; }
+
+ /**
+ * Returns the multiplicity allowed for wires connected to this reference.
+ * @return The multiplicity allowed for wires connected to this reference
+ */
+ Multiplicity getMultiplicity() const { return multiplicity; }
+
+ /**
+ * Returns the binding supported by the reference.
+ * @return The binding supported by the reference.
+ */
+ Binding* getBinding() const;
+
+ /**
+ * Sets the binding supported by the reference.
+ * @param binding The binding supported by the reference.
+ */
+ void setBinding(Binding* binding);
+
+ /**
+ * Get the multiplicity corresponding to the given
+ * string.
+ */
+ static Multiplicity getMultiplicityFromString(const string& multip);
+
+ private:
+
+ /**
+ * The component type on which this reference is defined.
+ */
+ ComponentType *componentType;
+
+ /**
+ * The name of the reference type.
+ */
+ string name;
+
+ /**
+ * The multiplicity allowed for wires connected to this reference.
+ */
+ Multiplicity multiplicity;
+
+ /**
+ * The binding supported by this reference type.
+ */
+ Binding* binding;
+
+ };
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_referencetype_h
+
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceType.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Service.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Service.cpp?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Service.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Service.cpp Mon Aug 28 03:42:10 2006
@@ -18,6 +18,7 @@
/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
#include "tuscany/sca/model/Service.h"
namespace tuscany
@@ -27,21 +28,27 @@
namespace model
{
-
// Constructor
- Service::Service(const std::string& serviceName, Component* comp)
- : WireTarget(serviceName),
- component(comp)
+ Service::Service(Component* component, ServiceType* serviceType)
+ : component(component), type(serviceType), binding(0)
{
- LOGENTRY(1, "Service::constructor (Component)");
- LOGINFO_1(3, "Service::constructor: Service name: %s", serviceName.c_str());
- LOGEXIT(1, "Service::constructor");
}
-
+
+ // Destructor
Service::~Service()
{
}
-
- } // End namespace model
+
+ void Service::setBinding(ServiceBinding* binding)
+ {
+ this->binding = binding;
+ }
+
+ ServiceBinding* Service::getBinding() const
+ {
+ return binding;
+ }
+
+ } // End namespace model
} // End namespace sca
} // End namespace tuscany
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Service.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Service.h?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Service.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Service.h Mon Aug 28 03:42:10 2006
@@ -23,8 +23,6 @@
#include <string>
using std::string;
-#include "tuscany/sca/model/WireTarget.h"
-
namespace tuscany
{
namespace sca
@@ -32,45 +30,68 @@
namespace model
{
class Component;
+ class ServiceType;
+ class ServiceBinding;
/**
- * Information about a service defined on a component.
+ * An addressable instance of a service type associated with a particular component.
*/
- class Service : public WireTarget
+ class Service
{
public:
/**
+ * Constructor.
+ * @param component The component on which the service is defined.
+ * @param serviceType The service type defining the characteristics of the service.
+ */
+ Service(Component* component, ServiceType* serviceType);
+
+ /**
* Destructor.
*/
virtual ~Service();
/**
- * Return the type of the wire target.
- * @return Always returns ComponentServiceType.
+ * Returns the component on which this service is defined.
+ * @return The component on which this service is defined.
*/
- virtual Type getServiceType() {return ComponentServiceType;}
+ Component* getComponent() const { return component; }
/**
- * Get the component on which this service is defined.
- * @return The component on which this service is defined.
+ * Returns the service type defining the characteristics of the service.
+ * @return The service type defining the characteristics of the service.
*/
- Component* getComponent() {return component;}
+ ServiceType* getType() const { return type; }
+ /**
+ * Returns the binding supported by the service.
+ * @return The binding supported by the service.
+ */
+ ServiceBinding* getBinding() const;
- private:
- friend class Component;
/**
- * Constructor.
- * @param name The name of the service.
- * @param component The component on which this service is defined.
+ * Sets the binding supported by the service.
+ * @param binding The binding supported by the service.
*/
- Service(const std::string& name, Component* component);
+ void setBinding(ServiceBinding* binding);
+
+ private:
/**
* The component on which this service is defined.
*/
Component* component;
+ /**
+ * The service type defining the characteristics of the service.
+ */
+ ServiceType* type;
+
+ /**
+ * The binding supported by this service
+ */
+ ServiceBinding* binding;
+
};
} // End namespace model
@@ -78,4 +99,3 @@
} // End namespace tuscany
#endif // tuscany_sca_model_service_h
-
Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp?rev=437637&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp Mon Aug 28 03:42:10 2006
@@ -0,0 +1,45 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+
+ namespace model
+ {
+
+ // Constructor
+ ServiceBinding::ServiceBinding(Service* service, const string& uri) :
+ Binding(uri), service(service)
+ {
+ }
+
+ // Destructor
+ ServiceBinding::~ServiceBinding()
+ {
+ }
+
+ } // End namespace model
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ServiceBinding.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org