ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject svn commit: r690127 [2/11] - in /webservices/sandesha/trunk/c: ./ build/win32/ config/ ides/vc8/sandesha2/sandesha2/ include/ include/sandesha2/ samples/ samples/RMSampleService/ samples/rm_echo_1_0/ samples/rm_echo_1_0_large_sequence/ samples/rm_echo_...
Date Fri, 29 Aug 2008 06:56:38 GMT
Modified: webservices/sandesha/trunk/c/src/client/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/client/Makefile.am?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/client/Makefile.am (original)
+++ webservices/sandesha/trunk/c/src/client/Makefile.am Thu Aug 28 23:56:29 2008
@@ -6,6 +6,8 @@
 							report.c \
 							client.c
 
+libsandesha2_client_la_LIBADD = ../core/libsandesha2.la
+
 INCLUDES = -I$(top_builddir)/include \
 		   	@AXIS2INC@ \
 		   	@AXIOMINC@ \

Modified: webservices/sandesha/trunk/c/src/client/client.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/client/client.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/client/client.c (original)
+++ webservices/sandesha/trunk/c/src/client/client.c Thu Aug 28 23:56:29 2008
@@ -17,9 +17,11 @@
 #include <sandesha2_client.h>
 #include <sandesha2_storage_mgr.h>
 #include <sandesha2_seq_property_mgr.h>
+#include <sandesha2_sender_mgr.h>
 #include <sandesha2_create_seq_mgr.h>
 #include <sandesha2_next_msg_mgr.h>
 #include <sandesha2_permanent_seq_property_mgr.h>
+#include <sandesha2_permanent_sender_mgr.h>
 #include <sandesha2_permanent_create_seq_mgr.h>
 #include <sandesha2_permanent_next_msg_mgr.h>
 #include "sandesha2_client_constants.h"
@@ -30,6 +32,7 @@
 #include <sandesha2_close_seq.h>
 #include <sandesha2_terminate_seq.h>
 #include <sandesha2_ack_mgr.h>
+#include <sandesha2_msg_init.h>
 #include <sandesha2_constants.h>
 
 #include <axis2_callback_recv.h>
@@ -58,6 +61,16 @@
  *
  * @return internal_seq_id
  */
+
+static void
+sandesha2_client_fire_and_forget(
+    const axutil_env_t *env,
+    axis2_svc_client_t *svc_client,
+    axis2_options_t *options,
+    axutil_qname_t *op_qname,
+    axis2_callback_t *callback,
+    axiom_node_t *payload);
+
 static axis2_char_t *
 sandesha2_client_get_internal_seq_id(
         const axutil_env_t *env,
@@ -89,13 +102,6 @@
         axis2_char_t *internal_seq_id,
         sandesha2_seq_property_mgr_t *seq_prop_mgr);
 
-/*static axis2_status_t
-sandesha2_client_fill_timedout_outgoing_seq_info(
-        const axutil_env_t *env,
-        sandesha2_seq_report_t *report,
-        axis2_char_t *internal_seq_id,
-        sandesha2_seq_property_mgr_t *seq_prop_mgr);*/
-
 static axis2_status_t
 sandesha2_client_fill_outgoing_seq_info(
         const axutil_env_t *env,
@@ -126,7 +132,8 @@
 sandesha2_client_configure_terminate_seq(
     const axutil_env_t *env,
     axis2_options_t *options, 
-    axis2_conf_ctx_t *conf_ctx);
+    axis2_conf_ctx_t *conf_ctx,
+    sandesha2_seq_property_mgr_t *seq_prop_mgr);
 
 static axis2_bool_t
 fill_soap_envelope(
@@ -213,7 +220,7 @@
     AXIS2_PARAM_CHECK(env->error, seq_key, NULL);
     AXIS2_PARAM_CHECK(env->error, conf_ctx, NULL);
 
-    internal_seq_id = sandesha2_utils_get_internal_seq_id(env, to, seq_key);
+    internal_seq_id = sandesha2_utils_get_client_internal_sequence_id(env, to, seq_key);
     return (sandesha2_seq_report_t *) 
         sandesha2_client_get_outgoing_seq_report_with_internal_seq_id(env, 
         internal_seq_id, conf_ctx);
@@ -251,8 +258,7 @@
     ctx = axis2_conf_ctx_get_base(conf_ctx, env);
     sandesha2_seq_report_set_internal_seq_id(seq_report, env, internal_seq_id);
     create_seq_find_bean = sandesha2_create_seq_bean_create(env);
-    sandesha2_create_seq_bean_set_internal_seq_id(create_seq_find_bean, 
-        env, internal_seq_id);
+    sandesha2_create_seq_bean_set_internal_sequence_id(create_seq_find_bean, env, internal_seq_id);
     create_seq_bean = sandesha2_create_seq_mgr_find_unique(create_seq_mgr, env, 
         create_seq_find_bean);
 	/* if data is not available seq has to be terminated or timedOut.*/
@@ -306,7 +312,7 @@
             sandesha2_storage_mgr_free(storage_mgr, env);
         return seq_report;
     }
-    out_seq_id = sandesha2_create_seq_bean_get_seq_id(create_seq_bean, env);
+    out_seq_id = sandesha2_create_seq_bean_get_rms_sequence_id(create_seq_bean, env);
     if(!out_seq_id)
     {
         sandesha2_seq_report_set_internal_seq_id(seq_report, env, 
@@ -419,7 +425,7 @@
     ctx = axis2_conf_ctx_get_base(conf_ctx, env);
     if(internal_seq_find_bean) 
         sandesha2_seq_property_bean_set_name(internal_seq_find_bean, env, 
-            SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID);
+            SANDESHA2_SEQUENCE_PROPERTY_RMS_INTERNAL_SEQ_ID);
     if (seq_prop_mgr)
     {
         collection = sandesha2_seq_property_mgr_find(seq_prop_mgr, env, 
@@ -602,8 +608,7 @@
 sandesha2_client_terminate_seq_with_svc_client(
     const axutil_env_t *env,
     axis2_svc_client_t *svc_client,
-    axis2_callback_t *callback,
-    axis2_listener_manager_t *listener_manager)
+    axis2_callback_t *callback)
 {
     axis2_svc_ctx_t *svc_ctx = NULL;
     axis2_options_t *options = NULL;
@@ -620,66 +625,140 @@
     axiom_element_t *terminate_body_element = NULL;
     axiom_element_t *element = NULL;
     axutil_qname_t *qname = NULL;
+    sandesha2_storage_mgr_t *storage_mgr = NULL;
+    sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL;
+    sandesha2_sender_mgr_t *sender_mgr = NULL;
+    axis2_char_t *dbname = NULL;
 
     if(!svc_client)
+    {
         return AXIS2_FAILURE;
-    svc_ctx = (axis2_svc_ctx_t *) axis2_svc_client_get_svc_ctx(svc_client, 
-        env);
+    }
+
+    svc_ctx = (axis2_svc_ctx_t *) axis2_svc_client_get_svc_ctx(svc_client, env);
     if(!svc_ctx)
     {
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SVC_CTX_NULL, 
-                AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SVC_CTX_NULL, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
+
     options = (axis2_options_t *) axis2_svc_client_get_options(svc_client, env);
     if(!options)
     {
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_OPTIONS_OBJECT_NOT_SET, 
-                AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_OPTIONS_OBJECT_NOT_SET, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
     property = (axutil_property_t *) axis2_options_get_property(options, env, 
             SANDESHA2_CLIENT_RM_SPEC_VERSION);
     if(property)
+    {
         rm_spec_version = axutil_property_get_value(property, env);
+    }
+
     if(!rm_spec_version)
     {
-        rm_spec_version = 
-            sandesha2_spec_specific_consts_get_default_spec_version(env);
+        rm_spec_version = sandesha2_spec_specific_consts_get_default_spec_version(env);
     }
-    rm_namespc_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, 
-            rm_spec_version);
+    rm_namespc_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_spec_version);
     conf_ctx =  axis2_svc_ctx_get_conf_ctx(svc_ctx, env);
-    terminate_envelope = sandesha2_client_configure_terminate_seq(env, options, 
-            conf_ctx);
+
+    dbname = sandesha2_util_get_dbname(env, conf_ctx);
+    storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
+    if(storage_mgr)
+    {
+        seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
+        sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
+    }
+
+    terminate_envelope = sandesha2_client_configure_terminate_seq(env, options, conf_ctx, 
+            seq_prop_mgr);
+
     if (!terminate_envelope)
+    {
+        if(sender_mgr)
+        {
+            sandesha2_sender_mgr_free(sender_mgr, env);
+        }
+        
+        if(seq_prop_mgr)
+        {
+            sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+        }
+
+        if(storage_mgr)
+        {
+            sandesha2_storage_mgr_free(storage_mgr, env);
+        }
+
         return AXIS2_FAILURE;
+    }
+
     body = axiom_soap_envelope_get_body(terminate_envelope, env);
     node = axiom_soap_body_get_base_node(body, env);
     element = axiom_node_get_data_element(node, env);
-    qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_TERMINATE_SEQ, 
-        rm_namespc_value, NULL);
-    terminate_body_element = axiom_element_get_first_child_with_qname(element, 
-        env, qname, node, &terminate_body_node);
+    qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_TERMINATE_SEQ, rm_namespc_value, NULL);
+    terminate_body_element = axiom_element_get_first_child_with_qname(element, env, qname, node, 
+            &terminate_body_node);
+
     if(qname)
+    {
         axutil_qname_free(qname, env);
+    }
+
     old_action = axutil_strdup(env, axis2_options_get_action(options, env));
-    action = sandesha2_spec_specific_consts_get_terminate_seq_action(env, 
-            rm_spec_version);
+    action = sandesha2_spec_specific_consts_get_terminate_seq_action(env, rm_spec_version);
     if(action)
+    {
         axis2_options_set_action(options, env, action);
-    sandesha2_client_fire_and_forget(env, svc_client, options, NULL, callback, 
-        terminate_body_node, listener_manager);
+    }
+
+    sandesha2_client_fire_and_forget(env, svc_client, options, NULL, callback, terminate_body_node);
+
     if(!AXIS2_ERROR_GET_STATUS_CODE(env->error))
     {
-        AXIS2_ERROR_SET(env->error, 
-            SANDESHA2_ERROR_COULD_NOT_SEND_TERMINATE_MESSAGE, AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_COULD_NOT_SEND_TERMINATE_MESSAGE, AXIS2_FAILURE);
         axis2_options_set_action(options, env, old_action);
+
+        if(sender_mgr)
+        {
+            sandesha2_sender_mgr_free(sender_mgr, env);
+        }
+        
+        if(seq_prop_mgr)
+        {
+            sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+        }
+
+        if(storage_mgr)
+        {
+            sandesha2_storage_mgr_free(storage_mgr, env);
+        }
+
         return AXIS2_FAILURE;
     }
+
     if(old_action)
+    {
         axis2_options_set_action(options, env, old_action);
+    }
+
+    if(sender_mgr)
+    {
+        sandesha2_sender_mgr_free(sender_mgr, env);
+    }
+    
+    if(seq_prop_mgr)
+    {
+        sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+    }
+
+    if(storage_mgr)
+    {
+        sandesha2_storage_mgr_free(storage_mgr, env);
+    }
+
     AXIS2_FREE(env->allocator, old_action);
+
     return AXIS2_SUCCESS;
 }
 
