From 2e6a3a1b76fcb42c106900486b8b4f633891b904 Mon Sep 17 00:00:00 2001 From: nandika Date: Sat, 20 Feb 2010 10:41:38 +0000 Subject: axis2_svc_grp_disengage_module function added git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@912097 13f79535-47bb-0310-9956-ffa450edef68 --- include/axis2_svc_grp.h | 52 +++++++++++++++--------- src/core/description/svc_grp.c | 89 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 19 deletions(-) diff --git a/include/axis2_svc_grp.h b/include/axis2_svc_grp.h index 1bf28ac..c922e2d 100644 --- a/include/axis2_svc_grp.h +++ b/include/axis2_svc_grp.h @@ -49,6 +49,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" @@ -60,6 +61,7 @@ extern "C" struct axis2_svc; struct axis2_svc_grp_ctx; + struct axis2_module_desc; /** * Frees service group. @@ -119,10 +121,10 @@ extern "C" * reference, not a cloned copy */ AXIS2_EXTERN struct axis2_svc *AXIS2_CALL - axis2_svc_grp_get_svc( - const axis2_svc_grp_t * svc_grp, - const axutil_env_t * env, - const axutil_qname_t * svc_qname); + axis2_svc_grp_get_svc( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + const axutil_qname_t * svc_qname); /** * Gets all services associated with service group. @@ -236,9 +238,9 @@ extern "C" * reference, not a cloned copy */ AXIS2_EXTERN struct axis2_conf *AXIS2_CALL - axis2_svc_grp_get_parent( - const axis2_svc_grp_t * svc_grp, - const axutil_env_t * env); + axis2_svc_grp_get_parent( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env); /** * Sets parent which is of type configuration. @@ -277,10 +279,9 @@ extern "C" * reference, not a cloned copy */ AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL - - axis2_svc_grp_get_all_module_qnames( - const axis2_svc_grp_t * svc_grp, - const axutil_env_t * env); + axis2_svc_grp_get_all_module_qnames( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env); /** * Adds module reference. @@ -303,7 +304,6 @@ extern "C" * a reference, not a cloned copy */ AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL - axis2_svc_grp_get_all_module_refs( const axis2_svc_grp_t * svc_grp, const axutil_env_t * env); @@ -318,14 +318,12 @@ extern "C" * group, returns a reference, not a cloned copy */ AXIS2_EXTERN struct axis2_svc_grp_ctx *AXIS2_CALL - - axis2_svc_grp_get_svc_grp_ctx( - const axis2_svc_grp_t * svc_grp, - const axutil_env_t * env, - struct axis2_conf_ctx *parent); + axis2_svc_grp_get_svc_grp_ctx( + const axis2_svc_grp_t * svc_grp, + const axutil_env_t * env, + struct axis2_conf_ctx *parent); AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL - axis2_svc_grp_get_param_container( const axis2_svc_grp_t * svc_grp, const axutil_env_t * env); @@ -364,7 +362,7 @@ extern "C" /** * Checks whether a given module is engaged to the service group - * @param svc_grp point to service group + * @param svc_grp pointer to service group * @param env pointer to the environment struct * @return pointer to base description struct */ @@ -375,6 +373,22 @@ extern "C" const axutil_env_t *env, const axutil_qname_t *qname); + /** + * Disengage a module from a service group. This method will disengage the + * all the services belonging to the service group from the specified module. + * @param svc_grp pointer to the service group instance + * @param env environment struct + * @param mod_desc pointer to the module description instance + * @Param conf pointer to the configuration + */ + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axis2_svc_grp_disengage_module( + const axis2_svc_grp_t *svc_grp, + const axutil_env_t *env, + struct axis2_module_desc *module_desc, + struct axis2_conf *conf); + #ifdef __cplusplus } diff --git a/src/core/description/svc_grp.c b/src/core/description/svc_grp.c index 5cca895..074444a 100644 --- a/src/core/description/svc_grp.c +++ b/src/core/description/svc_grp.c @@ -623,3 +623,92 @@ axis2_svc_grp_is_module_engaged( } return AXIS2_FALSE; } + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axis2_svc_grp_disengage_module( + const axis2_svc_grp_t *svc_grp, + const axutil_env_t *env, + axis2_module_desc_t *module_desc, + axis2_conf_t *conf) +{ + int i = 0; + axis2_status_t status = AXIS2_FAILURE; + const axutil_qname_t *module_qname = NULL; + axis2_char_t *module_name = NULL; + axis2_svc_t *axis_svc = NULL; + axutil_hash_index_t *index = NULL; + axutil_hash_t *svc_map = NULL; + axis2_phase_resolver_t *phase_resolver = NULL; + int size = 0; + + const axis2_char_t *svc_grp_name = axis2_svc_grp_get_name(svc_grp, env); + module_qname = axis2_module_desc_get_qname(module_desc, env); + module_name = axutil_qname_get_localpart(module_qname, env); + + if(!axis2_svc_grp_is_module_engaged(svc_grp, env, module_qname)) + { + AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "Module %s is not engaged to the service group %s", + axutil_qname_get_localpart(module_qname, env), svc_grp_name); + return AXIS2_FAILURE; + } + /** Module is engaged to the service group, now disengage all the services contained within the + service group */ + svc_map = axis2_svc_grp_get_all_svcs(svc_grp, env); + if(!svc_map) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Services map not found for service group %s", + svc_grp_name); + + return AXIS2_FAILURE; + } + + phase_resolver = axis2_phase_resolver_create_with_config(env, svc_grp->parent); + + if(!phase_resolver) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Creating phase resolver failed for service group %s", svc_grp_name); + + return AXIS2_FAILURE; + } + + index = axutil_hash_first(svc_map, env); + while(index) + { + const axis2_char_t *svc_name = NULL; + void *v = NULL; + /* engage in per each service */ + axutil_hash_this(index, NULL, NULL, &v); + axis_svc = (axis2_svc_t *)v; + svc_name = axis2_svc_get_name(axis_svc, env); + status = axis2_phase_resolver_disengage_module_from_svc(phase_resolver, env, axis_svc, + module_desc); + + if(!status) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "disengaging module %s to service %s failed", + module_name, svc_name); + } + + index = axutil_hash_next(env, index); + } + + if(phase_resolver) + { + axis2_phase_resolver_free(phase_resolver, env); + } + /** Remove module qname from the engaged module qname list */ + size = axutil_array_list_size(svc_grp->module_qname_list, env); + for(i = 0; i < size ; i++) + { + axutil_qname_t *qname = NULL; + qname = axutil_array_list_get(svc_grp->module_qname_list, env, i); + if(axutil_qname_equals(qname, env, module_qname)) + { + /** Remove the qname from the qname list */ + axutil_array_list_remove(svc_grp->module_qname_list, env, i); + break; + } + } + return status; +} -- cgit v1.1-32-gdbae