summaryrefslogtreecommitdiffstats
path: root/src/core/description/svc_grp.c
blob: 074444a64f08331dd425f4d9f23f051f8d92a113 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */

#include <axis2_svc_grp.h>
#include <axis2_conf_ctx.h>

struct axis2_svc_grp
{

    /** service group name */
    axis2_char_t *svc_grp_name;

    /** map of services */
    axutil_hash_t *svcs;

    /** to store service group modules QNames */
    axutil_array_list_t *module_qname_list;

    /** to store module ref at deploy time parsing */
    axis2_conf_t *parent;

    /** list of module references */
    axutil_array_list_t *module_list;

    /** parameter container to hold service related parameters */
    axutil_param_container_t *param_container;

    /** base description struct */
    axis2_desc_t *base;
};

AXIS2_EXTERN axis2_svc_grp_t *AXIS2_CALL
axis2_svc_grp_create(
    const axutil_env_t * env)
{
    axis2_svc_grp_t *svc_grp = NULL;
    svc_grp = (axis2_svc_grp_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_grp_t));

    if(!svc_grp)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
        return NULL;
    }

    svc_grp->param_container = NULL;
    svc_grp->module_qname_list = NULL;
    svc_grp->svcs = NULL;
    svc_grp->parent = NULL;
    svc_grp->svc_grp_name = NULL;
    svc_grp->module_list = NULL;
    svc_grp->base = NULL;

    svc_grp->param_container = axutil_param_container_create(env);
    if(!svc_grp->param_container)
    {
        axis2_svc_grp_free(svc_grp, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating parameter container failed");
        return NULL;
    }

    svc_grp->module_qname_list = axutil_array_list_create(env, 20);
    if(!svc_grp->module_qname_list)
    {
        axis2_svc_grp_free(svc_grp, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating module qnames list failed");
        return NULL;
    }

    svc_grp->module_list = axutil_array_list_create(env, 0);
    if(!svc_grp->module_list)
    {
        axis2_svc_grp_free(svc_grp, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating modules list failed");
        return NULL;
    }

    svc_grp->svcs = axutil_hash_make(env);
    if(!svc_grp->svcs)
    {
        axis2_svc_grp_free(svc_grp, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating services map failed");
        return NULL;
    }

    svc_grp->base = axis2_desc_create(env);
    if(!svc_grp->base)
    {
        axis2_svc_grp_free(svc_grp, env);
        return NULL;
    }

    return svc_grp;
}

AXIS2_EXTERN axis2_svc_grp_t *AXIS2_CALL
axis2_svc_grp_create_with_conf(
    const axutil_env_t * env,
    axis2_conf_t * conf)
{
    axis2_svc_grp_t *svc_grp = NULL;

    AXIS2_PARAM_CHECK(env->error, conf, NULL);

    svc_grp = (axis2_svc_grp_t *)axis2_svc_grp_create(env);
    if(svc_grp)
        svc_grp->parent = conf;
    if(conf)
    {
        axis2_desc_set_parent(svc_grp->base, env, axis2_conf_get_base(conf, env));
    }

    return svc_grp;

}

AXIS2_EXTERN void AXIS2_CALL
axis2_svc_grp_free(
    axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env)
{
    if(svc_grp->param_container)
    {
        axutil_param_container_free(svc_grp->param_container, env);
    }

    if(svc_grp->svc_grp_name)
    {
        AXIS2_FREE(env->allocator, svc_grp->svc_grp_name);
    }

    if(svc_grp->svcs)
    {
        /* services are freed by arch_file_data */
        axutil_hash_free(svc_grp->svcs, env);
    }

    if(svc_grp->module_qname_list)
    {
        axutil_array_list_free(svc_grp->module_qname_list, env);
    }

    if(svc_grp->module_list)
    {
        axutil_array_list_free(svc_grp->module_list, env);
    }

    if(svc_grp->base)
    {
        axis2_desc_free(svc_grp->base, env);
    }

    if(svc_grp)
    {
        AXIS2_FREE(env->allocator, svc_grp);
    }
    return;
}

AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_grp_set_name(
    axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    const axis2_char_t * name)
{
    if(svc_grp->svc_grp_name)
        AXIS2_FREE(env->allocator, svc_grp->svc_grp_name);
    svc_grp->svc_grp_name = axutil_strdup(env, name);
    if(!svc_grp->svc_grp_name)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No Memory");
        return AXIS2_FAILURE;
    }

    return AXIS2_SUCCESS;
}

AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
axis2_svc_grp_get_name(
    const axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env)
{
    return svc_grp->svc_grp_name;
}

AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_grp_add_svc(
    axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    axis2_svc_t * svc)
{
    axis2_status_t status = AXIS2_FAILURE;
    const axutil_qname_t *svc_qname = NULL;
    axis2_char_t *svc_name = NULL;

    AXIS2_PARAM_CHECK(env->error, svc, AXIS2_FAILURE);

    if(!svc_grp->svcs)
    {
        svc_grp->svcs = axutil_hash_make(env);
        if(!svc_grp->svcs)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating services list failed");
            return AXIS2_FAILURE;
        }
    }

    svc_qname = axis2_svc_get_qname(svc, env);
    svc_name = axutil_qname_to_string((axutil_qname_t *)svc_qname, env);
    axutil_hash_set(svc_grp->svcs, svc_name, AXIS2_HASH_KEY_STRING, svc);

    status = axis2_svc_set_last_update(svc, env);

    if(AXIS2_SUCCESS != status)
    {
        /* remove the previously added service */
        axutil_hash_set(svc_grp->svcs, svc_name, AXIS2_HASH_KEY_STRING, NULL);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting last update failed for service %s",
            svc_name);

        return status;
    }

    status = axis2_svc_set_parent(svc, env, svc_grp);
    if(AXIS2_SUCCESS != status)
    {
        /* remove the previously added service */
        axutil_hash_set(svc_grp->svcs, svc_name, AXIS2_HASH_KEY_STRING, NULL);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting parent failed for service %s", svc_name);

        return status;
    }

    return status;
}