@@ -704,7 +783,7 @@
         SANDESHA2_CLIENT_SEQ_KEY);
     property = axutil_property_create_with_args(env, 0, 0, 0, seq_key);
     axis2_options_set_property(options, env, SANDESHA2_CLIENT_SEQ_KEY, property);
-    sandesha2_client_terminate_seq_with_svc_client(env, svc_client, NULL, NULL);
+    sandesha2_client_terminate_seq_with_svc_client(env, svc_client, NULL);
     axis2_options_set_property(options, env, SANDESHA2_CLIENT_SEQ_KEY, old_property);
     return AXIS2_SUCCESS;
 }
@@ -1011,7 +1090,7 @@
     storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
     seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
     seq_id_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, 
-            internal_seq_id, SANDESHA2_SEQ_PROP_OUT_SEQ_ID);
+            internal_seq_id, SANDESHA2_SEQUENCE_PROPERTY_RMS_SEQ_ID);
     if(!seq_id_bean)
     {
         AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SEQ_ID_BEAN_NOT_SET, 
@@ -1196,7 +1275,7 @@
     axis2_char_t *to,
     axis2_char_t *seq_key)
 {
-    return (axis2_char_t *) sandesha2_utils_get_internal_seq_id(env, to, seq_key);
+    return (axis2_char_t *) sandesha2_utils_get_client_internal_sequence_id(env, to, seq_key);
 }
 
 static axiom_soap_envelope_t *
@@ -1242,7 +1321,7 @@
     property = (axutil_property_t *) axis2_options_get_property(options, env, 
             SANDESHA2_CLIENT_SEQ_KEY);
     seq_key = axutil_property_get_value(property, env);
-    internal_seq_id = sandesha2_utils_get_internal_seq_id(env, to, seq_key);
+    internal_seq_id = sandesha2_utils_get_client_internal_sequence_id(env, to, seq_key);
 
     seq_report = sandesha2_client_get_outgoing_seq_report_with_internal_seq_id(
             env, internal_seq_id, conf_ctx);
@@ -1264,7 +1343,7 @@
     storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
     seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
     seq_id_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, 
-            internal_seq_id, SANDESHA2_SEQ_PROP_OUT_SEQ_ID);
+            internal_seq_id, SANDESHA2_SEQUENCE_PROPERTY_RMS_SEQ_ID);
     if(!seq_id_bean)
     {
         AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SEQ_ID_BEAN_NOT_SET, 
@@ -1354,7 +1433,7 @@
     sandesha2_seq_property_bean_set_value(internal_seq_find_bean, env, 
             internal_seq_id);
     sandesha2_seq_property_bean_set_name(internal_seq_find_bean, env, 
-           SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID);
+           SANDESHA2_SEQUENCE_PROPERTY_RMS_INTERNAL_SEQ_ID);
     internal_seq_bean = sandesha2_seq_property_mgr_find_unique(seq_prop_mgr, 
             env, internal_seq_find_bean);
     if(!internal_seq_bean)
@@ -1399,7 +1478,7 @@
     sandesha2_seq_property_bean_set_value(internal_seq_find_bean, env, 
             internal_seq_id);
     sandesha2_seq_property_bean_set_name(internal_seq_find_bean, env, 
-           SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID);
+           SANDESHA2_SEQUENCE_PROPERTY_RMS_INTERNAL_SEQ_ID);
     internal_seq_bean = sandesha2_seq_property_mgr_find_unique(seq_prop_mgr, 
             env, internal_seq_find_bean);
     if(!internal_seq_bean)
@@ -1441,7 +1520,7 @@
     sandesha2_seq_property_bean_set_value(internal_seq_find_bean, env, 
             internal_seq_id);
     sandesha2_seq_property_bean_set_name(internal_seq_find_bean, env, 
-           SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID);
+           SANDESHA2_SEQUENCE_PROPERTY_RMS_INTERNAL_SEQ_ID);
     internal_seq_bean = sandesha2_seq_property_mgr_find_unique(seq_prop_mgr, 
             env, internal_seq_find_bean);
     if(!internal_seq_bean)
@@ -1459,44 +1538,6 @@
     return AXIS2_SUCCESS; 
 }
 
-/*static axis2_status_t
-sandesha2_client_fill_timedout_outgoing_seq_info(
-    const axutil_env_t *env,
-    sandesha2_seq_report_t *report,
-    axis2_char_t *internal_seq_id,
-    sandesha2_seq_property_mgr_t *seq_prop_mgr)
-{
-    sandesha2_seq_property_bean_t *internal_seq_find_bean = NULL;
-    sandesha2_seq_property_bean_t *internal_seq_bean = NULL;
-    axis2_char_t *out_seq_id = NULL;
-
-    internal_seq_find_bean =sandesha2_seq_property_bean_create(env);
-    if(!internal_seq_find_bean)
-    {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return AXIS2_FALSE;
-    }
-    sandesha2_seq_property_bean_set_value(internal_seq_find_bean, env, 
-            internal_seq_id);
-    sandesha2_seq_property_bean_set_name(internal_seq_find_bean, env, 
-           SANDESHA2_SEQ_PROP_INTERNAL_SEQ_ID);
-    internal_seq_bean = sandesha2_seq_property_mgr_find_UNIQUE(seq_prop_mgr, 
-            env, internal_seq_find_bean);
-    if(!internal_seq_bean)
-    {
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-                "Not a valid terminated sequence. Internal sequence bean is not \
-                available for the given sequence.");
-        AXIS2_ERROR_SET(env->error, NOT_A_VALID_TERMINATED_SEQ, AXIS2_FAILURE); 
-        return AXIS2_FAILURE;
-    }
-    sandesha2_seq_report_set_seq_status(report, env, 
-            SANDESHA2_SEQ_STATUS_TIMED_OUT);
-    out_seq_id = sandesha2_seq_property_bean_get_seq_id(internal_seq_bean, env);
-    sandesha2_client_fill_outgoing_seq_info(env, report, out_seq_id, seq_prop_mgr);
-    return AXIS2_SUCCESS; 
-}*/
-
 static axis2_status_t
 sandesha2_client_fill_outgoing_seq_info(
     const axutil_env_t *env,
@@ -1561,7 +1602,7 @@
     axis2_char_t *to_epr,
     axis2_char_t *seq_key)
 {
-    return sandesha2_utils_get_internal_seq_id(env, to_epr, seq_key); 
+    return sandesha2_utils_get_client_internal_sequence_id(env, to_epr, seq_key); 
 }
 
 static sandesha2_seq_report_t *
@@ -1608,16 +1649,23 @@
         incoming side internal_seq_id = seq_id*/
     sandesha2_seq_report_set_seq_direction(seq_report, env, 
         SANDESHA2_SEQ_DIRECTION_IN);
-    status = sandesha2_client_get_svr_seq_status(env, seq_id, seq_prop_mgr, 
-        next_msg_mgr);
-    sandesha2_seq_report_set_seq_status(seq_report, env, 
-        status);
+    status = sandesha2_client_get_svr_seq_status(env, seq_id, seq_prop_mgr, next_msg_mgr);
+    sandesha2_seq_report_set_seq_status(seq_report, env, status);
     if(seq_prop_mgr)
+    {
         sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+    }
+
     if(next_msg_mgr)
+    {
         sandesha2_next_msg_mgr_free(next_msg_mgr, env);
+    }
+
     if(storage_mgr)
+    {
         sandesha2_storage_mgr_free(storage_mgr, env);
+    }
+
     return seq_report;
 }
 
