From qcarrillo@example.net Tue Jan 02 07:58:47 2007 Return-Path: <qcarrillo@example.net> Delivered-To: qcarrillo@example.net Received: (qmail 14397 invoked from network); 2 Jan 2007 07:58:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 07:58:43 -0000 Received: (qmail 91795 invoked by uid 500); 2 Jan 2007 07:58:49 -0000 Delivered-To: qcarrillo@example.net Received: (qmail 91571 invoked by uid 500); 2 Jan 2007 07:58:47 -0000 Mailing-List: contact qcarrillo@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:qcarrillo@example.net> List-Unsubscribe: <mailto:qcarrillo@example.net> List-Post: <mailto:qcarrillo@example.net> List-Id: <sandesha-dev.ws.apache.org> Delivered-To: mailing list qcarrillo@example.net Received: (qmail 91557 invoked by uid 500); 2 Jan 2007 07:58:47 -0000 Delivered-To: qcarrillo@example.net Received: (qmail 90842 invoked by uid 99); 2 Jan 2007 07:58:45 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 23:58:44 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 23:58:34 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id B6AF71A9820; Mon, 1 Jan 2007 23:57:37 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r491758 [3/4] - in /webservices/sandesha/trunk/c: include/ samples/rm_1_1_echo/ samples/rm_echo/ samples/rm_mtom/ samples/rm_ping/ src/client/ src/core/ src/handlers/ src/msgprocessors/ src/storage/beans/ src/storage/inmemory/ src/storage/p... Date: Tue, 02 Jan 2007 07:57:35 -0000 To: qcarrillo@example.net From: qcarrillo@example.net X-Mailer: svnmailer-1.1.0 Message-Id: <qcarrillo@example.net> X-Virus-Checked: Checked by ClamAV on apache.org Modified: webservices/sandesha/trunk/c/src/storage/permanent/permanent_sender_mgr.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/permanent/permanent_sender_mgr.c?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/storage/permanent/permanent_sender_mgr.c (original) +++ webservices/sandesha/trunk/c/src/storage/permanent/permanent_sender_mgr.c Mon Jan 1 23:57:33 2007 @@ -48,51 +48,55 @@ char **argv, char **col_name) { - int i; + int i = 0; + sandesha2_sender_bean_t *bean = NULL; sandesha2_bean_mgr_args_t *args = (sandesha2_bean_mgr_args_t *) not_used; - axis2_array_list_t *data_list = (axis2_array_list_t *) args->data; const axis2_env_t *env = args->env; + axis2_array_list_t *data_list = (axis2_array_list_t *) args->data; + if(argc < 1) + { + args->data = NULL; + return 0; + } + if(!data_list) + { + data_list = axis2_array_list_create(env, 0); + args->data = data_list; + } + bean = sandesha2_sender_bean_create(env); for(i = 0; i < argc; i++) { - sandesha2_sender_bean_t *bean = NULL; if(0 == AXIS2_STRCMP(col_name[i], "msg_id")) - sandesha2_sender_bean_set_msg_id(bean, env, - argv[i] ? argv[i] : "NULL"); + sandesha2_sender_bean_set_msg_id(bean, env, argv[i]); if(0 == AXIS2_STRCMP(col_name[i], "msg_ctx_ref_key")) - sandesha2_sender_bean_set_msg_ctx_ref_key(bean, env, - argv[i] ? argv[i] : "NULL"); + if(argv[i]) + sandesha2_sender_bean_set_msg_ctx_ref_key(bean, env, argv[i]); if(0 == AXIS2_STRCMP(col_name[i], "internal_seq_ID")) - sandesha2_sender_bean_set_internal_seq_id(bean, env, - argv[i] ? argv[i] : "NULL"); + if(argv[i]) + sandesha2_sender_bean_set_internal_seq_id(bean, env, argv[i]); if(0 == AXIS2_STRCMP(col_name[i], "sent_count")) - sandesha2_sender_bean_set_sent_count(bean, env, - argv[i] ? AXIS2_ATOI(argv[i]) : 0); + sandesha2_sender_bean_set_sent_count(bean, env, AXIS2_ATOI(argv[i])); if(0 == AXIS2_STRCMP(col_name[i], "msg_no")) - sandesha2_sender_bean_set_msg_no(bean, env, - argv[i] ? atol(argv[i]) : 0); + sandesha2_sender_bean_set_msg_no(bean, env, atol(argv[i])); if(0 == AXIS2_STRCMP(col_name[i], "send")) - sandesha2_sender_bean_set_send(bean, env, - argv[i] ? AXIS2_ATOI(argv[i]) : 0); + sandesha2_sender_bean_set_send(bean, env, AXIS2_ATOI(argv[i])); if(0 == AXIS2_STRCMP(col_name[i], "resend")) - sandesha2_sender_bean_set_resend(bean, env, - argv[i] ? AXIS2_ATOI(argv[i]) : 0); + sandesha2_sender_bean_set_resend(bean, env, AXIS2_ATOI(argv[i])); if(0 == AXIS2_STRCMP(col_name[i], "time_to_send")) - sandesha2_sender_bean_set_time_to_send(bean, env, - argv[i] ? atol(argv[i]) : 0); + sandesha2_sender_bean_set_time_to_send(bean, env, atol(argv[i])); if(0 == AXIS2_STRCMP(col_name[i], "msg_type")) - sandesha2_sender_bean_set_msg_type(bean, env, - argv[i] ? AXIS2_ATOI(argv[i]) : 0); + sandesha2_sender_bean_set_msg_type(bean, env, AXIS2_ATOI(argv[i])); if(0 == AXIS2_STRCMP(col_name[i], "seq_id")) - sandesha2_sender_bean_set_seq_id(bean, env, - argv[i] ? argv[i] : "NULL"); + if(argv[i]) + sandesha2_sender_bean_set_seq_id(bean, env, argv[i]); if(0 == AXIS2_STRCMP(col_name[i], "wsrm_anon_uri")) - sandesha2_sender_bean_set_wsrm_anon_uri(bean, env, - argv[i] ? argv[i] : "NULL"); + if(argv[i]) + sandesha2_sender_bean_set_wsrm_anon_uri(bean, env, argv[i]); if(0 == AXIS2_STRCMP(col_name[i], "to_address")) - sandesha2_sender_bean_set_to_address(bean, env, - argv[i] ? argv[i] : "NULL"); - axis2_array_list_add(data_list, env, bean); + if(argv[i]) + sandesha2_sender_bean_set_to_address(bean, env, argv[i]); } + axis2_array_list_add(data_list, env, bean); return 0; } @@ -103,33 +107,52 @@ char **argv, char **col_name) { + int i = 0; sandesha2_bean_mgr_args_t *args = (sandesha2_bean_mgr_args_t *) not_used; const axis2_env_t *env = args->env; sandesha2_sender_bean_t *bean = (sandesha2_sender_bean_t *) args->data; - sandesha2_sender_bean_set_msg_id(bean, env, - argv[0] ? argv[0] : "NULL"); - sandesha2_sender_bean_set_msg_ctx_ref_key(bean, env, - argv[0] ? argv[0] : "NULL"); - sandesha2_sender_bean_set_internal_seq_id(bean, env, - argv[0] ? argv[0] : "NULL"); - sandesha2_sender_bean_set_sent_count(bean, env, - argv[0] ? AXIS2_ATOI(argv[0]) : 0); - sandesha2_sender_bean_set_msg_no(bean, env, - argv[0] ? atol(argv[0]) : 0); - sandesha2_sender_bean_set_send(bean, env, - argv[0] ? AXIS2_ATOI(argv[0]) : 0); - sandesha2_sender_bean_set_resend(bean, env, - argv[0] ? AXIS2_ATOI(argv[0]) : 0); - sandesha2_sender_bean_set_time_to_send(bean, env, - argv[0] ? atol(argv[0]) : 0); - sandesha2_sender_bean_set_msg_type(bean, env, - argv[0] ? AXIS2_ATOI(argv[0]) : 0); - sandesha2_sender_bean_set_seq_id(bean, env, - argv[0] ? argv[0] : "NULL"); - sandesha2_sender_bean_set_wsrm_anon_uri(bean, env, - argv[0] ? argv[0] : "NULL"); - sandesha2_sender_bean_set_to_address(bean, env, - argv[0] ? argv[0] : "NULL"); + if(argc < 1) + { + args->data = NULL; + return 0; + } + if(!bean) + { + bean = sandesha2_sender_bean_create(env); + args->data = bean; + } + for(i = 0; i < argc; i++) + { + if(0 == AXIS2_STRCMP(col_name[i], "msg_id")) + sandesha2_sender_bean_set_msg_id(bean, env, argv[i]); + if(0 == AXIS2_STRCMP(col_name[i], "msg_ctx_ref_key")) + if(argv[i]) + sandesha2_sender_bean_set_msg_ctx_ref_key(bean, env, argv[i]); + if(0 == AXIS2_STRCMP(col_name[i], "internal_seq_ID")) + if(argv[i]) + sandesha2_sender_bean_set_internal_seq_id(bean, env, argv[i]); + if(0 == AXIS2_STRCMP(col_name[i], "sent_count")) + sandesha2_sender_bean_set_sent_count(bean, env, AXIS2_ATOI(argv[i])); + if(0 == AXIS2_STRCMP(col_name[i], "msg_no")) + sandesha2_sender_bean_set_msg_no(bean, env, atol(argv[i])); + if(0 == AXIS2_STRCMP(col_name[i], "send")) + sandesha2_sender_bean_set_send(bean, env, AXIS2_ATOI(argv[i])); + if(0 == AXIS2_STRCMP(col_name[i], "resend")) + sandesha2_sender_bean_set_resend(bean, env, AXIS2_ATOI(argv[i])); + if(0 == AXIS2_STRCMP(col_name[i], "time_to_send")) + sandesha2_sender_bean_set_time_to_send(bean, env, atol(argv[i])); + if(0 == AXIS2_STRCMP(col_name[i], "msg_type")) + sandesha2_sender_bean_set_msg_type(bean, env, AXIS2_ATOI(argv[i])); + if(0 == AXIS2_STRCMP(col_name[i], "seq_id")) + if(argv[i]) + sandesha2_sender_bean_set_seq_id(bean, env, argv[i]); + if(0 == AXIS2_STRCMP(col_name[i], "wsrm_anon_uri")) + if(argv[i]) + sandesha2_sender_bean_set_wsrm_anon_uri(bean, env, argv[i]); + if(0 == AXIS2_STRCMP(col_name[i], "to_address")) + if(argv[i]) + sandesha2_sender_bean_set_to_address(bean, env, argv[i]); + } return 0; } @@ -263,50 +286,79 @@ const axis2_env_t *env, sandesha2_sender_bean_t *bean) { - axis2_char_t *insert_sql = NULL; - axis2_char_t *msg_id = NULL; - axis2_char_t *msg_ctx_ref_key = NULL; - axis2_char_t *internal_seq_id = NULL; - int sent_count = -1; - long msg_no = -1; - axis2_bool_t send = AXIS2_FALSE; - axis2_bool_t resend = AXIS2_FALSE; - long time_to_send = -1; - int msg_type = -1; - axis2_char_t *seq_id = NULL; - axis2_char_t *wsrm_anon_uri = NULL; - axis2_char_t *to_address = NULL; + axis2_char_t *sql_insert = NULL; + axis2_char_t *sql_retrieve = NULL; + axis2_char_t *sql_update = NULL; axis2_bool_t ret = AXIS2_FALSE; sandesha2_permanent_sender_mgr_t *sender_mgr_impl = NULL; + axis2_char_t *msg_id = sandesha2_sender_bean_get_msg_id((sandesha2_rm_bean_t *) bean, + env); + axis2_char_t str_msg_id[msg_id?AXIS2_STRLEN(msg_id):8]; + axis2_char_t *msg_ctx_ref_key = sandesha2_sender_bean_get_msg_ctx_ref_key(bean, env); + axis2_char_t str_msg_ctx_ref_key[msg_ctx_ref_key?AXIS2_STRLEN(msg_ctx_ref_key):8]; + axis2_char_t *internal_seq_id = sandesha2_sender_bean_get_internal_seq_id(bean, env); + axis2_char_t str_internal_seq_id[internal_seq_id?AXIS2_STRLEN(internal_seq_id):8]; + int sent_count = sandesha2_sender_bean_get_sent_count(bean, env); + axis2_char_t str_sent_count[32]; + long msg_no = sandesha2_sender_bean_get_msg_no(bean, env); + axis2_char_t str_msg_no[32]; + axis2_bool_t send = sandesha2_sender_bean_is_send(bean, env); + axis2_char_t str_send[32]; + axis2_bool_t resend = sandesha2_sender_bean_is_resend(bean, env); + axis2_char_t str_resend[32]; + long time_to_send = sandesha2_sender_bean_get_time_to_send(bean, env); + axis2_char_t str_time_to_send[32]; + int msg_type = sandesha2_sender_bean_get_msg_type(bean, env); + axis2_char_t str_msg_type[32]; + axis2_char_t *seq_id = sandesha2_sender_bean_get_seq_id(bean, env); + axis2_char_t str_seq_id[seq_id?AXIS2_STRLEN(seq_id):8]; + axis2_char_t *wsrm_anon_uri = sandesha2_sender_bean_get_wsrm_anon_uri(bean, env); + axis2_char_t str_wsrm_anon_uri[wsrm_anon_uri?AXIS2_STRLEN(wsrm_anon_uri):8]; + axis2_char_t *to_address = sandesha2_sender_bean_get_to_address(bean, env); + axis2_char_t str_to_address[to_address?AXIS2_STRLEN(to_address):8]; + + sprintf(str_msg_id, "'%s'", msg_id); + sprintf(str_msg_ctx_ref_key, msg_ctx_ref_key?"'%s'":"NULL", msg_ctx_ref_key); + sprintf(str_internal_seq_id, internal_seq_id?"'%s'":"NULL", internal_seq_id); + sprintf(str_sent_count, "%d", sent_count); + sprintf(str_msg_no, "%ld", msg_no); + sprintf(str_send, "%d", send); + sprintf(str_resend, "%d", resend); + sprintf(str_time_to_send, "%ld", time_to_send); + sprintf(str_msg_type, "%d", msg_type); + sprintf(str_seq_id, seq_id?"'%s'":"NULL", seq_id); + sprintf(str_wsrm_anon_uri, wsrm_anon_uri?"'%s'":"NULL", wsrm_anon_uri); + sprintf(str_to_address, to_address?"'%s'":"NULL", to_address); + AXIS2_LOG_INFO(env->log, "[sandesha2]Entry:sandesha2_permanent_sender_mgr_insert"); AXIS2_ENV_CHECK(env, AXIS2_FALSE); AXIS2_PARAM_CHECK(env->error, bean, AXIS2_FALSE); sender_mgr_impl = SANDESHA2_INTF_TO_IMPL(sender_mgr); - msg_id = sandesha2_sender_bean_get_msg_id((sandesha2_rm_bean_t *) bean, - env); - msg_ctx_ref_key = sandesha2_sender_bean_get_msg_ctx_ref_key(bean, env); - internal_seq_id = sandesha2_sender_bean_get_internal_seq_id(bean, env); - sent_count = sandesha2_sender_bean_get_sent_count(bean, env); - msg_no = sandesha2_sender_bean_get_msg_no(bean, env); - send = sandesha2_sender_bean_is_send(bean, env); - resend = sandesha2_sender_bean_is_resend(bean, env); - time_to_send = sandesha2_sender_bean_get_time_to_send(bean, env); - msg_type = sandesha2_sender_bean_get_msg_type(bean, env); - seq_id = sandesha2_sender_bean_get_seq_id(bean, env); - wsrm_anon_uri = sandesha2_sender_bean_get_wsrm_anon_uri(bean, env); - to_address = sandesha2_sender_bean_get_to_address(bean, env); - insert_sql = axis2_strcat(env, "insert into sender(msg_id, msg_ctx_ref_key, "\ + sql_retrieve = axis2_strcat(env, "select msg_id, msg_ctx_ref_key, "\ + "internal_seq_id, sent_count, msg_no, send, resend, time_to_send, "\ + "msg_type, seq_id, wsrm_anon_uri, to_address from sender "\ + "where msg_id=", str_msg_id, ";", NULL); + sql_update = axis2_strcat(env, "update sender set msg_ctx_ref_key=", + str_msg_ctx_ref_key,",internal_seq_id=",str_internal_seq_id, + ", sent_count=", str_sent_count, ", msg_no=", str_msg_no, + ", send=", str_send, ", resend=", str_resend, ", time_to_send=", + str_time_to_send, ", msg_type=", str_msg_type, ", seq_id=", + str_seq_id, ", wsrm_anon_uri=", str_wsrm_anon_uri, + ", to_address=", str_to_address, + "' where msg_id=", str_msg_id, ";", NULL); + sql_insert = axis2_strcat(env, "insert into sender(msg_id, msg_ctx_ref_key,"\ "internal_seq_id, sent_count, msg_no, send, resend, time_to_send,"\ - "msg_type, seq_id, wsrm_anon_uri, to_address) values('", msg_id, "','", - msg_ctx_ref_key, "','", internal_seq_id, "','", sent_count, "','", - msg_no, "','", send, "','", resend, "','", time_to_send, "','", - msg_type, "','", seq_id, "','", wsrm_anon_uri, "','", to_address, "');", - NULL); + "msg_type, seq_id, wsrm_anon_uri, to_address) values(", str_msg_id, ",", + str_msg_ctx_ref_key, ",", str_internal_seq_id, ",", str_sent_count, ",", + str_msg_no, ",", str_send, ",", str_resend, ",", str_time_to_send, + ",", str_msg_type, ",", str_seq_id, ",", str_wsrm_anon_uri, ",", + str_to_address, ");", NULL); ret = sandesha2_permanent_bean_mgr_insert(sender_mgr_impl->bean_mgr, env, - insert_sql); + (sandesha2_rm_bean_t *) bean, sandesha2_sender_retrieve_callback, + sql_retrieve, sql_update, sql_insert); AXIS2_LOG_INFO(env->log, "[sandesha2]Exit:sandesha2_permanent_sender_mgr_insert:return:%d", ret); return ret; @@ -320,21 +372,18 @@ { axis2_char_t *sql_retrieve = NULL; axis2_char_t *sql_remove = NULL; - sandesha2_sender_bean_t *bean = NULL; sandesha2_permanent_sender_mgr_t *sender_mgr_impl = NULL; AXIS2_ENV_CHECK(env, AXIS2_FALSE); AXIS2_PARAM_CHECK(env->error, msg_id, AXIS2_FALSE); sender_mgr_impl = SANDESHA2_INTF_TO_IMPL(sender_mgr); sql_remove = axis2_strcat(env, "delete from sender where msg_id='", msg_id, "';", NULL); - sql_retrieve = axis2_strcat(env, "select msg_ctx_ref_key, internal_seq_id, "\ - "sent_count, msg_no, send, resend, time_to_send, msg_type, seq_id, "\ - "wsrm_anon_uri, to_address from sender "\ + sql_retrieve = axis2_strcat(env, "select msg_id, msg_ctx_ref_key, "\ + "internal_seq_id, sent_count, msg_no, send, resend, time_to_send, "\ + "msg_type, seq_id, wsrm_anon_uri, to_address from sender "\ "where msg_id='", msg_id, "';", NULL); - bean = sandesha2_sender_bean_create(env); return sandesha2_permanent_bean_mgr_remove(sender_mgr_impl->bean_mgr, env, - (sandesha2_rm_bean_t *) bean, sandesha2_sender_retrieve_callback, - sql_retrieve, sql_remove); + sandesha2_sender_retrieve_callback, sql_retrieve, sql_remove); } sandesha2_sender_bean_t *AXIS2_CALL @@ -344,7 +393,6 @@ axis2_char_t *msg_id) { axis2_char_t *sql_retrieve = NULL; - sandesha2_sender_bean_t *bean = NULL; sandesha2_sender_bean_t *ret = NULL; sandesha2_permanent_sender_mgr_t *sender_mgr_impl = NULL; sender_mgr_impl = SANDESHA2_INTF_TO_IMPL(sender_mgr); @@ -353,14 +401,13 @@ "[sandesha2]Entry:sandesha2_permanent_sender_mgr_retrieve"); AXIS2_ENV_CHECK(env, AXIS2_FALSE); AXIS2_PARAM_CHECK(env->error, msg_id, AXIS2_FALSE); - sql_retrieve = axis2_strcat(env, "select msg_ctx_ref_key, internal_seq_id, "\ - "sent_count, msg_no, send, resend, time_to_send, msg_type, seq_id, "\ - "wsrm_anon_uri, to_address from sender "\ + sql_retrieve = axis2_strcat(env, "select msg_id, msg_ctx_ref_key, "\ + "internal_seq_id, sent_count, msg_no, send, resend, time_to_send, "\ + "msg_type, seq_id, wsrm_anon_uri, to_address from sender "\ "where msg_id='", msg_id, "';", NULL); - bean = sandesha2_sender_bean_create(env); ret = (sandesha2_sender_bean_t *) sandesha2_permanent_bean_mgr_retrieve( - sender_mgr_impl->bean_mgr, env, (sandesha2_rm_bean_t *) bean, - sandesha2_sender_retrieve_callback, sql_retrieve); + sender_mgr_impl->bean_mgr, env, sandesha2_sender_retrieve_callback, + sql_retrieve); AXIS2_LOG_INFO(env->log, "[sandesha2]Exit:sandesha2_permanent_sender_mgr_retrieve"); @@ -373,15 +420,76 @@ const axis2_env_t *env, sandesha2_sender_bean_t *bean) { + axis2_char_t *sql_update = NULL; + axis2_char_t *sql_retrieve = NULL; + axis2_bool_t ret = AXIS2_FALSE; sandesha2_permanent_sender_mgr_t *sender_mgr_impl = NULL; - AXIS2_LOG_INFO(env->log, - "[sandesha2]Entry:sandesha2_permanent_sender_mgr_update"); + axis2_char_t *msg_id = sandesha2_sender_bean_get_msg_id((sandesha2_rm_bean_t *) bean, + env); + axis2_char_t str_msg_id[msg_id?AXIS2_STRLEN(msg_id):8]; + axis2_char_t *msg_ctx_ref_key = sandesha2_sender_bean_get_msg_ctx_ref_key(bean, env); + axis2_char_t str_msg_ctx_ref_key[msg_ctx_ref_key?AXIS2_STRLEN(msg_ctx_ref_key):8]; + axis2_char_t *internal_seq_id = sandesha2_sender_bean_get_internal_seq_id(bean, env); + axis2_char_t str_internal_seq_id[internal_seq_id?AXIS2_STRLEN(internal_seq_id):8]; + int sent_count = sandesha2_sender_bean_get_sent_count(bean, env); + axis2_char_t str_sent_count[32]; + long msg_no = sandesha2_sender_bean_get_msg_no(bean, env); + axis2_char_t str_msg_no[32]; + axis2_bool_t send = sandesha2_sender_bean_is_send(bean, env); + axis2_char_t str_send[32]; + axis2_bool_t resend = sandesha2_sender_bean_is_resend(bean, env); + axis2_char_t str_resend[32]; + long time_to_send = sandesha2_sender_bean_get_time_to_send(bean, env); + axis2_char_t str_time_to_send[32]; + int msg_type = sandesha2_sender_bean_get_msg_type(bean, env); + axis2_char_t str_msg_type[32]; + axis2_char_t *seq_id = sandesha2_sender_bean_get_seq_id(bean, env); + axis2_char_t str_seq_id[seq_id?AXIS2_STRLEN(seq_id):8]; + axis2_char_t *wsrm_anon_uri = sandesha2_sender_bean_get_wsrm_anon_uri(bean, env); + axis2_char_t str_wsrm_anon_uri[wsrm_anon_uri?AXIS2_STRLEN(wsrm_anon_uri):8]; + axis2_char_t *to_address = sandesha2_sender_bean_get_to_address(bean, env); + axis2_char_t str_to_address[to_address?AXIS2_STRLEN(to_address):8]; + + sprintf(str_msg_id, "'%s'", msg_id); + sprintf(str_msg_ctx_ref_key, msg_ctx_ref_key?"'%s'":"NULL", msg_ctx_ref_key); + sprintf(str_internal_seq_id, internal_seq_id?"'%s'":"NULL", internal_seq_id); + sprintf(str_sent_count, "%d", sent_count); + sprintf(str_msg_no, "%ld", msg_no); + sprintf(str_send, "%d", send); + sprintf(str_resend, "%d", resend); + sprintf(str_time_to_send, "%ld", time_to_send); + sprintf(str_msg_type, "%d", msg_type); + sprintf(str_seq_id, seq_id?"'%s'":"NULL", seq_id); + sprintf(str_wsrm_anon_uri, wsrm_anon_uri?"'%s'":"NULL", wsrm_anon_uri); + sprintf(str_to_address, to_address?"'%s'":"NULL", to_address); + AXIS2_ENV_CHECK(env, AXIS2_FALSE); AXIS2_PARAM_CHECK(env->error, bean, AXIS2_FALSE); sender_mgr_impl = SANDESHA2_INTF_TO_IMPL(sender_mgr); + AXIS2_LOG_INFO(env->log, + "[sandesha2]Entry:sandesha2_permanent_sender_mgr_update"); + + sql_retrieve = axis2_strcat(env, "select msg_id, msg_ctx_ref_key, "\ + "internal_seq_id, sent_count, msg_no, send, resend, time_to_send, "\ + "msg_type, seq_id, wsrm_anon_uri, to_address from sender "\ + "where msg_id=", str_msg_id, ";", NULL); + + sql_update = axis2_strcat(env, "update sender set msg_ctx_ref_key=", + str_msg_ctx_ref_key,",internal_seq_id=",str_internal_seq_id, + ", sent_count=", str_sent_count, ", msg_no=", str_msg_no, + ", send=", str_send, ", resend=", str_resend, ", time_to_send=", + str_time_to_send, ", msg_type=", str_msg_type, ", seq_id=", + str_seq_id, ", wsrm_anon_uri=", str_wsrm_anon_uri, + ", to_address=", str_to_address, " where msg_id=", str_msg_id, + ";", NULL); + ret = sandesha2_permanent_bean_mgr_update(sender_mgr_impl->bean_mgr, env, + (sandesha2_rm_bean_t *) bean, sandesha2_sender_retrieve_callback, sql_retrieve, sql_update); + + AXIS2_LOG_INFO(env->log, + "[sandesha2]Exit:sandesha2_permanent_invoker_mgr_update:return:%d", ret); + return ret; - /* No need to update. Being a reference does the job. */ return AXIS2_SUCCESS; } @@ -404,13 +512,15 @@ bean = sandesha2_sender_bean_create(env); sandesha2_sender_bean_set_internal_seq_id(bean, env, internal_seq_id); - sql_find = axis2_strcat(env, "select msg_ctx_ref_key, internal_seq_id, "\ + sql_find = axis2_strcat(env, "select msg_id, msg_ctx_ref_key, internal_seq_id, "\ "sent_count, msg_no, send, resend, time_to_send, msg_type, seq_id, "\ "wsrm_anon_uri, to_address from sender;", NULL); sql_count = "select count(*) as no_recs from sender;"; ret = sandesha2_permanent_bean_mgr_find(sender_mgr_impl->bean_mgr, env, (sandesha2_rm_bean_t *) bean, sandesha2_sender_find_callback, sandesha2_sender_count_callback, sql_find, sql_count); + if(bean) + sandesha2_sender_bean_free((sandesha2_rm_bean_t *) bean, env); AXIS2_LOG_INFO(env->log, "[sandesha2]Exit:sandesha2_permanent_sender_mgr_find_by_internal_seq_id"); return ret; @@ -430,7 +540,7 @@ "[sandesha2]Entry:sandesha2_permanent_sender_mgr_find_by_sender_bean"); AXIS2_ENV_CHECK(env, AXIS2_FALSE); sender_mgr_impl = SANDESHA2_INTF_TO_IMPL(sender_mgr); - sql_find = axis2_strcat(env, "select msg_ctx_ref_key, internal_seq_id, "\ + sql_find = axis2_strcat(env, "select msg_id, msg_ctx_ref_key, internal_seq_id,"\ "sent_count, msg_no, send, resend, time_to_send, msg_type, seq_id, "\ "wsrm_anon_uri, to_address from sender;", NULL); sql_count = "select count(*) as no_recs from sender;"; @@ -501,8 +611,8 @@ (sandesha2_sender_bean_t *) bean, env); temp_time_to_send = sandesha2_sender_bean_get_time_to_send( (sandesha2_sender_bean_t *) candidate, env); - /*if(time_to_send > 0 && (time_to_send < temp_time_to_send))*/ - if(time_to_send > 0 && (time_to_send != temp_time_to_send)) + /*if(time_to_send > 0 && (time_to_send != temp_time_to_send))*/ + if(time_to_send > 0 && (time_to_send < temp_time_to_send)) { add = AXIS2_FALSE; } @@ -570,11 +680,11 @@ axis2_char_t *sql_find = NULL; axis2_char_t *sql_count = NULL; sandesha2_sender_bean_t *matcher = sandesha2_sender_bean_create(env); - sandesha2_sender_bean_t *result = NULL; long time_now = 0; int i = 0, size = 0; axis2_array_list_t *match_list = NULL; sandesha2_permanent_sender_mgr_t *sender_mgr_impl = NULL; + sandesha2_sender_bean_t *result = NULL; AXIS2_LOG_INFO(env->log, "[sandesha2]Entry:sandesha2_permanent_sender_mgr_get_next_msg_to_send"); AXIS2_ENV_CHECK(env, NULL); @@ -583,9 +693,10 @@ sandesha2_sender_bean_set_send(matcher, env, AXIS2_TRUE); time_now = sandesha2_utils_get_current_time_in_millis(env); sandesha2_sender_bean_set_time_to_send(matcher, env, time_now); - sql_find = axis2_strcat(env, "select msg_ctx_ref_key, internal_seq_id, "\ - "sent_count, msg_no, send, resend, time_to_send, msg_type, seq_id, "\ - "wsrm_anon_uri, to_address from sender;", NULL); + sql_find = axis2_strcat(env, "select msg_id, msg_ctx_ref_key, "\ + "internal_seq_id, sent_count, msg_no, send, resend, "\ + "time_to_send, msg_type, seq_id, wsrm_anon_uri, "\ + "to_address from sender;", NULL); sql_count = "select count(*) as no_recs from sender;"; match_list = sandesha2_permanent_bean_mgr_find(sender_mgr_impl->bean_mgr, env, (sandesha2_rm_bean_t *) matcher, sandesha2_sender_find_callback, Modified: webservices/sandesha/trunk/c/src/storage/permanent/permanent_seq_property_mgr.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/permanent/permanent_seq_property_mgr.c?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/storage/permanent/permanent_seq_property_mgr.c (original) +++ webservices/sandesha/trunk/c/src/storage/permanent/permanent_seq_property_mgr.c Mon Jan 1 23:57:33 2007 @@ -50,24 +50,34 @@ char **argv, char **col_name) { - int i; + int i = 0; + sandesha2_seq_property_bean_t *bean = NULL; sandesha2_bean_mgr_args_t *args = (sandesha2_bean_mgr_args_t *) not_used; - axis2_array_list_t *data_list = (axis2_array_list_t *) args->data; const axis2_env_t *env = args->env; + axis2_array_list_t *data_list = (axis2_array_list_t *) args->data; + if(argc < 1) + { + args->data = NULL; + return 0; + } + if(!data_list) + { + data_list = axis2_array_list_create(env, 0); + args->data = data_list; + } + bean = sandesha2_seq_property_bean_create(env); for(i = 0; i < argc; i++) { - sandesha2_seq_property_bean_t *bean = NULL; if(0 == AXIS2_STRCMP(col_name[i], "seq_id")) - sandesha2_seq_property_bean_set_seq_id(bean, env, - argv[i] ? argv[i] : "NULL"); + sandesha2_seq_property_bean_set_seq_id(bean, env, argv[i]); if(0 == AXIS2_STRCMP(col_name[i], "name")) - sandesha2_seq_property_bean_set_name(bean, env, - argv[i] ? argv[i] : "NULL"); + if(argv[i]) + sandesha2_seq_property_bean_set_name(bean, env, argv[i]); if(0 == AXIS2_STRCMP(col_name[i], "value")) - sandesha2_seq_property_bean_set_value(bean, env, - argv[i] ? argv[i] : "NULL"); - axis2_array_list_add(data_list, env, bean); + if(argv[i]) + sandesha2_seq_property_bean_set_value(bean, env, argv[i]); } + axis2_array_list_add(data_list, env, bean); return 0; } @@ -78,15 +88,32 @@ char **argv, char **col_name) { + int i = 0; sandesha2_bean_mgr_args_t *args = (sandesha2_bean_mgr_args_t *) not_used; const axis2_env_t *env = args->env; - sandesha2_seq_property_bean_t *bean = (sandesha2_seq_property_bean_t *) args->data; - sandesha2_seq_property_bean_set_seq_id(bean, env, - argv[0] ? argv[0] : "NULL"); - sandesha2_seq_property_bean_set_name(bean, env, - argv[0] ? argv[0] : "NULL"); - sandesha2_seq_property_bean_set_value(bean, env, - argv[0] ? argv[0] : "NULL"); + sandesha2_seq_property_bean_t *bean = NULL; + if(argc < 1) + { + args->data = NULL; + return 0; + } + bean = (sandesha2_seq_property_bean_t *) args->data; + if(!bean) + { + bean = sandesha2_seq_property_bean_create(env); + args->data = bean; + } + for(i = 0; i < argc; i++) + { + if(0 == AXIS2_STRCMP(col_name[i], "seq_id")) + sandesha2_seq_property_bean_set_seq_id(bean, env, argv[i]); + if(0 == AXIS2_STRCMP(col_name[i], "name")) + if(argv[i]) + sandesha2_seq_property_bean_set_name(bean, env, argv[i]); + if(0 == AXIS2_STRCMP(col_name[i], "value")) + if(argv[i]) + sandesha2_seq_property_bean_set_value(bean, env, argv[i]); + } return 0; } @@ -231,29 +258,43 @@ const axis2_env_t *env, sandesha2_seq_property_bean_t *bean) { - axis2_char_t *insert_sql = NULL; - axis2_char_t *id = NULL; - axis2_char_t *seq_id = NULL; - axis2_char_t *name = NULL; - axis2_char_t *value = NULL; + axis2_char_t *sql_insert = NULL; + axis2_char_t *sql_update = NULL; + axis2_char_t *sql_retrieve = NULL; axis2_bool_t ret = AXIS2_FALSE; sandesha2_permanent_seq_property_mgr_t *seq_prop_mgr_impl = NULL; + axis2_char_t *id = sandesha2_permanent_seq_property_mgr_get_id_with_bean(env, bean); + axis2_char_t str_id[AXIS2_STRLEN(id)]; + axis2_char_t *seq_id = sandesha2_seq_property_bean_get_seq_id(bean, env); + axis2_char_t str_seq_id[seq_id?AXIS2_STRLEN(seq_id):8]; + axis2_char_t *name = sandesha2_seq_property_bean_get_name(bean, env); + axis2_char_t str_name[name?AXIS2_STRLEN(name):8]; + axis2_char_t *value = sandesha2_seq_property_bean_get_value(bean, env); + axis2_char_t str_value[value?AXIS2_STRLEN(value):8]; + + sprintf(str_id, "'%s'", id); + sprintf(str_seq_id, seq_id?"'%s'":"NULL", seq_id); + sprintf(str_name, name?"'%s'":"NULL", name); + sprintf(str_value, value?"'%s'":"NULL", value); + AXIS2_LOG_INFO(env->log, "Entry:[sandesha2]sandesha2_permanent_seq_property_mgr_insert"); AXIS2_ENV_CHECK(env, AXIS2_FALSE); AXIS2_PARAM_CHECK(env->error, bean, AXIS2_FALSE); seq_prop_mgr_impl = SANDESHA2_INTF_TO_IMPL(seq_prop_mgr); - id = sandesha2_permanent_seq_property_mgr_get_id_with_bean(env, bean); - seq_id = sandesha2_seq_property_bean_get_seq_id(bean, env); - name = sandesha2_seq_property_bean_get_name(bean, env); - value = sandesha2_seq_property_bean_get_value(bean, env); - insert_sql = axis2_strcat(env, "insert into seq_property(seq_id, "\ - "name, value) values('", id, "','", seq_id, "','", name, "','", value, - "');", NULL); + sql_retrieve = axis2_strcat(env, "select seq_id, name, value from seq_property "\ + "where id=", str_id, ";", NULL); + sql_update = axis2_strcat(env, "update seq_property set seq_id=", + str_seq_id, ", name=", str_name, ", value=", str_value, + " where id=", str_id, ";", NULL); + sql_insert = axis2_strcat(env, "insert into seq_property(id, seq_id, "\ + "name, value) values(", str_id, ",", str_seq_id, ",", str_name, + ",", str_value, ");", NULL); ret = sandesha2_permanent_bean_mgr_insert(seq_prop_mgr_impl->bean_mgr, env, - insert_sql); + (sandesha2_rm_bean_t *) bean, sandesha2_seq_property_retrieve_callback, + sql_retrieve, sql_update, sql_insert); AXIS2_LOG_INFO(env->log, "Exit:[sandesha2]sandesha2_permanent_seq_property_mgr_insert:return%d", ret); @@ -267,7 +308,6 @@ axis2_char_t *seq_id, axis2_char_t *name) { - sandesha2_seq_property_bean_t *bean = NULL; axis2_char_t *key = NULL; axis2_char_t *sql_remove = NULL; axis2_char_t *sql_retrieve = NULL; @@ -284,10 +324,8 @@ key, "';", NULL); sql_retrieve = axis2_strcat(env, "select seq_id, name, value from seq_property "\ "where id='", key, "';", NULL); - bean = sandesha2_seq_property_bean_create(env); status = sandesha2_permanent_bean_mgr_remove(seq_prop_mgr_impl->bean_mgr, env, - (sandesha2_rm_bean_t *) bean, sandesha2_seq_property_retrieve_callback, - sql_retrieve, sql_remove); + sandesha2_seq_property_retrieve_callback, sql_retrieve, sql_remove); AXIS2_FREE(env->allocator, key); return status; } @@ -301,7 +339,6 @@ { axis2_char_t *key = NULL; axis2_char_t *sql_retrieve = NULL; - sandesha2_seq_property_bean_t *bean = NULL; sandesha2_seq_property_bean_t *ret = NULL; sandesha2_permanent_seq_property_mgr_t *seq_prop_mgr_impl = NULL; @@ -312,13 +349,12 @@ AXIS2_PARAM_CHECK(env->error, name, AXIS2_FALSE); seq_prop_mgr_impl = SANDESHA2_INTF_TO_IMPL(seq_prop_mgr); key = sandesha2_permanent_seq_property_mgr_get_id_with_seq_id_and_name(env, - seq_id, name); + seq_id, name); sql_retrieve = axis2_strcat(env, "select seq_id, name, value from seq_property "\ "where id='", key, "';", NULL); - bean = sandesha2_seq_property_bean_create(env); - return (sandesha2_seq_property_bean_t *) sandesha2_permanent_bean_mgr_retrieve( - seq_prop_mgr_impl->bean_mgr, env, (sandesha2_rm_bean_t *) bean, - sandesha2_seq_property_retrieve_callback, sql_retrieve); + ret = (sandesha2_seq_property_bean_t *) sandesha2_permanent_bean_mgr_retrieve( + seq_prop_mgr_impl->bean_mgr, env, sandesha2_seq_property_retrieve_callback, + sql_retrieve); AXIS2_FREE(env->allocator, key); AXIS2_LOG_INFO(env->log, "[sandesha2]Exit:sandesha2_permanent_seq_property_mgr_retrieve"); @@ -331,38 +367,38 @@ const axis2_env_t *env, sandesha2_seq_property_bean_t *bean) { - axis2_char_t *id = NULL; - axis2_char_t *seq_id = NULL; - axis2_char_t *name = NULL; - axis2_char_t *value = NULL; axis2_char_t *sql_update = NULL; axis2_char_t *sql_retrieve = NULL; axis2_bool_t ret = AXIS2_FALSE; - sandesha2_seq_property_bean_t *old_bean = NULL; sandesha2_permanent_seq_property_mgr_t *seq_prop_mgr_impl = NULL; + axis2_char_t *id = sandesha2_permanent_seq_property_mgr_get_id_with_bean(env, bean); + axis2_char_t str_id[AXIS2_STRLEN(id)]; + axis2_char_t *seq_id = sandesha2_seq_property_bean_get_seq_id(bean, env); + axis2_char_t str_seq_id[seq_id?AXIS2_STRLEN(seq_id):8]; + axis2_char_t *name = sandesha2_seq_property_bean_get_name(bean, env); + axis2_char_t str_name[name?AXIS2_STRLEN(name):8]; + axis2_char_t *value = sandesha2_seq_property_bean_get_value(bean, env); + axis2_char_t str_value[value?AXIS2_STRLEN(value):8]; + + sprintf(str_id, "'%s'", id); + sprintf(str_seq_id, seq_id?"'%s'":"NULL", seq_id); + sprintf(str_name, name?"'%s'":"NULL", name); + sprintf(str_value, value?"'%s'":"NULL", value); + AXIS2_LOG_INFO(env->log, "Entry:[sandesha2]sandesha2_permanent_seq_property_mgr_update"); AXIS2_ENV_CHECK(env, AXIS2_FALSE); AXIS2_PARAM_CHECK(env->error, bean, AXIS2_FALSE); seq_prop_mgr_impl = SANDESHA2_INTF_TO_IMPL(seq_prop_mgr); - id = sandesha2_permanent_seq_property_mgr_get_id_with_bean(env, bean); - if(!id) - { - return AXIS2_FALSE; - } - seq_id = sandesha2_seq_property_bean_get_seq_id(bean, env); - name = sandesha2_seq_property_bean_get_name(bean, env); - value = sandesha2_seq_property_bean_get_value(bean, env); - sql_retrieve = axis2_strcat(env, "select seq_id, name value from seq_property "\ - "where id='", id, "';", NULL); - sql_update = axis2_strcat(env, "update seq_property set seq_id='", seq_id, - "', seq_id='", seq_id, "', name='", name, "', value='", value, - "' where id='", id, "';", NULL); - old_bean = sandesha2_seq_property_bean_create(env); + sql_retrieve = axis2_strcat(env, "select seq_id, name, value from "\ + "seq_property where id=", str_id, ";", NULL); + sql_update = axis2_strcat(env, "update seq_property set seq_id=", + str_seq_id, ", name=", str_name, ", value=", str_value, + " where id=", str_id, ";", NULL); ret = sandesha2_permanent_bean_mgr_update(seq_prop_mgr_impl->bean_mgr, env, - (sandesha2_rm_bean_t *) old_bean, sandesha2_seq_property_retrieve_callback, + (sandesha2_rm_bean_t *) bean, sandesha2_seq_property_retrieve_callback, sql_retrieve, sql_update); AXIS2_LOG_INFO(env->log, "Exit:[sandesha2]sandesha2_permanent_seq_property_mgr_update:return:%d", ret); @@ -481,7 +517,7 @@ { axis2_char_t *id = NULL; - id = axis2_strcat(env, env, seq_id, ":", name, NULL); + id = axis2_strcat(env, seq_id, ":", name, NULL); return id; } @@ -496,7 +532,7 @@ seq_id = sandesha2_seq_property_bean_get_seq_id(bean, env); name = sandesha2_seq_property_bean_get_name(bean, env); - id = axis2_strcat(env, env, seq_id, ":", name, NULL); + id = axis2_strcat(env, seq_id, ":", name, NULL); return id; } Modified: webservices/sandesha/trunk/c/src/storage/permanent/permanent_storage_mgr.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/permanent/permanent_storage_mgr.c?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/storage/permanent/permanent_storage_mgr.c (original) +++ webservices/sandesha/trunk/c/src/storage/permanent/permanent_storage_mgr.c Mon Jan 1 23:57:33 2007 @@ -16,6 +16,9 @@ #include <sandesha2_storage_mgr.h> #include <sandesha2_create_seq_mgr.h> +#include <sandesha2_permanent_storage_mgr.h> +#include <sandesha2_permanent_bean_mgr.h> +#include <sandesha2_msg_store_bean.h> #include <sandesha2_permanent_create_seq_mgr.h> #include <sandesha2_invoker_mgr.h> #include <sandesha2_permanent_invoker_mgr.h> @@ -26,6 +29,7 @@ #include <sandesha2_seq_property_mgr.h> #include <sandesha2_permanent_seq_property_mgr.h> #include <sandesha2_transaction.h> +#include <sandesha2_property_bean.h> #include <sandesha2_permanent_transaction.h> #include <sandesha2_constants.h> #include <sandesha2_error.h> @@ -38,6 +42,14 @@ #include <axis2_msg_ctx.h> #include <axis2_uuid_gen.h> #include <axis2_conf_ctx.h> +#include <axis2_options.h> +#include <axis2_addr.h> +#include <axis2_http_transport.h> +#include <axiom_soap_const.h> +#include <axis2_transport_out_desc.h> +#include <axiom_xml_reader.h> +#include <axiom_stax_builder.h> +#include <axiom_soap_builder.h> /** * @brief Sandesha2 Permanent Storage Manager Struct Impl @@ -53,6 +65,12 @@ sandesha2_sender_mgr_t *sender_mgr; sandesha2_invoker_mgr_t *invoker_mgr; axis2_conf_ctx_t *conf_ctx; + axis2_char_t *db_name; + /*sqlite3 *db;*/ + axis2_hash_t *transactions; + sandesha2_permanent_bean_mgr_t *bean_mgr; + axis2_hash_t *msg_ctx_map; + axis2_thread_mutex_t *mutex; } sandesha2_permanent_storage_mgr_t; #define SANDESHA2_INTF_TO_IMPL(trans) \ @@ -167,6 +185,22 @@ axiom_soap_envelope_t *soap_env, axis2_char_t *key); +static sandesha2_msg_store_bean_t *AXIS2_CALL +sandesha2_permanent_storage_mgr_get_msg_store_bean ( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axis2_msg_ctx_t *msg_ctx); + +static axis2_hash_t *AXIS2_CALL +sandesha2_permanent_storage_mgr_get_property_map_from_string( + const axis2_env_t *env, + axis2_char_t *str); + +static axis2_char_t *AXIS2_CALL +sandesha2_permanent_storage_mgr_get_property_string( + const axis2_env_t *env, + axis2_msg_ctx_t *msg_ctx); + static const sandesha2_storage_mgr_ops_t storage_mgr_ops = { sandesha2_permanent_storage_mgr_free, @@ -196,7 +230,8 @@ axis2_conf_ctx_t *conf_ctx) { sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; - + axis2_conf_t *conf = NULL; + AXIS2_ENV_CHECK(env, NULL); storage_mgr_impl = AXIS2_MALLOC(env->allocator, sizeof(sandesha2_permanent_storage_mgr_t)); @@ -204,6 +239,31 @@ storage_mgr_impl->SANDESHA2_MSG_MAP_KEY = AXIS2_STRDUP("Sandesha2MessageMap", env); storage_mgr_impl->conf_ctx = conf_ctx; + /*storage_mgr_impl->db = NULL; + storage_mgr_impl->db_name = NULL;*/ + storage_mgr_impl->transactions = axis2_hash_make(env); + storage_mgr_impl->bean_mgr = NULL; + storage_mgr_impl->mutex = axis2_thread_mutex_create(env->allocator, + AXIS2_THREAD_MUTEX_DEFAULT); + storage_mgr_impl->msg_ctx_map = axis2_hash_make(env); + conf = AXIS2_CONF_CTX_GET_CONF((const axis2_conf_ctx_t *) conf_ctx, env); + /*prop_bean = sandesha2_utils_get_property_bean(env, conf); + path = sandesha2_property_bean_get_db_path(prop_bean, env); + storage_mgr_impl->db_name = axis2_strcat(env, path, AXIS2_PATH_SEP_STR, + "sandesha2", NULL); + storage_mgr_impl->rc = sqlite3_open(storage_mgr_impl->db_name, + &(storage_mgr_impl->db)); + if(rc) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Can't open database: %s\n", + sqlite3_errmsg(storage_mgr_impl->db)); + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_OPEN_DATABASE, + AXIS2_FAILURE); + sqlite3_close(storage_mgr_impl->db); + return NULL; + }*/ + storage_mgr_impl->bean_mgr = sandesha2_permanent_bean_mgr_create(env, + &(storage_mgr_impl->storage_mgr), conf_ctx, NULL); storage_mgr_impl->create_seq_mgr = sandesha2_permanent_create_seq_mgr_create( env, &(storage_mgr_impl->storage_mgr), conf_ctx); storage_mgr_impl->next_msg_mgr = sandesha2_permanent_next_msg_mgr_create( @@ -238,6 +298,16 @@ sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + /*sqlite3_close(storage_mgr_impl->db);*/ + if(storage_mgr_impl->transactions) + { + axis2_hash_free(storage_mgr_impl->transactions, env); + } + if(storage_mgr_impl->create_seq_mgr) + { + sandesha2_create_seq_mgr_free(storage_mgr_impl->create_seq_mgr, env); + storage_mgr_impl->create_seq_mgr = NULL; + } if(storage_mgr_impl->create_seq_mgr) { sandesha2_create_seq_mgr_free(storage_mgr_impl->create_seq_mgr, env); @@ -283,7 +353,43 @@ sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env) { - return sandesha2_permanent_transaction_create(env, storage_mgr); + sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + int key_len = 0; + unsigned long *thread_id = (unsigned long *) axis2_os_thread_current(); + sandesha2_transaction_t *transaction = NULL; + + axis2_thread_mutex_lock(storage_mgr_impl->mutex); + key_len = sizeof(unsigned long); + transaction = (sandesha2_transaction_t *) axis2_hash_get( + storage_mgr_impl->transactions, thread_id, key_len); + if(!transaction) + { + transaction = + sandesha2_permanent_transaction_create(env, storage_mgr, thread_id); + axis2_hash_set(storage_mgr_impl->transactions, thread_id, + key_len, transaction); + } + axis2_thread_mutex_unlock(storage_mgr_impl->mutex); + return transaction; +} + +void AXIS2_CALL +sandesha2_permanent_storage_mgr_remove_transaction( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + sandesha2_transaction_t *transaction) +{ + sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; + unsigned long *thread_id = NULL; + int key_len = sizeof(unsigned long); + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + + axis2_thread_mutex_lock(storage_mgr_impl->mutex); + thread_id = (unsigned long *) sandesha2_permanent_transaction_get_thread_id( + transaction, env); + axis2_hash_set(storage_mgr_impl->transactions, thread_id, key_len, NULL); + axis2_thread_mutex_unlock(storage_mgr_impl->mutex); } void AXIS2_CALL @@ -292,9 +398,12 @@ const axis2_env_t *env, sandesha2_rm_bean_t *rm_bean) { - sandesha2_transaction_t *t = sandesha2_permanent_storage_mgr_get_transaction( - storage_mgr, env); - sandesha2_transaction_enlist(t, env, rm_bean); + sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; + sandesha2_transaction_t *transaction = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + transaction = sandesha2_permanent_storage_mgr_get_transaction(storage_mgr, + env); + sandesha2_transaction_enlist(transaction, env, rm_bean); } sandesha2_create_seq_mgr_t *AXIS2_CALL @@ -307,6 +416,42 @@ return storage_mgr_impl->create_seq_mgr; } +/* +sqlite3 *AXIS2_CALL +sandesha2_permanent_storage_mgr_get_db( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env) +{ + sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + if(!storage_mgr_impl->db) + { + axis2_conf_t *conf = NULL; + sandesha2_property_bean_t *prop_bean = NULL; + axis2_char_t *path = NULL; + int rc = -1; + conf = AXIS2_CONF_CTX_GET_CONF((const axis2_conf_ctx_t *) + storage_mgr_impl->conf_ctx, env); + prop_bean = sandesha2_utils_get_property_bean(env, conf); + path = sandesha2_property_bean_get_db_path(prop_bean, env); + storage_mgr_impl->db_name = axis2_strcat(env, path, AXIS2_PATH_SEP_STR, + "sandesha2", NULL); + rc = sqlite3_open(storage_mgr_impl->db_name, + &(storage_mgr_impl->db)); + if(rc) + { + printf("cannot open database\n"); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Can't open database: %s\n", + sqlite3_errmsg(storage_mgr_impl->db)); + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_OPEN_DATABASE, + AXIS2_FAILURE); + sqlite3_close(storage_mgr_impl->db); + return NULL; + } + } + return storage_mgr_impl->db; +}*/ + sandesha2_next_msg_mgr_t *AXIS2_CALL sandesha2_permanent_storage_mgr_get_next_msg_mgr( sandesha2_storage_mgr_t *storage_mgr, @@ -384,29 +529,6 @@ return AXIS2_SUCCESS; } -axis2_msg_ctx_t *AXIS2_CALL -sandesha2_permanent_storage_mgr_retrieve_msg_ctx( - sandesha2_storage_mgr_t *storage_mgr, - const axis2_env_t *env, - axis2_char_t *key, - axis2_conf_ctx_t *conf_ctx) -{ - axis2_hash_t *storage_map = NULL; - axis2_property_t *property = NULL; - axis2_ctx_t *ctx = NULL; - sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; - storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); - conf_ctx = sandesha2_permanent_storage_mgr_get_ctx(storage_mgr, env); - ctx = AXIS2_CONF_CTX_GET_BASE(conf_ctx, env); - property = AXIS2_CTX_GET_PROPERTY(ctx, env, - storage_mgr_impl->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); - storage_map = (axis2_hash_t *) AXIS2_PROPERTY_GET_VALUE(property, env); - if(!storage_map) - return NULL; - return (axis2_msg_ctx_t *) axis2_hash_get(storage_map, key, - AXIS2_HASH_KEY_STRING); -} - axis2_status_t AXIS2_CALL sandesha2_permanent_storage_mgr_store_msg_ctx( sandesha2_storage_mgr_t *storage_mgr, @@ -414,37 +536,18 @@ axis2_char_t *key, axis2_msg_ctx_t *msg_ctx) { - axis2_hash_t *storage_map = NULL; - axis2_property_t *property = NULL; - axis2_conf_ctx_t *conf_ctx = NULL; - axis2_ctx_t *ctx = NULL; + sandesha2_msg_store_bean_t *msg_store_bean = NULL; sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); - - conf_ctx = sandesha2_permanent_storage_mgr_get_ctx(storage_mgr, env); - ctx = AXIS2_CONF_CTX_GET_BASE(conf_ctx, env); - property = AXIS2_CTX_GET_PROPERTY(ctx, env, - storage_mgr_impl->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); - if(!property) - { - property = axis2_property_create(env); - } - storage_map = (axis2_hash_t *) AXIS2_PROPERTY_GET_VALUE(property, env); - if(!storage_map) - { - storage_map = axis2_hash_make(env); - AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_APPLICATION); - AXIS2_PROPERTY_SET_VALUE(property, env, storage_map); - AXIS2_PROPERTY_SET_FREE_FUNC(property, env, axis2_hash_free_void_arg); - AXIS2_CTX_SET_PROPERTY(ctx, env, storage_mgr_impl->SANDESHA2_MSG_MAP_KEY, - property, AXIS2_FALSE); - } - if(!key) - { - key = axis2_uuid_gen(env); - } + + axis2_hash_set(storage_mgr_impl->msg_ctx_map, key, AXIS2_HASH_KEY_STRING, + msg_ctx); AXIS2_MSG_CTX_SET_KEEP_ALIVE(msg_ctx, env, AXIS2_TRUE); - axis2_hash_set(storage_map, key, AXIS2_HASH_KEY_STRING, msg_ctx); + msg_store_bean = sandesha2_permanent_storage_mgr_get_msg_store_bean( + storage_mgr, env, msg_ctx); + sandesha2_msg_store_bean_set_stored_key(msg_store_bean, env, key); + sandesha2_permanent_bean_mgr_insert_msg_store_bean(storage_mgr_impl->bean_mgr, + env, key, msg_store_bean); return AXIS2_SUCCESS; } @@ -455,38 +558,8 @@ axis2_char_t *key, axis2_msg_ctx_t *msg_ctx) { - axis2_hash_t *storage_map = NULL; - axis2_property_t *property = NULL; - axis2_conf_ctx_t *conf_ctx = NULL; - axis2_ctx_t *ctx = NULL; - void *old_entry = NULL; - sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; - storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); - conf_ctx = sandesha2_permanent_storage_mgr_get_ctx(storage_mgr, env); - ctx = AXIS2_CONF_CTX_GET_BASE(conf_ctx, env); - property = AXIS2_CTX_GET_PROPERTY(ctx, env, - storage_mgr_impl->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); - if(!property) - { - AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_STORAGE_MAP_NOT_PRESENT, - AXIS2_FAILURE); - return AXIS2_FAILURE; - } - storage_map = (axis2_hash_t *) AXIS2_PROPERTY_GET_VALUE(property, env); - if(!storage_map) - { - AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_STORAGE_MAP_NOT_PRESENT, - AXIS2_FAILURE); - return AXIS2_FAILURE; - } - old_entry = axis2_hash_get(storage_map, key, AXIS2_HASH_KEY_STRING); - if(!old_entry) - { - AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_ENTRY_IS_NOT_PRESENT_FOR_UPDATING, - AXIS2_FAILURE); - return AXIS2_FAILURE; - } - return sandesha2_permanent_storage_mgr_store_msg_ctx(storage_mgr, env, key, msg_ctx); + return sandesha2_permanent_storage_mgr_store_msg_ctx(storage_mgr, env, key, + msg_ctx); } axis2_status_t AXIS2_CALL @@ -495,35 +568,19 @@ const axis2_env_t *env, axis2_char_t *key) { - axis2_hash_t *storage_map = NULL; - axis2_property_t *property = NULL; - axis2_conf_ctx_t *conf_ctx = NULL; - axis2_ctx_t *ctx = NULL; void *entry = NULL; sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); - conf_ctx = sandesha2_permanent_storage_mgr_get_ctx(storage_mgr, env); - ctx = AXIS2_CONF_CTX_GET_BASE(conf_ctx, env); - property = AXIS2_CTX_GET_PROPERTY(ctx, env, - storage_mgr_impl->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); - if(!property) - { - AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_STORAGE_MAP_NOT_PRESENT, - AXIS2_FAILURE); - return AXIS2_FAILURE; - } - storage_map = (axis2_hash_t *) AXIS2_PROPERTY_GET_VALUE(property, env); - if(!storage_map) - { - AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_STORAGE_MAP_NOT_PRESENT, - AXIS2_FAILURE); - return AXIS2_FAILURE; - } - entry = axis2_hash_get(storage_map, key, AXIS2_HASH_KEY_STRING); + if(storage_mgr_impl->msg_ctx_map) + entry = axis2_hash_get(storage_mgr_impl->msg_ctx_map, key, + AXIS2_HASH_KEY_STRING); if(entry) { - axis2_hash_set(storage_map, key, AXIS2_HASH_KEY_STRING, NULL); + axis2_hash_set(storage_mgr_impl->msg_ctx_map, key, + AXIS2_HASH_KEY_STRING, NULL); } + sandesha2_permanent_bean_mgr_remove_msg_store_bean( + storage_mgr_impl->bean_mgr, env, key); return AXIS2_SUCCESS; } @@ -555,5 +612,530 @@ { /* TODO No real value */ return AXIS2_SUCCESS; +} + +static sandesha2_msg_store_bean_t *AXIS2_CALL +sandesha2_permanent_storage_mgr_get_msg_store_bean ( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axis2_msg_ctx_t *msg_ctx) +{ + axiom_soap_envelope_t *envelope = NULL; + axis2_char_t *soap_str = NULL; + int soap_version = 0; + axiom_xml_writer_t *xml_writer = NULL; + axiom_output_t *om_output = NULL; + axis2_transport_out_desc_t *transport_out_desc = NULL; + axis2_svc_grp_t *svc_grp = NULL; + axis2_svc_t *svc = NULL; + axis2_op_t *op = NULL; + axis2_endpoint_ref_t *to = NULL; + axis2_endpoint_ref_t *reply_to = NULL; + axis2_char_t *address = NULL; + axis2_char_t *action = NULL; + axis2_property_t *property = NULL; + axis2_options_t *options = NULL; + axis2_char_t *prop_str = NULL; + axis2_op_ctx_t *op_ctx = NULL; + sandesha2_msg_store_bean_t *bean = NULL; + envelope = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env); + if (!envelope) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_NULL_SOAP_ENVELOPE_IN_MSG_CTX, + AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "%s", + AXIS2_ERROR_GET_MESSAGE(env->error)); + return AXIS2_FAILURE; + } + xml_writer = axiom_xml_writer_create_for_memory(env, NULL, + AXIS2_TRUE, 0, AXIS2_XML_PARSER_TYPE_BUFFER); + if (!xml_writer) + { + return AXIS2_FAILURE; + } + om_output = axiom_output_create(env, xml_writer); + if (!om_output) + { + AXIOM_XML_WRITER_FREE(xml_writer, env); + xml_writer = NULL; + return AXIS2_FAILURE; + } + AXIOM_OUTPUT_SET_SOAP11(om_output, env, AXIS2_MSG_CTX_GET_IS_SOAP_11( + msg_ctx, env)); + AXIOM_SOAP_ENVELOPE_SERIALIZE(envelope, env, om_output, AXIS2_FALSE); + soap_str = (axis2_char_t *)AXIOM_XML_WRITER_GET_XML(xml_writer, env); + + if (AXIS2_MSG_CTX_GET_IS_SOAP_11(msg_ctx, env)) + soap_version = SANDESHA2_SOAP_VERSION_1_1; + else + soap_version = SANDESHA2_SOAP_VERSION_1_2; + bean = sandesha2_msg_store_bean_create(env); + transport_out_desc = AXIS2_MSG_CTX_GET_TRANSPORT_OUT_DESC(msg_ctx, env); + svc_grp = AXIS2_MSG_CTX_GET_SVC_GRP(msg_ctx, env); + svc = AXIS2_MSG_CTX_GET_SVC(msg_ctx, env); + op = AXIS2_MSG_CTX_GET_OP(msg_ctx, env); + if(transport_out_desc) + { + const axis2_qname_t *qname = AXIS2_TRANSPORT_OUT_DESC_GET_QNAME( + transport_out_desc, env); + axis2_char_t *str_qname = AXIS2_QNAME_TO_STRING(qname, env); + sandesha2_msg_store_bean_set_transport_out(bean, env, str_qname); + } + if(svc_grp) + { + axis2_char_t *svc_grp_name = (axis2_char_t *) AXIS2_SVC_GRP_GET_NAME( + svc_grp, env); + sandesha2_msg_store_bean_set_svc_grp(bean, env, svc_grp_name); + } + if (svc) + { + axis2_char_t *svc_name = (axis2_char_t *) AXIS2_SVC_GET_NAME(svc, env); + sandesha2_msg_store_bean_set_svc(bean, env, svc_name); + } + if(op) + { + axis2_qname_t *qname = (axis2_qname_t *) AXIS2_OP_GET_QNAME(op, env); + axis2_char_t *mep = NULL; + if(qname) + { + axis2_char_t *op_name = AXIS2_QNAME_TO_STRING(qname, env); + sandesha2_msg_store_bean_set_op(bean, env, op_name); + } + mep = (axis2_char_t *) AXIS2_OP_GET_MSG_EXCHANGE_PATTERN(op, env); + sandesha2_msg_store_bean_set_op_mep(bean, env, mep); + } + sandesha2_msg_store_bean_set_flow(bean, env, AXIS2_MSG_CTX_GET_FLOW(msg_ctx, + env)); + sandesha2_msg_store_bean_set_svr_side(bean, env, + AXIS2_MSG_CTX_GET_SERVER_SIDE(msg_ctx, env)); + sandesha2_msg_store_bean_set_soap_envelope_str(bean, env, soap_str); + sandesha2_msg_store_bean_set_soap_version(bean, env, soap_version); + sandesha2_msg_store_bean_set_msg_id(bean, env, (axis2_char_t *) + AXIS2_MSG_CTX_GET_MSG_ID(msg_ctx, env)); + to = AXIS2_MSG_CTX_GET_TO(msg_ctx, env); + if(to) + { + address = (axis2_char_t *) AXIS2_ENDPOINT_REF_GET_ADDRESS(to, env); + sandesha2_msg_store_bean_set_to_url(bean, env, address); + } + reply_to = AXIS2_MSG_CTX_GET_REPLY_TO(msg_ctx, env); + if(reply_to) + { + address = (axis2_char_t *) AXIS2_ENDPOINT_REF_GET_ADDRESS(reply_to, env); + sandesha2_msg_store_bean_set_reply_to(bean, env, address); + } + property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, AXIS2_TRANSPORT_URL, + AXIS2_FALSE); + if(property) + { + axis2_char_t *transport_to = NULL; + transport_to = (axis2_char_t *) AXIS2_PROPERTY_GET_VALUE(property, env); + sandesha2_msg_store_bean_set_transport_to(bean, env, transport_to); + } + options = (axis2_options_t *) AXIS2_MSG_CTX_GET_OPTIONS(msg_ctx, env); + action = (axis2_char_t *) AXIS2_OPTIONS_GET_ACTION(options, env); + sandesha2_msg_store_bean_set_action(bean, env, action); + prop_str = sandesha2_permanent_storage_mgr_get_property_string(env, msg_ctx); + sandesha2_msg_store_bean_set_persistent_property_str(bean, env, + prop_str); + + /* setting the request message if this a response message.*/ + op_ctx = AXIS2_MSG_CTX_GET_OP_CTX(msg_ctx, env); + if(op_ctx) + { + axis2_msg_ctx_t *in_msg_ctx = NULL; + in_msg_ctx = AXIS2_OP_CTX_GET_MSG_CTX(op_ctx, env, + AXIS2_WSDL_MESSAGE_LABEL_IN_VALUE); + if(in_msg_ctx) + { + axis2_char_t *in_msg_store_key = NULL; + axis2_bool_t insert = AXIS2_FALSE; + property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, + SANDESHA2_IN_MESSAGE_STORAGE_KEY, AXIS2_FALSE); + if(property) + in_msg_store_key = (axis2_char_t *) AXIS2_PROPERTY_GET_VALUE( + property, env); + if(!in_msg_store_key) + { + in_msg_store_key = (axis2_char_t *) axis2_uuid_gen(env); + insert = AXIS2_TRUE; + } + /*if(insert) + sandesha2_permanent_storage_mgr_store_msg_ctx(storage_mgr, env, + in_msg_store_key, in_msg_ctx); + else + sandesha2_permanent_storage_mgr_update_msg_ctx(storage_mgr, env, + in_msg_store_key, in_msg_ctx);*/ + sandesha2_msg_store_bean_set_in_msg_store_key(bean, env, + in_msg_store_key); + } + } + return bean; +} + +axis2_msg_ctx_t * AXIS2_CALL +sandesha2_permanent_storage_mgr_retrieve_msg_ctx( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axis2_char_t *key, + axis2_conf_ctx_t *conf_ctx) +{ + sandesha2_permanent_storage_mgr_t *storage_mgr_impl = NULL; + axis2_msg_ctx_t *msg_ctx = NULL; + axis2_conf_t *conf = NULL; + axis2_svc_grp_t *svc_grp = NULL; + axis2_svc_t *svc = NULL; + axis2_char_t *transport_out_str = NULL; + axis2_char_t *soap_env_str = NULL; + axis2_char_t *svc_grp_name_str = NULL; + axis2_char_t *svc_name_str = NULL; + axis2_char_t *op_name_str = NULL; + axis2_char_t *op_mep_str = NULL; + axis2_char_t *to_url_str = NULL; + axis2_char_t *reply_to_str = NULL; + axis2_char_t *transport_to_str = NULL; + axis2_char_t *persistent_prop_str = NULL; + axis2_endpoint_ref_t *endpoint_ref = NULL; + axis2_op_t *op = NULL; + axis2_property_t *property = NULL; + axis2_options_t *options = NULL; + axiom_xml_reader_t *reader = NULL; + int soap_version = -1; + axiom_stax_builder_t *om_builder = NULL; + axiom_soap_builder_t *soap_builder = NULL; + axiom_soap_envelope_t *soap_envelope = NULL; + sandesha2_msg_store_bean_t *msg_store_bean = NULL; + + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + msg_ctx = (axis2_msg_ctx_t *) axis2_hash_get(storage_mgr_impl->msg_ctx_map, + key, AXIS2_HASH_KEY_STRING); + if(msg_ctx) + return msg_ctx; + msg_store_bean = sandesha2_permanent_bean_mgr_retrieve_msg_store_bean( + storage_mgr_impl->bean_mgr, env, key); + if (!msg_store_bean) + { + return NULL; + } + msg_ctx = axis2_msg_ctx_create(env, conf_ctx, NULL, NULL); + soap_env_str = sandesha2_msg_store_bean_get_soap_envelope_str(msg_store_bean, env); + reader = axiom_xml_reader_create_for_memory(env, soap_env_str, AXIS2_STRLEN( + soap_env_str), NULL, AXIS2_XML_PARSER_TYPE_BUFFER); + om_builder = axiom_stax_builder_create(env, reader); + soap_version = sandesha2_msg_store_bean_get_soap_version(msg_store_bean, env); + if(SANDESHA2_SOAP_VERSION_1_1 == soap_version) + { + soap_builder = axiom_soap_builder_create(env, om_builder, + AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI); + } + else if(SANDESHA2_SOAP_VERSION_1_2 == soap_version) + { + soap_builder = axiom_soap_builder_create(env, om_builder, + AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI); + } + soap_envelope = AXIOM_SOAP_BUILDER_GET_SOAP_ENVELOPE(soap_builder, env); + if (!soap_envelope) + { + AXIOM_SOAP_BUILDER_FREE(soap_builder, env); + return NULL; + } + AXIS2_MSG_CTX_SET_SOAP_ENVELOPE(msg_ctx, env, soap_envelope); + AXIS2_MSG_CTX_SET_MSG_ID(msg_ctx, env, sandesha2_msg_store_bean_get_msg_id( + msg_store_bean, env)); + conf = AXIS2_CONF_CTX_GET_CONF(conf_ctx, env); + transport_out_str = sandesha2_msg_store_bean_get_transport_out( + msg_store_bean, env); + if (transport_out_str != NULL) + { + axis2_transport_out_desc_t *transport_out = NULL; + axis2_qname_t *transport_out_qname = axis2_qname_create_from_string(env, + transport_out_str); + transport_out = AXIS2_CONF_GET_TRANSPORT_OUT(conf, env, transport_out_qname); + AXIS2_MSG_CTX_SET_TRANSPORT_OUT_DESC(msg_ctx, env, transport_out); + } + svc_grp_name_str = sandesha2_msg_store_bean_get_svc_grp(msg_store_bean, env); + if(svc_grp_name_str) + { + svc_grp = AXIS2_CONF_GET_SVC_GRP(conf, env, svc_grp_name_str); + if(svc_grp) + AXIS2_MSG_CTX_SET_SVC_GRP(msg_ctx, env, svc_grp); + } + else + { + svc_grp = axis2_svc_grp_create_with_conf(env, conf); + AXIS2_MSG_CTX_SET_SVC_GRP(msg_ctx, env, svc_grp); + } + svc_name_str = sandesha2_msg_store_bean_get_svc(msg_store_bean, env); + if(svc_name_str) + { + svc = AXIS2_CONF_GET_SVC(conf, env, svc_name_str); + if(svc) + AXIS2_MSG_CTX_SET_SVC(msg_ctx, env, svc); + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot build message "\ + "context since service %s is not present", svc_name_str); + AXIS2_ERROR_SET(env->error, + SANDESHA2_ERROR_CANNOT_BUILD_MSG_CTX_WHEN_SVC_NOT_PRESENT, + AXIS2_FAILURE); + AXIOM_SOAP_BUILDER_FREE(soap_builder, env); + return NULL; + } + } + op_name_str = sandesha2_msg_store_bean_get_op(msg_store_bean, env); + op_mep_str = sandesha2_msg_store_bean_get_op_mep(msg_store_bean, env); + svc = AXIS2_MSG_CTX_GET_SVC(msg_ctx, env); + if((op_name_str || op_mep_str) && svc) + { + axis2_op_t *op = NULL; + if(op_name_str) + { + axis2_qname_t *op_qname = axis2_qname_create_from_string(env, + op_name_str); + op = AXIS2_SVC_GET_OP_WITH_QNAME(svc, env, op_qname); + } + if(!op && op_mep_str && svc) + { + axis2_hash_t *all_ops = NULL; + axis2_hash_index_t *index = NULL; + /* Finding an operation using the MEP */ + all_ops = AXIS2_SVC_GET_ALL_OPS(svc, env); + for (index = axis2_hash_first(all_ops, env); index; index = + axis2_hash_next(env, index)) + { + void *v = NULL; + axis2_char_t *mep = NULL; + axis2_op_t *temp = NULL; + axis2_hash_this(index, NULL, NULL, &v); + temp = (axis2_op_t *) v; + mep = (axis2_char_t *) AXIS2_OP_GET_MSG_EXCHANGE_PATTERN(temp, + env); + if(0 == AXIS2_STRCMP(mep, op_mep_str)) + { + op = temp; + break; + } + } + } + if(op) + AXIS2_MSG_CTX_SET_OP(msg_ctx, env, op); + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cant find a suitable "\ + "operation for the generated message"); + AXIS2_ERROR_SET(env->error, + SANDESHA2_ERROR_CANNOT_FIND_OP_FOR_GENERATED_MSG, AXIS2_FAILURE); + AXIOM_SOAP_BUILDER_FREE(soap_builder, env); + return NULL; + } + } + /* Setting contexts TODO is this necessary? */ + svc_grp = AXIS2_MSG_CTX_GET_SVC_GRP(msg_ctx, env); + if(svc_grp) + { + axis2_svc_grp_ctx_t *svc_grp_ctx = axis2_svc_grp_ctx_create(env, svc_grp, conf_ctx); + AXIS2_MSG_CTX_SET_SVC_GRP_CTX(msg_ctx, env, svc_grp_ctx); + } + svc = AXIS2_MSG_CTX_GET_SVC(msg_ctx, env); + if(svc) + { + axis2_svc_grp_ctx_t *svc_grp_ctx = AXIS2_MSG_CTX_GET_SVC_GRP_CTX( + msg_ctx, env); + axis2_svc_ctx_t *svc_ctx = axis2_svc_ctx_create(env, svc, svc_grp_ctx); + if(svc_ctx) + { + AXIS2_SVC_CTX_SET_PARENT(svc_ctx, env, svc_grp_ctx); + AXIS2_MSG_CTX_SET_SVC_CTX(msg_ctx, env, svc_ctx); + } + + } + op = AXIS2_MSG_CTX_GET_OP(msg_ctx, env); + if(op) + { + axis2_svc_ctx_t *svc_ctx = AXIS2_MSG_CTX_GET_SVC_CTX(msg_ctx, env); + axis2_op_ctx_t *op_ctx = axis2_op_ctx_create(env, op, svc_ctx); + if(op_ctx) + { + axis2_char_t *msg_id = NULL; + AXIS2_OP_CTX_SET_PARENT(op_ctx, env, svc_ctx); + AXIS2_MSG_CTX_SET_OP_CTX(msg_ctx, env, op_ctx); + /*AXIS2_OP_CTX_ADD_MSG_CTX(op_ctx, env, msg_ctx);*/ + msg_id = (axis2_char_t *) AXIS2_MSG_CTX_GET_MSG_ID(msg_ctx, env); + AXIS2_CONF_CTX_REGISTER_OP_CTX(conf_ctx, env, msg_id, op_ctx); + } + } + AXIS2_MSG_CTX_SET_SERVER_SIDE(msg_ctx, env, + sandesha2_msg_store_bean_is_svr_side(msg_store_bean, env)); + AXIS2_MSG_CTX_SET_FLOW(msg_ctx, env, + sandesha2_msg_store_bean_get_flow(msg_store_bean, env)); + transport_to_str = sandesha2_msg_store_bean_get_transport_to(msg_store_bean, + env); + property = axis2_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, + transport_to_str); + AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_TRANSPORT_URL, property, + AXIS2_FALSE); + to_url_str = sandesha2_msg_store_bean_get_to_url(msg_store_bean, env); + if(to_url_str) + { + endpoint_ref = axis2_endpoint_ref_create(env, to_url_str); + AXIS2_MSG_CTX_SET_TO(msg_ctx, env, endpoint_ref); + } + reply_to_str = sandesha2_msg_store_bean_get_reply_to(msg_store_bean, env); + if(reply_to_str) + { + endpoint_ref = axis2_endpoint_ref_create(env, reply_to_str); + AXIS2_MSG_CTX_SET_REPLY_TO(msg_ctx, env, endpoint_ref); + } + options = (axis2_options_t *) AXIS2_MSG_CTX_GET_OPTIONS(msg_ctx, env); + if(options) + { + axis2_char_t *action = sandesha2_msg_store_bean_get_action( + msg_store_bean, env); + AXIS2_OPTIONS_SET_ACTION(options, env, action); + } + persistent_prop_str = + sandesha2_msg_store_bean_get_persistent_property_str(msg_store_bean, + env); + if(persistent_prop_str && 0 != AXIS2_STRCMP("", AXIS2_STRTRIM(env, + persistent_prop_str, NULL))) + { + axis2_hash_t *map = + sandesha2_permanent_storage_mgr_get_property_map_from_string(env, + persistent_prop_str); + axis2_hash_index_t *index = NULL; + /* Finding an operation using the MEP */ + for (index = axis2_hash_first(map, env); index; index = + axis2_hash_next(env, index)) + { + axis2_property_t *property = NULL; + void *v = NULL; + const void *k = NULL; + axis2_char_t *key = NULL; + axis2_hash_this(index, &k, NULL, &v); + key = (axis2_char_t *) k; + property = (axis2_property_t *) v; + AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, key, property, + AXIS2_FALSE); + } + } + + return msg_ctx; +} + +static axis2_char_t *AXIS2_CALL +sandesha2_permanent_storage_mgr_get_property_string( + const axis2_env_t *env, + axis2_msg_ctx_t *msg_ctx) +{ + axis2_char_t *prop_str = NULL; + axis2_property_t *property = NULL; + axis2_options_t *options = (axis2_options_t *) AXIS2_MSG_CTX_GET_OPTIONS( + msg_ctx, env); + axis2_hash_t *properties = AXIS2_OPTIONS_GET_PROPERTIES(options, env); + axis2_hash_index_t *index = NULL; + + property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, + SANDESHA2_QUALIFIED_FOR_SENDING, AXIS2_FALSE); + if(property) + { + axis2_char_t *value = AXIS2_PROPERTY_GET_VALUE(property, env); + prop_str = axis2_strcat(env, SANDESHA2_QUALIFIED_FOR_SENDING, + SANDESHA2_PERSISTANT_PROPERTY_SEPERATOR, value, NULL); + } + else + { + property = axis2_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, + 0, SANDESHA2_VALUE_FALSE); + AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, SANDESHA2_QUALIFIED_FOR_SENDING, + property, AXIS2_FALSE); + prop_str = axis2_strcat(env, SANDESHA2_QUALIFIED_FOR_SENDING, + SANDESHA2_PERSISTANT_PROPERTY_SEPERATOR, SANDESHA2_VALUE_FALSE, NULL); + } + property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, + AXIS2_WSA_VERSION, AXIS2_FALSE); + if(property) + { + axis2_char_t *temp_str = NULL; + axis2_char_t *value = AXIS2_PROPERTY_GET_VALUE(property, env); + if(value) + { + temp_str = prop_str; + prop_str = axis2_strcat(env, temp_str, + SANDESHA2_PERSISTANT_PROPERTY_SEPERATOR, AXIS2_WSA_VERSION, + SANDESHA2_PERSISTANT_PROPERTY_SEPERATOR, value, NULL); + if(temp_str) + AXIS2_FREE(env->allocator, temp_str); + } + } + for (index = axis2_hash_first(properties, env); index; index = + axis2_hash_next(env, index)) + { + axis2_char_t *temp_str = NULL; + void *v = NULL; + const void *k = NULL; + axis2_char_t *key = NULL; + axis2_char_t *value = NULL; + axis2_hash_this(index, &k, NULL, &v); + key = (axis2_char_t *) k; + if(0 == axis2_strcmp(AXIS2_HTTP_OUT_TRANSPORT_INFO, key)) + continue; + if(0 == axis2_strcmp(AXIS2_TRANSPORT_OUT, key)) + continue; + if(0 == axis2_strcmp(AXIS2_TRANSPORT_IN, key)) + continue; + if(0 == axis2_strcmp(AXIS2_TRANSPORT_HEADERS, key)) + continue; + if(0 == axis2_strcmp(SANDESHA2_ORIGINAL_TRANSPORT_OUT_DESC, key)) + continue; + if(0 == axis2_strcmp(AXIS2_HTTP_CLIENT, key)) + continue; + + property = (axis2_property_t *) v; + if(property) + value = AXIS2_PROPERTY_GET_VALUE(property, env); + if(value) + { + temp_str = prop_str; + prop_str = axis2_strcat(env, temp_str, + SANDESHA2_PERSISTANT_PROPERTY_SEPERATOR, key, + SANDESHA2_PERSISTANT_PROPERTY_SEPERATOR, + value, NULL); + if(temp_str) + AXIS2_FREE(env->allocator, temp_str); + } + } + return prop_str; +} + +static axis2_hash_t *AXIS2_CALL +sandesha2_permanent_storage_mgr_get_property_map_from_string( + const axis2_env_t *env, + axis2_char_t *str) +{ + int i = 0, size = 0; + axis2_hash_t *map = axis2_hash_make(env); + axis2_array_list_t *values = sandesha2_utils_split(env, str, + SANDESHA2_PERSISTANT_PROPERTY_SEPERATOR); + if(values) + size = AXIS2_ARRAY_LIST_SIZE(values, env); + if((size % 2 != 0) || (size == 1 && 0 == AXIS2_STRCMP("", + AXIS2_ARRAY_LIST_GET(values, env, 0)))) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "Invalid persistence property string"); + AXIS2_ERROR_SET(env->error, + SANDESHA2_ERROR_INVALID_PERSISTENCE_PROPERTY_STRING, AXIS2_FAILURE); + return NULL; + } + for(i = 0; i < size; i=i+2) + { + axis2_char_t *key = AXIS2_ARRAY_LIST_GET(values, env, i); + axis2_char_t *value = AXIS2_ARRAY_LIST_GET(values, env, i+1); + axis2_property_t *property = axis2_property_create_with_args(env, + AXIS2_SCOPE_APPLICATION, 0, value); + axis2_hash_set(map, key, AXIS2_HASH_KEY_STRING, property); + } + return map; } Modified: webservices/sandesha/trunk/c/src/storage/permanent/permanent_transaction.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/permanent/permanent_transaction.c?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/storage/permanent/permanent_transaction.c (original) +++ webservices/sandesha/trunk/c/src/storage/permanent/permanent_transaction.c Mon Jan 1 23:57:33 2007 @@ -20,11 +20,13 @@ #include <sandesha2_error.h> #include <sandesha2_rm_bean.h> #include <sandesha2_storage_mgr.h> +#include <sandesha2_property_bean.h> #include <axis2_log.h> #include <axis2_hash.h> #include <axis2_thread.h> #include <axis2_property.h> #include <platforms/axis2_platform_auto_sense.h> +#include <sqlite3.h> typedef struct sandesha2_permanent_transaction_impl sandesha2_permanent_transaction_impl_t; @@ -39,6 +41,8 @@ sandesha2_storage_mgr_t *storage_mgr; axis2_array_list_t *enlisted_beans; axis2_thread_mutex_t *mutex; + sqlite3 *dbconn; + unsigned long *thread_id; }; #define SANDESHA2_INTF_TO_IMPL(trans) \ @@ -87,9 +91,17 @@ AXIS2_EXTERN sandesha2_transaction_t* AXIS2_CALL sandesha2_permanent_transaction_create( const axis2_env_t *env, - sandesha2_storage_mgr_t *storage_mgr) + sandesha2_storage_mgr_t *storage_mgr, + unsigned long *thread_id) { sandesha2_permanent_transaction_impl_t *trans_impl = NULL; + axis2_char_t *error_msg = NULL; + axis2_char_t *path = NULL; + axis2_char_t *db_name = NULL; + int rc = -1; + axis2_conf_ctx_t *conf_ctx = NULL; + axis2_conf_t *conf = NULL; + sandesha2_property_bean_t *prop_bean = NULL; AXIS2_ENV_CHECK(env, NULL); @@ -97,11 +109,40 @@ (env->allocator, sizeof(sandesha2_permanent_transaction_impl_t)); trans_impl->storage_mgr = storage_mgr; + trans_impl->thread_id = thread_id; + trans_impl->dbconn = NULL; trans_impl->enlisted_beans = axis2_array_list_create(env, 0); trans_impl->mutex = axis2_thread_mutex_create(env->allocator, AXIS2_THREAD_MUTEX_DEFAULT); trans_impl->trans.ops = &transaction_ops; - + conf_ctx = (axis2_conf_ctx_t *) sandesha2_permanent_storage_mgr_get_ctx( + storage_mgr, env); + conf = AXIS2_CONF_CTX_GET_CONF((const axis2_conf_ctx_t *) conf_ctx, env); + prop_bean = (sandesha2_property_bean_t *)sandesha2_utils_get_property_bean( + env, conf); + path = sandesha2_property_bean_get_db_path(prop_bean, env); + db_name = axis2_strcat(env, path, AXIS2_PATH_SEP_STR, "sandesha2", NULL); + rc = sqlite3_open(db_name, &(trans_impl->dbconn)); + printf("came1\n"); + if(rc != SQLITE_OK) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Can't open database: %s\n", + sqlite3_errmsg(trans_impl->dbconn)); + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_OPEN_DATABASE, + AXIS2_FAILURE); + sqlite3_close(trans_impl->dbconn); + return NULL; + } + rc = sqlite3_exec(trans_impl->dbconn, "BEGIN TRANSACTION;", 0, 0, + &error_msg); + if(rc != SQLITE_OK ) + { + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SQL_ERROR, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "SQL Error %s", + error_msg); + printf("transaction begin error_msg:%s\n", error_msg); + sqlite3_free(error_msg); + } return &(trans_impl->trans); } @@ -133,6 +174,26 @@ return AXIS2_SUCCESS; } +sqlite3 *AXIS2_CALL +sandesha2_permanent_transaction_get_dbconn( + sandesha2_transaction_t *trans, + const axis2_env_t *env) +{ + sandesha2_permanent_transaction_impl_t *trans_impl = NULL; + trans_impl = SANDESHA2_INTF_TO_IMPL(trans); + return trans_impl->dbconn; +} + +unsigned long *AXIS2_CALL +sandesha2_permanent_transaction_get_thread_id( + sandesha2_transaction_t *trans, + const axis2_env_t *env) +{ + sandesha2_permanent_transaction_impl_t *trans_impl = NULL; + trans_impl = SANDESHA2_INTF_TO_IMPL(trans); + return trans_impl->thread_id; +} + static axis2_bool_t sandesha2_permanent_transaction_is_active( sandesha2_transaction_t *trans, @@ -154,6 +215,22 @@ sandesha2_transaction_t *trans, const axis2_env_t *env) { + axis2_char_t *error_msg = NULL; + int rc = -1; + sandesha2_permanent_transaction_impl_t *trans_impl = NULL; + trans_impl = SANDESHA2_INTF_TO_IMPL(trans); + + rc = sqlite3_exec(trans_impl->dbconn, "COMMIT TRANSACTION;", 0, 0, &error_msg); + printf("came2\n"); + if(rc != SQLITE_OK ) + { + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SQL_ERROR, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "sql error %s", + error_msg); + printf("commit error_msg:%s\n", error_msg); + sqlite3_free(error_msg); + } + sqlite3_close(trans_impl->dbconn); sandesha2_permanent_transaction_release_locks(trans, env); } @@ -162,6 +239,23 @@ sandesha2_transaction_t *trans, const axis2_env_t *env) { + axis2_char_t *error_msg = NULL; + int rc = -1; + sandesha2_permanent_transaction_impl_t *trans_impl = NULL; + trans_impl = SANDESHA2_INTF_TO_IMPL(trans); + rc = sqlite3_exec(trans_impl->dbconn, "ROLLBACK TRANSACTION;", 0, 0, + &error_msg); + printf("came3\n"); + if(rc != SQLITE_OK ) + { + AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SQL_ERROR, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "sql error %s", + error_msg); + printf("sql_stmt_rollback:%s\n", "ROLLBACK TRANSACTION;"); + printf("rollback error_msg:%s\n", error_msg); + sqlite3_free(error_msg); + } + sqlite3_close(trans_impl->dbconn); sandesha2_permanent_transaction_release_locks(trans, env); } @@ -173,6 +267,8 @@ sandesha2_permanent_transaction_impl_t *trans_impl = NULL; int i = 0, size = 0; trans_impl = SANDESHA2_INTF_TO_IMPL(trans); + sandesha2_permanent_storage_mgr_remove_transaction(trans_impl->storage_mgr, + env, trans); if(trans_impl->enlisted_beans) size = AXIS2_ARRAY_LIST_SIZE(trans_impl->enlisted_beans, env); for(i = 0; i < size; i++) @@ -185,8 +281,8 @@ sandesha2_rm_bean_set_transaction(rm_bean_l, env, NULL); axis2_thread_mutex_unlock(trans_impl->mutex); } - AXIS2_ARRAY_LIST_FREE(trans_impl->enlisted_beans, env); - trans_impl->enlisted_beans = NULL; + /*AXIS2_ARRAY_LIST_FREE(trans_impl->enlisted_beans, env); + trans_impl->enlisted_beans = NULL;*/ } static void @@ -196,22 +292,27 @@ sandesha2_rm_bean_t *rm_bean) { sandesha2_rm_bean_t *rm_bean_l = NULL; + unsigned long *thread_id = NULL; sandesha2_permanent_transaction_impl_t *trans_impl = NULL; AXIS2_LOG_INFO(env->log, "[sandesha2]Start:sandesha2_permanent_transaction_enlist"); trans_impl = SANDESHA2_INTF_TO_IMPL(trans); rm_bean_l = sandesha2_rm_bean_get_base(rm_bean, env); + thread_id = trans_impl->thread_id; if(rm_bean) { sandesha2_transaction_t *other = NULL; + unsigned long *other_thread_id = NULL; axis2_thread_mutex_lock(trans_impl->mutex); other = sandesha2_rm_bean_get_transaction(rm_bean_l, env); - /*while(other && other != trans) + if(other) + other_thread_id = sandesha2_permanent_transaction_get_thread_id(other, + env); + while(other && *other_thread_id != *thread_id) { int size = 0; if(trans_impl->enlisted_beans) size = AXIS2_ARRAY_LIST_SIZE(trans_impl->enlisted_beans, env); - AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "size:%d", size); if(size > 0) { AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Possible deadlock"); @@ -220,7 +321,10 @@ } AXIS2_SLEEP(6); other = sandesha2_rm_bean_get_transaction(rm_bean_l, env); - }*/ + if(other) + other_thread_id = sandesha2_permanent_transaction_get_thread_id( + other, env); + } if(!other) { sandesha2_rm_bean_set_transaction(rm_bean_l, env, trans); Modified: webservices/sandesha/trunk/c/src/storage/permanent/sandesha2_permanent_bean_mgr.h URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/permanent/sandesha2_permanent_bean_mgr.h?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/storage/permanent/sandesha2_permanent_bean_mgr.h (original) +++ webservices/sandesha/trunk/c/src/storage/permanent/sandesha2_permanent_bean_mgr.h Mon Jan 1 23:57:33 2007 @@ -29,6 +29,7 @@ #include <axis2_utils.h> #include <axis2_array_list.h> #include <sandesha2_rm_bean.h> +#include <sandesha2_msg_store_bean.h> #ifdef __cplusplus extern "C" @@ -78,13 +79,16 @@ sandesha2_permanent_bean_mgr_insert( sandesha2_permanent_bean_mgr_t *bean_mgr, const axis2_env_t *env, + sandesha2_rm_bean_t *bean, + int (*retrieve_func)(void *, int, char **, char **), + axis2_char_t *sql_stmt_retrieve, + axis2_char_t *sql_stmt_update, axis2_char_t *sql_stmt_insert); axis2_bool_t AXIS2_CALL sandesha2_permanent_bean_mgr_remove( sandesha2_permanent_bean_mgr_t *bean_mgr, const axis2_env_t *env, - sandesha2_rm_bean_t *bean, int (*retrieve_func)(void *, int, char **, char **), axis2_char_t *sql_stmt_retrieve, axis2_char_t *sql_stmt_remove); @@ -93,7 +97,6 @@ sandesha2_permanent_bean_mgr_retrieve( sandesha2_permanent_bean_mgr_t *bean_mgr, const axis2_env_t *env, - sandesha2_rm_bean_t *bean, int (*retrieve_func)(void *, int, char **, char **), axis2_char_t *sql_stmt_retrieve); @@ -101,7 +104,7 @@ sandesha2_permanent_bean_mgr_update( sandesha2_permanent_bean_mgr_t *bean_mgr, const axis2_env_t *env, - sandesha2_rm_bean_t *old_bean, + sandesha2_rm_bean_t *bean, int (*update_func)(void *, int, char **, char **), axis2_char_t *sql_stmt_retrieve_old_bean, axis2_char_t *sql_stmt_update); @@ -132,6 +135,26 @@ const axis2_env_t *env, sandesha2_rm_bean_t *bean, sandesha2_rm_bean_t *candidate); + +sandesha2_msg_store_bean_t *AXIS2_CALL +sandesha2_permanent_bean_mgr_retrieve_msg_store_bean( + sandesha2_permanent_bean_mgr_t *bean_mgr, + const axis2_env_t *env, + axis2_char_t *key); + +axis2_bool_t AXIS2_CALL +sandesha2_permanent_bean_mgr_insert_msg_store_bean( + sandesha2_permanent_bean_mgr_t *bean_mgr, + const axis2_env_t *env, + axis2_char_t *key, + sandesha2_msg_store_bean_t *bean); + +axis2_bool_t AXIS2_CALL +sandesha2_permanent_bean_mgr_remove_msg_store_bean( + sandesha2_permanent_bean_mgr_t *bean_mgr, + const axis2_env_t *env, + axis2_char_t *key); + /** @} */ #ifdef __cplusplus Modified: webservices/sandesha/trunk/c/src/transport/sandesha2_transport_sender.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/transport/sandesha2_transport_sender.c?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/transport/sandesha2_transport_sender.c (original) +++ webservices/sandesha/trunk/c/src/transport/sandesha2_transport_sender.c Mon Jan 1 23:57:33 2007 @@ -183,9 +183,8 @@ storage_man = sandesha2_utils_get_storage_mgr(env, conf_ctx, conf); property = axis2_property_create(env); - AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_REQUEST); - AXIS2_PROPERTY_SET_VALUE(property, env, AXIS2_STRDUP(SANDESHA2_VALUE_TRUE, - env)); + AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_APPLICATION); + AXIS2_PROPERTY_SET_VALUE(property, env, SANDESHA2_VALUE_TRUE); AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, SANDESHA2_QUALIFIED_FOR_SENDING, property, AXIS2_FALSE); sandesha2_storage_mgr_update_msg_ctx(storage_man, env, key, msg_ctx); Modified: webservices/sandesha/trunk/c/src/util/ack_mgr.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/util/ack_mgr.c?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/util/ack_mgr.c (original) +++ webservices/sandesha/trunk/c/src/util/ack_mgr.c Mon Jan 1 23:57:33 2007 @@ -461,10 +461,12 @@ axis2_char_t *to = NULL; sandesha2_msg_ctx_t *ack_rm_msg = NULL; sandesha2_iom_rm_part_t *seq_ack = NULL; + axis2_char_t *msg_ctx_ref_key = NULL; + msg_ctx_ref_key = sandesha2_sender_bean_get_msg_ctx_ref_key( + sender_bean, env); msg_ctx1 = sandesha2_storage_mgr_retrieve_msg_ctx(storage_mgr, env, - sandesha2_sender_bean_get_msg_ctx_ref_key( - sender_bean, env), conf_ctx); + msg_ctx_ref_key, conf_ctx); to = (axis2_char_t*)AXIS2_ENDPOINT_REF_GET_ADDRESS( AXIS2_MSG_CTX_GET_TO(msg_ctx1, env), env); if(0 == AXIS2_STRCMP(to, to_str)) @@ -472,6 +474,8 @@ sandesha2_sender_mgr_remove(retrans_mgr, env, sandesha2_sender_bean_get_msg_id((sandesha2_rm_bean_t *) sender_bean, env)); + sandesha2_storage_mgr_remove_msg_ctx(storage_mgr, env, + msg_ctx_ref_key); ack_rm_msg = sandesha2_msg_init_init_msg(env, msg_ctx1); if(SANDESHA2_MSG_TYPE_ACK != sandesha2_msg_ctx_get_msg_type(ack_rm_msg, env)) Modified: webservices/sandesha/trunk/c/src/util/error.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/util/error.c?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/util/error.c (original) +++ webservices/sandesha/trunk/c/src/util/error.c Mon Jan 1 23:57:33 2007 @@ -189,6 +189,12 @@ "Database cannot be opened"; sandesha2_error_messages[SANDESHA2_ERROR_SQL_ERROR]= "There is an sql error. Please refer logs"; + sandesha2_error_messages[SANDESHA2_ERROR_CANNOT_BUILD_MSG_CTX_WHEN_SVC_NOT_PRESENT]= + "Cannot build message context since service is not present"; + sandesha2_error_messages[SANDESHA2_ERROR_CANNOT_FIND_OP_FOR_GENERATED_MSG]= + "Cannot find a operation for generated message"; + sandesha2_error_messages[SANDESHA2_ERROR_INVALID_PERSISTENCE_PROPERTY_STRING]= + "Invalid persistence property string"; return AXIS2_SUCCESS; } Modified: webservices/sandesha/trunk/c/src/util/msg_init.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/util/msg_init.c?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/util/msg_init.c (original) +++ webservices/sandesha/trunk/c/src/util/msg_init.c Mon Jan 1 23:57:33 2007 @@ -443,6 +443,7 @@ { axis2_char_t *spec_version = NULL; axis2_char_t *seq_rm_ns = NULL; + AXIS2_LOG_INFO(env->log, "prop_key:%s\n", prop_key); spec_version = sandesha2_utils_get_rm_version(env, prop_key, storage_mgr); if(spec_version) --------------------------------------------------------------------- To unsubscribe, e-mail: qcarrillo@example.net For additional commands, e-mail: qcarrillo@example.net From qcarrillo@example.net Tue Jan 02 07:58:50 2007 Return-Path: <qcarrillo@example.net> Delivered-To: qcarrillo@example.net Received: (qmail 14527 invoked from network); 2 Jan 2007 07:58:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jan 2007 07:58:45 -0000 Received: (qmail 90882 invoked by uid 500); 2 Jan 2007 07:58:45 -0000 Delivered-To: qcarrillo@example.net Received: (qmail 90812 invoked by uid 500); 2 Jan 2007 07:58:44 -0000 Mailing-List: contact qcarrillo@example.net; run by ezmlm Precedence: bulk List-Help: <mailto:qcarrillo@example.net> List-Unsubscribe: <mailto:qcarrillo@example.net> List-Post: <mailto:qcarrillo@example.net> List-Id: <sandesha-dev.ws.apache.org> Delivered-To: mailing list qcarrillo@example.net Received: (qmail 90798 invoked by uid 500); 2 Jan 2007 07:58:44 -0000 Delivered-To: qcarrillo@example.net Received: (qmail 90795 invoked by uid 99); 2 Jan 2007 07:58:44 -0000 Received: from herse.apache.org (HELO herse.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 23:58:44 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jan 2007 23:58:34 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id BD9F71A9823; Mon, 1 Jan 2007 23:57:37 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r491758 [4/4] - in /webservices/sandesha/trunk/c: include/ samples/rm_1_1_echo/ samples/rm_echo/ samples/rm_mtom/ samples/rm_ping/ src/client/ src/core/ src/handlers/ src/msgprocessors/ src/storage/beans/ src/storage/inmemory/ src/storage/p... Date: Tue, 02 Jan 2007 07:57:35 -0000 To: qcarrillo@example.net From: qcarrillo@example.net X-Mailer: svnmailer-1.1.0 Message-Id: <qcarrillo@example.net> X-Virus-Checked: Checked by ClamAV on apache.org Modified: webservices/sandesha/trunk/c/src/util/sandesha2_utils.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/util/sandesha2_utils.c?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/util/sandesha2_utils.c (original) +++ webservices/sandesha/trunk/c/src/util/sandesha2_utils.c Mon Jan 1 23:57:33 2007 @@ -509,34 +509,32 @@ { axis2_property_t *property = NULL; axis2_ctx_t *ctx = AXIS2_CONF_CTX_GET_BASE(conf_ctx, env); + /*axis2_array_list_t *storage_mgr_list = axis2_array_list_create(env, 0);*/ + sandesha2_storage_mgr_t *storage_mgr = NULL; AXIS2_ENV_CHECK(env, NULL); AXIS2_PARAM_CHECK(env->error, conf_ctx, NULL); - - property = AXIS2_CTX_GET_PROPERTY(ctx, env, SANDESHA2_PERMANENT_STORAGE_MGR, + + property = AXIS2_CTX_GET_PROPERTY(ctx, env, SANDESHA2_PERMANENT_STORAGE_MGR, AXIS2_FALSE); - - if(property && AXIS2_PROPERTY_GET_VALUE(property, env)) - { - sandesha2_storage_mgr_t *storage_mgr = NULL; - storage_mgr = (sandesha2_storage_mgr_t*)AXIS2_PROPERTY_GET_VALUE( - property, env); - return storage_mgr; - } + if(property) + storage_mgr = AXIS2_PROPERTY_GET_VALUE(property, env); else - { - sandesha2_storage_mgr_t *storage_mgr = - sandesha2_permanent_storage_mgr_create(env, conf_ctx); - property = axis2_property_create(env); - AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_APPLICATION); - AXIS2_PROPERTY_SET_VALUE(property, env, storage_mgr); - AXIS2_PROPERTY_SET_FREE_FUNC(property, env, - sandesha2_storage_mgr_free_void_arg); - AXIS2_CTX_SET_PROPERTY(ctx, env, SANDESHA2_PERMANENT_STORAGE_MGR, - property, AXIS2_FALSE); - return storage_mgr; - } - return NULL; + storage_mgr = sandesha2_permanent_storage_mgr_create(env, conf_ctx); + property = axis2_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, + storage_mgr); + AXIS2_CTX_SET_PROPERTY(ctx, env, SANDESHA2_PERMANENT_STORAGE_MGR, + property, AXIS2_FALSE); + /*if(property) + storage_mgr_list = AXIS2_PROPERTY_GET_VALUE(property, env); + sandesha2_storage_mgr_t *storage_mgr = + sandesha2_permanent_storage_mgr_create(env, conf_ctx); + AXIS2_ARRAY_LIST_ADD(storage_mgr_list, env, storage_mgr); + property = axis2_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, + storage_mgr_list); + AXIS2_CTX_SET_PROPERTY(ctx, env, SANDESHA2_PERMANENT_STORAGE_MGR, + property, AXIS2_FALSE);*/ + return storage_mgr; } AXIS2_EXTERN axis2_char_t* AXIS2_CALL @@ -1307,5 +1305,29 @@ return AXIS2_TRUE; return AXIS2_FALSE; +} + +axis2_array_list_t *AXIS2_CALL +sandesha2_utils_split( + const axis2_env_t *env, + axis2_char_t *str, + axis2_char_t *pattern) +{ + axis2_array_list_t *list = axis2_array_list_create(env, 0); + axis2_char_t *ptr = NULL; + axis2_char_t *value = NULL; + ptr = AXIS2_STRSTR(str, pattern); + while(ptr) + { + ptr[0] = AXIS2_EOLN; + value = AXIS2_STRDUP(str, env); + AXIS2_ARRAY_LIST_ADD(list, env, value); + str = ptr + 3; + ptr = AXIS2_STRSTR(str, pattern); + } + value = AXIS2_STRDUP(str, env); + AXIS2_ARRAY_LIST_ADD(list, env, value); + + return list; } Modified: webservices/sandesha/trunk/c/src/util/terminate_mgr.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/util/terminate_mgr.c?view=diff&rev=491758&r1=491757&r2=491758 ============================================================================== --- webservices/sandesha/trunk/c/src/util/terminate_mgr.c (original) +++ webservices/sandesha/trunk/c/src/util/terminate_mgr.c Mon Jan 1 23:57:33 2007 @@ -34,16 +34,44 @@ #include <axis2_array_list.h> #include <axis2_engine.h> #include <sandesha2_msg_creator.h> +#include <sandesha2_rm_bean.h> #include <axis2_transport_out_desc.h> axis2_hash_t *sandesha2_terminate_mgr_rcv_side_clean_map = NULL; +static axis2_status_t +sandesha2_terminate_mgr_clean_sending_side_data( + const axis2_env_t *env, + axis2_conf_ctx_t *conf_ctx, + axis2_char_t *seq_id, + axis2_bool_t svr_side, + sandesha2_storage_mgr_t *storage_mgr); + +static axis2_status_t +sandesha2_terminate_mgr_complete_termination_of_recv_side( + const axis2_env_t *env, + axis2_conf_ctx_t *conf_ctx, + axis2_char_t *seq_id, + sandesha2_storage_mgr_t *storage_mgr); + +static axis2_status_t +sandesha2_terminate_mgr_remove_recv_side_properties( + const axis2_env_t *env, + axis2_conf_ctx_t *conf_ctx, + axis2_char_t *seq_id, + sandesha2_storage_mgr_t *storage_mgr); + +static axis2_bool_t +sandesha2_terminate_mgr_is_property_deletable( + const axis2_env_t *env, + axis2_char_t *name); + AXIS2_EXTERN axis2_status_t AXIS2_CALL sandesha2_terminate_mgr_clean_recv_side_after_terminate_msg( const axis2_env_t *env, axis2_conf_ctx_t *conf_ctx, axis2_char_t *seq_id, - sandesha2_storage_mgr_t *storage_man) + sandesha2_storage_mgr_t *storage_mgr) { axis2_bool_t in_order_invoke = AXIS2_FALSE; sandesha2_property_bean_t *prop_bean = NULL; @@ -52,9 +80,9 @@ AXIS2_ENV_CHECK(env, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE); AXIS2_PARAM_CHECK(env->error, seq_id, AXIS2_FAILURE); - AXIS2_PARAM_CHECK(env->error, storage_man, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, storage_mgr, AXIS2_FAILURE); - if(NULL == sandesha2_terminate_mgr_rcv_side_clean_map) + if(!sandesha2_terminate_mgr_rcv_side_clean_map) { sandesha2_terminate_mgr_rcv_side_clean_map = axis2_hash_make(env); } @@ -62,15 +90,15 @@ prop_bean = sandesha2_utils_get_property_bean(env, AXIS2_CONF_CTX_GET_CONF( conf_ctx, env)); in_order_invoke = sandesha2_property_bean_is_in_order(prop_bean, env); - if(AXIS2_FALSE == in_order_invoke) + if(!in_order_invoke) sandesha2_terminate_mgr_clean_recv_side_after_invocation(env, conf_ctx, - seq_id,
{'source': 'Apache Software Foundation Public Mail Archives'}