AXIS2_EXTERN axis2_svc_t *AXIS2_CALL
axis2_svc_grp_get_svc(
    const axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    const axutil_qname_t * qname)
{
    axis2_char_t *name = NULL;

    AXIS2_PARAM_CHECK(env->error, qname, NULL);

    name = axutil_qname_to_string((axutil_qname_t *)qname, env);
    return (axis2_svc_t *)axutil_hash_get(svc_grp->svcs, name, AXIS2_HASH_KEY_STRING);
}

AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
axis2_svc_grp_get_all_svcs(
    const axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env)
{
    return svc_grp->svcs;
}

AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_grp_remove_svc(
    axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    const axutil_qname_t * svc_qname)
{
    axis2_svc_t *svc = NULL;
    axis2_char_t *svc_name = NULL;

    AXIS2_PARAM_CHECK(env->error, svc_name, AXIS2_FAILURE);

    svc = axis2_svc_grp_get_svc(svc_grp, env, svc_qname);

    svc_name = axutil_qname_to_string((axutil_qname_t *)svc_qname, env);
    axutil_hash_set(svc_grp->svcs, svc_name, AXIS2_HASH_KEY_STRING, NULL);

    return AXIS2_SUCCESS;
}

AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_grp_add_param(
    axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    axutil_param_t * param)
{
    const axis2_char_t *svc_grp_name = axis2_svc_grp_get_name(svc_grp, env);
    axis2_char_t *param_name = axutil_param_get_name(param, env);
    AXIS2_PARAM_CHECK(env->error, param, AXIS2_FAILURE);
    if(axis2_svc_grp_is_param_locked(svc_grp, env, param_name))
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Parameter %s is locked for service group %s",
            param_name, svc_grp_name);
        return AXIS2_FAILURE;
    }
    return axutil_param_container_add_param(svc_grp->param_container, env, param);
}