@@ -1625,7 +1673,8 @@
 sandesha2_client_configure_terminate_seq(
     const axutil_env_t *env,
     axis2_options_t *options, 
-    axis2_conf_ctx_t *conf_ctx)
+    axis2_conf_ctx_t *conf_ctx,
+    sandesha2_seq_property_mgr_t *seq_prop_mgr)
 {
     axis2_endpoint_ref_t *to_epr = NULL;
     axis2_char_t *to = NULL;
@@ -1638,41 +1687,44 @@
     sandesha2_seq_report_t *seq_report = NULL;
     axis2_conf_t *conf = NULL;
     axutil_property_t *property = NULL;
-    axis2_char_t *dbname = NULL;
+
     if(!options)
     {
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_OPTIONS_OBJECT_NOT_SET, 
-                AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_OPTIONS_OBJECT_NOT_SET, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
+
     to_epr = axis2_options_get_to(options, env);
+
     if(!to_epr)
     {
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_TO_EPR_NOT_SET, 
-                AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_TO_EPR_NOT_SET, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
+
     to = (axis2_char_t*)axis2_endpoint_ref_get_address(to_epr, env);
     property = (axutil_property_t *) axis2_options_get_property(options, env, 
-        SANDESHA2_CLIENT_SEQ_KEY);
+            SANDESHA2_CLIENT_SEQ_KEY);
     if(property)
+    {
         seq_key = axutil_property_get_value(property, env);
-    internal_seq_id = sandesha2_utils_get_internal_seq_id(env, to, seq_key);
+    }
 
-    seq_report = sandesha2_client_get_outgoing_seq_report_with_internal_seq_id(
-            env, internal_seq_id, conf_ctx);
+    internal_seq_id = sandesha2_utils_get_client_internal_sequence_id(env, to, seq_key);
+
+    seq_report = sandesha2_client_get_outgoing_seq_report_with_internal_seq_id(env, internal_seq_id, 
+            conf_ctx);
     if(!seq_report)
     {
-        AXIS2_ERROR_SET(env->error, 
-                SANDESHA2_ERROR_CANNOT_FIND_SEQ_REPORT_FOR_GIVEN_SEQ_ID, 
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_REPORT_FOR_GIVEN_SEQ_ID, 
                 AXIS2_FAILURE);
         return NULL;
     }
+
     status = sandesha2_seq_report_get_seq_status(seq_report, env);
     if(status != SANDESHA2_SEQ_STATUS_ESTABLISHED)
     {
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SEQ_NOT_IN_ACTIVE_STATE, 
-            AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SEQ_NOT_IN_ACTIVE_STATE, AXIS2_FAILURE);
         return NULL;
     }
     if(conf_ctx)
@@ -1684,85 +1736,74 @@
         sandesha2_identifier_t *identifier = NULL;
         sandesha2_seq_property_bean_t *seq_id_bean = NULL;
         axis2_char_t *seq_id = NULL;
-        sandesha2_storage_mgr_t *storage_mgr = NULL;
-        sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL;
 
         conf = axis2_conf_ctx_get_conf(conf_ctx, env);
-        dbname = sandesha2_util_get_dbname(env, conf_ctx);
-        storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
-        if(storage_mgr)
+    
+        if(seq_prop_mgr)
         {
-            seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
+            seq_id_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, 
+                    SANDESHA2_SEQUENCE_PROPERTY_RMS_SEQ_ID);
         }
-        if(seq_prop_mgr)
-            seq_id_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, 
-                internal_seq_id, SANDESHA2_SEQ_PROP_OUT_SEQ_ID);
+
         if(!seq_id_bean)
         {
-            AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SEQ_ID_BEAN_NOT_SET, 
-                AXIS2_FAILURE);
-            if(seq_prop_mgr)
-                sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
-            if(storage_mgr)
-                sandesha2_storage_mgr_free(storage_mgr, env);
+            AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SEQ_ID_BEAN_NOT_SET, AXIS2_FAILURE);
+
             return NULL;
         }
+
         seq_id = sandesha2_seq_property_bean_get_value(seq_id_bean, env);
         if(!seq_id)
         {
-            AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID, 
-                AXIS2_FAILURE);
-            if(seq_prop_mgr)
-                sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
-            if(storage_mgr)
-                sandesha2_storage_mgr_free(storage_mgr, env);
+            AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID, AXIS2_FAILURE);
+
             return NULL;
         }
-        property = axis2_options_get_property(options, env, 
-            SANDESHA2_CLIENT_RM_SPEC_VERSION);
+
+        property = axis2_options_get_property(options, env, SANDESHA2_CLIENT_RM_SPEC_VERSION);
         if(property)
+        {
             rm_spec_version = axutil_property_get_value(property, env);
+        }
+
         if(!rm_spec_version)
         {
-            rm_spec_version = 
-                sandesha2_spec_specific_consts_get_default_spec_version(env);
+            rm_spec_version = sandesha2_spec_specific_consts_get_default_spec_version(env);
         }
-        action = sandesha2_spec_specific_consts_get_terminate_seq_action(env, 
-            rm_spec_version);
+
+        action = sandesha2_spec_specific_consts_get_terminate_seq_action(env, rm_spec_version);
         axis2_options_set_action(options, env, action);
-        soap_ns_uri = (axis2_char_t *) axis2_options_get_soap_version_uri(options, 
-            env);
-        if(0 == axutil_strcmp(AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI, soap_ns_uri))
+        soap_ns_uri = (axis2_char_t *) axis2_options_get_soap_version_uri(options, env);
+        if(!axutil_strcmp(AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI, soap_ns_uri))
         {
-            dummy_envelope = axiom_soap_envelope_create_default_soap_envelope(env, 
-                AXIOM_SOAP12); 
+            dummy_envelope = axiom_soap_envelope_create_default_soap_envelope(env, AXIOM_SOAP12); 
         }
         else
         {
-            dummy_envelope = axiom_soap_envelope_create_default_soap_envelope(env, 
-                AXIOM_SOAP11); 
+            dummy_envelope = axiom_soap_envelope_create_default_soap_envelope(env, AXIOM_SOAP11); 
         }
-        rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, 
-            rm_spec_version);
+
+        rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_spec_version);
         terminate_seq = sandesha2_terminate_seq_create(env, rm_ns_value);
         identifier = sandesha2_identifier_create(env, rm_ns_value);
         if(identifier)
+        {
             sandesha2_identifier_set_identifier(identifier, env, seq_id);
+        }
+
         if(terminate_seq)
         {
-            sandesha2_terminate_seq_set_identifier(terminate_seq, env, 
-                identifier);
-            sandesha2_terminate_seq_to_soap_envelope(terminate_seq, env, 
-                dummy_envelope);
+            sandesha2_terminate_seq_set_identifier(terminate_seq, env, identifier);
+            sandesha2_terminate_seq_to_soap_envelope(terminate_seq, env, dummy_envelope);
         }
-        if(seq_prop_mgr)
-            sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
-        if(storage_mgr)
-            sandesha2_storage_mgr_free(storage_mgr, env);
+
         return dummy_envelope;
     }
+
     else
+    {
         return NULL;
+    }
 }
 
 axis2_status_t AXIS2_CALL
@@ -1799,8 +1840,12 @@
     {
         return AXIS2_FAILURE;
     }
+
     if (!fill_soap_envelope(env, msg_ctx, options, payload))
+    {
         return AXIS2_FAILURE;
+    }
+
     axis2_op_client_set_callback(op_client, env, callback);
     axis2_op_client_add_out_msg_ctx(op_client, env, msg_ctx);
     transport_in_protocol = axis2_options_get_transport_in_protocol(
@@ -1820,15 +1865,14 @@
     return axis2_op_client_execute(op_client, env, AXIS2_FALSE);
 }
 
-void AXIS2_CALL
+static void AXIS2_CALL
 sandesha2_client_fire_and_forget(
     const axutil_env_t *env,
     axis2_svc_client_t *svc_client,
     axis2_options_t *options,
     axutil_qname_t *op_qname,
     axis2_callback_t *callback,
-    axiom_node_t *payload,
-    axis2_listener_manager_t *listener_manager)
+    axiom_node_t *payload)
 {
     axis2_op_client_t *op_client = NULL;
     axis2_svc_ctx_t *svc_ctx = NULL;
@@ -1844,40 +1888,44 @@
     {
         op_qname = axutil_qname_create(env, AXIS2_ANON_OUT_ONLY_OP, NULL, NULL);
     }
+
     svc_ctx = axis2_svc_client_get_svc_ctx(svc_client, env);
     conf_ctx =  axis2_svc_ctx_get_conf_ctx(svc_ctx, env);
+
     msg_ctx = axis2_msg_ctx_create(env, conf_ctx, NULL, NULL);
 	svc = axis2_svc_client_get_svc(svc_client, env);
     op = axis2_svc_get_op_with_qname(svc, env, op_qname);
     if(op_qname)
+    {
         axutil_qname_free(op_qname, env);
+    }
+
     if (!fill_soap_envelope(env, msg_ctx, options, payload))
     {
         return;
     }
+
     op_client = axis2_op_client_create(env, op, svc_ctx, options);
     if (!op_client)
     {
         return;
     }
+
     if(callback)
     {
         axis2_op_client_set_callback(op_client, env, callback);
-        /*axis2_op_client_add_out_msg_ctx(op_client, env, msg_ctx);*/
-        transport_in_protocol = axis2_options_get_transport_in_protocol(
-            options, env);
-        axis2_listener_manager_make_sure_started(listener_manager, env,
-            transport_in_protocol, conf_ctx);
+        transport_in_protocol = axis2_options_get_transport_in_protocol(options, env);
         callback_recv = axis2_callback_recv_create(env);
         if (!(callback_recv))
         {
             axis2_svc_client_free(svc_client, env);
         }
-        axis2_op_set_msg_recv(op, env, AXIS2_CALLBACK_RECV_GET_BASE(callback_recv, 
-            env));
+
+        axis2_op_set_msg_recv(op, env, AXIS2_CALLBACK_RECV_GET_BASE(callback_recv, env));
         axis2_op_client_set_callback_recv(op_client, env, callback_recv);
         block = AXIS2_FALSE;
     }
+
     axis2_op_client_add_out_msg_ctx(op_client, env, msg_ctx);
     axis2_op_client_execute(op_client, env, block);
 }
@@ -1900,18 +1948,21 @@
         return AXIS2_FALSE;
     }
 
-    if (axutil_strcmp(soap_version_uri,
-            AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI) == 0)
+    if (!axutil_strcmp(soap_version_uri, AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI))
+    {
         soap_version = AXIOM_SOAP11;
+    }
     else
+    {
         soap_version = AXIOM_SOAP12;
+    }
 
-    envelope = axiom_soap_envelope_create_default_soap_envelope(env,
-            soap_version);
+    envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_version);
     if (!envelope)
     {
         return AXIS2_FALSE;
     }
