正在显示
2 个修改的文件
包含
0 行增加
和
398 行删除
1 | -<<<<<<< HEAD | |
2 | -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -o -lfcgi++ -lfcgi") | |
3 | - | |
4 | -INCLUDE_DIRECTORIES( | |
5 | - ${CMAKE_SOURCE_DIR}/src/server/spserver | |
6 | -) | |
7 | - | |
8 | - | |
9 | -ADD_SUBDIRECTORY(spserver) | |
10 | -ADD_SUBDIRECTORY(services) | |
11 | - | |
12 | - | |
13 | - | |
14 | -######################################################## | |
15 | -# Files | |
16 | -SET (DMAP_SERVER_SRCS | |
17 | - dmpfilterresponsedecorator.cpp | |
18 | - dmpmainserver.cpp | |
19 | - dmprequesthandler.cpp | |
20 | - dmpserver.cpp | |
21 | - dmpserverapi.cpp | |
22 | - dmpserverconfig.cpp | |
23 | - dmpservercontext.cpp | |
24 | - dmpserverapicontext.cpp | |
25 | - dmpserverapihandler.cpp | |
26 | - dmpserverfilter.cpp | |
27 | - dmpserverinterface.cpp | |
28 | - dmpserverinterfaceimpl.cpp | |
29 | - dmpservermanager.cpp | |
30 | - dmpservermanagerapi.cpp | |
31 | - dmpserverresponse.cpp | |
32 | - dmpserverrequest.cpp | |
33 | - dmpserverparameters.cpp | |
34 | - dmpserverplugins.cpp | |
35 | - dmpserverutils.cpp | |
36 | - dmpserverloader.cpp | |
37 | - dmpserverproject.cpp | |
38 | - dmpserverregistry.cpp | |
39 | - python/dmppythonutils.cpp | |
40 | - python/dmpserverwrapper.cpp | |
41 | - dmphttpbase.cpp | |
42 | - dmphttputils.cpp | |
43 | - | |
44 | -) | |
45 | - | |
46 | -SET (DMAP_SERVER_HDRS | |
47 | - dmpfilterresponsedecorator.h | |
48 | - dmpmainserver.h | |
49 | - dmprequesthandler.h | |
50 | - dmpserver.h | |
51 | - dmpserverapi.h | |
52 | - dmpserverapihandler.h | |
53 | - dmpserverapicontext.h | |
54 | - dmpservercontext.h | |
55 | - dmpserverconfig.h | |
56 | - dmpserverentity.h | |
57 | - dmpserverfilter.h | |
58 | - dmpserverinterface.h | |
59 | - dmpserverinterfaceimpl.h | |
60 | - dmpservermanager.h | |
61 | - dmpservermanagerapi.h | |
62 | - dmpserverrequest.h | |
63 | - dmpserverresponse.h | |
64 | - dmpserverparameters.h | |
65 | - dmpserverplugins.h | |
66 | - dmpserverutils.h | |
67 | - dmpservice.h | |
68 | - dmpservermodule.h | |
69 | - dmpserverloader.h | |
70 | - dmpserverproject.h | |
71 | - dmpserverregistry.h | |
72 | - python/dmppythonutils.h | |
73 | - dmphttpbase.h | |
74 | - dmphttputils.h | |
75 | - | |
76 | -) | |
77 | - | |
78 | -############################################################# | |
79 | -# dmap_server library | |
80 | - | |
81 | - | |
82 | - | |
83 | -INCLUDE_DIRECTORIES( | |
84 | - ${CMAKE_SOURCE_DIR}/src/core | |
85 | - ${CMAKE_SOURCE_DIR}/src/core/geometry | |
86 | - ${CMAKE_SOURCE_DIR}/src/core/symbology | |
87 | -) | |
88 | - | |
89 | -INCLUDE_DIRECTORIES(SYSTEM | |
90 | - ${PYTHON_INCLUDE_PATH} | |
91 | -) | |
92 | -ADD_LIBRARY(dmap_server SHARED ${DMAP_SERVER_SRCS} ${DMAP_SERVER_HDRS}) | |
93 | - | |
94 | -target_link_libraries(dmap_server | |
95 | - dmap_core | |
96 | - ${Boost_LIBRARIES} | |
97 | - Boost::regex | |
98 | - ${PYTHON_LIBRARIES} | |
99 | - dl) | |
100 | - | |
101 | -IF (WITH_BINDINGS) | |
102 | - TARGET_LINK_LIBRARIES(dmap_server | |
103 | - Boost::${DMAP_BOOST_PYTHON_FOUND} | |
104 | - ) | |
105 | -ENDIF(WITH_BINDINGS) | |
106 | - | |
107 | -set_target_properties(dmap_server | |
108 | - PROPERTIES | |
109 | - POSITION_INDEPENDENT_CODE 1 | |
110 | - CXX_VISIBILITY_PRESET hidden | |
111 | - VISIBILITY_INLINES_HIDDEN 1 | |
112 | - #VERSION ${COMPLETE_VERSION} | |
113 | - #SOVERSION ${COMPLETE_VERSION} | |
114 | - ) | |
115 | - | |
116 | -generate_export_header( | |
117 | - dmap_server | |
118 | - BASE_NAME SERVER | |
119 | - EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/dmap_server.h" | |
120 | -) | |
121 | - | |
122 | - | |
123 | -target_include_directories(dmap_server | |
124 | - PUBLIC | |
125 | - ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR} | |
126 | - ) | |
127 | - MESSAGE(STATUS "dmap_server path: ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}") | |
128 | - | |
129 | - | |
130 | -add_executable(dmap_spserv | |
131 | - dmap_spserv.cpp | |
132 | - dmpspserverrequest.h | |
133 | - dmpspserverresponse.h | |
134 | - dmpspserverrequest.cpp | |
135 | - dmpspserverresponse.cpp | |
136 | -) | |
137 | - | |
138 | -add_executable(dmap_serv | |
139 | - dmap_serv.cpp | |
140 | - dmpapacheserverrequest.h | |
141 | - dmpapacheserverresponse.h | |
142 | - dmpapacheserverrequest.cpp | |
143 | - dmpapacheserverresponse.cpp | |
144 | -) | |
145 | - | |
146 | -target_link_libraries(dmap_spserv | |
147 | - spserver | |
148 | - dmap_server | |
149 | - ) | |
150 | - | |
151 | -target_link_libraries(dmap_serv | |
152 | - dmap_server | |
153 | -) | |
154 | - | |
155 | -INCLUDE_DIRECTORIES( | |
156 | - ${CMAKE_SOURCE_DIR}/pgsql/include | |
157 | -) | |
158 | -LINK_DIRECTORIES(dmap_server ${CMAKE_SOURCE_DIR}/pgsql/lib) | |
159 | -TARGET_LINK_LIBRARIES(dmap_server ${CMAKE_SOURCE_DIR}/pgsql/lib/libpq.so) | |
160 | - | |
161 | -find_package(Fcgi REQUIRED) | |
162 | -if (NOT FCGI_FOUND) | |
163 | - message (SEND_ERROR "Fast CGI dependency was not found!") | |
164 | -endif() | |
165 | - | |
166 | -target_include_directories(dmap_serv SYSTEM PRIVATE | |
167 | - ${FCGI_INCLUDE_DIR} | |
168 | -) | |
169 | -target_link_libraries(dmap_serv | |
170 | - ${FCGI_LIBRARY} | |
171 | -) | |
172 | -######################################################## | |
173 | -# Install | |
174 | -INSTALL(FILES | |
175 | - dmpserver.ini | |
176 | - DESTINATION ${DMAP_LIBEXEC_SUBDIR} | |
177 | -) | |
178 | - | |
179 | -INSTALL(TARGETS dmap_server | |
180 | - RUNTIME DESTINATION ${DMAP_BIN_DIR} | |
181 | - LIBRARY DESTINATION ${DMAP_LIB_DIR} | |
182 | - ARCHIVE DESTINATION ${DMAP_LIB_DIR} | |
183 | - PUBLIC_HEADER DESTINATION ${DMAP_INCLUDE_DIR} | |
184 | -) | |
185 | - | |
186 | -INSTALL(TARGETS dmap_serv | |
187 | - DESTINATION ${DMAP_BIN_DIR} | |
188 | -) | |
189 | - | |
190 | -INSTALL(TARGETS dmap_spserv | |
191 | - DESTINATION ${DMAP_BIN_DIR} | |
192 | -======= | |
193 | 1 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -o -lfcgi++ -lfcgi") |
194 | 2 | |
195 | 3 | INCLUDE_DIRECTORIES( |
... | ... | @@ -380,5 +188,4 @@ INSTALL(TARGETS dmap_serv |
380 | 188 | |
381 | 189 | INSTALL(TARGETS dmap_spserv |
382 | 190 | DESTINATION ${DMAP_BIN_DIR} |
383 | ->>>>>>> 678abfd93ad90c860e277df725c22d74ff408a82 | |
384 | 191 | ) |
\ No newline at end of file | ... | ... |
... | ... | @@ -126,211 +126,6 @@ bool DmpServerManager::publish(const std::string& serverName, const std::string& |
126 | 126 | delete project; |
127 | 127 | return false; |
128 | 128 | } |
129 | - projects_[serviceName] = project; | |
130 | - return true; | |
131 | -} | |
132 | - | |
133 | -bool DmpServerManager::deleteService(const std::string &serverName, const std::string &serviceName) | |
134 | -{ | |
135 | - if (serverRegistry_->getServer(serverName)->remove(serviceName) && removeProject(serviceName)) | |
136 | - { | |
137 | - return true; | |
138 | - } | |
139 | - else | |
140 | - { | |
141 | - return false; | |
142 | - } | |
143 | -} | |
144 | - | |
145 | -bool DmpServerManager::startService(const std::string &serverName, const std::string &serviceName) | |
146 | -{ | |
147 | - return serverRegistry_->getServer(serverName)->start(serviceName); | |
148 | -} | |
149 | - | |
150 | -bool DmpServerManager::stopService(const std::string &serverName, const std::string &serviceName) | |
151 | -{ | |
152 | - return serverRegistry_->getServer(serverName)->stop(serviceName); | |
153 | -} | |
154 | -bool DmpServerManager::loadServices() | |
155 | -{ | |
156 | - boost::property_tree::ptree pt,ptList; | |
157 | - std::string conn = DmpServerConfig::Instance()->getMetaUrl(); | |
158 | - const std::string url= conn + URI_RELOAD; | |
159 | - std::string strContent=DmpHttp::get(url); | |
160 | - if(strContent.length()==0) | |
161 | - { | |
162 | - return false; | |
163 | - } | |
164 | - std::stringstream ssData; | |
165 | - ssData<<strContent.c_str(); | |
166 | - boost::property_tree::read_json(ssData, pt); | |
167 | - int iCount = std::atoi(pt.get<std::string>("data.count").c_str()); | |
168 | - if(iCount>0) | |
169 | - { | |
170 | - ptList=pt.get_child("data.list"); | |
171 | - for (auto& e : ptList) | |
172 | - { | |
173 | - std::string name = e.second.get<std::string>("name"); | |
174 | - std::string title = e.second.get<std::string>("title"); | |
175 | - std::string type = e.second.get<std::string>("type"); | |
176 | - int capabilities =e.second.get<int>("capabilities"); | |
177 | - std::string project = e.second.get<std::string>("project"); | |
178 | - this->initServices(type,name,title,capabilities,project); | |
179 | - } | |
180 | - } | |
181 | - return true; | |
182 | -} | |
183 | -bool DmpServerManager::initServices(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData) | |
184 | -{ | |
185 | - //project | |
186 | - std::string projData; | |
187 | - if (!DmpServerUtils::Base64Decode(projectData, &projData)) | |
188 | - { | |
189 | - return false; | |
190 | - } | |
191 | - DmpProject *project = new DmpProject(); | |
192 | - if (!project->Read(projData)) | |
193 | - { | |
194 | - delete project; | |
195 | - return false; | |
196 | - } | |
197 | - | |
198 | - if (!serverRegistry_->getServer(serverName)->publish(serviceName, title, capabilities, *project)) | |
199 | - { | |
200 | - delete project; | |
201 | - return false; | |
202 | - } | |
203 | - projects_[serviceName] = project; | |
204 | - return true; | |
205 | -======= | |
206 | -/************************************************************************** | |
207 | -* file: dmpservermanager.cpp | |
208 | - | |
209 | -* Author: wanzhongping | |
210 | -* Date: 2021-07-27 21:59:46 | |
211 | -* Email: zhongpingw@chinadci.com | |
212 | -* copyright: 广州城市信息研究所有限公司 | |
213 | -***************************************************************************/ | |
214 | -#include "dmpservermanager.h" | |
215 | -#include "dmpserver.h" | |
216 | -#include "dmphttputils.h" | |
217 | -#include "dmpserverConfig.h" | |
218 | -#include <memory> | |
219 | -#include <boost/property_tree/ptree.hpp> | |
220 | -#include <boost/property_tree/json_parser.hpp> | |
221 | -#include <boost/property_tree/xml_parser.hpp> | |
222 | -#include <sstream> | |
223 | -#include <fstream> | |
224 | -#include <math.h> | |
225 | -#include "dmptilelayer.h" | |
226 | -#include <iostream> | |
227 | -#include "dmplogger.h" | |
228 | -#include "dmptilelayer.h" | |
229 | - | |
230 | -DmpServerManager::DmpServerManager() | |
231 | -{ | |
232 | - serverRegistry_ = new DmpServerRegistry(); | |
233 | -} | |
234 | - | |
235 | -DmpServerManager::~DmpServerManager() | |
236 | -{ | |
237 | - if (serverRegistry_) | |
238 | - { | |
239 | - delete serverRegistry_; | |
240 | - serverRegistry_ = NULL; | |
241 | - } | |
242 | - | |
243 | - ProjectMap::iterator iter = projects_.begin(); | |
244 | - for (; iter != projects_.end(); ++iter) | |
245 | - { | |
246 | - DmpProject *mapProject = iter->second; | |
247 | - if (mapProject) | |
248 | - { | |
249 | - delete mapProject; | |
250 | - mapProject = nullptr; | |
251 | - } | |
252 | - } | |
253 | - projects_.clear(); | |
254 | -} | |
255 | - | |
256 | -void DmpServerManager::init(const boost::filesystem::path &modulePath) | |
257 | -{ | |
258 | - serverRegistry_->init(modulePath); | |
259 | - if(!loadServices()) | |
260 | - { | |
261 | - std::cout << "加载服务失败!" << std::endl; | |
262 | - LOGGER_ERROR("加载服务失败!"); | |
263 | - } | |
264 | - //LoadDmpServices(); | |
265 | -} | |
266 | - | |
267 | -std::string DmpServerManager::getCapabilities() | |
268 | -{ | |
269 | - return serverRegistry_->getCapabilities(); | |
270 | -} | |
271 | - | |
272 | -std::shared_ptr<DmpServer> DmpServerManager::serverForRequest(const DmpServerRequest &request) | |
273 | -{ | |
274 | - return serverRegistry_->getServerForRequest(request); | |
275 | -} | |
276 | - | |
277 | -std::shared_ptr<DmpServerApi> DmpServerManager::apiForRequest(const DmpServerRequest &request) | |
278 | -{ | |
279 | - return serverRegistry_->getApiForRequest(request); | |
280 | -} | |
281 | - | |
282 | -DmpProject *DmpServerManager::getProject(const std::string &serviceName) | |
283 | -{ | |
284 | - std::map<std::string, DmpProject *>::iterator iter = projects_.find(serviceName); | |
285 | - if (iter != projects_.end()) | |
286 | - { | |
287 | - return iter->second; | |
288 | - } | |
289 | - else | |
290 | - { | |
291 | - return nullptr; | |
292 | - } | |
293 | -} | |
294 | - | |
295 | -bool DmpServerManager::removeProject(const std::string &serviceName) | |
296 | -{ | |
297 | - try | |
298 | - { | |
299 | - std::map<std::string, DmpProject *>::iterator iter = projects_.find(serviceName); | |
300 | - if (iter != projects_.end()) | |
301 | - { | |
302 | - delete iter->second; | |
303 | - projects_.erase(iter); | |
304 | - } | |
305 | - } | |
306 | - catch (const std::exception &e) | |
307 | - { | |
308 | - std::cerr << e.what() << '\n'; | |
309 | - return false; | |
310 | - } | |
311 | - return true; | |
312 | -} | |
313 | - | |
314 | -bool DmpServerManager::publish(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData) | |
315 | -{ | |
316 | - //project | |
317 | - std::string projData; | |
318 | - if (!DmpServerUtils::Base64Decode(projectData, &projData)) | |
319 | - { | |
320 | - return false; | |
321 | - } | |
322 | - DmpProject *project = new DmpProject(); | |
323 | - if (!project->Read(projData)) | |
324 | - { | |
325 | - delete project; | |
326 | - return false; | |
327 | - } | |
328 | - | |
329 | - if (!serverRegistry_->getServer(serverName)->publish(serviceName, title, capabilities, *project)) | |
330 | - { | |
331 | - delete project; | |
332 | - return false; | |
333 | - } | |
334 | 129 | projects_[serviceName] = project; |
335 | 130 | |
336 | 131 | return true; | ... | ... |
请
注册
或
登录
后发表评论