AXIS2_EXTERN axutil_param_t *AXIS2_CALL
axis2_svc_grp_get_param(
    const axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    const axis2_char_t * name)
{
    axutil_param_t *param = NULL;
    AXIS2_PARAM_CHECK(env->error, name, NULL);

    param = axutil_param_container_get_param(svc_grp->param_container, env, name);
    if(!param && svc_grp->parent)
    {
        param = axis2_conf_get_param(svc_grp->parent, env, name);
    }
    return param;
}

AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_grp_remove_param(
	const axis2_svc_grp_t *svc_grp,
	const axutil_env_t *env,
	const axis2_char_t *param_name)
{
	axis2_status_t status = AXIS2_FAILURE;
	status = axutil_param_container_delete_param(svc_grp->param_container, env, param_name);
	return status;
}

AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
axis2_svc_grp_get_all_params(
    const axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env)
{
    return axutil_param_container_get_params(svc_grp->param_container, env);
}

AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_svc_grp_is_param_locked(
    axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    const axis2_char_t * param_name)
{
    axis2_bool_t locked = AXIS2_FALSE;
    axis2_conf_t *parent = NULL;
    axutil_param_t *param = NULL;
    axis2_bool_t ret = AXIS2_FALSE;

    AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FALSE);

    parent = axis2_svc_grp_get_parent(svc_grp, env);
    /* Checking the locked value of parent */
    if(parent)
    {
        locked = axis2_conf_is_param_locked(parent, env, param_name);
    }
    if(locked)
    {
        ret = AXIS2_TRUE;
    }
    param = axis2_svc_grp_get_param(svc_grp, env, param_name);
    if(param && axutil_param_is_locked(param, env))
    {
        ret = AXIS2_TRUE;
    }
    else
    {
        ret = AXIS2_FALSE;
    }
    return ret;
}

AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_grp_add_module_qname(
    axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    const axutil_qname_t * module_qname)
{
    return axutil_array_list_add(svc_grp->module_qname_list, env, module_qname);
}

AXIS2_EXTERN axis2_conf_t *AXIS2_CALL
axis2_svc_grp_get_parent(
    const axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env)
{
    return svc_grp->parent;
}

AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_grp_set_parent(
    axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    axis2_conf_t * parent)
{
    AXIS2_PARAM_CHECK(env->error, parent, AXIS2_FAILURE);

    if(svc_grp->parent)
        axis2_conf_free(svc_grp->parent, env);
    svc_grp->parent = parent;
    if(parent)
    {
        axis2_desc_set_parent(svc_grp->base, env, axis2_conf_get_base(parent, env));
    }
    return AXIS2_SUCCESS;
}

AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_grp_engage_module(
    axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    const axutil_qname_t * module_name)
{
    int i = 0;
    axis2_status_t status = AXIS2_FAILURE;
    axutil_qname_t *modu = NULL;
    axis2_char_t *modu_local = NULL;
    axis2_char_t *module_name_local = NULL;
    axutil_hash_t *svc_map = NULL;
    axis2_phase_resolver_t *phase_resolver = NULL;
    axis2_module_desc_t *module = NULL;
    const axis2_char_t *svc_grp_name = axis2_svc_grp_get_name(svc_grp, env);

    int size = 0;

    AXIS2_PARAM_CHECK(env->error, module_name, AXIS2_FAILURE);

    size = axutil_array_list_size(svc_grp->module_qname_list, env);
    for(i = 0; i < size; i++)
    {
        modu = axutil_array_list_get(svc_grp->module_qname_list, env, i);
        modu_local = axutil_qname_get_localpart(modu, env);
        module_name_local = axutil_qname_get_localpart(module_name, env);
        if(!axutil_strcmp(modu_local, module_name_local))
        {
            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MODULE_ALREADY_ENGAGED_TO_SVC_GRP,
                AXIS2_FAILURE);
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                "Module %s is already engaged to service group %s", module_name_local, svc_grp_name);

            return AXIS2_FAILURE;
        }
    }

    svc_map = axis2_svc_grp_get_all_svcs(svc_grp, env);
    if(!svc_map)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service 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;
    }

    module = axis2_conf_get_module(svc_grp->parent, env, module_name);
    if(module)
    {
        axis2_svc_t *axis_svc = NULL;
        axutil_hash_index_t *index = NULL;

        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_engage_module_to_svc(phase_resolver, env, axis_svc,
                module);

            if(!status)
            {
                if(phase_resolver)
                {
                    axis2_phase_resolver_free(phase_resolver, env);
                }

                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Engaging module %s to service %s failed",
                    module_name_local, svc_name);

                return status;
            }

            index = axutil_hash_next(env, index);
        }
    }

    if(phase_resolver)
    {
        axis2_phase_resolver_free(phase_resolver, env);
    }

    return axis2_svc_grp_add_module_qname(svc_grp, env, module_name);
}

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)
{
    return svc_grp->module_qname_list;
}

AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_grp_add_module_ref(
    axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    const axutil_qname_t * moduleref)
{
    const axis2_char_t *svc_grp_name = NULL;

    AXIS2_PARAM_CHECK(env->error, moduleref, AXIS2_FAILURE);
    svc_grp_name = axis2_svc_grp_get_name(svc_grp, env);

    if(!svc_grp->module_list)
    {
        svc_grp->module_list = axutil_array_list_create(env, 0);
        if(!svc_grp->module_list)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                "Creating module list failed for service group %s", svc_grp_name);
            return AXIS2_FAILURE;
        }
    }

    return axutil_array_list_add(svc_grp->module_list, env, moduleref);
}

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)
{
    return svc_grp->module_list;
}

AXIS2_EXTERN axis2_svc_grp_ctx_t *AXIS2_CALL
axis2_svc_grp_get_svc_grp_ctx(
    const axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env,
    axis2_conf_ctx_t * parent)
{
    axis2_svc_grp_ctx_t *svc_grp_ctx = NULL;
    const axis2_char_t *svc_grp_name = NULL;

    AXIS2_PARAM_CHECK(env->error, parent, NULL);
    svc_grp_name = axis2_svc_grp_get_name(svc_grp, env);

    svc_grp_ctx = axis2_svc_grp_ctx_create(env, (axis2_svc_grp_t *)svc_grp, parent);
    if(!svc_grp_ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "Creating service group context failed for service group %s", svc_grp_name);
        return NULL;
    }

    return svc_grp_ctx;
}

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)
{
    return svc_grp->param_container;
}

AXIS2_EXTERN axis2_desc_t *AXIS2_CALL
axis2_svc_grp_get_base(
    const axis2_svc_grp_t * svc_grp,
    const axutil_env_t * env)
{
    return svc_grp->base;
}

AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_svc_grp_is_module_engaged(
	const axis2_svc_grp_t *svc_grp,
	const axutil_env_t *env,
	const axutil_qname_t *module_name)
{
    int i = 0;
    axutil_qname_t *modu = NULL;
    axis2_char_t *modu_local = NULL;
    axis2_char_t *module_name_local = NULL;
    int size = 0;

    size = axutil_array_list_size(svc_grp->module_qname_list, env);
    for(i = 0; i < size ; i++)
    {
        modu = axutil_array_list_get(svc_grp->module_qname_list, env, i);
        modu_local = axutil_qname_get_localpart(modu, env);
        module_name_local = axutil_qname_get_localpart(module_name, env);
        if(!axutil_strcmp(modu_local, module_name_local))
        {
            return AXIS2_TRUE;
        }
    }
	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;
}