+
     if (payload)
     {
         axiom_soap_body_t *soap_body = NULL;
@@ -1919,6 +1970,7 @@
         if (soap_body)
         {
             axiom_node_t *node = NULL;
+
             node = axiom_soap_body_get_base_node(soap_body, env);
             if (node)
             {
@@ -1926,6 +1978,7 @@
             }
         }
     }
+
     axis2_msg_ctx_set_soap_envelope(msg_ctx, env, envelope);
 
     return AXIS2_TRUE;

Modified: webservices/sandesha/trunk/c/src/core/mod_sandesha2.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/core/mod_sandesha2.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/core/mod_sandesha2.c (original)
+++ webservices/sandesha/trunk/c/src/core/mod_sandesha2.c Thu Aug 28 23:56:29 2008
@@ -21,7 +21,6 @@
 #include <sandesha2_constants.h>
 #include <sandesha2_permanent_storage_mgr.h>
 
-/******************************************************************************/
 axis2_status_t AXIS2_CALL
 mod_sandesha2_shutdown(
     axis2_module_t *module,
@@ -46,19 +45,15 @@
     mod_sandesha2_fill_handler_create_func_map
 };
 
-/******************************************************************************/
-
 AXIS2_EXTERN axis2_module_t * AXIS2_CALL
 mod_sandesha2_create(
     const axutil_env_t *env)
 {
     axis2_module_t *module = NULL;
-    module = AXIS2_MALLOC(env->allocator, 
-        sizeof(axis2_module_t));
+    module = AXIS2_MALLOC(env->allocator, sizeof(axis2_module_t));
 
-    /*module->ops = AXIS2_MALLOC(
-        env->allocator, sizeof(axis2_module_ops_t));*/
     module->ops = &mod_sandesha2_ops_var;
+
     return module;
 }
 
@@ -74,21 +69,19 @@
     axis2_conf_t *conf = NULL;
     axis2_ctx_t *ctx = NULL;
     
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:mod_sandesha2_init");
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:mod_sandesha2_init");
     AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE);
     
     sandesha2_error_init();
-    property_bean = sandesha2_property_mgr_load_properties_from_module_desc(env,
-        module_desc);
+    property_bean = sandesha2_property_mgr_load_properties_from_module_desc(env, module_desc);
     if(!property_bean)
-        property_bean = sandesha2_property_mgr_load_properties_from_def_values
-            (env);
+    {
+        property_bean = sandesha2_property_mgr_load_properties_from_def_values(env);
+    }
         
-    param = axutil_param_create(env, SANDESHA2_SANDESHA_PROPERTY_BEAN, 
-        property_bean);
-    axutil_param_set_value_free(param, env, 
-        sandesha2_property_bean_free_void_arg); 
+    param = axutil_param_create(env, SANDESHA2_SANDESHA_PROPERTY_BEAN, property_bean);
+    axutil_param_set_value_free(param, env, sandesha2_property_bean_free_void_arg); 
 
     conf = axis2_conf_ctx_get_conf(conf_ctx, env);
     axis2_conf_add_param(conf, env, param);
@@ -97,17 +90,15 @@
     axis2_ctx_set_property(ctx, env, SANDESHA2_INMEMORY_STORAGE_MGR, NULL);
     axis2_ctx_set_property(ctx, env, SANDESHA2_PERMANENT_STORAGE_MGR, NULL);
     
-    /*if(!sandesha2_permanent_storage_mgr_create_db(env, conf_ctx))
-    {
-        return AXIS2_FAILURE;
-    }*/
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:mod_sandesha2_init");
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:mod_sandesha2_init");
+
     return AXIS2_SUCCESS;
 }
 
 axis2_status_t AXIS2_CALL
-mod_sandesha2_shutdown(axis2_module_t *module,
-                        const axutil_env_t *env)
+mod_sandesha2_shutdown(
+    axis2_module_t *module,
+    const axutil_env_t *env)
 {
 
     /* currently we don't have conf_ctx passing to shutdown. When we have that
@@ -133,22 +124,24 @@
 }
 
 axis2_status_t AXIS2_CALL
-mod_sandesha2_fill_handler_create_func_map(axis2_module_t *module,
-                                            const axutil_env_t *env)
+mod_sandesha2_fill_handler_create_func_map(
+    axis2_module_t *module,
+    const axutil_env_t *env)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     
     module->handler_create_func_map = axutil_hash_make(env);
     if(!module->handler_create_func_map)
     {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, 
-            AXIS2_FAILURE);
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
     axutil_hash_set(module->handler_create_func_map, "SandeshaGlobalInHandler", 
         AXIS2_HASH_KEY_STRING, sandesha2_global_in_handler_create);
+
     axutil_hash_set(module->handler_create_func_map, "SandeshaInHandler", 
         AXIS2_HASH_KEY_STRING, sandesha2_in_handler_create);
+
     axutil_hash_set(module->handler_create_func_map, "SandeshaOutHandler",
         AXIS2_HASH_KEY_STRING, sandesha2_out_handler_create);
     
@@ -160,8 +153,9 @@
  */
 
 AXIS2_EXPORT int 
-axis2_get_instance(axis2_module_t **inst,
-                   const axutil_env_t *env)
+axis2_get_instance(
+    axis2_module_t **inst,
+    const axutil_env_t *env)
 {
    *inst = mod_sandesha2_create(env);
     if(!(*inst))
@@ -173,13 +167,17 @@
 }
 
 AXIS2_EXPORT int 
-axis2_remove_instance(axis2_module_t *inst,
-                      const axutil_env_t *env)
+axis2_remove_instance(
+    axis2_module_t *inst,
+    const axutil_env_t *env)
 {
     axis2_status_t status = AXIS2_FAILURE;
-   if (inst)
-   {
+
+    if (inst)
+    {
         status = mod_sandesha2_shutdown(inst, env);
     }
+
     return status;
 }
+

Modified: webservices/sandesha/trunk/c/src/core/sandesha2_msg_ctx.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/core/sandesha2_msg_ctx.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/core/sandesha2_msg_ctx.c (original)
+++ webservices/sandesha/trunk/c/src/core/sandesha2_msg_ctx.c Thu Aug 28 23:56:29 2008
@@ -51,6 +51,7 @@
     sandesha2_terminate_seq_t *terminate_seq;
     sandesha2_terminate_seq_res_t *terminate_seq_res;
     sandesha2_ack_requested_t *ack_requested;
+    axis2_bool_t is_server_side;
 };
 
 AXIS2_EXTERN sandesha2_msg_ctx_t* AXIS2_CALL
@@ -60,8 +61,7 @@
 {
     sandesha2_msg_ctx_t *rm_msg_ctx = NULL;
     
-    rm_msg_ctx =  (sandesha2_msg_ctx_t *)AXIS2_MALLOC 
-        (env->allocator, sizeof(sandesha2_msg_ctx_t));
+    rm_msg_ctx =  (sandesha2_msg_ctx_t *)AXIS2_MALLOC(env->allocator, sizeof(sandesha2_msg_ctx_t));
 	
     if(!rm_msg_ctx)
 	{
@@ -86,6 +86,7 @@
     
     rm_msg_ctx->msg_type = SANDESHA2_MSG_TYPE_UNKNOWN;
     rm_msg_ctx->msg_ctx = msg_ctx;
+    rm_msg_ctx->is_server_side = AXIS2_FALSE;
 
 	return rm_msg_ctx;
 }
@@ -166,6 +167,7 @@
         sandesha2_ack_requested_free(rm_msg_ctx->ack_requested, env);
         rm_msg_ctx->ack_requested = NULL;
     }
+
 	AXIS2_FREE(env->allocator, rm_msg_ctx);
 	return AXIS2_SUCCESS;
 }
@@ -198,15 +200,16 @@
     int soap_ver = AXIOM_SOAP11;
     axiom_soap_envelope_t *soap_envelope = NULL;
     
-    if(AXIS2_FALSE == axis2_msg_ctx_get_is_soap_11(rm_msg_ctx->msg_ctx, env))
+    if(!axis2_msg_ctx_get_is_soap_11(rm_msg_ctx->msg_ctx, env))
+    {
         soap_ver = AXIOM_SOAP12;
+    }
+
     soap_envelope = axis2_msg_ctx_get_soap_envelope(rm_msg_ctx->msg_ctx, env);
-    if(NULL == soap_envelope)
+    if(!soap_envelope)
     {
-        soap_envelope = axiom_soap_envelope_create_default_soap_envelope(env,
-                        soap_ver);
-        axis2_msg_ctx_set_soap_envelope(rm_msg_ctx->msg_ctx, env, 
-                        soap_envelope);
+        soap_envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_ver);
+        axis2_msg_ctx_set_soap_envelope(rm_msg_ctx->msg_ctx, env, soap_envelope);
     }
     
     if(rm_msg_ctx->close_seq)
@@ -214,30 +217,26 @@
         sandesha2_close_seq_to_soap_envelope(rm_msg_ctx->close_seq, env, 
             soap_envelope);
     }
