| 1 | /* | |
| 2 | * Copyright 1999-2006 University of Chicago | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | ||
| 17 | ||
| 18 | #include "globus_common.h" | |
| 19 | #include "version.h" | |
| 20 | #include "libxml/xmlschemastypes.h" | |
| 21 | #include "globus_xio.h" | |
| 22 | #include "globus_xio_buffer.h" | |
| 23 | #include "globus_xsd_types.h" | |
| 24 | #include "globus_i_soap_message.h" | |
| 25 | #include "globus_soap_message_utils.h" | |
| 26 | #include "globus_xsd_type_registry.h" | |
| 27 | ||
| 28 | globus_xsd_type_registry_t GLOBUS_XSD_BASE_REGISTRY = NULL; | |
| 29 | globus_xsd_type_registry_t GLOBUS_GLOBAL_TYPE_REGISTRY = NULL; | |
| 30 | ||
| 31 | static int | |
| 32 | globus_l_soap_message_activate(void); | |
| 33 | ||
| 34 | static int | |
| 35 | globus_l_soap_message_deactivate(void); | |
| 36 | ||
| 37 | globus_module_descriptor_t | |
| 38 | globus_i_soap_message_module = | |
| 39 | { | |
| 40 | "globus_soap_message_module", | |
| 41 | globus_l_soap_message_activate, | |
| 42 | globus_l_soap_message_deactivate, | |
| 43 | NULL, | |
| 44 | NULL, | |
| 45 | &local_version | |
| 46 | }; | |
| 47 | ||
| 48 | 0 | GlobusDebugDefine(GLOBUS_SOAP_MESSAGE); |
| 49 | ||
| 50 | globus_xio_stack_t globus_i_soap_message_xio_stack; | |
| 51 | globus_xio_driver_t globus_i_soap_message_tcp_driver; | |
| 52 | globus_xio_driver_t globus_i_soap_message_http_driver; | |
| 53 | globus_xio_driver_t globus_i_soap_message_buffer_driver; | |
| 54 | ||
| 55 | globus_xio_stack_t globus_i_soap_message_xio_file_stack; | |
| 56 | globus_xio_driver_t globus_i_soap_message_file_driver; | |
| 57 | ||
| 58 | globus_xio_stack_t globus_i_soap_message_xio_https_stack; | |
| 59 | globus_xio_driver_t globus_i_soap_message_gsi_driver; | |
| 60 | ||
| 61 | extern globus_mutex_t globus_i_service_engine_extensions_mutex; | |
| 62 | ||
| 63 | ||
| 64 | static int | |
| 65 | globus_l_soap_message_activate(void) | |
| 66 | 804 | { |
| 67 | 804 | globus_result_t result = GLOBUS_SUCCESS; |
| 68 | 804 | int rc = 0; |
| 69 | GlobusFuncName(globus_l_soap_message_activate); | |
| 70 | ||
| 71 | 804 | globus_i_soap_message_xio_stack = NULL; |
| 72 | 804 | globus_i_soap_message_tcp_driver = NULL; |
| 73 | 804 | globus_i_soap_message_http_driver = NULL; |
| 74 | 804 | globus_i_soap_message_buffer_driver = NULL; |
| 75 | ||
| 76 | 804 | globus_i_soap_message_xio_file_stack = NULL; |
| 77 | 804 | globus_i_soap_message_file_driver = NULL; |
| 78 | ||
| 79 | 804 | globus_i_soap_message_xio_https_stack = NULL; |
| 80 | 804 | globus_i_soap_message_gsi_driver = NULL; |
| 81 | ||
| 82 | 804 | rc = globus_module_activate(GLOBUS_COMMON_MODULE); |
| 83 | 804 | if(rc != GLOBUS_SUCCESS) |
| 84 | { | |
| 85 | 0 | return rc; |
| 86 | } | |
| 87 | 804 | globus_mutex_init(&globus_i_service_engine_extensions_mutex, NULL); |
| 88 | ||
| 89 | ||
| 90 | 804 | GlobusDebugInit(GLOBUS_SOAP_MESSAGE, |
| 91 | MESSAGES INFO DEBUG TRACE WARN REGISTRY WILDCARDS); | |
| 92 | 804 | GlobusSoapMessageDebugEnter(); |
| 93 | ||
| 94 | 804 | rc = globus_module_activate(GLOBUS_XIO_MODULE); |
| 95 | 804 | if(rc != GLOBUS_SUCCESS) |
| 96 | { | |
| 97 | 0 | return rc; |
| 98 | } | |
| 99 | ||
| 100 | 804 | result = globus_xio_stack_init( |
| 101 | &globus_i_soap_message_xio_stack, NULL); | |
| 102 | 804 | if(result != GLOBUS_SUCCESS) |
| 103 | { | |
| 104 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 105 | result, "Failed xio stack initialization"); | |
| 106 | 0 | goto error; |
| 107 | } | |
| 108 | ||
| 109 | 804 | result = globus_xio_driver_load( |
| 110 | "tcp", &globus_i_soap_message_tcp_driver); | |
| 111 | 804 | if(result != GLOBUS_SUCCESS) |
| 112 | { | |
| 113 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 114 | result, "Failed to load tcp driver"); | |
| 115 | 0 | goto error; |
| 116 | } | |
| 117 | ||
| 118 | 804 | result = globus_xio_stack_push_driver( |
| 119 | globus_i_soap_message_xio_stack, globus_i_soap_message_tcp_driver); | |
| 120 | 804 | if(result != GLOBUS_SUCCESS) |
| 121 | { | |
| 122 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 123 | result, "Failed to push tcp driver onto stack"); | |
| 124 | 0 | goto error; |
| 125 | } | |
| 126 | ||
| 127 | 804 | result = globus_xio_driver_load( |
| 128 | "http", &globus_i_soap_message_http_driver); | |
| 129 | 804 | if(result != GLOBUS_SUCCESS) |
| 130 | { | |
| 131 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 132 | result, "Failed to load http driver"); | |
| 133 | 0 | goto error; |
| 134 | } | |
| 135 | ||
| 136 | 804 | result = globus_xio_driver_load( |
| 137 | "buffer", &globus_i_soap_message_buffer_driver); | |
| 138 | 804 | if(result != GLOBUS_SUCCESS) |
| 139 | { | |
| 140 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 141 | result, "Failed to load buffer driver"); | |
| 142 | 0 | goto error; |
| 143 | } | |
| 144 | ||
| 145 | 804 | result = globus_xio_stack_push_driver( |
| 146 | globus_i_soap_message_xio_stack, globus_i_soap_message_http_driver); | |
| 147 | 804 | if(result != GLOBUS_SUCCESS) |
| 148 | { | |
| 149 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 150 | result, "Failed to push http driver"); | |
| 151 | 0 | goto error; |
| 152 | } | |
| 153 | ||
| 154 | 804 | result = globus_xio_stack_push_driver( |
| 155 | globus_i_soap_message_xio_stack, globus_i_soap_message_buffer_driver); | |
| 156 | 804 | if(result != GLOBUS_SUCCESS) |
| 157 | { | |
| 158 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 159 | result, "Failed to push buffer driver"); | |
| 160 | 0 | goto error; |
| 161 | } | |
| 162 | ||
| 163 | 804 | result = globus_xio_stack_init( |
| 164 | &globus_i_soap_message_xio_file_stack, NULL); | |
| 165 | 804 | if(result != GLOBUS_SUCCESS) |
| 166 | { | |
| 167 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 168 | result, "Failed xio stack initialization"); | |
| 169 | 0 | goto error; |
| 170 | } | |
| 171 | ||
| 172 | 804 | result = globus_xio_driver_load( |
| 173 | "file", &globus_i_soap_message_file_driver); | |
| 174 | 804 | if(result != GLOBUS_SUCCESS) |
| 175 | { | |
| 176 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 177 | result, "Failed to load file driver"); | |
| 178 | 0 | goto error; |
| 179 | } | |
| 180 | ||
| 181 | 804 | result = globus_xio_stack_push_driver( |
| 182 | globus_i_soap_message_xio_file_stack, | |
| 183 | globus_i_soap_message_file_driver); | |
| 184 | 804 | if(result != GLOBUS_SUCCESS) |
| 185 | { | |
| 186 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 187 | result, "Failed to push file driver onto stack"); | |
| 188 | 0 | goto error; |
| 189 | } | |
| 190 | ||
| 191 | 804 | result = globus_xio_stack_init( |
| 192 | &globus_i_soap_message_xio_https_stack, NULL); | |
| 193 | 804 | if(result != GLOBUS_SUCCESS) |
| 194 | { | |
| 195 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 196 | result, "Failed xio stack initialization"); | |
| 197 | 0 | goto error; |
| 198 | } | |
| 199 | ||
| 200 | 804 | result = globus_xio_driver_load( |
| 201 | "gsi", &globus_i_soap_message_gsi_driver); | |
| 202 | 804 | if(result != GLOBUS_SUCCESS) |
| 203 | { | |
| 204 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 205 | result, "Failed to load gsi driver"); | |
| 206 | 0 | goto error; |
| 207 | } | |
| 208 | ||
| 209 | 804 | result = globus_xio_stack_push_driver( |
| 210 | globus_i_soap_message_xio_https_stack, | |
| 211 | globus_i_soap_message_tcp_driver); | |
| 212 | 804 | if(result != GLOBUS_SUCCESS) |
| 213 | { | |
| 214 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 215 | result, "Failed to push gsi driver onto stack"); | |
| 216 | 0 | goto error; |
| 217 | } | |
| 218 | ||
| 219 | 804 | result = globus_xio_stack_push_driver( |
| 220 | globus_i_soap_message_xio_https_stack, | |
| 221 | globus_i_soap_message_gsi_driver); | |
| 222 | 804 | if(result != GLOBUS_SUCCESS) |
| 223 | { | |
| 224 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 225 | result, "Failed to push gsi driver onto stack"); | |
| 226 | 0 | goto error; |
| 227 | } | |
| 228 | ||
| 229 | 804 | result = globus_xio_stack_push_driver( |
| 230 | globus_i_soap_message_xio_https_stack, | |
| 231 | globus_i_soap_message_http_driver); | |
| 232 | 804 | if(result != GLOBUS_SUCCESS) |
| 233 | { | |
| 234 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 235 | result, "Failed to push gsi driver onto stack"); | |
| 236 | 0 | goto error; |
| 237 | } | |
| 238 | ||
| 239 | 804 | result = globus_xio_stack_push_driver( |
| 240 | globus_i_soap_message_xio_https_stack, | |
| 241 | globus_i_soap_message_buffer_driver); | |
| 242 | 804 | if(result != GLOBUS_SUCCESS) |
| 243 | { | |
| 244 | 0 | result = GlobusSoapMessageErrorFailedTransport( |
| 245 | result, "Failed to push gsi driver onto stack"); | |
| 246 | 0 | goto error; |
| 247 | } | |
| 248 | ||
| 249 | 804 | xmlSchemaInitTypes(); |
| 250 | ||
| 251 | 804 | GLOBUS_XSD_BASE_REGISTRY = NULL; |
| 252 | 804 | globus_xsd_type_registry_init(&GLOBUS_XSD_BASE_REGISTRY); |
| 253 | 804 | globus_xsd_type_registry_add_base_types(GLOBUS_XSD_BASE_REGISTRY); |
| 254 | ||
| 255 | 804 | GLOBUS_GLOBAL_TYPE_REGISTRY = NULL; |
| 256 | 804 | globus_xsd_type_registry_init(&GLOBUS_GLOBAL_TYPE_REGISTRY); |
| 257 | 804 | globus_xsd_type_registry_add_base_types(GLOBUS_GLOBAL_TYPE_REGISTRY); |
| 258 | ||
| 259 | 804 | goto exit; |
| 260 | ||
| 261 | 0 | error: |
| 262 | ||
| 263 | 0 | if(globus_i_soap_message_xio_stack) |
| 264 | { | |
| 265 | 0 | globus_xio_stack_destroy(globus_i_soap_message_xio_stack); |
| 266 | } | |
| 267 | ||
| 268 | 0 | if(globus_i_soap_message_buffer_driver) |
| 269 | { | |
| 270 | 0 | globus_xio_driver_unload(globus_i_soap_message_buffer_driver); |
| 271 | } | |
| 272 | ||
| 273 | 0 | if(globus_i_soap_message_http_driver) |
| 274 | { | |
| 275 | 0 | globus_xio_driver_unload(globus_i_soap_message_http_driver); |
| 276 | } | |
| 277 | ||
| 278 | 0 | if(globus_i_soap_message_tcp_driver) |
| 279 | { | |
| 280 | 0 | globus_xio_driver_unload(globus_i_soap_message_tcp_driver); |
| 281 | } | |
| 282 | ||
| 283 | 0 | if(globus_i_soap_message_file_driver) |
| 284 | { | |
| 285 | 0 | globus_xio_driver_unload(globus_i_soap_message_file_driver); |
| 286 | } | |
| 287 | ||
| 288 | 0 | if(globus_i_soap_message_xio_file_stack) |
| 289 | { | |
| 290 | 0 | globus_xio_stack_destroy(globus_i_soap_message_xio_file_stack); |
| 291 | } | |
| 292 | ||
| 293 | 0 | if(globus_i_soap_message_gsi_driver) |
| 294 | { | |
| 295 | 0 | globus_xio_driver_unload(globus_i_soap_message_gsi_driver); |
| 296 | } | |
| 297 | ||
| 298 | 0 | if(globus_i_soap_message_xio_https_stack) |
| 299 | { | |
| 300 | 0 | globus_xio_stack_destroy(globus_i_soap_message_xio_https_stack); |
| 301 | } | |
| 302 | ||
| 303 | 804 | exit: |
| 304 | ||
| 305 | 804 | GlobusSoapMessageDebugExit(); |
| 306 | 804 | return (int) result; |
| 307 | } | |
| 308 | ||
| 309 | static int | |
| 310 | globus_l_soap_message_deactivate(void) | |
| 311 | 277 | { |
| 312 | 277 | int rc = 0; |
| 313 | GlobusFuncName(globus_l_soap_message_deactivate); | |
| 314 | 277 | GlobusSoapMessageDebugEnter(); |
| 315 | ||
| 316 | 277 | if(GLOBUS_XSD_BASE_REGISTRY) |
| 317 | { | |
| 318 | 277 | globus_xsd_type_registry_destroy(GLOBUS_XSD_BASE_REGISTRY); |
| 319 | 277 | GLOBUS_XSD_BASE_REGISTRY = NULL; |
| 320 | } | |
| 321 | ||
| 322 | 277 | if(GLOBUS_GLOBAL_TYPE_REGISTRY) |
| 323 | { | |
| 324 | 277 | globus_xsd_type_registry_destroy(GLOBUS_GLOBAL_TYPE_REGISTRY); |
| 325 | 277 | GLOBUS_GLOBAL_TYPE_REGISTRY = NULL; |
| 326 | } | |
| 327 | ||
| 328 | 277 | xmlSchemaCleanupTypes(); |
| 329 | ||
| 330 | 277 | if(globus_i_soap_message_file_driver) |
| 331 | { | |
| 332 | 277 | globus_xio_driver_unload(globus_i_soap_message_file_driver); |
| 333 | } | |
| 334 | ||
| 335 | 277 | if(globus_i_soap_message_xio_https_stack) |
| 336 | { | |
| 337 | 277 | globus_xio_stack_destroy(globus_i_soap_message_xio_https_stack); |
| 338 | } | |
| 339 | ||
| 340 | 277 | if(globus_i_soap_message_xio_file_stack) |
| 341 | { | |
| 342 | 277 | globus_xio_stack_destroy(globus_i_soap_message_xio_file_stack); |
| 343 | } | |
| 344 | ||
| 345 | 277 | if(globus_i_soap_message_xio_stack) |
| 346 | { | |
| 347 | 277 | globus_xio_stack_destroy(globus_i_soap_message_xio_stack); |
| 348 | } | |
| 349 | ||
| 350 | 277 | if(globus_i_soap_message_buffer_driver) |
| 351 | { | |
| 352 | 277 | globus_xio_driver_unload(globus_i_soap_message_buffer_driver); |
| 353 | } | |
| 354 | ||
| 355 | 277 | if(globus_i_soap_message_http_driver) |
| 356 | { | |
| 357 | 277 | globus_xio_driver_unload(globus_i_soap_message_http_driver); |
| 358 | } | |
| 359 | ||
| 360 | 277 | if(globus_i_soap_message_tcp_driver) |
| 361 | { | |
| 362 | 277 | globus_xio_driver_unload(globus_i_soap_message_tcp_driver); |
| 363 | } | |
| 364 | ||
| 365 | 277 | if(globus_i_soap_message_gsi_driver) |
| 366 | { | |
| 367 | 277 | globus_xio_driver_unload(globus_i_soap_message_gsi_driver); |
| 368 | } | |
| 369 | ||
| 370 | 277 | rc = globus_module_deactivate(GLOBUS_XIO_MODULE); |
| 371 | 277 | if(rc != GLOBUS_SUCCESS) |
| 372 | { | |
| 373 | 0 | return rc; |
| 374 | } | |
| 375 | ||
| 376 | 277 | rc = globus_module_deactivate(GLOBUS_COMMON_MODULE); |
| 377 | 277 | if(rc != GLOBUS_SUCCESS) |
| 378 | { | |
| 379 | 0 | return rc; |
| 380 | } | |
| 381 | ||
| 382 | 277 | rc = globus_mutex_destroy(&globus_i_service_engine_extensions_mutex); |
| 383 | 277 | if(rc != GLOBUS_SUCCESS) |
| 384 | { | |
| 385 | 0 | return rc; |
| 386 | } | |
| 387 | ||
| 388 | 277 | return GLOBUS_SUCCESS; |