DeploymentConfiguration.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "config.h"
00031
00032 #include "DeploymentConfiguration.hpp"
00033
00034 #include <Exception.hpp>
00035
00036 #include <XmlCharData.hpp>
00037 #include <XmlElement.hpp>
00038 #include <XmlElementVector.hpp>
00039
00040
00041 #include <ActiveObjectConfiguration.hpp>
00042 #include <ServiceDeploymentConfiguration.hpp>
00043
00044 #include <iostream>
00045 #include <iterator>
00046 #include <sstream>
00047
00048 using namespace mermaid::mermaidloader;
00049
00050 using std::string;
00051
00052 using mermaid::support::errorhandling::Exception;
00053
00054 using mermaid::support::xml::XmlCharData;
00055 using mermaid::support::xml::XmlElement;
00056 using mermaid::support::xml::XmlElementVector;
00057
00058 void DeploymentConfiguration::loadConfiguration (shared_ptr<XmlDocument> config)
00059 {
00060
00061
00062 _dataDescriptionFileList.clear();
00063 _serviceTypeDescriptionFileList.clear();
00064 _entityDescriptionFileList.clear();
00065 _activeObjectMap.clear();
00066 _activeObjectBelongedServices.clear();
00067 _serviceMap.clear();
00068
00069
00070 shared_ptr<XmlElement> rootElement = config->getRootElement();
00071
00072 if (rootElement->getName().compare ("deployment-configuration") != 0) {
00073 throw Exception ("DeploymentConfiguration::loadConfiguration : invalid configuration");
00074 }
00075
00076 XmlElementVector childrenElements = rootElement->getChildrenElements();
00077
00078 XmlElementVector::iterator it;
00079
00080 for (it = childrenElements.begin(); it != childrenElements.end(); it++) {
00081 shared_ptr<XmlElement> e = *it;
00082
00083
00084
00085 if (e->getName().compare ("file-search-path") == 0) {
00086 shared_ptr<XmlCharData> pathCharData = e->getFirstNonBlankCharData();
00087 std::string path = (std::string) ( (*pathCharData));
00088 _fileSearchPathList.push_back (path);
00089 }
00090 else if (e->getName().compare ("data-description-file") == 0) {
00091 shared_ptr<XmlCharData> filenameCharData = e->getFirstNonBlankCharData();
00092 std::string filename = (std::string) ( (*filenameCharData));
00093 _dataDescriptionFileList.push_back (filename);
00094 }
00095 else if (e->getName().compare ("service-type-description-file") == 0) {
00096 shared_ptr<XmlCharData> filenameCharData = e->getFirstNonBlankCharData();
00097 std::string filename = (std::string) ( (*filenameCharData));
00098 _serviceTypeDescriptionFileList.push_back (filename);
00099 }
00100 else if (e->getName().compare ("entity-description-file") == 0) {
00101 shared_ptr<XmlCharData> filenameCharData = e->getFirstNonBlankCharData();
00102 std::string filename = (std::string) ( (*filenameCharData));
00103 _entityDescriptionFileList.push_back (filename);
00104 }
00105 else if (e->getName().compare ("active-object") == 0) {
00106
00107 shared_ptr<ActiveObjectConfiguration> aoc = shared_ptr<ActiveObjectConfiguration> (new ActiveObjectConfiguration (e));
00108 if (_activeObjectMap.count (aoc->getName()) != 0) {
00109 throw Exception ("DeploymentConfiguration::loadConfiguration : more than one Active Object with the same name:" + aoc->getName());
00110 }
00111 _activeObjectMap[aoc->getName() ] = aoc;
00112 _activeObjectBelongedServices[aoc->getName() ] = vector< shared_ptr<ServiceDeploymentConfiguration> >();
00113 }
00114 else if (e->getName().compare ("service") == 0) {
00115
00116 shared_ptr<ServiceDeploymentConfiguration> sc = shared_ptr<ServiceDeploymentConfiguration> (new ServiceDeploymentConfiguration (e));
00117 if (_serviceMap.count (sc->getServiceInstanceName()) != 0) {
00118 throw Exception ("DeploymentConfiguration::loadConfiguration : more than one Service with the same instance name:" + sc->getServiceInstanceName());
00119 }
00120 _serviceMap[sc->getServiceInstanceName() ] = sc;
00121
00122 vector< shared_ptr<ServiceDeploymentConfiguration> > aoBelongedServiceVector = _activeObjectBelongedServices[sc->getServiceActiveObjectName() ];
00123 aoBelongedServiceVector.push_back (sc);
00124 _activeObjectBelongedServices[sc->getServiceActiveObjectName() ] = aoBelongedServiceVector;
00125 }
00126 else {
00127 throw Exception ("DeploymentConfiguration::loadConfiguration : invalid configuration");
00128 }
00129 }
00130
00131 };
00132
00133 FileSearchPathList DeploymentConfiguration::getFileSearchPathList()
00134 {
00135 return _fileSearchPathList;
00136 };
00137
00138 DataDescriptionFileList DeploymentConfiguration::getDataDescriptionFileList()
00139 {
00140 return _dataDescriptionFileList;
00141 };
00142
00143 ServiceTypeDescriptionFileList DeploymentConfiguration::getServiceTypeDescriptionFileList()
00144 {
00145 return _serviceTypeDescriptionFileList;
00146 };
00147
00148 EntityDescriptionFileList DeploymentConfiguration::getEntityDescriptionFileList()
00149 {
00150 return _entityDescriptionFileList;
00151 };
00152
00153 ActiveObjectConfigurationNameMap DeploymentConfiguration::getActiveObjectConfigurationNameMap()
00154 {
00155 return ActiveObjectConfigurationNameMap (_activeObjectMap);
00156 };
00157
00158 ActiveObjectConfigurationServiceMap DeploymentConfiguration::getActiveObjectConfigurationServiceMap()
00159 {
00160 return ActiveObjectConfigurationServiceMap (_activeObjectBelongedServices);
00161 };
00162
00163 ServiceDeploymentConfigurationNameMap DeploymentConfiguration::getServiceDeploymentConfigurationNameMap()
00164 {
00165 return ServiceDeploymentConfigurationNameMap (_serviceMap);
00166 };