+
     if(rm_msg_ctx->close_seq_res)
     {
-        sandesha2_close_seq_res_to_soap_envelope(rm_msg_ctx->close_seq_res, env, 
-            soap_envelope);
+        sandesha2_close_seq_res_to_soap_envelope(rm_msg_ctx->close_seq_res, env, soap_envelope);
     }
     if(rm_msg_ctx->create_seq)
     {
-        sandesha2_create_seq_to_soap_envelope(rm_msg_ctx->create_seq, env, 
-            soap_envelope);
+        sandesha2_create_seq_to_soap_envelope(rm_msg_ctx->create_seq, env, soap_envelope);
     }
     if(rm_msg_ctx->create_seq_res)
     {
-        sandesha2_create_seq_res_to_soap_envelope(rm_msg_ctx->create_seq_res, env, 
-            soap_envelope);
+        sandesha2_create_seq_res_to_soap_envelope(rm_msg_ctx->create_seq_res, env, soap_envelope);
     }
     if(rm_msg_ctx->make_connection)
     {
-        sandesha2_make_connection_to_soap_envelope(rm_msg_ctx->make_connection, 
-            env, soap_envelope);
+        sandesha2_make_connection_to_soap_envelope(rm_msg_ctx->make_connection, env, soap_envelope);
     }
     if(rm_msg_ctx->msg_pending)
     {
-        sandesha2_msg_pending_to_soap_envelope(rm_msg_ctx->msg_pending, env, 
-            soap_envelope);
+        sandesha2_msg_pending_to_soap_envelope(rm_msg_ctx->msg_pending, env, soap_envelope);
     }
     if(rm_msg_ctx->seq_ack)
     {
@@ -249,13 +248,11 @@
     }
     if(rm_msg_ctx->terminate_seq)
     {
-        sandesha2_terminate_seq_to_soap_envelope(rm_msg_ctx->terminate_seq, env, 
-            soap_envelope);
+        sandesha2_terminate_seq_to_soap_envelope(rm_msg_ctx->terminate_seq, env, soap_envelope);
     }
     if(rm_msg_ctx->terminate_seq_res)
     {
-        sandesha2_terminate_seq_res_to_soap_envelope(rm_msg_ctx->terminate_seq_res, 
-            env, soap_envelope);
+        sandesha2_terminate_seq_res_to_soap_envelope(rm_msg_ctx->terminate_seq_res, env, soap_envelope);
     }
     return AXIS2_SUCCESS;
 }
@@ -293,7 +290,7 @@
 {
     AXIS2_PARAM_CHECK(env->error, from, AXIS2_FAILURE);
     
-    return axis2_msg_ctx_set_to(rm_msg_ctx->msg_ctx, env, from);;
+    return axis2_msg_ctx_set_from(rm_msg_ctx->msg_ctx, env, from);;
 }
     
 axis2_endpoint_ref_t *AXIS2_CALL
@@ -499,7 +496,7 @@
     rm_msg_ctx->rm_ns_val = axutil_strdup(env, ns_val);
     if(0 == axutil_strcmp(ns_val, SANDESHA2_SPEC_2005_02_NS_URI))
         rm_msg_ctx->spec_ver = axutil_strdup(env, SANDESHA2_SPEC_VERSION_1_0);
-    if(0 == axutil_strcmp(ns_val, SANDESHA2_SPEC_2006_08_NS_URI))
+    if(0 == axutil_strcmp(ns_val, SANDESHA2_SPEC_2007_02_NS_URI))
         rm_msg_ctx->spec_ver = axutil_strdup(env, SANDESHA2_SPEC_VERSION_1_1);
         
     return AXIS2_SUCCESS;
@@ -639,7 +636,13 @@
     sandesha2_create_seq_res_t *create_seq_res)
 {
     AXIS2_PARAM_CHECK(env->error, create_seq_res, AXIS2_FAILURE);
-    
+   
+    if(rm_msg_ctx->create_seq_res)
+    {
+        sandesha2_create_seq_res_free(rm_msg_ctx->create_seq_res, env);
+        rm_msg_ctx->create_seq_res = NULL;
+    }
+
     rm_msg_ctx->create_seq_res = create_seq_res;
     return AXIS2_SUCCESS;
 }
@@ -832,3 +835,20 @@
     return rm_msg_ctx->ack_requested;
 }
 
+axis2_bool_t AXIS2_CALL
+sandesha2_msg_ctx_get_server_side(
+    const sandesha2_msg_ctx_t * rm_msg_ctx,
+    const axutil_env_t * env)
+{
+    return axis2_msg_ctx_get_server_side(rm_msg_ctx->msg_ctx, env);
+}
+
+axis2_status_t AXIS2_CALL
+sandesha2_msg_ctx_set_server_side(
+    const sandesha2_msg_ctx_t * rm_msg_ctx,
+    const axutil_env_t * env,
+    const axis2_bool_t server_side)
+{
+    return axis2_msg_ctx_set_server_side(rm_msg_ctx->msg_ctx, env, server_side);
+}
+

Modified: webservices/sandesha/trunk/c/src/handlers/sandesha2_global_in_handler.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/handlers/sandesha2_global_in_handler.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/handlers/sandesha2_global_in_handler.c (original)
+++ webservices/sandesha/trunk/c/src/handlers/sandesha2_global_in_handler.c Thu Aug 28 23:56:29 2008
@@ -81,9 +81,10 @@
     const axis2_char_t *wsa_action = NULL;
     const axis2_char_t *soap_action = NULL;
     axis2_bool_t is_rm_global_msg = AXIS2_FALSE;
+
     AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
-        "[sandesha2]Entry:sandesha2_global_in_handler");
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Entry:sandesha2_global_in_handler");
+
    /* This handler needs to identify messages which follow the WSRM 1.0 
     * convention for sending 'LastMessage' when the sender doesn't have a 
     * reliable message to piggyback the last message marker onto.
@@ -99,10 +100,9 @@
     if(wsa_action && !axutil_strcmp(wsa_action, SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE))
     {
         axutil_property_t *property = NULL;
-        property = axutil_property_create_with_args(env, 0, 0, 0, 
-            AXIS2_VALUE_TRUE);
-        axis2_msg_ctx_set_property(msg_ctx, env, 
-            SANDESHA2_ISOLATED_LAST_MSG, property);
+        property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
+        axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_ISOLATED_LAST_MSG, property);
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Isolated last message");
         return AXIS2_SUCCESS;
     }
     if(!soap_action && !wsa_action)
@@ -113,63 +113,103 @@
         {
             axis2_bool_t last_msg_header = AXIS2_FALSE;
             axiom_soap_header_t *header = NULL;
+
             header = axiom_soap_envelope_get_header(envelope, env);
             if(header)
             {
                 sandesha2_seq_t *sequence = NULL;
                 axiom_node_t *seq_node = NULL;
+                axiom_node_t *header_node = NULL;
+
                 sequence = sandesha2_seq_create(env, SANDESHA2_SPEC_2005_02_NS_URI);
-                seq_node = axiom_soap_header_get_base_node(header, env);
-                sandesha2_seq_from_om_node(sequence, env, seq_node);
+                header_node = axiom_soap_header_get_base_node(header, env);
+                if(header_node)
+                {
+                    axutil_qname_t *seq_qname = NULL;
+                    axiom_element_t *header_element = NULL;
+    
+                    seq_qname = axutil_qname_create(env, SANDESHA2_WSRM_COMMON_SEQ, 
+                            SANDESHA2_SPEC_2005_02_NS_URI, NULL);
+                    if(seq_qname)
+                    {
+                        axiom_element_t *seq_element = NULL;
+
+                        header_element = axiom_node_get_data_element(header_node, env);
+                        seq_element = axiom_element_get_first_child_with_qname(header_element, env,
+                            seq_qname, header_node, &seq_node);
+
+                        axutil_qname_free(seq_qname, env);
+                    }
+                }
+
+                if(sequence && seq_node)
+                {
+                    sandesha2_seq_from_om_node(sequence, env, seq_node);
+                }
+
                 if(sandesha2_seq_get_last_msg(sequence, env))
+                {
                     last_msg_header = AXIS2_TRUE;
-                 
+                }
             }
+
             if(last_msg_header)
             {
                 axiom_soap_body_t *body = NULL;
                 axiom_node_t *body_node = NULL;
+
                 body = axiom_soap_envelope_get_body(envelope, env);
                 body_node = axiom_soap_body_get_base_node(body, env);
                 if(body && !axiom_node_get_first_element(body_node, env))
                 {
                     axutil_property_t *property = NULL;
-                    axutil_string_t *temp_soap_action = axutil_string_create(env, 
-                        SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE);
-                    /* There is an empty body so we know this is the kind of message
-                     * that we are looking for.
+                    axutil_string_t *temp_soap_action = NULL;
+
+                    /* There is an empty body so we know this is the kind of message that we are 
+                     * looking for.
                      */
-                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]"\
-                        "Setting SOAP Action for a WSRM 1.0 last message");
-                    axis2_msg_ctx_set_soap_action(msg_ctx, env, 
-                        temp_soap_action);
-
-                    property = axutil_property_create_with_args(env, 0, 0, 0, 
-                        AXIS2_VALUE_TRUE);
-                    axis2_msg_ctx_set_property(msg_ctx, env, 
-                        SANDESHA2_ISOLATED_LAST_MSG, property);
+                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                            "[sandesha2] Setting SOAP Action for a WSRM 1.0 last message");
+
+                    temp_soap_action = axutil_string_create(env, 
+                            SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE);
+                    if(temp_soap_action)
+                    {
+                        axis2_msg_ctx_set_soap_action(msg_ctx, env, temp_soap_action);
+                        axutil_string_free(temp_soap_action, env);
+                    }
+                    
+                    axis2_msg_ctx_set_wsa_action(msg_ctx, env, 
+                            SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE);
+
+                    property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
+                    axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_ISOLATED_LAST_MSG, property);
                 }
             }
         }
+
         AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
             "[sandesha2]soap::action and wsa::action are NULL. So return here");
+
         return AXIS2_SUCCESS;
     }
+
     is_rm_global_msg = sandesha2_utils_is_rm_global_msg(env, msg_ctx);
     if(!is_rm_global_msg)
     {
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Not a global RM Message");
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Not a global RM Message");
         return AXIS2_SUCCESS;
     }
+
     conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
     if(!conf_ctx)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Configuration Context is NULL");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Configuration Context is NULL");
+
         AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
+
     /*ctx = axis2_msg_ctx_get_base(msg_ctx, env);
     if(!axis2_msg_ctx_get_server_side(msg_ctx, env))
     {
@@ -183,10 +223,10 @@
     soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
     if(!soap_envelope)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]SOAP envelope "\
-            "is NULL");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]SOAP envelope is NULL");
         return AXIS2_FAILURE;
     }
+
     /*property = axis2_ctx_get_property(ctx, env, SANDESHA2_REINJECTED_MESSAGE);
     if(property)
         reinjected_msg = (axis2_char_t *) axutil_property_get_value(property, env); 
@@ -197,8 +237,8 @@
         return AXIS2_SUCCESS; // Reinjected Messages are not processed by 
                                  sandesha2 inflow handlers
     }*/
