Copied: webservices/sandesha/trunk/c/src/storage/inmemory/inmemory_storage_mgr.c (from r482886, webservices/sandesha/trunk/c/src/storage/inmemory/storage_mgr.c) URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/inmemory/inmemory_storage_mgr.c?view=diff&rev=483051&p1=webservices/sandesha/trunk/c/src/storage/inmemory/storage_mgr.c&r1=482886&p2=webservices/sandesha/trunk/c/src/storage/inmemory/inmemory_storage_mgr.c&r2=483051 ============================================================================== --- webservices/sandesha/trunk/c/src/storage/inmemory/storage_mgr.c (original) +++ webservices/sandesha/trunk/c/src/storage/inmemory/inmemory_storage_mgr.c Wed Dec 6 04:27:54 2006 @@ -24,6 +24,7 @@ #include <sandesha2_constants.h> #include <sandesha2_error.h> #include <sandesha2_utils.h> +#include <sandesha2_rm_bean.h> #include <axis2_log.h> #include <axis2_hash.h> #include <axis2_thread.h> @@ -33,12 +34,12 @@ #include <axis2_conf_ctx.h> /** - * @brief Sandesha2 Storage Manager Struct Impl - * Sandesha2 Storage Manager + * @brief Sandesha2 Inmemory Storage Manager Struct Impl + * Sandesha2 Inmemory Storage Manager */ -struct sandesha2_storage_mgr_t +typedef struct sandesha2_inmemory_storage_mgr { - sandesha2_storage_mgr_t *instance; + sandesha2_storage_mgr_t storage_mgr; axis2_char_t *SANDESHA2_MSG_MAP_KEY; sandesha2_create_seq_mgr_t *create_seq_mgr; sandesha2_next_msg_mgr_t *next_msg_mgr; @@ -46,217 +47,337 @@ sandesha2_sender_mgr_t *sender_mgr; sandesha2_invoker_mgr_t *invoker_mgr; axis2_conf_ctx_t *conf_ctx; +} sandesha2_inmemory_storage_mgr_t; + +#define SANDESHA2_INTF_TO_IMPL(trans) \ + ((sandesha2_inmemory_storage_mgr_t *) trans) + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +sandesha2_inmemory_storage_mgr_free_void_arg( + void *storage_mgr, + const axis2_env_t *env); + +axis2_status_t AXIS2_CALL +sandesha2_inmemory_storage_mgr_free( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *envv); + +struct sandesha2_transaction *AXIS2_CALL +sandesha2_inmemory_storage_mgr_get_transaction( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env); + +void AXIS2_CALL +sandesha2_inmemory_storage_mgr_enlist_bean( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + sandesha2_rm_bean_t *rm_bean); + +sandesha2_create_seq_mgr_t *AXIS2_CALL +sandesha2_inmemory_storage_mgr_get_create_seq_mgr( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env); + +sandesha2_next_msg_mgr_t *AXIS2_CALL +sandesha2_inmemory_storage_mgr_get_next_msg_mgr( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env); + +sandesha2_sender_mgr_t *AXIS2_CALL +sandesha2_inmemory_storage_mgr_get_retrans_mgr( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env); + +sandesha2_seq_property_mgr_t *AXIS2_CALL +sandesha2_inmemory_storage_mgr_get_seq_property_mgr( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env); + +sandesha2_invoker_mgr_t *AXIS2_CALL +sandesha2_inmemory_storage_mgr_get_storage_map_mgr( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env); + +axis2_status_t AXIS2_CALL +sandesha2_inmemory_storage_mgr_set_ctx( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env, + axis2_conf_ctx_t *conf_ctx); + +axis2_conf_ctx_t *AXIS2_CALL +sandesha2_inmemory_storage_mgr_get_ctx( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env); + +axis2_status_t AXIS2_CALL +sandesha2_inmemory_storage_mgr_init( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env, + axis2_conf_ctx_t *conf_ctx); + +axis2_msg_ctx_t *AXIS2_CALL +sandesha2_inmemory_storage_mgr_retrieve_msg_ctx( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env, + axis2_char_t *key, + axis2_conf_ctx_t *conf_ctx); + +axis2_status_t AXIS2_CALL +sandesha2_inmemory_storage_mgr_store_msg_ctx( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env, + axis2_char_t *key, + axis2_msg_ctx_t *msg_ctx); + +axis2_status_t AXIS2_CALL +sandesha2_inmemory_storage_mgr_update_msg_ctx( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env, + axis2_char_t *key, + axis2_msg_ctx_t *msg_ctx); + +axis2_status_t AXIS2_CALL +sandesha2_inmemory_storage_mgr_remove_msg_ctx( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env, + axis2_char_t *key); + +axis2_status_t AXIS2_CALL +sandesha2_inmemory_storage_mgr_init_storage( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env, + axis2_module_desc_t *module_desc); + +axiom_soap_envelope_t *AXIS2_CALL +sandesha2_inmemory_storage_mgr_retrieve_soap_envelope( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env, + axis2_char_t *key); + +axis2_status_t AXIS2_CALL +sandesha2_inmemory_storage_mgr_store_soap_envelope( + sandesha2_storage_mgr_t *storage, + const axis2_env_t *env, + axiom_soap_envelope_t *soap_env, + axis2_char_t *key); + +static const sandesha2_storage_mgr_ops_t storage_mgr_ops = +{ + sandesha2_inmemory_storage_mgr_free, + sandesha2_inmemory_storage_mgr_free_void_arg, + sandesha2_inmemory_storage_mgr_get_transaction, + sandesha2_inmemory_storage_mgr_enlist_bean, + sandesha2_inmemory_storage_mgr_get_create_seq_mgr, + sandesha2_inmemory_storage_mgr_get_next_msg_mgr, + sandesha2_inmemory_storage_mgr_get_retrans_mgr, + sandesha2_inmemory_storage_mgr_get_seq_property_mgr, + sandesha2_inmemory_storage_mgr_get_storage_map_mgr, + sandesha2_inmemory_storage_mgr_set_ctx, + sandesha2_inmemory_storage_mgr_get_ctx, + sandesha2_inmemory_storage_mgr_init, + sandesha2_inmemory_storage_mgr_retrieve_msg_ctx, + sandesha2_inmemory_storage_mgr_store_msg_ctx, + sandesha2_inmemory_storage_mgr_update_msg_ctx, + sandesha2_inmemory_storage_mgr_remove_msg_ctx, + sandesha2_inmemory_storage_mgr_init_storage, + sandesha2_inmemory_storage_mgr_retrieve_soap_envelope, + sandesha2_inmemory_storage_mgr_store_soap_envelope }; AXIS2_EXTERN sandesha2_storage_mgr_t * AXIS2_CALL -sandesha2_storage_mgr_create( +sandesha2_inmemory_storage_mgr_create( const axis2_env_t *env, axis2_conf_ctx_t *conf_ctx) { - sandesha2_storage_mgr_t *storage_mgr = NULL; + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; axis2_ctx_t *ctx = NULL; AXIS2_ENV_CHECK(env, NULL); - storage_mgr = AXIS2_MALLOC(env->allocator, - sizeof(sandesha2_storage_mgr_t)); - - storage_mgr->instance = NULL; - storage_mgr->SANDESHA2_MSG_MAP_KEY = AXIS2_STRDUP("Sandesha2MessageMap", env); - storage_mgr->create_seq_mgr = NULL; - storage_mgr->next_msg_mgr = NULL; - storage_mgr->seq_property_mgr = NULL; - storage_mgr->sender_mgr = NULL; - storage_mgr->invoker_mgr = NULL; - storage_mgr->conf_ctx = conf_ctx; + storage_mgr_impl = AXIS2_MALLOC(env->allocator, + sizeof(sandesha2_inmemory_storage_mgr_t)); + storage_mgr_impl->SANDESHA2_MSG_MAP_KEY = AXIS2_STRDUP("Sandesha2MessageMap", + env); + storage_mgr_impl->conf_ctx = conf_ctx; ctx = AXIS2_CONF_CTX_GET_BASE(conf_ctx, env); - storage_mgr->create_seq_mgr = sandesha2_create_seq_mgr_create(env, ctx); - storage_mgr->next_msg_mgr = sandesha2_next_msg_mgr_create(env, ctx); - storage_mgr->seq_property_mgr = sandesha2_seq_property_mgr_create(env, ctx); - storage_mgr->sender_mgr = sandesha2_sender_mgr_create(env, ctx); - storage_mgr->invoker_mgr = sandesha2_invoker_mgr_create(env, ctx); - - return storage_mgr; -} + storage_mgr_impl->create_seq_mgr = sandesha2_create_seq_mgr_create(env, + ctx); + storage_mgr_impl->next_msg_mgr = sandesha2_next_msg_mgr_create(env, ctx); + storage_mgr_impl->seq_property_mgr = sandesha2_seq_property_mgr_create(env, + ctx); + storage_mgr_impl->sender_mgr = sandesha2_sender_mgr_create(env, ctx); + storage_mgr_impl->invoker_mgr = sandesha2_invoker_mgr_create(env, ctx); -sandesha2_storage_mgr_t *AXIS2_CALL -sandesha2_storage_mgr_get_instance( - sandesha2_storage_mgr_t *storage_mgr, - const axis2_env_t *env, - axis2_conf_ctx_t *conf_ctx) -{ - AXIS2_ENV_CHECK(env, AXIS2_FALSE); - - if(!storage_mgr->instance) - { - storage_mgr->instance = sandesha2_storage_mgr_create(env, conf_ctx); - } + storage_mgr_impl->storage_mgr.ops = &storage_mgr_ops; - return storage_mgr->instance; + return &(storage_mgr_impl->storage_mgr); } axis2_status_t AXIS2_CALL -sandesha2_storage_mgr_free_void_arg( +sandesha2_inmemory_storage_mgr_free_void_arg( void *storage_mgr, const axis2_env_t *env) { - sandesha2_storage_mgr_t *storage_mgr_l = NULL; - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); - - storage_mgr_l = (sandesha2_storage_mgr_t *) storage_mgr; - return sandesha2_storage_mgr_free(storage_mgr_l, env); - return AXIS2_SUCCESS; + storage_mgr = (sandesha2_inmemory_storage_mgr_t *) storage_mgr; + return sandesha2_inmemory_storage_mgr_free(storage_mgr, env); } axis2_status_t AXIS2_CALL -sandesha2_storage_mgr_free( +sandesha2_inmemory_storage_mgr_free( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); - if(storage_mgr->instance) - { - sandesha2_storage_mgr_free(storage_mgr->instance, env); - storage_mgr->instance = NULL; - } - if(storage_mgr->create_seq_mgr) + if(storage_mgr_impl->create_seq_mgr) { - SANDESHA2_CREATE_SEQ_MGR_FREE(storage_mgr->create_seq_mgr, env); - storage_mgr->create_seq_mgr = NULL; + SANDESHA2_CREATE_SEQ_MGR_FREE(storage_mgr_impl->create_seq_mgr, env); + storage_mgr_impl->create_seq_mgr = NULL; } - if(storage_mgr->next_msg_mgr) + if(storage_mgr_impl->next_msg_mgr) { - sandesha2_next_msg_mgr_free(storage_mgr->next_msg_mgr, env); - storage_mgr->next_msg_mgr = NULL; + sandesha2_next_msg_mgr_free(storage_mgr_impl->next_msg_mgr, env); + storage_mgr_impl->next_msg_mgr = NULL; } - if(storage_mgr->sender_mgr) + if(storage_mgr_impl->sender_mgr) { - sandesha2_sender_mgr_free(storage_mgr->sender_mgr, env); - storage_mgr->sender_mgr = NULL; + sandesha2_sender_mgr_free(storage_mgr_impl->sender_mgr, env); + storage_mgr_impl->sender_mgr = NULL; } - if(storage_mgr->seq_property_mgr) + if(storage_mgr_impl->seq_property_mgr) { - sandesha2_seq_property_mgr_free(storage_mgr->seq_property_mgr, env); - storage_mgr->seq_property_mgr = NULL; + sandesha2_seq_property_mgr_free(storage_mgr_impl->seq_property_mgr, + env); + storage_mgr_impl->seq_property_mgr = NULL; } - if(storage_mgr->invoker_mgr) + if(storage_mgr_impl->invoker_mgr) { - sandesha2_invoker_mgr_free(storage_mgr->invoker_mgr, env); - storage_mgr->invoker_mgr = NULL; + sandesha2_invoker_mgr_free(storage_mgr_impl->invoker_mgr, env); + storage_mgr_impl->invoker_mgr = NULL; } - if(storage_mgr->SANDESHA2_MSG_MAP_KEY) + if(storage_mgr_impl->SANDESHA2_MSG_MAP_KEY) { - AXIS2_FREE(env->allocator, storage_mgr->SANDESHA2_MSG_MAP_KEY); - storage_mgr->SANDESHA2_MSG_MAP_KEY = NULL; + AXIS2_FREE(env->allocator, storage_mgr_impl->SANDESHA2_MSG_MAP_KEY); + storage_mgr_impl->SANDESHA2_MSG_MAP_KEY = NULL; } - if(storage_mgr) + if(storage_mgr_impl) { - AXIS2_FREE(env->allocator, storage_mgr); - storage_mgr = NULL; + AXIS2_FREE(env->allocator, storage_mgr_impl); + storage_mgr_impl = NULL; } return AXIS2_SUCCESS; } sandesha2_transaction_t *AXIS2_CALL -sandesha2_storage_mgr_get_transaction( +sandesha2_inmemory_storage_mgr_get_transaction( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env) { - AXIS2_ENV_CHECK(env, AXIS2_FALSE); + return sandesha2_transaction_create(env, storage_mgr); +} - return sandesha2_transaction_create(env); +void AXIS2_CALL +sandesha2_inmemory_storage_mgr_enlist_bean( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + sandesha2_rm_bean_t *rm_bean) +{ + sandesha2_transaction_t *t = sandesha2_inmemory_storage_mgr_get_transaction( + storage_mgr, env); + sandesha2_transaction_enlist(t, env, rm_bean); } sandesha2_create_seq_mgr_t *AXIS2_CALL -sandesha2_storage_mgr_get_create_seq_mgr( +sandesha2_inmemory_storage_mgr_get_create_seq_mgr( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env) { - AXIS2_ENV_CHECK(env, AXIS2_FALSE); - - return storage_mgr->create_seq_mgr; + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + return storage_mgr_impl->create_seq_mgr; } sandesha2_next_msg_mgr_t *AXIS2_CALL -sandesha2_storage_mgr_get_next_msg_mgr( +sandesha2_inmemory_storage_mgr_get_next_msg_mgr( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env) { - AXIS2_ENV_CHECK(env, AXIS2_FALSE); - - return storage_mgr->next_msg_mgr; + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + return storage_mgr_impl->next_msg_mgr; } sandesha2_sender_mgr_t *AXIS2_CALL -sandesha2_storage_mgr_get_retrans_mgr( +sandesha2_inmemory_storage_mgr_get_retrans_mgr( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env) { - AXIS2_ENV_CHECK(env, AXIS2_FALSE); - - return storage_mgr->sender_mgr; + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + return storage_mgr_impl->sender_mgr; } sandesha2_seq_property_mgr_t *AXIS2_CALL -sandesha2_storage_mgr_get_seq_property_mgr( +sandesha2_inmemory_storage_mgr_get_seq_property_mgr( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env) { - AXIS2_ENV_CHECK(env, AXIS2_FALSE); + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); - return storage_mgr->seq_property_mgr; + return storage_mgr_impl->seq_property_mgr; } sandesha2_invoker_mgr_t *AXIS2_CALL -sandesha2_storage_mgr_get_storage_map_mgr( +sandesha2_inmemory_storage_mgr_get_storage_map_mgr( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env) { - AXIS2_ENV_CHECK(env, AXIS2_FALSE); - - return storage_mgr->invoker_mgr; + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + return storage_mgr_impl->invoker_mgr; } axis2_status_t AXIS2_CALL -sandesha2_storage_mgr_set_ctx( +sandesha2_inmemory_storage_mgr_set_ctx( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env, axis2_conf_ctx_t *conf_ctx) { - AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE); - - storage_mgr->conf_ctx = conf_ctx; + storage_mgr_impl->conf_ctx = conf_ctx; return AXIS2_SUCCESS; } axis2_conf_ctx_t *AXIS2_CALL -sandesha2_storage_mgr_get_ctx( +sandesha2_inmemory_storage_mgr_get_ctx( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env) { - AXIS2_ENV_CHECK(env, NULL); - - return storage_mgr->conf_ctx; + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + return storage_mgr_impl->conf_ctx; } axis2_status_t AXIS2_CALL -sandesha2_storage_mgr_init( +sandesha2_inmemory_storage_mgr_init( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env, axis2_conf_ctx_t *conf_ctx) { AXIS2_ENV_CHECK(env, AXIS2_FALSE); - sandesha2_storage_mgr_set_ctx(storage_mgr, env, conf_ctx); + sandesha2_inmemory_storage_mgr_set_ctx(storage_mgr, env, conf_ctx); return AXIS2_SUCCESS; } axis2_msg_ctx_t *AXIS2_CALL -sandesha2_storage_mgr_retrieve_msg_ctx( +sandesha2_inmemory_storage_mgr_retrieve_msg_ctx( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env, axis2_char_t *key, @@ -265,22 +386,21 @@ axis2_hash_t *storage_map = NULL; axis2_property_t *property = NULL; axis2_ctx_t *ctx = NULL; - - AXIS2_ENV_CHECK(env, AXIS2_FALSE); - - conf_ctx = sandesha2_storage_mgr_get_ctx(storage_mgr, env); + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + conf_ctx = sandesha2_inmemory_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->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); + 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); + return (axis2_msg_ctx_t *) axis2_hash_get(storage_map, key, + AXIS2_HASH_KEY_STRING); } axis2_status_t AXIS2_CALL -sandesha2_storage_mgr_store_msg_ctx( +sandesha2_inmemory_storage_mgr_store_msg_ctx( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env, axis2_char_t *key, @@ -290,13 +410,13 @@ axis2_property_t *property = NULL; axis2_conf_ctx_t *conf_ctx = NULL; axis2_ctx_t *ctx = NULL; - - AXIS2_ENV_CHECK(env, AXIS2_FALSE); + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); - conf_ctx = sandesha2_storage_mgr_get_ctx(storage_mgr, env); + conf_ctx = sandesha2_inmemory_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->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); + storage_mgr_impl->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); if(!property) { property = axis2_property_create(env); @@ -308,7 +428,7 @@ 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->SANDESHA2_MSG_MAP_KEY, + AXIS2_CTX_SET_PROPERTY(ctx, env, storage_mgr_impl->SANDESHA2_MSG_MAP_KEY, property, AXIS2_FALSE); } if(!key) @@ -321,7 +441,7 @@ } axis2_status_t AXIS2_CALL -sandesha2_storage_mgr_update_msg_ctx( +sandesha2_inmemory_storage_mgr_update_msg_ctx( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env, axis2_char_t *key, @@ -332,13 +452,12 @@ axis2_conf_ctx_t *conf_ctx = NULL; axis2_ctx_t *ctx = NULL; void *old_entry = NULL; - - AXIS2_ENV_CHECK(env, AXIS2_FALSE); - - conf_ctx = sandesha2_storage_mgr_get_ctx(storage_mgr, env); + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + conf_ctx = sandesha2_inmemory_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->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); + storage_mgr_impl->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); if(!property) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_STORAGE_MAP_NOT_PRESENT, @@ -359,11 +478,11 @@ AXIS2_FAILURE); return AXIS2_FAILURE; } - return sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, key, msg_ctx); + return sandesha2_inmemory_storage_mgr_store_msg_ctx(storage_mgr, env, key, msg_ctx); } axis2_status_t AXIS2_CALL -sandesha2_storage_mgr_remove_msg_ctx( +sandesha2_inmemory_storage_mgr_remove_msg_ctx( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env, axis2_char_t *key) @@ -373,13 +492,12 @@ axis2_conf_ctx_t *conf_ctx = NULL; axis2_ctx_t *ctx = NULL; void *entry = NULL; - - AXIS2_ENV_CHECK(env, AXIS2_FALSE); - - conf_ctx = sandesha2_storage_mgr_get_ctx(storage_mgr, env); + sandesha2_inmemory_storage_mgr_t *storage_mgr_impl = NULL; + storage_mgr_impl = SANDESHA2_INTF_TO_IMPL(storage_mgr); + conf_ctx = sandesha2_inmemory_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->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); + storage_mgr_impl->SANDESHA2_MSG_MAP_KEY, AXIS2_FALSE); if(!property) { AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_STORAGE_MAP_NOT_PRESENT, @@ -402,7 +520,7 @@ } axis2_status_t AXIS2_CALL -sandesha2_storage_mgr_init_storage( +sandesha2_inmemory_storage_mgr_init_storage( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env, axis2_module_desc_t *module_desc) @@ -411,7 +529,7 @@ } axiom_soap_envelope_t *AXIS2_CALL -sandesha2_storage_mgr_retrieve_soap_envelope( +sandesha2_inmemory_storage_mgr_retrieve_soap_envelope( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env, axis2_char_t *key) @@ -421,7 +539,7 @@ } axis2_status_t AXIS2_CALL -sandesha2_storage_mgr_store_soap_envelope( +sandesha2_inmemory_storage_mgr_store_soap_envelope( sandesha2_storage_mgr_t *storage_mgr, const axis2_env_t *env, axiom_soap_envelope_t *soap_env,
Copied: webservices/sandesha/trunk/c/src/storage/inmemory/inmemory_transaction.c (from r482886, webservices/sandesha/trunk/c/src/storage/inmemory/transaction.c) URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/inmemory/inmemory_transaction.c?view=diff&rev=483051&p1=webservices/sandesha/trunk/c/src/storage/inmemory/transaction.c&r1=482886&p2=webservices/sandesha/trunk/c/src/storage/inmemory/inmemory_transaction.c&r2=483051 ============================================================================== --- webservices/sandesha/trunk/c/src/storage/inmemory/transaction.c (original) +++ webservices/sandesha/trunk/c/src/storage/inmemory/inmemory_transaction.c Wed Dec 6 04:27:54 2006 @@ -14,105 +14,222 @@ * limitations under the License. */ +#include <sandesha2_inmemory_transaction.h> #include <sandesha2_transaction.h> #include <sandesha2_constants.h> #include <sandesha2_error.h> +#include <sandesha2_rm_bean.h> +#include <sandesha2_storage_mgr.h> #include <axis2_log.h> #include <axis2_hash.h> #include <axis2_thread.h> #include <axis2_property.h> +#include <platforms/axis2_platform_auto_sense.h> -typedef struct sandesha2_transaction_impl sandesha2_transaction_impl_t; +typedef struct sandesha2_inmemory_transaction_impl + sandesha2_inmemory_transaction_impl_t; /** - * @brief Sandesha Sequence Report Struct Impl - * Sandesha Sequence Report + * @brief Sandesha Inmemory Transaction Struct Impl + * Sandesha2 Inmemory Transaction */ -struct sandesha2_transaction_impl +struct sandesha2_inmemory_transaction_impl { - sandesha2_transaction_t transaction; - + sandesha2_transaction_t trans; + sandesha2_storage_mgr_t *storage_mgr; + axis2_array_list_t *enlisted_beans; + axis2_thread_mutex_t *mutex; }; -#define SANDESHA2_INTF_TO_IMPL(transaction) ((sandesha2_transaction_impl_t *) transaction) +#define SANDESHA2_INTF_TO_IMPL(trans) \ + ((sandesha2_inmemory_transaction_impl_t *) trans) -axis2_status_t AXIS2_CALL -sandesha2_transaction_free( - void *transaction, - const axis2_env_t *envv); - -axis2_status_t AXIS2_CALL -sandesha2_transaction_commit( - sandesha2_transaction_t *transaction, - const axis2_env_t *env); - -axis2_status_t AXIS2_CALL -sandesha2_transaction_rollback( - sandesha2_transaction_t *transaction, - const axis2_env_t *env); +static axis2_status_t +sandesha2_inmemory_transaction_free( + sandesha2_transaction_t *trans, + const axis2_env_t *env); + +static axis2_bool_t +sandesha2_inmemory_transaction_is_active( + sandesha2_transaction_t *trans, + const axis2_env_t *env); + +static void +sandesha2_inmemory_transaction_commit( + sandesha2_transaction_t *trans, + const axis2_env_t *env); + +static void +sandesha2_inmemory_transaction_rollback( + sandesha2_transaction_t *trans, + const axis2_env_t *env); + +static void +sandesha2_inmemory_transaction_enlist( + sandesha2_transaction_t *trans, + const axis2_env_t *env, + sandesha2_rm_bean_t *rm_bean); + +static void +sandesha2_inmemory_transaction_release_locks( + sandesha2_transaction_t *trans, + const axis2_env_t *env); + +static const sandesha2_transaction_ops_t transaction_ops = +{ + sandesha2_inmemory_transaction_free, + sandesha2_inmemory_transaction_is_active, + sandesha2_inmemory_transaction_commit, + sandesha2_inmemory_transaction_rollback, + sandesha2_inmemory_transaction_enlist +}; AXIS2_EXTERN sandesha2_transaction_t* AXIS2_CALL -sandesha2_transaction_create( - const axis2_env_t *env) +sandesha2_inmemory_transaction_create( + const axis2_env_t *env, + sandesha2_storage_mgr_t *storage_mgr) { - sandesha2_transaction_impl_t *transaction_impl = NULL; + sandesha2_inmemory_transaction_impl_t *trans_impl = NULL; AXIS2_ENV_CHECK(env, NULL); - transaction_impl = (sandesha2_transaction_impl_t *)AXIS2_MALLOC - (env->allocator, - sizeof(sandesha2_transaction_impl_t)); + trans_impl = (sandesha2_inmemory_transaction_impl_t *)AXIS2_MALLOC + (env->allocator, sizeof(sandesha2_inmemory_transaction_impl_t)); - transaction_impl->transaction.ops = AXIS2_MALLOC(env->allocator, - sizeof(sandesha2_transaction_ops_t)); + trans_impl->storage_mgr = storage_mgr; + trans_impl->enlisted_beans = NULL; + trans_impl->mutex = axis2_thread_mutex_create(env->allocator, + AXIS2_THREAD_MUTEX_DEFAULT); + trans_impl->trans.ops = AXIS2_MALLOC(env->allocator, + sizeof(sandesha2_transaction_ops_t)); - transaction_impl->transaction.ops->free = sandesha2_transaction_free; - transaction_impl->transaction.ops->commit = - sandesha2_transaction_commit; - transaction_impl->transaction.ops->rollback = - sandesha2_transaction_rollback; + trans_impl->trans.ops = &transaction_ops; - return &(transaction_impl->transaction); + return &(trans_impl->trans); } -axis2_status_t AXIS2_CALL -sandesha2_transaction_free( - void *transaction, - const axis2_env_t *env) +static axis2_status_t +sandesha2_inmemory_transaction_free( + sandesha2_transaction_t *trans, + const axis2_env_t *env) { - sandesha2_transaction_impl_t *transaction_impl = NULL; + sandesha2_inmemory_transaction_impl_t *trans_impl = NULL; AXIS2_ENV_CHECK(env, AXIS2_FAILURE); - transaction_impl = SANDESHA2_INTF_TO_IMPL(transaction); + trans_impl = SANDESHA2_INTF_TO_IMPL(trans); - if((&(transaction_impl->transaction))->ops) + if(trans_impl->mutex) + { + axis2_thread_mutex_destroy(trans_impl->mutex); + trans_impl->mutex = NULL; + } + if((&(trans_impl->trans))->ops) { - AXIS2_FREE(env->allocator, (&(transaction_impl->transaction))->ops); - (&(transaction_impl->transaction))->ops = NULL; + AXIS2_FREE(env->allocator, (&(trans_impl->trans))->ops); + (&(trans_impl->trans))->ops = NULL; } - - if(transaction_impl) + if(trans_impl->enlisted_beans) + { + AXIS2_ARRAY_LIST_FREE(trans_impl->enlisted_beans, env); + trans_impl->enlisted_beans = NULL; + } + if(trans_impl) { - AXIS2_FREE(env->allocator, transaction_impl); - transaction_impl = NULL; + AXIS2_FREE(env->allocator, trans_impl); + trans_impl = NULL; } return AXIS2_SUCCESS; } -axis2_status_t AXIS2_CALL -sandesha2_transaction_commit( - sandesha2_transaction_t *transaction, - const axis2_env_t *env) +static axis2_bool_t +sandesha2_inmemory_transaction_is_active( + sandesha2_transaction_t *trans, + const axis2_env_t *env) { - return AXIS2_SUCCESS; + sandesha2_inmemory_transaction_impl_t *trans_impl = NULL; + trans_impl = SANDESHA2_INTF_TO_IMPL(trans); + int size = 0; + if(trans_impl->enlisted_beans) + size = AXIS2_ARRAY_LIST_SIZE(trans_impl->enlisted_beans, env); + if(size > 0) + return AXIS2_TRUE; + else + return AXIS2_FALSE; } -axis2_status_t AXIS2_CALL -sandesha2_transaction_rollback( - sandesha2_transaction_t *transaction, - const axis2_env_t *env) +static void +sandesha2_inmemory_transaction_commit( + sandesha2_transaction_t *trans, + const axis2_env_t *env) { - return AXIS2_SUCCESS; + sandesha2_inmemory_transaction_release_locks(trans, env); } +static void +sandesha2_inmemory_transaction_rollback( + sandesha2_transaction_t *trans, + const axis2_env_t *env) +{ + sandesha2_inmemory_transaction_release_locks(trans, env); +} + +static void +sandesha2_inmemory_transaction_release_locks( + sandesha2_transaction_t *trans, + const axis2_env_t *env) +{ + sandesha2_inmemory_transaction_impl_t *trans_impl = NULL; + int i = 0, size = 0; + trans_impl = SANDESHA2_INTF_TO_IMPL(trans); + sandesha2_storage_mgr_remove_inmemory_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++) + { + sandesha2_rm_bean_t *rm_bean = (sandesha2_rm_bean_t *) + AXIS2_ARRAY_LIST_GET(trans_impl->enlisted_beans, env, i); + axis2_thread_mutex_lock(trans_impl->mutex); + sandesha2_rm_bean_set_transaction(rm_bean, env, NULL); + axis2_thread_mutex_unlock(trans_impl->mutex); + } + AXIS2_ARRAY_LIST_FREE(trans_impl->enlisted_beans, env); + trans_impl->enlisted_beans = NULL; +} + +static void +sandesha2_inmemory_transaction_enlist( + sandesha2_transaction_t *trans, + const axis2_env_t *env, + sandesha2_rm_bean_t *rm_bean) +{ + sandesha2_inmemory_transaction_impl_t *trans_impl = NULL; + trans_impl = SANDESHA2_INTF_TO_IMPL(trans); + if(rm_bean) + { + sandesha2_transaction_t *other = NULL; + axis2_thread_mutex_lock(trans_impl->mutex); + other = sandesha2_rm_bean_get_transaction(rm_bean, env); + while(other && other != trans) + { + int size = 0; + if(trans_impl->enlisted_beans) + size = AXIS2_ARRAY_LIST_SIZE(trans_impl->enlisted_beans, env); + if(size > 0) + { + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Possible deadlock"); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_POSSIBLE_DEADLOCK, + AXIS2_FAILURE); + AXIS2_SLEEP(6); + } + other = sandesha2_rm_bean_get_transaction(rm_bean, env); + } + if(!other) + { + sandesha2_rm_bean_set_transaction(rm_bean, env, trans); + AXIS2_ARRAY_LIST_ADD(trans_impl->enlisted_beans, env, rm_bean); + } + axis2_thread_mutex_unlock(trans_impl->mutex); + } +} Added: webservices/sandesha/trunk/c/src/storage/storage_mgr.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/storage_mgr.c?view=auto&rev=483051 ============================================================================== --- webservices/sandesha/trunk/c/src/storage/storage_mgr.c (added) +++ webservices/sandesha/trunk/c/src/storage/storage_mgr.c Wed Dec 6 04:27:54 2006 @@ -0,0 +1,202 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <sandesha2_storage_mgr.h> +#include <sandesha2_create_seq_mgr.h> +#include <sandesha2_invoker_mgr.h> +#include <sandesha2_next_msg_mgr.h> +#include <sandesha2_sender_mgr.h> +#include <sandesha2_seq_property_mgr.h> +#include <sandesha2_transaction.h> +#include <sandesha2_constants.h> +#include <sandesha2_error.h> +#include <sandesha2_utils.h> +#include <sandesha2_rm_bean.h> +#include <axis2_log.h> +#include <axis2_hash.h> +#include <axis2_thread.h> +#include <axis2_property.h> +#include <axis2_msg_ctx.h> +#include <axis2_uuid_gen.h> +#include <axis2_conf_ctx.h> + +axis2_status_t AXIS2_CALL +sandesha2_storage_mgr_free_void_arg( + void *storage_mgr, + const axis2_env_t *env) +{ + return ((sandesha2_storage_mgr_t *) storage_mgr)->ops->free_void_arg( + storage_mgr, env); +} + +axis2_status_t AXIS2_CALL +sandesha2_storage_mgr_free( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env) +{ + return storage_mgr->ops->free(storage_mgr, env); +} + +sandesha2_transaction_t *AXIS2_CALL +sandesha2_storage_mgr_get_transaction( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env) +{ + return storage_mgr->ops->get_transaction(storage_mgr, env); +} + +void AXIS2_CALL +sandesha2_storage_mgr_enlist_bean( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + sandesha2_rm_bean_t *rm_bean) +{ + return storage_mgr->ops->enlist_bean(storage_mgr, env, rm_bean); +} + +sandesha2_create_seq_mgr_t *AXIS2_CALL +sandesha2_storage_mgr_get_create_seq_mgr( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env) +{ + return storage_mgr->ops->get_create_seq_mgr(storage_mgr, env); +} + +sandesha2_next_msg_mgr_t *AXIS2_CALL +sandesha2_storage_mgr_get_next_msg_mgr( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env) +{ + return storage_mgr->ops->get_next_msg_mgr(storage_mgr, env); +} + +sandesha2_sender_mgr_t *AXIS2_CALL +sandesha2_storage_mgr_get_retrans_mgr( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env) +{ + return storage_mgr->ops->get_retrans_mgr(storage_mgr, env); +} + +sandesha2_seq_property_mgr_t *AXIS2_CALL +sandesha2_storage_mgr_get_seq_property_mgr( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env) +{ + return storage_mgr->ops->get_seq_property_mgr(storage_mgr, env); +} + +sandesha2_invoker_mgr_t *AXIS2_CALL +sandesha2_storage_mgr_get_storage_map_mgr( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env) +{ + return storage_mgr->ops->get_storage_map_mgr(storage_mgr, env); +} + +axis2_status_t AXIS2_CALL +sandesha2_storage_mgr_set_ctx( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axis2_conf_ctx_t *conf_ctx) +{ + return storage_mgr->ops->set_ctx(storage_mgr, env, conf_ctx); +} + +axis2_conf_ctx_t *AXIS2_CALL +sandesha2_storage_mgr_get_ctx( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env) +{ + return storage_mgr->ops->get_ctx(storage_mgr, env); +} + +axis2_status_t AXIS2_CALL +sandesha2_storage_mgr_init( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axis2_conf_ctx_t *conf_ctx) +{ + return storage_mgr->ops->init(storage_mgr, env, conf_ctx); +} + +axis2_msg_ctx_t *AXIS2_CALL +sandesha2_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) +{ + return storage_mgr->ops->retrieve_msg_ctx(storage_mgr, env, key, conf_ctx); +} + +axis2_status_t AXIS2_CALL +sandesha2_storage_mgr_store_msg_ctx( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axis2_char_t *key, + axis2_msg_ctx_t *msg_ctx) +{ + return storage_mgr->ops->store_msg_ctx(storage_mgr, env, key, msg_ctx); +} + +axis2_status_t AXIS2_CALL +sandesha2_storage_mgr_update_msg_ctx( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axis2_char_t *key, + axis2_msg_ctx_t *msg_ctx) +{ + return storage_mgr->ops->update_msg_ctx(storage_mgr, env, key, msg_ctx); +} + +axis2_status_t AXIS2_CALL +sandesha2_storage_mgr_remove_msg_ctx( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axis2_char_t *key) +{ + return storage_mgr->ops->remove_msg_ctx(storage_mgr, env, key); +} + +axis2_status_t AXIS2_CALL +sandesha2_storage_mgr_init_storage( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axis2_module_desc_t *module_desc) +{ + return storage_mgr->ops->init_storage(storage_mgr, env, module_desc); +} + +axiom_soap_envelope_t *AXIS2_CALL +sandesha2_storage_mgr_retrieve_soap_envelope( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axis2_char_t *key) +{ + return storage_mgr->ops->retrieve_soap_envelope(storage_mgr, env, key); +} + +axis2_status_t AXIS2_CALL +sandesha2_storage_mgr_store_soap_envelope( + sandesha2_storage_mgr_t *storage_mgr, + const axis2_env_t *env, + axiom_soap_envelope_t *soap_env, + axis2_char_t *key) +{ + return storage_mgr->ops->store_soap_envelope(storage_mgr, env, soap_env, key); +} + Added: webservices/sandesha/trunk/c/src/storage/transaction.c URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/src/storage/transaction.c?view=auto&rev=483051 ============================================================================== --- webservices/sandesha/trunk/c/src/storage/transaction.c (added) +++ webservices/sandesha/trunk/c/src/storage/transaction.c Wed Dec 6 04:27:54 2006 @@ -0,0 +1,68 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <sandesha2_transaction.h> +#include <sandesha2_constants.h> +#include <sandesha2_error.h> +#include <sandesha2_rm_bean.h> +#include <sandesha2_storage_mgr.h> +#include <axis2_log.h> +#include <axis2_hash.h> +#include <axis2_thread.h> +#include <axis2_property.h> +#include <platforms/axis2_platform_auto_sense.h> + +axis2_status_t AXIS2_CALL +sandesha2_transaction_free( + sandesha2_transaction_t *trans, + const axis2_env_t *env) +{ + return trans->ops->free (trans, env); +} + +axis2_bool_t AXIS2_CALL +sandesha2_transaction_is_active( + sandesha2_transaction_t *trans, + const axis2_env_t *env) +{ + return trans->ops->is_active(trans, env); +} + +void AXIS2_CALL +sandesha2_transaction_commit( + sandesha2_transaction_t *trans, + const axis2_env_t *env) +{ + trans->ops->commit(trans, env); +} + +void AXIS2_CALL +sandesha2_transaction_rollback( + sandesha2_transaction_t *trans, + const axis2_env_t *env) +{ + trans->ops->rollback(trans, env); +} + +void AXIS2_CALL +sandesha2_transaction_enlist( + sandesha2_transaction_t *trans, + const axis2_env_t *env, + sandesha2_rm_bean_t *rm_bean) +{ + trans->ops->rollback(trans, env); +} + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