-    fault_part = axiom_soap_body_get_fault(axiom_soap_envelope_get_body(
-                        soap_envelope, env), env);
+
+    fault_part = axiom_soap_body_get_fault(axiom_soap_envelope_get_body(soap_envelope, env), env);
     if(fault_part)
     {
         axis2_relates_to_t *relates_to = NULL;
@@ -213,16 +253,13 @@
             if(op_ctx)
             {
                 axis2_msg_ctx_t *req_msg_ctx = NULL;
-                req_msg_ctx =  axis2_op_ctx_get_msg_ctx(op_ctx, env, 
-                    AXIS2_WSDL_MESSAGE_LABEL_OUT);
+                req_msg_ctx =  axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_OUT);
                 if(req_msg_ctx)
                 {
-                    if(sandesha2_utils_is_retrievable_on_faults(env,
-                        req_msg_ctx))
+                    if(sandesha2_utils_is_retrievable_on_faults(env, req_msg_ctx))
                     {
                         /* TODO we need to notify the listeners */
-                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
-                            "[sandesha2] soap fault generated");
+                        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] soap fault generated");
                         axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE);
                         return AXIS2_SUCCESS;
                     }
@@ -230,6 +267,7 @@
             }
         }
     }
+
     /*Process if global processing possible. - Currently none*/
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
         "[sandesha2]Exit:sandesha2_global_in_handler");

Modified: webservices/sandesha/trunk/c/src/handlers/sandesha2_in_handler.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/handlers/sandesha2_in_handler.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/handlers/sandesha2_in_handler.c (original)
+++ webservices/sandesha/trunk/c/src/handlers/sandesha2_in_handler.c Thu Aug 28 23:56:29 2008
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <axis2_engine.h>
 #include <axis2_handler_desc.h>
 #include <axutil_array_list.h>
 #include <axis2_svc.h>
@@ -32,6 +33,7 @@
 #include <sandesha2_ack_msg_processor.h>
 #include <sandesha2_ack_req_msg_processor.h>
 #include <sandesha2_msg_init.h>
+#include <sandesha2_msg_creator.h>
 #include <sandesha2_seq.h>
 #include <sandesha2_constants.h>
 #include <sandesha2_utils.h>
@@ -58,6 +60,7 @@
 sandesha2_in_handler_process_dropped_msg(
     struct axis2_handler *handler, 
     const axutil_env_t *env,
+    axis2_conf_ctx_t *conf_ctx,
     sandesha2_msg_ctx_t *rm_msg_ctx,
     sandesha2_storage_mgr_t *storage_mgr,
     sandesha2_seq_property_mgr_t *seq_prop_mgr,
@@ -111,93 +114,122 @@
     axutil_property_t *property = NULL;
     AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
     
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
-        "[sandesha2] Start:sandesha2_in_handler_invoke");
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Start:sandesha2_in_handler_invoke");
 
     conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
     if(!conf_ctx)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Configuration Context is NULL");
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, 
-                AXIS2_FAILURE);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Configuration Context is NULL");
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
+
     if(!sandesha2_permanent_storage_mgr_create_db(env, conf_ctx))
     {
         return AXIS2_FAILURE;
     }
+
     ctx = axis2_msg_ctx_get_base(msg_ctx, env);
-    temp_prop = axis2_ctx_get_property(ctx, env, 
-        SANDESHA2_APPLICATION_PROCESSING_DONE);
+    temp_prop = axis2_ctx_get_property(ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE);
     if(temp_prop)
+    {
         str_done = (axis2_char_t *) axutil_property_get_value(temp_prop, env); 
-    if(str_done && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, str_done))
+    }
+
+    if(str_done && !axutil_strcmp(AXIS2_VALUE_TRUE, str_done))
     {
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Application processing done");
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Application processing done");
         return AXIS2_SUCCESS;
     }
+
     temp_prop = axis2_ctx_get_property(ctx, env, SANDESHA2_REINJECTED_MESSAGE);
     if(temp_prop)
-        reinjected_msg = (axis2_char_t *) axutil_property_get_value(temp_prop, 
-            env);
-    if(reinjected_msg && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, reinjected_msg))
-    {
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Reinjected_msg. So return here");
-        return AXIS2_SUCCESS; /* Reinjected Messages are not processed by 
-             sandesha2 inflow handlers */
+    {
+        reinjected_msg = (axis2_char_t *) axutil_property_get_value(temp_prop, env);
     }
+
+    if(reinjected_msg && !axutil_strcmp(AXIS2_VALUE_TRUE, reinjected_msg))
+    {
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Reinjected_msg. So return here");
+
+        return AXIS2_SUCCESS; /* Reinjected Messages are not processed by sandesha2 inflow handlers */
+    }
+
     conf = axis2_conf_ctx_get_conf(conf_ctx, env);
     svc = axis2_msg_ctx_get_svc(msg_ctx, env);
     if(!svc)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
-                "[sandesha2]Axis2 Service is NULL");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Axis2 Service is NULL");
+
         AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SVC_NULL, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
+
     rm_msg_ctx = sandesha2_msg_init_init_msg(env, msg_ctx);
     dbname = sandesha2_util_get_dbname(env, conf_ctx);
     storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
     seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
     sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
-    property = axis2_msg_ctx_get_property(msg_ctx, env, 
-        SANDESHA2_ISOLATED_LAST_MSG);
+    property = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_ISOLATED_LAST_MSG);
     if(property)
+    {
         value = axutil_property_get_value(property, env);
-    if(value && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, value))
+    }
+
+    if(value && !axutil_strcmp(AXIS2_VALUE_TRUE, value))
+    {
         isolated_last_msg = AXIS2_TRUE;
+    }
+
     if(!isolated_last_msg)
-        dropped = sandesha2_in_handler_drop_if_duplicate(handler, env, 
-            rm_msg_ctx, storage_mgr, seq_prop_mgr, sender_mgr);
+    {
+        dropped = sandesha2_in_handler_drop_if_duplicate(handler, env, rm_msg_ctx, storage_mgr, 
+                seq_prop_mgr, sender_mgr);
+    }
+
     if(dropped)
     {
-        sandesha2_in_handler_process_dropped_msg(handler, env, 
-            rm_msg_ctx, storage_mgr, seq_prop_mgr, sender_mgr);
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]msg_ctx dropped. So return here");
+        sandesha2_in_handler_process_dropped_msg(handler, env, conf_ctx, rm_msg_ctx, storage_mgr, 
+                seq_prop_mgr, sender_mgr);
+
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] msg_ctx dropped. So return here");
+
         if(rm_msg_ctx)
+        {
             sandesha2_msg_ctx_free(rm_msg_ctx, env);
+        }
+
         if(seq_prop_mgr)
+        {
             sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+        }
+
+        if(sender_mgr)
+        {
+            sandesha2_sender_mgr_free(sender_mgr, env);
+        }
+
         if(storage_mgr)
+        {
             sandesha2_storage_mgr_free(storage_mgr, env);
+        }
+
         return AXIS2_SUCCESS;
     }
+
     /* 
      * TODO Validate the message
      * sandesha2_msg_validator_validate(env, rm_msg_ctx);
      */
-    seq_ack = sandesha2_msg_ctx_get_seq_ack(rm_msg_ctx, env);
+    /*seq_ack = sandesha2_msg_ctx_get_seq_ack(rm_msg_ctx, env);
     if(seq_ack)
     {
         sandesha2_msg_processor_t *ack_proc = NULL;
         ack_proc = sandesha2_ack_msg_processor_create(env);
         sandesha2_msg_processor_process_in_msg(ack_proc, env, rm_msg_ctx);
         sandesha2_msg_processor_free(ack_proc, env);
-    }
+    }*/
+
     ack_requested = sandesha2_msg_ctx_get_ack_requested(rm_msg_ctx, env);
     if(ack_requested)
     {
@@ -205,21 +237,45 @@
             AXIS2_FALSE);
         sandesha2_msg_ctx_add_soap_envelope(rm_msg_ctx, env);
     }
-    msg_processor = sandesha2_msg_processor_create_msg_processor(env, 
-        rm_msg_ctx);
+
+    msg_processor = sandesha2_msg_processor_create_msg_processor(env, rm_msg_ctx);
     if(msg_processor)
     {
         sandesha2_msg_processor_process_in_msg(msg_processor, env, rm_msg_ctx);
         sandesha2_msg_processor_free(msg_processor, env);
     }
+
+    seq_ack = sandesha2_msg_ctx_get_seq_ack(rm_msg_ctx, env);
+    if(seq_ack)
+    {
+        sandesha2_msg_processor_t *ack_proc = NULL;
+        ack_proc = sandesha2_ack_msg_processor_create(env);
+        sandesha2_msg_processor_process_in_msg(ack_proc, env, rm_msg_ctx);
+        sandesha2_msg_processor_free(ack_proc, env);
+    }
+
     if(rm_msg_ctx)
+    {
         sandesha2_msg_ctx_free(rm_msg_ctx, env);
+    }
+
     if(seq_prop_mgr)
+    {
         sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
+    }
+
+    if(sender_mgr)
+    {
+        sandesha2_sender_mgr_free(sender_mgr, env);
+    }
+
     if(storage_mgr)
+    {
         sandesha2_storage_mgr_free(storage_mgr, env);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
-        "[sandesha2]Exit:sandesha2_in_handler_invoke");
+    }
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Exit:sandesha2_in_handler_invoke");
+
     return AXIS2_SUCCESS;
 }
 
@@ -234,54 +290,65 @@
 {
     axis2_bool_t drop = AXIS2_FALSE;
     
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
-        "[sandesha2]Entry:sandesha2_in_handler_drop_if_duplicate");
     AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FALSE);
     AXIS2_PARAM_CHECK(env->error, storage_mgr, AXIS2_FALSE);
     
-    if(SANDESHA2_MSG_TYPE_APPLICATION == sandesha2_msg_ctx_get_msg_type(
-        rm_msg_ctx, env))
+    if(SANDESHA2_MSG_TYPE_APPLICATION == sandesha2_msg_ctx_get_msg_type(rm_msg_ctx, env))
     {
         sandesha2_seq_t *sequence = NULL;
         long msg_no = -1;
-        axis2_char_t *seq_id = NULL;
+        axis2_char_t *rmd_sequence_id = NULL;
         
         sequence = sandesha2_msg_ctx_get_sequence(rm_msg_ctx, env);
         if(sequence)
         {
-            seq_id = sandesha2_identifier_get_identifier(
-                sandesha2_seq_get_identifier(sequence, env), env);
-            msg_no = sandesha2_msg_number_get_msg_num(sandesha2_seq_get_msg_num(
-                sequence, env), env);
+            rmd_sequence_id = sandesha2_identifier_get_identifier(sandesha2_seq_get_identifier(sequence, 
+                        env), env);
+
+            msg_no = sandesha2_msg_number_get_msg_num(sandesha2_seq_get_msg_num(sequence, env), env);
         }
-        if(seq_id && 0 < msg_no)
+        if(rmd_sequence_id && 0 < msg_no)
         {
             sandesha2_seq_property_bean_t *rcvd_msgs_bean = NULL;
             
             if(seq_prop_mgr)
-                rcvd_msgs_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr,
-                    env, seq_id, SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES);
+            {
+                rcvd_msgs_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, rmd_sequence_id, 
+                        SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES);
+            }
+
             if(rcvd_msgs_bean)
             {
                 axis2_char_t *rcvd_msgs_str = NULL;
                 axutil_array_list_t *msg_no_list = NULL;
                 int i = 0, size = 0;
                 
-                rcvd_msgs_str = sandesha2_seq_property_bean_get_value(
-                        rcvd_msgs_bean, env);
-                msg_no_list = sandesha2_utils_get_array_list_from_string(env,
-                        rcvd_msgs_str);
+                rcvd_msgs_str = sandesha2_seq_property_bean_get_value(rcvd_msgs_bean, env);
+
+                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "rcvd_msgs_str:%s", rcvd_msgs_str);
+
+                msg_no_list = sandesha2_utils_get_array_list_from_string(env, rcvd_msgs_str);
                 if(msg_no_list)
-                    size = axutil_array_list_size(msg_no_list, env);
-                for(i = 0; i < size; i++)
                 {
-                    axis2_char_t *temp = NULL;
-                    
-                    temp = axutil_array_list_get(msg_no_list, env, i);
-                    if(atol(temp) == msg_no)
-                        drop = AXIS2_TRUE;
+                    size = axutil_array_list_size(msg_no_list, env);
+                    for(i = 0; i < size; i++)
+                    {
+                        axis2_char_t *temp = NULL;
+                        
+                        temp = axutil_array_list_get(msg_no_list, env, i);
+                        if(axutil_atol(temp) == msg_no)
+                        {
+                            drop = AXIS2_TRUE;
+                        }
+
+                        AXIS2_FREE(env->allocator, temp);
+                    }
+
+                    axutil_array_list_free(msg_no_list, env);
                 }
+
             }
+
             if(!drop)
             {
                 axiom_soap_body_t *soap_body = NULL;
@@ -290,15 +357,16 @@
                 axiom_children_iterator_t *children_iterator = NULL;
                 axis2_bool_t empty_body = AXIS2_FALSE;
             
-                soap_body = axiom_soap_envelope_get_body(
-                    sandesha2_msg_ctx_get_soap_envelope(rm_msg_ctx, env), 
-                    env);
+                soap_body = axiom_soap_envelope_get_body(sandesha2_msg_ctx_get_soap_envelope(
+                        rm_msg_ctx, env), env);
                 body_node = axiom_soap_body_get_base_node(soap_body, env);
                 body_element = axiom_node_get_data_element(body_node, env);
-                children_iterator = axiom_element_get_children(body_element, env, 
-                    body_node);
+                children_iterator = axiom_element_get_children(body_element, env, body_node);
                 if(!axiom_children_iterator_has_next(children_iterator, env))
+                {
                     empty_body = AXIS2_TRUE;
+                }
+
                 if(empty_body)
                 {
                     axis2_char_t *rcvd_msgs_str1 = NULL;
@@ -307,36 +375,40 @@
                     sandesha2_msg_processor_t *app_msg_processor = NULL;
                     
                     AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-                        "[sandesha2]Empty body last msg recieved");
+                            "[sandesha2] Empty body last msg recieved");
+
                     drop = AXIS2_TRUE;
                     if(!rcvd_msgs_bean)
                     {
-                        rcvd_msgs_bean = sandesha2_seq_property_bean_create_with_data
-                            (env, seq_id, 
-                            SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES, "");
-                        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env,
-                            rcvd_msgs_bean);
+                        rcvd_msgs_bean = sandesha2_seq_property_bean_create_with_data(env, 
+                                rmd_sequence_id, SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES, "");
+                        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, rcvd_msgs_bean);
                     }
-                    rcvd_msgs_str1 = sandesha2_seq_property_bean_get_value(
-                            rcvd_msgs_bean, env);
+
+                    rcvd_msgs_str1 = sandesha2_seq_property_bean_get_value(rcvd_msgs_bean, env);
                     sprintf(msg_no_str, "%ld", msg_no);
                     if(rcvd_msgs_str1 && 0 < axutil_strlen(rcvd_msgs_str1))
-                        bean_value = axutil_strcat(env, rcvd_msgs_str1, ",",
-                            msg_no_str, NULL);
+                    {
+                        bean_value = axutil_strcat(env, rcvd_msgs_str1, ",", msg_no_str, NULL);
+                    }
                     else
+                    {
                         bean_value = axutil_strdup(env, msg_no_str);
+                    }
                     
-                    sandesha2_seq_property_bean_set_value(rcvd_msgs_bean, env,
-                        bean_value);
-                    sandesha2_seq_property_mgr_update(seq_prop_mgr, env, 
-                        rcvd_msgs_bean);
+                    sandesha2_seq_property_bean_set_value(rcvd_msgs_bean, env, bean_value);
+                    sandesha2_seq_property_mgr_update(seq_prop_mgr, env, rcvd_msgs_bean);
                     app_msg_processor = sandesha2_app_msg_processor_create(env);
-                    sandesha2_app_msg_processor_send_ack_if_reqd(env, 
-                        rm_msg_ctx, bean_value, storage_mgr, sender_mgr, 
-                        seq_prop_mgr);
+                    sandesha2_app_msg_processor_send_ack_if_reqd(env, rm_msg_ctx, bean_value, 
+                            rmd_sequence_id, storage_mgr, sender_mgr, seq_prop_mgr);
                     sandesha2_msg_processor_free(app_msg_processor, env);
                 }
             }
+
+            if(rcvd_msgs_bean)
+            {
+                sandesha2_seq_property_bean_free(rcvd_msgs_bean, env);
+            }
         }        
     } 
     else if(SANDESHA2_MSG_TYPE_UNKNOWN == sandesha2_msg_ctx_get_msg_type(
@@ -359,8 +431,7 @@
                         rm_msg_ctx, env), env);
             if(!op_ctx && !op_ctx1)
             {
-                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Dropping"
-                        " duplicate RM message");
+                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Dropping duplicate RM message");
                 drop = AXIS2_TRUE;
             }
         }
@@ -370,54 +441,115 @@
         sandesha2_msg_ctx_set_paused(rm_msg_ctx, env, AXIS2_TRUE);
         return AXIS2_TRUE;
     }
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
-        "[sandesha2]Exit:sandesha2_in_handler_drop_if_duplicate");
+
     return AXIS2_FALSE;
 }
 
-
+/* In this function appropriately respond for the dropeed message. In two way messaging if the
+ * response for the dropped application message is not acknowledged then take the the response
+ * message from the database and append acknowledgment for the dropped message to it.
+ * Otherwise send the acknowledgment for the dropped message.
+ */
 static axis2_status_t AXIS2_CALL
 sandesha2_in_handler_process_dropped_msg(
     struct axis2_handler *handler, 
     const axutil_env_t *env,
+    axis2_conf_ctx_t *conf_ctx,
     sandesha2_msg_ctx_t *rm_msg_ctx,
     sandesha2_storage_mgr_t *storage_mgr,
     sandesha2_seq_property_mgr_t *seq_prop_mgr,
     sandesha2_sender_mgr_t *sender_mgr)
 {
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
+        "[sandesha2] Entry:sandesha2_in_handler_process_dropped_msg");
+
     AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FALSE);
     AXIS2_PARAM_CHECK(env->error, storage_mgr, AXIS2_FALSE);
     
-    if(SANDESHA2_MSG_TYPE_APPLICATION == sandesha2_msg_ctx_get_msg_type(
-        rm_msg_ctx, env))
+    if(SANDESHA2_MSG_TYPE_APPLICATION == sandesha2_msg_ctx_get_msg_type(rm_msg_ctx, env))
     {
         sandesha2_seq_t *sequence = NULL;
-        axis2_char_t *seq_id = NULL;
+        axis2_char_t *rmd_sequence_id = NULL;
         
         sequence = sandesha2_msg_ctx_get_sequence(rm_msg_ctx, env);
         if(sequence)
-            seq_id = sandesha2_identifier_get_identifier(
-                sandesha2_seq_get_identifier(sequence, env), env);
+        {
+            rmd_sequence_id = sandesha2_identifier_get_identifier(sandesha2_seq_get_identifier(sequence, 
+                        env), env);
+        }
             
-        if(seq_id)
+        if(rmd_sequence_id)
         {
             sandesha2_seq_property_bean_t *rcvd_msgs_bean = NULL;
             axis2_char_t *rcvd_msgs_str = NULL;
             sandesha2_msg_processor_t *app_msg_processor = NULL;
             
-            rcvd_msgs_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr,
-                env, seq_id, SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES);
+            rcvd_msgs_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, rmd_sequence_id, 
+                    SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES);
+
             if(rcvd_msgs_bean)
             {
-                rcvd_msgs_str = sandesha2_seq_property_bean_get_value(
-                    rcvd_msgs_bean, env);
-                app_msg_processor = sandesha2_app_msg_processor_create(env);
-                sandesha2_app_msg_processor_send_ack_if_reqd(env, rm_msg_ctx, 
-                    rcvd_msgs_str, storage_mgr, sender_mgr, seq_prop_mgr);
-                sandesha2_msg_processor_free(app_msg_processor, env);
+                sandesha2_sender_bean_t *sender_bean = NULL;
+                axis2_char_t *internal_sequence_id = NULL;
+                long msg_no = -1;
+                sandesha2_sender_bean_t *find_sender_bean = NULL;
+
+                rcvd_msgs_str = sandesha2_seq_property_bean_get_value(rcvd_msgs_bean, env);
+                
+                msg_no = sandesha2_msg_number_get_msg_num(sandesha2_seq_get_msg_num(sequence, env), env);
+                internal_sequence_id = sandesha2_utils_get_internal_sequence_id(env, rmd_sequence_id);
+                find_sender_bean = sandesha2_sender_bean_create(env);
+                sandesha2_sender_bean_set_msg_no(find_sender_bean, env, msg_no);
+                sandesha2_sender_bean_set_internal_seq_id(find_sender_bean, env, internal_sequence_id);
+                sandesha2_sender_bean_set_send(find_sender_bean, env, AXIS2_TRUE);
+
+                sender_bean = sandesha2_sender_mgr_find_unique(sender_mgr, env, find_sender_bean);
+                if(sender_bean)
+                {
+                    axis2_char_t *storage_key = NULL;
+                    axis2_msg_ctx_t *app_msg_ctx = NULL;
+                    sandesha2_msg_ctx_t *app_rm_msg_ctx = NULL;
+                    axis2_engine_t *engine = NULL;
+                    axis2_op_ctx_t *op_ctx = NULL;
+                    axis2_msg_ctx_t *in_msg_ctx = NULL;
+
+                    storage_key = sandesha2_sender_bean_get_msg_ctx_ref_key(sender_bean, env);
+                    app_msg_ctx = sandesha2_storage_mgr_retrieve_msg_ctx(storage_mgr, env, storage_key, 
+                            conf_ctx, AXIS2_TRUE);
+
+                    in_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
+
+                    axis2_msg_ctx_set_transport_out_stream(app_msg_ctx, env, 
+                            axis2_msg_ctx_get_transport_out_stream(in_msg_ctx, env));
+
+                    axis2_msg_ctx_set_out_transport_info(app_msg_ctx, env, 
+                            axis2_msg_ctx_get_out_transport_info(in_msg_ctx, env));
+
+                    op_ctx = axis2_msg_ctx_get_op_ctx(in_msg_ctx, env);
+
+                    axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE);
+
+                    app_rm_msg_ctx = sandesha2_msg_init_init_msg(env, app_msg_ctx);
+                    sandesha2_msg_creator_add_ack_msg(env, app_rm_msg_ctx, rmd_sequence_id, seq_prop_mgr);
+                    engine = axis2_engine_create(env, conf_ctx);
+                    axis2_engine_send(engine, env, app_msg_ctx);
+                    sandesha2_msg_ctx_free(app_rm_msg_ctx, env);
+                }
+                else
+                {
+                    app_msg_processor = sandesha2_app_msg_processor_create(env);
+                    sandesha2_app_msg_processor_send_ack_if_reqd(env, rm_msg_ctx, rcvd_msgs_str, 
+                        rmd_sequence_id, storage_mgr, sender_mgr, seq_prop_mgr);
+                    
+                    sandesha2_msg_processor_free(app_msg_processor, env);
+                }
             }
         }
     }
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
+        "[sandesha2] Exit:sandesha2_in_handler_process_dropped_msg");
+
     return AXIS2_SUCCESS;
 }
 

Modified: webservices/sandesha/trunk/c/src/handlers/sandesha2_out_handler.c
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/handlers/sandesha2_out_handler.c?rev=690127&r1=690126&r2=690127&view=diff
==============================================================================
--- webservices/sandesha/trunk/c/src/handlers/sandesha2_out_handler.c (original)
+++ webservices/sandesha/trunk/c/src/handlers/sandesha2_out_handler.c Thu Aug 28 23:56:29 2008
@@ -39,8 +39,6 @@
     const axutil_env_t *env,
     struct axis2_msg_ctx *msg_ctx);
                                          
-/******************************************************************************/                         
-
 AXIS2_EXTERN axis2_handler_t* AXIS2_CALL
 sandesha2_out_handler_create(
     const axutil_env_t *env, 
@@ -82,22 +80,29 @@
     int msg_type = -1;
 
     AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
-        "[sandesha2]Entry:sandesha2_out_handler_invoke");
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_out_handler_invoke");
+            
+    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_SEQ_PROP_MAKE_CONNECTION_OUT_PATH);
+    if (temp_prop)
+    {
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+            "[sandesha2] In make connection out path. So return here.");
+        return AXIS2_SUCCESS;
+        temp_prop = NULL;
+    }
+
     conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
     if(!conf_ctx)
     {
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Configuration Context is NULL");
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, 
-            AXIS2_FAILURE);
+            "[sandesha2] Configuration Context is NULL");
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
     svc = axis2_msg_ctx_get_svc(msg_ctx, env);
     if(!svc)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Axis2 Service is NULL");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Axis2 Service is NULL");
         AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SVC_NULL, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
@@ -105,40 +110,52 @@
     if(!axis2_svc_is_module_engaged(svc, env, module_qname))
     {
         if(module_qname)
+        {
             axutil_qname_free(module_qname, env);
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]RM is not engaged. So return here");
+        }
+
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]RM is not engaged. So return here");
         return AXIS2_SUCCESS;
     }
+
     if(module_qname)
+    {
         axutil_qname_free(module_qname, env);
-    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, 
-            SANDESHA2_APPLICATION_PROCESSING_DONE);
+    }
+    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE);
     if(temp_prop)
+    {
         str_done = (axis2_char_t *) axutil_property_get_value(temp_prop, env); 
+    }
+
     if(str_done && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, str_done))
     {
         AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
             "[sandesha2]Application Processing Done. So return here.");
         return AXIS2_SUCCESS; 
     }
+
     temp_prop = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
-    axis2_msg_ctx_set_property(msg_ctx, env, 
-        SANDESHA2_APPLICATION_PROCESSING_DONE, temp_prop);
+    axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, temp_prop);
     conf = axis2_conf_ctx_get_conf(conf_ctx, env);
     if(!sandesha2_permanent_storage_mgr_create_db(env, conf_ctx))
     {
         return AXIS2_FAILURE;
     }
+
     /* Getting rm message */ 
     rm_msg_ctx = sandesha2_msg_init_init_msg(env, msg_ctx);
     temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_CLIENT_DUMMY_MESSAGE);
     if(NULL != temp_prop)
+    {
         dummy_msg_str = (axis2_char_t *) axutil_property_get_value(temp_prop, env); 
+    }
+
     if(dummy_msg_str && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, dummy_msg_str))
     {
         dummy_msg = AXIS2_TRUE;
     }
+
     msg_type = sandesha2_msg_ctx_get_msg_type(rm_msg_ctx, env);
     if(msg_type == SANDESHA2_MSG_TYPE_UNKNOWN)
     {
@@ -146,8 +163,7 @@
         axis2_op_ctx_t *op_ctx = NULL;
 
         op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
-        req_msg_ctx =  axis2_op_ctx_get_msg_ctx(op_ctx, env, 
-            AXIS2_WSDL_MESSAGE_LABEL_IN);
+        req_msg_ctx =  axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
         if(req_msg_ctx) /* For the server side */
         {
             sandesha2_msg_ctx_t *req_rm_msg_ctx = NULL;
@@ -165,14 +181,12 @@
         }
         else if(!axis2_msg_ctx_get_server_side(msg_ctx, env))
         {
-            msg_processor = (sandesha2_msg_processor_t *) 
-            sandesha2_app_msg_processor_create(env);
+            msg_processor = (sandesha2_msg_processor_t *) sandesha2_app_msg_processor_create(env);
         }
     }
     else
     {
-        msg_processor = sandesha2_msg_processor_create_msg_processor(env, 
-            rm_msg_ctx);
+        msg_processor = sandesha2_msg_processor_create_msg_processor(env, rm_msg_ctx);
     }
     if(msg_processor)
     {
@@ -182,24 +196,30 @@
     if(AXIS2_SUCCESS != AXIS2_ERROR_GET_STATUS_CODE(env->error))
     {
         /* Message should not be sent in an exception situation */
+
         axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE);
         if(rm_msg_ctx)
+        {
             sandesha2_msg_ctx_free(rm_msg_ctx, env);
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
-            "[sandesha2]Error in processing the message");
-        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_PROCESS_MSG, 
-                AXIS2_FAILURE);
+        }
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Error in processing the message");
+        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_PROCESS_MSG, AXIS2_FAILURE);
         return AXIS2_FAILURE;
     }
     
-    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, 
-            SANDESHA2_APPLICATION_PROCESSING_DONE);
+    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE);
     if(temp_prop)
+    {
         axutil_property_set_value(temp_prop, env, AXIS2_VALUE_FALSE);
+    }
+
     if(rm_msg_ctx)
+    {
         sandesha2_msg_ctx_free(rm_msg_ctx, env);
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
-        "[sandesha2]Exit:sandesha2_out_handler_invoke");
+    }
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_out_handler_invoke");
+
     return AXIS2_SUCCESS;
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org


Mime
View raw message