summaryrefslogtreecommitdiffstats
path: root/src/core/context
diff options
context:
space:
mode:
authorGravatar gmcdonald2010-02-13 01:32:03 +0000
committerGravatar gmcdonald2010-02-13 01:32:03 +0000
commit0425aadc78680e53000fd0108b540d6eca048516 (patch)
tree8ec7ab8e015d454c5ec586dfc91e05a2dce1cfc0 /src/core/context
downloadaxis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.gz
axis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.bz2
Moving axis svn, part of TLP move INFRA-2441
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/core/context')
-rw-r--r--src/core/context/Makefile.am13
-rw-r--r--src/core/context/conf_ctx.c599
-rw-r--r--src/core/context/ctx.c197
-rw-r--r--src/core/context/msg_ctx.c2768
-rw-r--r--src/core/context/op_ctx.c420
-rw-r--r--src/core/context/svc_ctx.c200
-rw-r--r--src/core/context/svc_grp_ctx.c256
7 files changed, 4453 insertions, 0 deletions
diff --git a/src/core/context/Makefile.am b/src/core/context/Makefile.am
new file mode 100644
index 0000000..30184e0
--- /dev/null
+++ b/src/core/context/Makefile.am
@@ -0,0 +1,13 @@
+noinst_LTLIBRARIES = libaxis2_context.la
+
+libaxis2_context_la_SOURCES = ctx.c \
+ msg_ctx.c \
+ op_ctx.c \
+ svc_ctx.c \
+ svc_grp_ctx.c \
+ conf_ctx.c
+
+INCLUDES = -I$(top_builddir)/include \
+ -I$(top_builddir)/src/core/engine \
+ -I$(top_builddir)/util/include \
+ -I$(top_builddir)/axiom/include
diff --git a/src/core/context/conf_ctx.c b/src/core/context/conf_ctx.c
new file mode 100644
index 0000000..9922649
--- /dev/null
+++ b/src/core/context/conf_ctx.c
@@ -0,0 +1,599 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <axis2_conf_ctx.h>
+#include <axis2_svc_grp.h>
+#include <axis2_const.h>
+#include <axutil_uuid_gen.h>
+
+
+struct axis2_conf_ctx
+{
+
+ /** base context struct */
+ axis2_ctx_t *base;
+
+ /** engine configuration */
+ axis2_conf_t *conf;
+
+ /** root directory */
+ /* should be handled as a URL string ? */
+ axis2_char_t *root_dir;
+
+ /**
+ * axutil_hash_t *containing message ID to
+ * operation context mapping.
+ */
+ axutil_hash_t *op_ctx_map;
+
+ axutil_hash_t *svc_ctx_map;
+
+ axutil_hash_t *svc_grp_ctx_map;
+
+ /* Mutex to synchronize the read/write operations */
+ axutil_thread_mutex_t *mutex;
+};
+
+AXIS2_EXTERN axis2_conf_ctx_t *AXIS2_CALL
+axis2_conf_ctx_create(
+ const axutil_env_t * env,
+ axis2_conf_t * conf)
+{
+ axis2_conf_ctx_t *conf_ctx = NULL;
+
+ conf_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_conf_ctx_t));
+ if(!conf_ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
+ return NULL;
+ }
+
+ conf_ctx->base = NULL;
+ conf_ctx->conf = NULL;
+ conf_ctx->root_dir = NULL;
+ conf_ctx->op_ctx_map = NULL;
+ conf_ctx->svc_ctx_map = NULL;
+ conf_ctx->svc_grp_ctx_map = NULL;
+ conf_ctx->mutex = axutil_thread_mutex_create(env->allocator, AXIS2_THREAD_MUTEX_DEFAULT);
+ if(!conf_ctx->mutex)
+ {
+ axis2_conf_ctx_free(conf_ctx, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not create thread mutex");
+ return NULL;
+ }
+
+ if(conf)
+ conf_ctx->conf = conf;
+
+ conf_ctx->base = axis2_ctx_create(env);
+ if(!(conf_ctx->base))
+ {
+ axis2_conf_ctx_free(conf_ctx, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not create base context");
+ return NULL;
+ }
+
+ conf_ctx->op_ctx_map = axutil_hash_make(env);
+ if(!(conf_ctx->op_ctx_map))
+ {
+ axis2_conf_ctx_free(conf_ctx, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not create operation context map");
+ return NULL;
+ }
+
+ conf_ctx->svc_ctx_map = axutil_hash_make(env);
+ if(!(conf_ctx->svc_ctx_map))
+ {
+ axis2_conf_ctx_free(conf_ctx, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not create service context map");
+ return NULL;
+ }
+
+ conf_ctx->svc_grp_ctx_map = axutil_hash_make(env);
+ if(!(conf_ctx->svc_grp_ctx_map))
+ {
+ axis2_conf_ctx_free(conf_ctx, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not create service group context map");
+ return NULL;
+ }
+
+ return conf_ctx;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_ctx_set_conf(
+ axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ axis2_conf_t * conf)
+{
+ conf_ctx->conf = conf; /* We just maintain a shallow copy here */
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_ctx_t *AXIS2_CALL
+axis2_conf_ctx_get_base(
+ const axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env)
+{
+ return conf_ctx->base;
+}
+
+AXIS2_EXTERN axis2_conf_t *AXIS2_CALL
+axis2_conf_ctx_get_conf(
+ const axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env)
+{
+ return conf_ctx->conf;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_conf_ctx_get_op_ctx_map(
+ const axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env)
+{
+ return conf_ctx->op_ctx_map;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_conf_ctx_get_svc_ctx_map(
+ const axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env)
+{
+ return conf_ctx->svc_ctx_map;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_conf_ctx_get_svc_grp_ctx_map(
+ const axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env)
+{
+ return conf_ctx->svc_grp_ctx_map;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_ctx_register_op_ctx(
+ axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * message_id,
+ axis2_op_ctx_t * op_ctx)
+{
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ if(conf_ctx->op_ctx_map)
+ {
+ axutil_hash_set(conf_ctx->op_ctx_map, message_id, AXIS2_HASH_KEY_STRING, op_ctx);
+ }
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_op_ctx_t *AXIS2_CALL
+axis2_conf_ctx_get_op_ctx(
+ const axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * message_id)
+{
+ axis2_op_ctx_t *rv = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, message_id, NULL);
+
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ if(conf_ctx->op_ctx_map)
+ {
+ rv = (axis2_op_ctx_t *)axutil_hash_get(conf_ctx->op_ctx_map, message_id,
+ AXIS2_HASH_KEY_STRING);
+ }
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+ return rv;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_ctx_register_svc_ctx(
+ axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_id,
+ axis2_svc_ctx_t * svc_ctx)
+{
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ if(conf_ctx->svc_ctx_map)
+ {
+ axutil_hash_set(conf_ctx->svc_ctx_map, svc_id, AXIS2_HASH_KEY_STRING, svc_ctx);
+ }
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_svc_ctx_t *AXIS2_CALL
+axis2_conf_ctx_get_svc_ctx(
+ const axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_id)
+{
+ axis2_svc_ctx_t *rv = NULL;
+
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ if(conf_ctx->svc_ctx_map)
+ {
+ rv = (axis2_svc_ctx_t *)axutil_hash_get(conf_ctx->svc_ctx_map, svc_id,
+ AXIS2_HASH_KEY_STRING);
+ }
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+ return rv;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_ctx_register_svc_grp_ctx(
+ axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_grp_id,
+ axis2_svc_grp_ctx_t * svc_grp_ctx)
+{
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ if(conf_ctx->svc_grp_ctx_map)
+ {
+ axutil_hash_set(conf_ctx->svc_grp_ctx_map, svc_grp_id, AXIS2_HASH_KEY_STRING, svc_grp_ctx);
+ }
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_svc_grp_ctx_t *AXIS2_CALL
+axis2_conf_ctx_get_svc_grp_ctx(
+ const axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_grp_id)
+{
+ axis2_svc_grp_ctx_t *rv = NULL;
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ if(conf_ctx->svc_grp_ctx_map)
+ {
+ rv = (axis2_svc_grp_ctx_t *)axutil_hash_get(conf_ctx->svc_grp_ctx_map, svc_grp_id,
+ AXIS2_HASH_KEY_STRING);
+ }
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+ return rv;
+}
+
+AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
+axis2_conf_ctx_get_root_dir(
+ const axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env)
+{
+ axis2_char_t *rv = NULL;
+ /* Do we need to lock here? - damitha */
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ rv = conf_ctx->root_dir;
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+ return rv;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_ctx_set_root_dir(
+ axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * path)
+{
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ if(conf_ctx->root_dir)
+ {
+ AXIS2_FREE(env->allocator, conf_ctx->root_dir);
+ conf_ctx->root_dir = NULL;
+ }
+
+ if(path)
+ {
+ conf_ctx->root_dir = axutil_strdup(env, path);
+ if(!(conf_ctx->root_dir))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
+ return AXIS2_FAILURE;
+ }
+ }
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_ctx_init(
+ axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ axis2_conf_t * conf)
+{
+ axutil_hash_index_t *hi = NULL;
+ void *ctx = NULL;
+
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ conf_ctx->conf = conf;
+
+ for(hi = axutil_hash_first(conf_ctx->op_ctx_map, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axutil_hash_this(hi, NULL, NULL, &ctx);
+ if(ctx)
+ {
+ axis2_op_ctx_t *op_ctx = (axis2_op_ctx_t *)ctx;
+ axis2_op_ctx_init(op_ctx, env, conf);
+ }
+ }
+
+ for(hi = axutil_hash_first(conf_ctx->svc_ctx_map, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axutil_hash_this(hi, NULL, NULL, &ctx);
+ if(ctx)
+ {
+ axis2_svc_ctx_t *svc_ctx = (axis2_svc_ctx_t *)ctx;
+ axis2_svc_ctx_init(svc_ctx, env, conf);
+ }
+ }
+
+ for(hi = axutil_hash_first(conf_ctx->svc_grp_ctx_map, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axutil_hash_this(hi, NULL, NULL, &ctx);
+ if(ctx)
+ {
+ axis2_svc_grp_ctx_t *svc_grp_ctx = (axis2_svc_grp_ctx_t *)ctx;
+ axis2_svc_grp_ctx_init(svc_grp_ctx, env, conf);
+ }
+ }
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_conf_ctx_free(
+ axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env)
+{
+ if(conf_ctx->base)
+ {
+ axis2_ctx_free(conf_ctx->base, env);
+ }
+
+ if(conf_ctx->op_ctx_map)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ for(hi = axutil_hash_first(conf_ctx->op_ctx_map, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axis2_op_ctx_t *op_ctx = NULL;
+ axutil_hash_this(hi, NULL, NULL, &val);
+ op_ctx = (axis2_op_ctx_t *)val;
+ if(op_ctx)
+ axis2_op_ctx_free(op_ctx, env);
+ val = NULL;
+ op_ctx = NULL;
+
+ }
+ axutil_hash_free(conf_ctx->op_ctx_map, env);
+ }
+
+ if(conf_ctx->svc_ctx_map)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ for(hi = axutil_hash_first(conf_ctx->svc_ctx_map, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axutil_hash_this(hi, NULL, NULL, &val);
+ svc_ctx = (axis2_svc_ctx_t *)val;
+ if(svc_ctx)
+ axis2_svc_ctx_free(svc_ctx, env);
+
+ val = NULL;
+ svc_ctx = NULL;
+
+ }
+ axutil_hash_free(conf_ctx->svc_ctx_map, env);
+ }
+
+ if(conf_ctx->svc_grp_ctx_map)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ for(hi = axutil_hash_first(conf_ctx->svc_grp_ctx_map, env); hi; hi = axutil_hash_next(env,
+ hi))
+ {
+ axis2_svc_grp_ctx_t *svc_grp_ctx = NULL;
+ axutil_hash_this(hi, NULL, NULL, &val);
+ svc_grp_ctx = (axis2_svc_grp_ctx_t *)val;
+ if(svc_grp_ctx)
+ axis2_svc_grp_ctx_free(svc_grp_ctx, env);
+
+ val = NULL;
+ svc_grp_ctx = NULL;
+
+ }
+ axutil_hash_free(conf_ctx->svc_grp_ctx_map, env);
+ }
+ if(conf_ctx->conf)
+ {
+ axis2_conf_free(conf_ctx->conf, env);
+ }
+ if(conf_ctx->mutex)
+ {
+ axutil_thread_mutex_destroy(conf_ctx->mutex);
+ }
+
+ if(conf_ctx->root_dir)
+ {
+ AXIS2_FREE(env->allocator, conf_ctx->root_dir);
+ }
+
+ AXIS2_FREE(env->allocator, conf_ctx);
+}
+
+AXIS2_EXTERN axis2_svc_grp_ctx_t *AXIS2_CALL
+axis2_conf_ctx_fill_ctxs(
+ axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_char_t *svc_grp_ctx_id = NULL;
+ axis2_svc_grp_ctx_t *svc_grp_ctx = NULL;
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axis2_svc_t *svc = NULL;
+ axis2_svc_grp_t *svc_grp = NULL;
+ const axutil_qname_t *qname = NULL;
+ axis2_char_t *svc_id = NULL;
+ axis2_op_ctx_t *op_ctx = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+
+ svc = axis2_msg_ctx_get_svc(msg_ctx, env);
+ if(!svc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SERVICE_NOT_YET_FOUND, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Service not yet found in message context. Cannot proceed");
+
+ return NULL;
+ }
+
+ qname = axis2_svc_get_qname(svc, env);
+ if(!qname)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service found in message context has no name.");
+ return NULL;
+ }
+
+ svc_id = axutil_qname_get_localpart(qname, env);
+ if(!svc_id)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service found in message context has no name.");
+ return NULL;
+ }
+
+ svc_grp = axis2_svc_get_parent(svc, env);
+ if(svc_grp)
+ {
+ svc_grp_ctx_id = (axis2_char_t *)axis2_svc_grp_get_name(svc_grp, env);
+ }
+
+ if(!svc_grp_ctx_id)
+ {
+ svc_grp_ctx_id = (axis2_char_t *)axutil_string_get_buffer(axis2_msg_ctx_get_svc_grp_ctx_id(
+ msg_ctx, env), env);
+ }
+
+ /* By this time service group context id must have a value, either from transport or from
+ * addressing
+ */
+ if(svc_grp_ctx_id)
+ {
+ svc_grp_ctx = (axis2_svc_grp_ctx_t *)axutil_hash_get(conf_ctx->svc_grp_ctx_map,
+ svc_grp_ctx_id, AXIS2_HASH_KEY_STRING);
+
+ if(svc_grp_ctx)
+ {
+ svc_ctx = axis2_svc_grp_ctx_get_svc_ctx(svc_grp_ctx, env, svc_id);
+ if(!svc_ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC_GRP, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Service group context has no servie context set for service %s", svc_id);
+
+ return NULL;
+ }
+ }
+ }
+
+ if(!svc_grp_ctx_id)
+ {
+ svc_grp_ctx_id = axutil_uuid_gen(env);
+ if(svc_grp_ctx_id)
+ {
+ axutil_string_t *svc_grp_ctx_id_str = axutil_string_create_assume_ownership(env,
+ &svc_grp_ctx_id);
+
+ axis2_msg_ctx_set_svc_grp_ctx_id(msg_ctx, env, svc_grp_ctx_id_str);
+ axutil_string_free(svc_grp_ctx_id_str, env);
+ }
+ }
+
+ if(!svc_grp_ctx)
+ {
+ axis2_svc_grp_t *svc_grp = NULL;
+ svc_grp = axis2_svc_get_parent(svc, env);
+ svc_grp_ctx = axis2_svc_grp_get_svc_grp_ctx(svc_grp, env, conf_ctx);
+ svc_ctx = axis2_svc_grp_ctx_get_svc_ctx(svc_grp_ctx, env, svc_id);
+ if(!svc_ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC_GRP, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Service group context has no servie context set for service %s", svc_id);
+
+ return NULL;
+ }
+
+ axis2_svc_grp_ctx_set_id(svc_grp_ctx, env, svc_grp_ctx_id);
+ axis2_conf_ctx_register_svc_grp_ctx(conf_ctx, env, svc_grp_ctx_id, svc_grp_ctx);
+ }
+
+ /* When you come here operation context MUST have already been assigned
+ to the message context */
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if(!op_ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_MSG_CTX, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Operation context not set for message context");
+ return NULL;
+ }
+
+ axis2_op_ctx_set_parent(op_ctx, env, svc_ctx);
+ axis2_msg_ctx_set_svc_ctx(msg_ctx, env, svc_ctx);
+ axis2_msg_ctx_set_svc_grp_ctx(msg_ctx, env, svc_grp_ctx);
+ return svc_grp_ctx;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_ctx_set_property(
+ axis2_conf_ctx_t *conf_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * key,
+ axutil_property_t * value)
+{
+ axis2_status_t status = AXIS2_FAILURE;
+ AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, key, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE);
+
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ status = axis2_ctx_set_property(conf_ctx->base, env, key, value);
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+
+ return status;
+}
+
+AXIS2_EXTERN axutil_property_t *AXIS2_CALL
+axis2_conf_ctx_get_property(
+ const axis2_conf_ctx_t * conf_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * key)
+{
+ axutil_property_t* property = NULL;
+ AXIS2_PARAM_CHECK(env->error, conf_ctx, NULL);
+ AXIS2_PARAM_CHECK(env->error, key, NULL);
+
+ axutil_thread_mutex_lock(conf_ctx->mutex);
+ property = axis2_ctx_get_property(conf_ctx->base, env, key);
+ axutil_thread_mutex_unlock(conf_ctx->mutex);
+
+ return property;
+}
diff --git a/src/core/context/ctx.c b/src/core/context/ctx.c
new file mode 100644
index 0000000..df39a9b
--- /dev/null
+++ b/src/core/context/ctx.c
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <axis2_ctx.h>
+#include <axis2_const.h>
+#include <axutil_hash.h>
+
+struct axis2_ctx
+{
+
+ /** non persistent map */
+ axutil_hash_t *property_map;
+
+ /** non persistent map is a deep copy */
+ axis2_bool_t property_map_deep_copy;
+};
+
+AXIS2_EXTERN axis2_ctx_t *AXIS2_CALL
+axis2_ctx_create(
+ const axutil_env_t * env)
+{
+ axis2_ctx_t *ctx = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_ctx_t));
+ if(!ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ ctx->property_map = NULL;
+
+ ctx->property_map = axutil_hash_make(env);
+ ctx->property_map_deep_copy = AXIS2_TRUE;
+ if(!(ctx->property_map))
+ {
+ axis2_ctx_free(ctx, env);
+ return NULL;
+ }
+
+ return ctx;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_ctx_set_property(
+ struct axis2_ctx * ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * key,
+ axutil_property_t * value)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ if(value)
+ {
+ /* handle the case where we are setting a new value with the
+ same key, we would have to free the existing value */
+ axutil_property_t *temp_value = axutil_hash_get(ctx->property_map, key,
+ AXIS2_HASH_KEY_STRING);
+ if(temp_value)
+ {
+ void *temp_value_value = axutil_property_get_value(temp_value, env);
+ void *value_value = axutil_property_get_value(value, env);
+ if(temp_value_value != value_value)
+ {
+ axutil_property_free(temp_value, env);
+ }
+ }
+ }
+ if(ctx->property_map)
+ {
+ axutil_hash_set(ctx->property_map, key, AXIS2_HASH_KEY_STRING, value);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_property_t *AXIS2_CALL
+axis2_ctx_get_property(
+ const axis2_ctx_t * ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * key)
+{
+ axutil_property_t *ret = NULL;
+
+ if(ctx->property_map)
+ {
+ ret = axutil_hash_get(ctx->property_map, key, AXIS2_HASH_KEY_STRING);
+ }
+
+ /** it is the responsibility of the caller to look-up parent if key is not found here
+ Note that in C implementation it is the responsibility of the deriving struct to
+ handle the parent as we do not have the inheritance facility. In case of
+ context it is not worth trying to mimic inheritance. */
+
+ return ret;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_ctx_get_all_properties(
+ const axis2_ctx_t * ctx,
+ const axutil_env_t * env)
+{
+ return ctx->property_map;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_ctx_get_property_map(
+ const axis2_ctx_t * ctx,
+ const axutil_env_t * env)
+{
+ return ctx->property_map;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_ctx_free(
+ struct axis2_ctx *ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_ENV_CHECK(env, void);
+
+ if(ctx->property_map && ctx->property_map_deep_copy)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ const void *key = NULL;
+ for(hi = axutil_hash_first(ctx->property_map, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axutil_property_t *property = NULL;
+
+ axutil_hash_this(hi, &key, NULL, &val);
+ property = (axutil_property_t *)val;
+
+ if(property)
+ {
+ axutil_property_free(property, env);
+ }
+ }
+ axutil_hash_free(ctx->property_map, env);
+ }
+
+ AXIS2_FREE(env->allocator, ctx);
+
+ return;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_ctx_set_property_map(
+ struct axis2_ctx * ctx,
+ const axutil_env_t * env,
+ axutil_hash_t * map)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ if(ctx->property_map && ctx->property_map_deep_copy)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ const void *key = NULL;
+ for(hi = axutil_hash_first(ctx->property_map, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axutil_property_t *property = NULL;
+
+ axutil_hash_this(hi, &key, NULL, &val);
+ property = (axutil_property_t *)val;
+
+ if(property)
+ {
+ axutil_property_free(property, env);
+ }
+ }
+ if(ctx->property_map != map) /* handle repeated invocation case */
+ {
+ axutil_hash_free(ctx->property_map, env);
+ }
+ }
+
+ ctx->property_map = map;
+ ctx->property_map_deep_copy = AXIS2_FALSE;
+
+ return AXIS2_SUCCESS;
+}
diff --git a/src/core/context/msg_ctx.c b/src/core/context/msg_ctx.c
new file mode 100644
index 0000000..c2342c4
--- /dev/null
+++ b/src/core/context/msg_ctx.c
@@ -0,0 +1,2768 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <axis2_msg_ctx.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_op.h>
+#include <axis2_svc.h>
+#include <axis2_svc_grp.h>
+#include <axis2_conf.h>
+#include <axis2_transport_in_desc.h>
+#include <axis2_transport_out_desc.h>
+#include <axis2_out_transport_info.h>
+#include <axis2_http_accept_record.h>
+#include <axis2_http_header.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_const.h>
+#include <axis2_options.h>
+
+
+struct axis2_msg_ctx
+{
+
+ /** base context struct */
+ axis2_ctx_t *base;
+
+ /** parent of message context is an op context instance */
+ struct axis2_op_ctx *parent;
+
+ /** process fault enabled? */
+ axis2_bool_t process_fault;
+
+ /**
+ * Addressing Information for Axis 2
+ * Following Properties will be kept inside this, these fields will be initially filled by
+ * the transport. Then later an addressing handler will make relevant changes to this, if addressing
+ * information is present in the SOAP header.
+ */
+ axis2_msg_info_headers_t *msg_info_headers;
+ axis2_bool_t msg_info_headers_deep_copy;
+
+ struct axis2_op_ctx *op_ctx;
+ struct axis2_svc_ctx *svc_ctx;
+ struct axis2_svc_grp_ctx *svc_grp_ctx;
+ struct axis2_conf_ctx *conf_ctx;
+
+ /** op */
+ axis2_op_t *op;
+
+ /** service */
+ axis2_svc_t *svc;
+
+ /** service group */
+ axis2_svc_grp_t *svc_grp;
+
+ axis2_transport_in_desc_t *transport_in_desc;
+ axis2_transport_out_desc_t *transport_out_desc;
+
+ /** SOAP envelope */
+ axiom_soap_envelope_t *soap_envelope;
+
+ /** Response SOAP envelope */
+ axiom_soap_envelope_t *response_soap_envelope;
+
+ /** SOAP Fault envelope */
+ axiom_soap_envelope_t *fault_soap_envelope;
+
+ /** in fault flow? */
+ axis2_bool_t in_fault_flow;
+
+ /** is this server side? */
+ axis2_bool_t server_side;
+
+ /** message ID */
+ axis2_char_t *message_id;
+
+ /** new thread required? */
+ axis2_bool_t new_thread_required;
+
+ /** paused */
+ axis2_bool_t paused;
+ axis2_bool_t keep_alive;
+
+ /** output written? */
+ axis2_bool_t output_written;
+
+ /** service context ID */
+ axis2_char_t *svc_ctx_id;
+
+ /** paused phase name */
+ axis2_char_t *paused_phase_name;
+
+ /** paused handler name */
+ axutil_string_t *paused_handler_name;
+
+ /** SOAP action */
+ axutil_string_t *soap_action;
+
+ /** REST HTTP Method */
+ axis2_char_t *rest_http_method;
+
+ /**
+ * Supported REST HTTP Methods
+ * Made use of in a 405 Error Scenario
+ */
+ axutil_array_list_t *supported_rest_http_methods;
+
+ /** are we doing MTOM now? */
+ axis2_bool_t doing_mtom;
+
+ /** are we doing REST now? */
+ axis2_bool_t doing_rest;
+
+ /** Rest through HTTP POST? */
+ axis2_bool_t do_rest_through_post;
+
+ /** Session management enabled? */
+ axis2_bool_t manage_session;
+
+ /* http status code */
+ int status_code;
+
+ /** use SOAP 1.1? */
+ axis2_bool_t is_soap_11;
+
+ /** service group context id */
+ axutil_string_t *svc_grp_ctx_id;
+
+ /** qname of transport in */
+ AXIS2_TRANSPORT_ENUMS transport_in_desc_enum;
+
+ /** qname of transport out */
+ AXIS2_TRANSPORT_ENUMS transport_out_desc_enum;
+
+ /** service group id */
+ axis2_char_t *svc_grp_id;
+
+ /** service description qname */
+ axutil_qname_t *svc_qname;
+
+ /** op qname */
+ axutil_qname_t *op_qname;
+ /* To keep track of the direction */
+ int flow;
+
+ /** The chain of Handlers/Phases for processing this message */
+ axutil_array_list_t *execution_chain;
+
+ /** Index into the execution chain of the currently executing handler */
+ int current_handler_index;
+
+ /** Index of the paused handler */
+ int paused_handler_index;
+
+ /** Index of the paused phase */
+ int paused_phase_index;
+
+ /** Index into the current Phase of the currently executing handler (if any)*/
+ int current_phase_index;
+
+ /* axis2 options container */
+
+ axis2_options_t *options;
+
+ /**
+ * Finds the service to be invoked. This function is used by dispatchers
+ * to locate the service to be invoked.
+ * @param msg_ctx message context
+ * @param env pointer to environment struct
+ * @return pointer to service to be invoked
+ */
+ struct axis2_svc *
+ (
+ AXIS2_CALL * find_svc)
+ (
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env);
+
+ /**
+ * Finds the operation to be invoked in the given service. This function
+ * is used by dispatchers to locate the operation to be invoked.
+ * @param msg_ctx message context
+ * @param env pointer to environment struct
+ * @param svc pointer to service to whom the operation belongs
+ * @return pointer to the operation to be invoked
+ */
+ struct axis2_op *
+ (
+ AXIS2_CALL * find_op)
+ (
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ struct axis2_svc * svc);
+
+ axutil_string_t *charset_encoding;
+ axutil_stream_t *transport_out_stream;
+ axis2_out_transport_info_t *out_transport_info;
+ axutil_hash_t *transport_headers;
+ axutil_array_list_t *output_headers;
+ axutil_array_list_t *accept_record_list;
+ axutil_array_list_t *accept_charset_record_list;
+ axutil_array_list_t *accept_language_record_list;
+ axis2_char_t *transfer_encoding;
+ axis2_char_t *content_language;
+ axis2_char_t *transport_url;
+ axis2_bool_t is_auth_failure;
+ axis2_bool_t required_auth_is_http;
+ axis2_char_t *auth_type;
+ axis2_bool_t no_content;
+
+ axutil_array_list_t *mime_parts;
+ int ref;
+};
+
+AXIS2_EXTERN axis2_msg_ctx_t *AXIS2_CALL
+axis2_msg_ctx_create(
+ const axutil_env_t * env,
+ struct axis2_conf_ctx *conf_ctx,
+ struct axis2_transport_in_desc *transport_in_desc,
+ struct axis2_transport_out_desc *transport_out_desc)
+{
+ axis2_msg_ctx_t *msg_ctx = NULL;
+
+ msg_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_msg_ctx_t));
+ if(!msg_ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ memset((void *)msg_ctx, 0, sizeof(axis2_msg_ctx_t));
+ msg_ctx->base = NULL;
+ msg_ctx->process_fault = AXIS2_FALSE;
+ msg_ctx->msg_info_headers = NULL;
+ msg_ctx->op_ctx = NULL;
+ msg_ctx->svc_ctx = NULL;
+ msg_ctx->svc_grp_ctx = NULL;
+ msg_ctx->conf_ctx = NULL;
+ msg_ctx->op = NULL;
+ msg_ctx->svc = NULL;
+ msg_ctx->svc_grp = NULL;
+ msg_ctx->transport_in_desc = NULL;
+ msg_ctx->transport_out_desc = NULL;
+ msg_ctx->soap_envelope = NULL;
+ msg_ctx->fault_soap_envelope = NULL;
+ msg_ctx->in_fault_flow = AXIS2_FALSE;
+ msg_ctx->server_side = AXIS2_FALSE;
+ msg_ctx->message_id = NULL;
+ msg_ctx->new_thread_required = AXIS2_FALSE;
+ msg_ctx->paused = AXIS2_FALSE;
+ msg_ctx->keep_alive = AXIS2_FALSE;
+ msg_ctx->output_written = AXIS2_FALSE;
+ msg_ctx->svc_ctx_id = NULL;
+ msg_ctx->paused_phase_name = NULL;
+ msg_ctx->paused_handler_name = NULL;
+ msg_ctx->soap_action = NULL;
+ msg_ctx->rest_http_method = NULL;
+ msg_ctx->supported_rest_http_methods = NULL;
+ msg_ctx->doing_mtom = AXIS2_FALSE;
+ msg_ctx->doing_rest = AXIS2_FALSE;
+ msg_ctx->do_rest_through_post = AXIS2_FALSE;
+ msg_ctx->manage_session = AXIS2_FALSE;
+ msg_ctx->is_soap_11 = AXIS2_FALSE;
+ msg_ctx->svc_grp_ctx_id = NULL;
+ msg_ctx->transport_in_desc_enum = AXIS2_TRANSPORT_ENUM_MAX;
+ msg_ctx->transport_out_desc_enum = AXIS2_TRANSPORT_ENUM_MAX;
+ msg_ctx->svc_grp_id = NULL;
+ msg_ctx->svc_qname = NULL;
+ msg_ctx->op_qname = NULL;
+ msg_ctx->flow = AXIS2_IN_FLOW;
+ msg_ctx->execution_chain = NULL;
+ msg_ctx->current_handler_index = -1;
+ msg_ctx->paused_handler_index = -1;
+ msg_ctx->current_phase_index = 0;
+ msg_ctx->paused_phase_index = 0;
+ msg_ctx->charset_encoding = NULL;
+ msg_ctx->transport_out_stream = NULL;
+ msg_ctx->out_transport_info = NULL;
+ msg_ctx->transport_headers = NULL;
+ msg_ctx->accept_record_list = NULL;
+ msg_ctx->accept_charset_record_list = NULL;
+ msg_ctx->output_headers = NULL;
+ msg_ctx->accept_language_record_list = NULL;
+ msg_ctx->transfer_encoding = NULL;
+ msg_ctx->content_language = NULL;
+ msg_ctx->transport_url = NULL;
+ msg_ctx->response_soap_envelope = NULL;
+ msg_ctx->is_auth_failure = AXIS2_FALSE;
+ msg_ctx->required_auth_is_http = AXIS2_FALSE;
+ msg_ctx->auth_type = NULL;
+ msg_ctx->no_content = AXIS2_FALSE;
+ msg_ctx->status_code = 0;
+ msg_ctx->options = NULL;
+ msg_ctx->mime_parts = NULL;
+
+ msg_ctx->base = axis2_ctx_create(env);
+ if(!(msg_ctx->base))
+ {
+ axis2_msg_ctx_free(msg_ctx, env);
+ return NULL;
+ }
+
+ if(transport_in_desc)
+ msg_ctx->transport_in_desc = transport_in_desc;
+ if(transport_out_desc)
+ msg_ctx->transport_out_desc = transport_out_desc;
+ if(conf_ctx)
+ msg_ctx->conf_ctx = conf_ctx;
+
+ if(msg_ctx->transport_in_desc)
+ msg_ctx->transport_in_desc_enum = axis2_transport_in_desc_get_enum(transport_in_desc, env);
+ if(msg_ctx->transport_out_desc)
+ msg_ctx->transport_out_desc_enum = axis2_transport_out_desc_get_enum(transport_out_desc,
+ env);
+
+ msg_ctx->msg_info_headers = axis2_msg_info_headers_create(env, NULL, NULL);
+ if(!(msg_ctx->msg_info_headers))
+ {
+ axis2_msg_ctx_free(msg_ctx, env);
+ return NULL;
+ }
+ msg_ctx->msg_info_headers_deep_copy = AXIS2_TRUE;
+ msg_ctx->ref = 1;
+
+ return msg_ctx;
+}
+
+/******************************************************************************/
+struct axis2_ctx *AXIS2_CALL
+axis2_msg_ctx_get_base(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ return msg_ctx->base;
+}
+
+struct axis2_op_ctx *AXIS2_CALL
+axis2_msg_ctx_get_parent(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->parent;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_parent(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ struct axis2_op_ctx * parent)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(parent)
+ {
+ msg_ctx->parent = parent;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+void AXIS2_CALL
+axis2_msg_ctx_free(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(--(msg_ctx->ref) > 0)
+ {
+ return;
+ }
+
+ if(msg_ctx->keep_alive)
+ {
+ return;
+ }
+
+ if(msg_ctx->base)
+ {
+ axis2_ctx_free(msg_ctx->base, env);
+ }
+
+ if(msg_ctx->msg_info_headers && msg_ctx->msg_info_headers_deep_copy)
+ {
+ axis2_msg_info_headers_free(msg_ctx->msg_info_headers, env);
+ }
+
+ if(msg_ctx->message_id)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->message_id);
+ }
+
+ if(msg_ctx->svc_ctx_id)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->svc_ctx_id);
+ }
+
+ if(msg_ctx->soap_action)
+ {
+ axutil_string_free(msg_ctx->soap_action, env);
+ }
+
+ if(msg_ctx->rest_http_method)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->rest_http_method);
+ }
+
+ if(msg_ctx->svc_grp_ctx_id)
+ {
+ axutil_string_free(msg_ctx->svc_grp_ctx_id, env);
+ }
+
+ if(msg_ctx->soap_envelope)
+ {
+ axiom_soap_envelope_free(msg_ctx->soap_envelope, env);
+ }
+
+ if(msg_ctx->fault_soap_envelope)
+ {
+ axiom_soap_envelope_free(msg_ctx->fault_soap_envelope, env);
+ }
+
+ if(msg_ctx->charset_encoding)
+ {
+ axutil_string_free(msg_ctx->charset_encoding, env);
+ }
+
+ if(msg_ctx->transport_out_stream)
+ {
+ axutil_stream_free(msg_ctx->transport_out_stream, env);
+ }
+
+ if(msg_ctx->out_transport_info)
+ {
+ AXIS2_OUT_TRANSPORT_INFO_FREE(msg_ctx->out_transport_info, env);
+ }
+
+ if(msg_ctx->transport_headers)
+ {
+ axutil_hash_free(msg_ctx->transport_headers, env);
+ }
+
+ if(msg_ctx->accept_charset_record_list)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ while(axutil_array_list_size(msg_ctx->accept_charset_record_list, env))
+ {
+ rec = (axis2_http_accept_record_t *)axutil_array_list_remove(
+ msg_ctx->accept_charset_record_list, env, 0);
+ if(rec)
+ {
+ axis2_http_accept_record_free(rec, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->accept_charset_record_list, env);
+ }
+
+ if(msg_ctx->output_headers)
+ {
+ axis2_http_header_t *header = NULL;
+ while(axutil_array_list_size(msg_ctx->output_headers, env))
+ {
+ header = (axis2_http_header_t *)axutil_array_list_remove(msg_ctx->output_headers, env,
+ 0);
+ if(header)
+ {
+ axis2_http_header_free(header, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->output_headers, env);
+ }
+
+ if(msg_ctx->accept_language_record_list)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ while(axutil_array_list_size(msg_ctx->accept_language_record_list, env))
+ {
+ rec = (axis2_http_accept_record_t *)axutil_array_list_remove(
+ msg_ctx->accept_language_record_list, env, 0);
+ if(rec)
+ {
+ axis2_http_accept_record_free(rec, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->accept_language_record_list, env);
+ }
+
+ if(msg_ctx->accept_record_list)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ while(axutil_array_list_size(msg_ctx->accept_record_list, env))
+ {
+ rec = (axis2_http_accept_record_t *)axutil_array_list_remove(
+ msg_ctx->accept_record_list, env, 0);
+ if(rec)
+ {
+ axis2_http_accept_record_free(rec, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->accept_record_list, env);
+ }
+
+ if(msg_ctx->transfer_encoding)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->transfer_encoding);
+ }
+
+ if(msg_ctx->content_language)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->content_language);
+ }
+
+ if(msg_ctx->auth_type)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->auth_type);
+ }
+
+ if(msg_ctx->supported_rest_http_methods)
+ {
+ int i = 0;
+ int size = 0;
+
+ size = axutil_array_list_size(msg_ctx->supported_rest_http_methods, env);
+ for(i = 0; i < size; i++)
+ {
+ axis2_char_t *rest_http_method = NULL;
+ rest_http_method = axutil_array_list_get(msg_ctx->supported_rest_http_methods, env, i);
+ if(rest_http_method)
+ {
+ AXIS2_FREE(env->allocator, rest_http_method);
+ }
+ }
+ axutil_array_list_free(msg_ctx->supported_rest_http_methods, env);
+ }
+
+ if(msg_ctx->options)
+ {
+ /* freeing only axis2_options_t allocated space, should not
+ * call axis2_options_free because it will free internal
+ * properties as well. */
+ AXIS2_FREE(env->allocator, msg_ctx->options);
+ }
+
+ AXIS2_FREE(env->allocator, msg_ctx);
+
+ return;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_increment_ref(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ msg_ctx->ref++;
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_init(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ struct axis2_conf * conf)
+{
+ AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ msg_ctx->transport_in_desc = axis2_conf_get_transport_in(conf, env,
+ msg_ctx-> transport_in_desc_enum);
+
+ msg_ctx->transport_out_desc = axis2_conf_get_transport_out(conf, env,
+ msg_ctx-> transport_out_desc_enum);
+
+ if(msg_ctx->svc_grp_id)
+ {
+ msg_ctx->svc_grp = axis2_conf_get_svc_grp(conf, env, msg_ctx->svc_grp_id);
+ }
+
+ if(msg_ctx->svc_qname)
+ {
+ msg_ctx->svc = axis2_conf_get_svc(conf, env, axutil_qname_get_localpart(
+ msg_ctx-> svc_qname, env));
+ }
+
+ if(msg_ctx->op_qname)
+ {
+ if(msg_ctx->svc)
+ msg_ctx->op = axis2_svc_get_op_with_qname(msg_ctx->svc, env, msg_ctx->op_qname);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_endpoint_ref_t *AXIS2_CALL
+axis2_msg_ctx_get_fault_to(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_get_fault_to(msg_ctx->msg_info_headers, env);
+ }
+
+ return NULL;
+}
+
+axis2_endpoint_ref_t *AXIS2_CALL
+axis2_msg_ctx_get_from(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_get_from(msg_ctx->msg_info_headers, env);
+ }
+
+ return NULL;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_in_fault_flow(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->in_fault_flow;
+}
+
+axiom_soap_envelope_t *AXIS2_CALL
+axis2_msg_ctx_get_soap_envelope(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->soap_envelope;
+}
+
+axiom_soap_envelope_t *AXIS2_CALL
+axis2_msg_ctx_get_response_soap_envelope(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->response_soap_envelope;
+}
+
+axiom_soap_envelope_t *AXIS2_CALL
+axis2_msg_ctx_get_fault_soap_envelope(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->fault_soap_envelope;
+}
+
+const axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_msg_id(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_get_message_id(msg_ctx->msg_info_headers, env);
+ }
+
+ return NULL;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_msg_id(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_char_t * msg_id)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_id, AXIS2_FAILURE);
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_set_message_id(msg_ctx->msg_info_headers, env, msg_id);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_process_fault(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->process_fault;
+}
+
+axis2_relates_to_t *AXIS2_CALL
+axis2_msg_ctx_get_relates_to(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_get_relates_to(msg_ctx->msg_info_headers, env);
+ }
+
+ return NULL;
+}
+
+axis2_endpoint_ref_t *AXIS2_CALL
+axis2_msg_ctx_get_reply_to(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_get_reply_to(msg_ctx->msg_info_headers, env);
+ }
+
+ return NULL;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_server_side(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->server_side;
+}
+
+axis2_endpoint_ref_t *AXIS2_CALL
+axis2_msg_ctx_get_to(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_get_to(msg_ctx->msg_info_headers, env);
+ }
+
+ return NULL;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_fault_to(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axis2_endpoint_ref_t * reference)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_set_to(msg_ctx->msg_info_headers, env, reference);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_from(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axis2_endpoint_ref_t * reference)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_set_from(msg_ctx->msg_info_headers, env, reference);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_in_fault_flow(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t in_fault_flow)
+{
+ msg_ctx->in_fault_flow = in_fault_flow;
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_soap_envelope(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axiom_soap_envelope_t * soap_envelope)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ if(soap_envelope)
+ {
+ int soap_v = AXIOM_SOAP12;
+ soap_v = axiom_soap_envelope_get_soap_version(soap_envelope, env);
+ msg_ctx->is_soap_11 = (soap_v == AXIOM_SOAP12) ? AXIS2_FALSE : AXIS2_TRUE;
+ msg_ctx->soap_envelope = soap_envelope;
+ }
+ else
+ {
+ msg_ctx->soap_envelope = NULL;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_response_soap_envelope(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axiom_soap_envelope_t * soap_envelope)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ if(soap_envelope)
+ {
+ int soap_v = AXIOM_SOAP12;
+ soap_v = axiom_soap_envelope_get_soap_version(soap_envelope, env);
+ msg_ctx->response_soap_envelope = soap_envelope;
+ }
+ else
+ {
+ msg_ctx->response_soap_envelope = NULL;
+ }
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_fault_soap_envelope(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axiom_soap_envelope_t * soap_envelope)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->fault_soap_envelope = soap_envelope;
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_message_id(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * message_id)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_set_message_id(msg_ctx->msg_info_headers, env, message_id);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_process_fault(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t process_fault)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->process_fault = process_fault;
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_relates_to(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axis2_relates_to_t * reference)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_set_relates_to(msg_ctx->msg_info_headers, env, reference);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_reply_to(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axis2_endpoint_ref_t * reference)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_set_reply_to(msg_ctx->msg_info_headers, env, reference);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_server_side(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t server_side)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->server_side = server_side;
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_to(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axis2_endpoint_ref_t * reference)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_set_to(msg_ctx->msg_info_headers, env, reference);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_new_thread_required(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ return msg_ctx->new_thread_required;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_new_thread_required(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t new_thread_required)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->new_thread_required = new_thread_required;
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_wsa_action(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * action_uri)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_set_action(msg_ctx->msg_info_headers, env, action_uri);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+const axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_wsa_action(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_get_action(msg_ctx->msg_info_headers, env);
+ }
+
+ return NULL;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_wsa_message_id(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * message_id)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_set_message_id(msg_ctx->msg_info_headers, env, message_id);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+const axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_wsa_message_id(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+
+ if(msg_ctx->msg_info_headers)
+ {
+ return axis2_msg_info_headers_get_message_id(msg_ctx->msg_info_headers, env);
+ }
+
+ return NULL;
+
+}
+
+axis2_msg_info_headers_t *AXIS2_CALL
+axis2_msg_ctx_get_msg_info_headers(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->msg_info_headers;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_paused(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->paused;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_paused(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t paused)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->paused = paused;
+ msg_ctx->paused_phase_index = msg_ctx->current_phase_index;
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_keep_alive(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t keep_alive)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->keep_alive = keep_alive;
+ return AXIS2_SUCCESS;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_is_keep_alive(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->keep_alive;
+}
+
+struct axis2_transport_in_desc *AXIS2_CALL
+axis2_msg_ctx_get_transport_in_desc(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->transport_in_desc;
+}
+
+struct axis2_transport_out_desc *AXIS2_CALL
+axis2_msg_ctx_get_transport_out_desc(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->transport_out_desc;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_transport_in_desc(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ struct axis2_transport_in_desc * transport_in_desc)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(transport_in_desc)
+ {
+ msg_ctx->transport_in_desc = transport_in_desc;
+ msg_ctx->transport_in_desc_enum = axis2_transport_in_desc_get_enum(transport_in_desc, env);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_transport_out_desc(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ struct axis2_transport_out_desc * transport_out_desc)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(transport_out_desc)
+ {
+ msg_ctx->transport_out_desc = transport_out_desc;
+ msg_ctx->transport_out_desc_enum = axis2_transport_out_desc_get_enum(transport_out_desc,
+ env);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+struct axis2_op_ctx *AXIS2_CALL
+axis2_msg_ctx_get_op_ctx(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->op_ctx;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_op_ctx(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ struct axis2_op_ctx * op_ctx)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(op_ctx)
+ {
+ msg_ctx->op_ctx = op_ctx;
+
+ if(msg_ctx->svc_ctx)
+ {
+ if(!(axis2_op_ctx_get_parent(msg_ctx->op_ctx, env)))
+ {
+ axis2_op_ctx_set_parent(msg_ctx->op_ctx, env, msg_ctx->svc_ctx);
+ }
+ }
+ axis2_msg_ctx_set_parent(msg_ctx, env, op_ctx);
+ axis2_msg_ctx_set_op(msg_ctx, env, axis2_op_ctx_get_op(op_ctx, env));
+ }
+ return AXIS2_SUCCESS;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_output_written(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->output_written;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_output_written(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t output_written)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->output_written = output_written;
+ return AXIS2_SUCCESS;
+}
+
+const axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_rest_http_method(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->rest_http_method;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_rest_http_method(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * rest_http_method)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx->rest_http_method)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->rest_http_method);
+ msg_ctx->rest_http_method = NULL;
+ }
+
+ if(rest_http_method)
+ {
+ msg_ctx->rest_http_method = axutil_strdup(env, rest_http_method);
+ if(!(msg_ctx->rest_http_method))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+const axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_svc_ctx_id(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->svc_ctx_id;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_svc_ctx_id(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_ctx_id)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx->svc_ctx_id)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->svc_ctx_id);
+ msg_ctx->svc_ctx_id = NULL;
+ }
+
+ if(svc_ctx_id)
+ {
+ msg_ctx->svc_ctx_id = axutil_strdup(env, svc_ctx_id);
+ if(!(msg_ctx->svc_ctx_id))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+struct axis2_conf_ctx *AXIS2_CALL
+axis2_msg_ctx_get_conf_ctx(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->conf_ctx;
+}
+
+struct axis2_svc_ctx *AXIS2_CALL
+axis2_msg_ctx_get_svc_ctx(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->svc_ctx;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_conf_ctx(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ struct axis2_conf_ctx * conf_ctx)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(conf_ctx)
+ {
+ msg_ctx->conf_ctx = conf_ctx;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_svc_ctx(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ struct axis2_svc_ctx * svc_ctx)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(svc_ctx)
+ {
+ msg_ctx->svc_ctx = svc_ctx;
+
+ if(msg_ctx->op_ctx)
+ {
+ if(!axis2_op_ctx_get_parent(msg_ctx->op_ctx, env))
+ axis2_op_ctx_set_parent(msg_ctx->op_ctx, env, svc_ctx);
+ }
+ axis2_msg_ctx_set_svc(msg_ctx, env, axis2_svc_ctx_get_svc(svc_ctx, env));
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_msg_info_headers(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axis2_msg_info_headers_t * msg_info_headers)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_info_headers, AXIS2_FAILURE);
+
+ if(msg_info_headers)
+ {
+ if(msg_ctx->msg_info_headers && msg_ctx->msg_info_headers_deep_copy)
+ {
+ axis2_msg_info_headers_free(msg_ctx->msg_info_headers, env);
+ msg_ctx->msg_info_headers = NULL;
+ }
+ msg_ctx->msg_info_headers = msg_info_headers;
+ msg_ctx->msg_info_headers_deep_copy = AXIS2_FALSE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axutil_param_t *AXIS2_CALL
+axis2_msg_ctx_get_parameter(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * key)
+{
+ axutil_param_t *param = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+
+ if(msg_ctx->op)
+ {
+ param = axis2_op_get_param(msg_ctx->op, env, key);
+ if(param)
+ {
+ return param;
+ }
+ }
+
+ if(msg_ctx->svc)
+ {
+ param = axis2_svc_get_param(msg_ctx->svc, env, key);
+ if(param)
+ {
+ return param;
+ }
+ }
+
+ if(msg_ctx->svc_grp)
+ {
+ param = axis2_svc_grp_get_param(msg_ctx->svc_grp, env, key);
+ if(param)
+ {
+ return param;
+ }
+ }
+
+ if(msg_ctx->conf_ctx)
+ {
+ axis2_conf_t *conf = axis2_conf_ctx_get_conf(msg_ctx->conf_ctx, env);
+ param = axis2_conf_get_param(conf, env, key);
+ }
+
+ return param;
+}
+
+AXIS2_EXTERN void *AXIS2_CALL
+axis2_msg_ctx_get_property_value(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * property_str)
+{
+ axutil_property_t *property;
+ void *property_value = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ property = axis2_msg_ctx_get_property(msg_ctx, env, property_str);
+
+ if(!property)
+ {
+ AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "%s not set in message context", property_str);
+ return NULL;
+ }
+
+ property_value = axutil_property_get_value(property, env);
+ if(!property_value)
+ {
+ AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "%s properties not set in message context",
+ property_str);
+ return NULL;
+ }
+
+ return property_value;
+}
+
+axutil_property_t *AXIS2_CALL
+axis2_msg_ctx_get_property(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * key)
+{
+ void *obj = NULL;
+ axis2_ctx_t *ctx = NULL;
+
+ /* Don't use AXIS2_PARAM_CHECK to verify msg_ctx, as it clobbers
+ env->error->status_code destroying the information therein that
+ an error has already occurred. */
+ if(!msg_ctx)
+ {
+ if(axutil_error_get_status_code(env->error) == AXIS2_SUCCESS)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ }
+ return obj;
+ }
+
+ /* search in message context */
+ obj = axis2_ctx_get_property(msg_ctx->base, env, key);
+ if(obj)
+ {
+ return obj;
+ }
+
+ if(msg_ctx->op_ctx)
+ {
+ ctx = axis2_op_ctx_get_base(msg_ctx->op_ctx, env);
+ if(ctx)
+ {
+ obj = axis2_ctx_get_property(ctx, env, key);
+ if(obj)
+ {
+ return obj;
+ }
+ }
+ }
+
+ if(msg_ctx->svc_ctx)
+ {
+ ctx = axis2_svc_ctx_get_base(msg_ctx->svc_ctx, env);
+ if(ctx)
+ {
+ obj = axis2_ctx_get_property(ctx, env, key);
+ if(obj)
+ {
+ return obj;
+ }
+ }
+ }
+
+ if(msg_ctx->svc_grp_ctx)
+ {
+ ctx = axis2_svc_grp_ctx_get_base(msg_ctx->svc_grp_ctx, env);
+ if(ctx)
+ {
+ obj = axis2_ctx_get_property(ctx, env, key);
+ if(obj)
+ {
+ return obj;
+ }
+ }
+ }
+
+ if(msg_ctx->conf_ctx)
+ {
+ ctx = axis2_conf_ctx_get_base(msg_ctx->conf_ctx, env);
+ if(ctx)
+ {
+ obj = axis2_ctx_get_property(ctx, env, key);
+ if(obj)
+ {
+ return obj;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_property(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * key,
+ axutil_property_t * value)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ return axis2_ctx_set_property(msg_ctx->base, env, key, value);
+}
+
+const axutil_string_t *AXIS2_CALL
+axis2_msg_ctx_get_paused_handler_name(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->paused_handler_name;
+}
+
+const axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_paused_phase_name(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->paused_phase_name;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_paused_phase_name(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * paused_phase_name)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ /* a shallow copy is sufficient as phase lives beyond message */
+ msg_ctx->paused_phase_name = (axis2_char_t *)paused_phase_name;
+ return AXIS2_SUCCESS;
+}
+
+axutil_string_t *AXIS2_CALL
+axis2_msg_ctx_get_soap_action(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->soap_action;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_soap_action(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axutil_string_t * soap_action)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ if(msg_ctx->soap_action)
+ {
+ axutil_string_free(msg_ctx->soap_action, env);
+ }
+
+ if(soap_action)
+ {
+ msg_ctx->soap_action = axutil_string_clone(soap_action, env);
+ if(!(msg_ctx->soap_action))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_doing_mtom(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+
+ if(!(msg_ctx->doing_mtom) && msg_ctx->conf_ctx)
+ {
+ axis2_conf_t *conf = axis2_conf_ctx_get_conf(msg_ctx->conf_ctx, env);
+ msg_ctx->doing_mtom = axis2_conf_get_enable_mtom(conf, env);
+ }
+
+ return msg_ctx->doing_mtom;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_doing_mtom(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t doing_mtom)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->doing_mtom = doing_mtom;
+ return AXIS2_SUCCESS;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_doing_rest(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ /* Don't use AXIS2_PARAM_CHECK to verify msg_ctx, as it clobbers
+ env->error->status_code destroying the information therein that
+ an error has already occurred. */
+ if(!msg_ctx)
+ {
+ if(axutil_error_get_status_code(env->error) == AXIS2_SUCCESS)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ }
+ return AXIS2_FALSE;
+ }
+ return msg_ctx->doing_rest;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_doing_rest(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t doing_rest)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->doing_rest = doing_rest;
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_do_rest_through_post(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t do_rest_through_post)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->do_rest_through_post = do_rest_through_post;
+ return AXIS2_SUCCESS;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_do_rest_through_post(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->do_rest_through_post;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_manage_session(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->manage_session;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_manage_session(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t manage_session)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->manage_session = manage_session;
+ return AXIS2_SUCCESS;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_is_soap_11(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->is_soap_11;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_is_soap_11(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t is_soap11)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->is_soap_11 = is_soap11;
+ return AXIS2_SUCCESS;
+}
+
+struct axis2_svc_grp_ctx *AXIS2_CALL
+axis2_msg_ctx_get_svc_grp_ctx(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->svc_grp_ctx;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_svc_grp_ctx(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ struct axis2_svc_grp_ctx * svc_grp_ctx)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(svc_grp_ctx)
+ {
+ msg_ctx->svc_grp_ctx = svc_grp_ctx;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_op_t *AXIS2_CALL
+axis2_msg_ctx_get_op(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->op;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_op(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axis2_op_t * op)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(op)
+ {
+ msg_ctx->op = op;
+ msg_ctx->op_qname = (axutil_qname_t *)axis2_op_get_qname(op, env);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_svc_t *AXIS2_CALL
+axis2_msg_ctx_get_svc(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->svc;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_svc(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(svc)
+ {
+ axis2_svc_grp_t *svc_grp = NULL;
+ msg_ctx->svc = svc;
+ msg_ctx->svc_qname = (axutil_qname_t *)axis2_svc_get_qname(svc, env);
+
+ svc_grp = axis2_svc_get_parent(svc, env);
+ if(svc_grp)
+ {
+ msg_ctx->svc_grp = svc_grp;
+ msg_ctx->svc_grp_id = (axis2_char_t *)axis2_svc_grp_get_name(svc_grp, env);
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_svc_grp_t *AXIS2_CALL
+axis2_msg_ctx_get_svc_grp(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->svc_grp;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_svc_grp(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_grp_t * svc_grp)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ if(svc_grp)
+ {
+ msg_ctx->svc_grp = svc_grp;
+ msg_ctx->svc_grp_id = (axis2_char_t *)axis2_svc_grp_get_name(svc_grp, env);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+const axutil_string_t *AXIS2_CALL
+axis2_msg_ctx_get_svc_grp_ctx_id(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->svc_grp_ctx_id;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_svc_grp_ctx_id(
+ struct axis2_msg_ctx * msg_ctx,
+ const axutil_env_t * env,
+ axutil_string_t * svc_grp_ctx_id)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ if(msg_ctx->svc_grp_ctx_id)
+ {
+ axutil_string_free(msg_ctx->svc_grp_ctx_id, env);
+ msg_ctx->svc_grp_ctx_id = NULL;
+ }
+
+ if(svc_grp_ctx_id)
+ {
+ msg_ctx->svc_grp_ctx_id = axutil_string_clone(svc_grp_ctx_id, env);
+ }
+ return AXIS2_SUCCESS;
+}
+
+axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_is_paused(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->paused;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ AXIS2_MSG_CTX_FIND_SVC func)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->find_svc = func;
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ AXIS2_MSG_CTX_FIND_OP func)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->find_op = func;
+ return AXIS2_SUCCESS;
+}
+
+axis2_options_t *AXIS2_CALL
+axis2_msg_ctx_get_options(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ axutil_hash_t *properties = NULL;
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+
+ if(!msg_ctx->options)
+ {
+ msg_ctx->options = axis2_options_create(env);
+
+ if(!msg_ctx->options)
+ {
+ return NULL;
+ }
+ }
+
+ axis2_options_set_msg_info_headers(msg_ctx->options, env, msg_ctx->msg_info_headers);
+ properties = axis2_ctx_get_property_map(msg_ctx->base, env);
+ axis2_options_set_properties(msg_ctx->options, env, properties);
+ return msg_ctx->options;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_options(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_options_t * options)
+{
+ axutil_property_t *rest_val = NULL;
+ axis2_char_t *value;
+ axutil_string_t *soap_action = NULL;
+ ;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, options, AXIS2_FAILURE);
+
+ if(msg_ctx->msg_info_headers && msg_ctx->msg_info_headers_deep_copy)
+ {
+ axis2_msg_info_headers_free(msg_ctx->msg_info_headers, env);
+ }
+ msg_ctx->msg_info_headers = axis2_options_get_msg_info_headers(options, env);
+ msg_ctx->msg_info_headers_deep_copy = AXIS2_FALSE;
+
+ msg_ctx->doing_mtom = axis2_options_get_enable_mtom(options, env);
+
+ msg_ctx->manage_session = axis2_options_get_manage_session(options, env);
+
+ axis2_ctx_set_property_map(msg_ctx->base, env, axis2_options_get_properties(options, env));
+ rest_val = (axutil_property_t *)axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_ENABLE_REST);
+ if(rest_val)
+ {
+ value = (axis2_char_t *)axutil_property_get_value(rest_val, env);
+ if(value)
+ {
+ if(axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0)
+ axis2_msg_ctx_set_doing_rest(msg_ctx, env, AXIS2_TRUE);
+ }
+ }
+
+ if(msg_ctx->soap_action)
+ {
+ axutil_string_free(msg_ctx->soap_action, env);
+ }
+
+ soap_action = axis2_options_get_soap_action(options, env);
+ if(soap_action)
+ {
+ msg_ctx->soap_action = axutil_string_clone(soap_action, env);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_flow(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ int flow)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->flow = flow;
+ return AXIS2_SUCCESS;
+}
+
+int AXIS2_CALL
+axis2_msg_ctx_get_flow(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, 0);
+ return msg_ctx->flow;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_execution_chain(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t * execution_chain)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->execution_chain = execution_chain;
+ msg_ctx->current_handler_index = -1;
+ msg_ctx->paused_handler_index = -1;
+ msg_ctx->current_phase_index = 0;
+
+ return AXIS2_SUCCESS;
+}
+
+axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_execution_chain(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->execution_chain;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_supported_rest_http_methods(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t * supported_rest_http_methods)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->supported_rest_http_methods = supported_rest_http_methods;
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_supported_rest_http_methods(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->supported_rest_http_methods;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_current_handler_index(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ const int index)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->current_handler_index = index;
+ if(msg_ctx->execution_chain)
+ {
+ axis2_handler_t *handler = (axis2_handler_t *)axutil_array_list_get(
+ msg_ctx->execution_chain, env, index);
+ if(handler)
+ {
+ msg_ctx->paused_handler_name = (axutil_string_t *)axis2_handler_get_name(handler, env);
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+int AXIS2_CALL
+axis2_msg_ctx_get_current_handler_index(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, 0);
+ return msg_ctx->current_handler_index;
+}
+
+int AXIS2_CALL
+axis2_msg_ctx_get_paused_handler_index(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, 0);
+ return msg_ctx->paused_handler_index;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_current_phase_index(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ const int index)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->current_phase_index = index;
+ return AXIS2_SUCCESS;
+
+}
+
+int AXIS2_CALL
+axis2_msg_ctx_get_current_phase_index(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, 0);
+ return msg_ctx->current_phase_index;
+}
+
+int AXIS2_CALL
+axis2_msg_ctx_get_paused_phase_index(
+ const axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, 0);
+ return msg_ctx->paused_phase_index;
+}
+
+AXIS2_EXTERN axis2_svc_t *AXIS2_CALL
+axis2_msg_ctx_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->find_svc(msg_ctx, env);
+}
+
+AXIS2_EXTERN axis2_op_t *AXIS2_CALL
+axis2_msg_ctx_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ return msg_ctx->find_op(msg_ctx, env, svc);
+}
+
+AXIS2_EXTERN axutil_string_t *AXIS2_CALL
+axis2_msg_ctx_get_charset_encoding(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ if(msg_ctx)
+ return msg_ctx->charset_encoding;
+ else
+ return NULL;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_charset_encoding(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_string_t * str)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx)
+ {
+ if(msg_ctx->charset_encoding)
+ {
+ axutil_string_free(msg_ctx->charset_encoding, env);
+ msg_ctx->charset_encoding = NULL;
+ }
+ if(str)
+ {
+ msg_ctx->charset_encoding = axutil_string_clone(str, env);
+ }
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_stream_t *AXIS2_CALL
+axis2_msg_ctx_get_transport_out_stream(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ if(msg_ctx)
+ {
+ return msg_ctx->transport_out_stream;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_transport_out_stream(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_stream_t * stream)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx)
+ {
+ if(msg_ctx->transport_out_stream)
+ {
+ axutil_stream_free(msg_ctx->transport_out_stream, env);
+ }
+
+ msg_ctx->transport_out_stream = stream;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_reset_transport_out_stream(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx)
+ {
+ msg_ctx->transport_out_stream = NULL;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_out_transport_info_t *AXIS2_CALL
+axis2_msg_ctx_get_out_transport_info(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+ if(msg_ctx)
+ {
+ return msg_ctx->out_transport_info;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_out_transport_info(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_out_transport_info_t * out_transport_info)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx)
+ {
+ if(msg_ctx->out_transport_info)
+ {
+ AXIS2_OUT_TRANSPORT_INFO_FREE(msg_ctx->out_transport_info, env);
+ }
+
+ msg_ctx->out_transport_info = out_transport_info;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_reset_out_transport_info(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ if(msg_ctx)
+ {
+ msg_ctx->out_transport_info = NULL;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_msg_ctx_get_transport_headers(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(msg_ctx)
+ {
+ return msg_ctx->transport_headers;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_msg_ctx_extract_transport_headers(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ axutil_hash_t *temp = NULL;
+ if(msg_ctx)
+ {
+ temp = msg_ctx->transport_headers;
+ msg_ctx->transport_headers = NULL;
+ return temp;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_transport_headers(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_hash_t * transport_headers)
+{
+ if(msg_ctx)
+ {
+ if(msg_ctx->transport_headers)
+ {
+ axutil_hash_free(msg_ctx->transport_headers, env);
+ }
+
+ msg_ctx->transport_headers = transport_headers;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_http_accept_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(msg_ctx)
+ {
+ return msg_ctx->accept_record_list;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_extract_http_accept_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ axutil_array_list_t *temp = NULL;
+ if(msg_ctx)
+ {
+ temp = msg_ctx->accept_record_list;
+ msg_ctx->accept_record_list = NULL;
+ return temp;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_http_accept_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t * accept_record_list)
+{
+ if(msg_ctx)
+ {
+ if(msg_ctx->accept_record_list && msg_ctx->accept_record_list != accept_record_list)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ while(axutil_array_list_size(msg_ctx->accept_record_list, env))
+ {
+ rec = (axis2_http_accept_record_t *)axutil_array_list_remove(
+ msg_ctx->accept_record_list, env, 0);
+ if(rec)
+ {
+ axis2_http_accept_record_free(rec, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->accept_record_list, env);
+ }
+ msg_ctx->accept_record_list = accept_record_list;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_http_accept_charset_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(msg_ctx)
+ {
+ return msg_ctx->accept_charset_record_list;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_extract_http_accept_charset_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ axutil_array_list_t *temp = NULL;
+ if(msg_ctx)
+ {
+ temp = msg_ctx->accept_charset_record_list;
+ msg_ctx->accept_charset_record_list = NULL;
+ return temp;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_http_accept_charset_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t * accept_charset_record_list)
+{
+ if(msg_ctx)
+ {
+ if(msg_ctx->accept_charset_record_list && msg_ctx->accept_charset_record_list
+ != accept_charset_record_list)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ while(axutil_array_list_size(msg_ctx->accept_charset_record_list, env))
+ {
+ rec = (axis2_http_accept_record_t *)axutil_array_list_remove(
+ msg_ctx->accept_charset_record_list, env, 0);
+ if(rec)
+ {
+ axis2_http_accept_record_free(rec, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->accept_charset_record_list, env);
+ }
+ msg_ctx->accept_charset_record_list = accept_charset_record_list;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_http_output_headers(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(msg_ctx)
+ {
+ return msg_ctx->output_headers;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_extract_http_output_headers(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(msg_ctx)
+ {
+ axutil_array_list_t *temp = NULL;
+ temp = msg_ctx->output_headers;
+ msg_ctx->output_headers = NULL;
+ return temp;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_http_output_headers(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t * output_headers)
+{
+ if(msg_ctx)
+ {
+ if(msg_ctx->output_headers && msg_ctx->output_headers != output_headers)
+ {
+ axis2_http_header_t *header = NULL;
+ while(axutil_array_list_size(msg_ctx->output_headers, env))
+ {
+ header = (axis2_http_header_t *)axutil_array_list_remove(msg_ctx->output_headers,
+ env, 0);
+ if(header)
+ {
+ axis2_http_header_free(header, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->output_headers, env);
+ }
+ msg_ctx->output_headers = output_headers;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_http_accept_language_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(msg_ctx)
+ {
+ return msg_ctx->accept_language_record_list;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_extract_http_accept_language_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ axutil_array_list_t *temp = NULL;
+ if(msg_ctx)
+ {
+ temp = msg_ctx->accept_language_record_list;
+ msg_ctx->accept_language_record_list = NULL;
+ return temp;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_http_accept_language_record_list(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t * accept_language_record_list)
+{
+ if(msg_ctx)
+ {
+ if(msg_ctx->accept_language_record_list && msg_ctx->accept_language_record_list
+ != accept_language_record_list)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ while(axutil_array_list_size(msg_ctx->accept_language_record_list, env))
+ {
+ rec = (axis2_http_accept_record_t *)axutil_array_list_remove(
+ msg_ctx->accept_language_record_list, env, 0);
+ if(rec)
+ {
+ axis2_http_accept_record_free(rec, env);
+ }
+ }
+ axutil_array_list_free(msg_ctx->accept_language_record_list, env);
+ }
+ msg_ctx->accept_language_record_list = accept_language_record_list;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_transfer_encoding(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(msg_ctx)
+ return msg_ctx->transfer_encoding;
+ else
+ return NULL;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_transfer_encoding(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_char_t * str)
+{
+ if(msg_ctx)
+ {
+ if(msg_ctx->transfer_encoding)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->transfer_encoding);
+ msg_ctx->transfer_encoding = NULL;
+ }
+ if(str)
+ {
+ msg_ctx->transfer_encoding = str;
+ }
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_content_language(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(msg_ctx)
+ return msg_ctx->content_language;
+ else
+ return NULL;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_content_language(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_char_t * str)
+{
+ if(msg_ctx)
+ {
+ if(msg_ctx->content_language)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->content_language);
+ msg_ctx->content_language = NULL;
+ }
+ if(str)
+ {
+ msg_ctx->content_language = str;
+ }
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_transport_url(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(msg_ctx)
+ return msg_ctx->transport_url;
+ else
+ return NULL;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_transport_url(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_char_t * str)
+{
+ if(msg_ctx)
+ {
+ /* this is a shallow copy, no need to free */
+ msg_ctx->transport_url = str;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+axis2_msg_ctx_get_status_code(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, 0);
+ return msg_ctx->status_code;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_status_code(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ const int status_code)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->status_code = status_code;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_auth_failed(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->is_auth_failure;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_auth_failed(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t status)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->is_auth_failure = status;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_no_content(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->no_content;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_no_content(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t no_content)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->no_content = no_content;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_msg_ctx_get_required_auth_is_http(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FALSE);
+ return msg_ctx->required_auth_is_http;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_required_auth_is_http(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t status)
+{
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_ctx->required_auth_is_http = status;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_msg_ctx_set_auth_type(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * auth_type)
+{
+ if(msg_ctx->auth_type)
+ {
+ AXIS2_FREE(env->allocator, msg_ctx->auth_type);
+ }
+ msg_ctx->auth_type = NULL;
+ if(auth_type)
+ {
+ msg_ctx->auth_type = axutil_strdup(env, auth_type);
+ }
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axis2_msg_ctx_get_auth_type(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ return msg_ctx->auth_type;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_mime_parts(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ return msg_ctx->mime_parts;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_msg_ctx_set_mime_parts(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axutil_array_list_t *mime_parts)
+{
+ if(msg_ctx->mime_parts)
+ {
+ axutil_array_list_free(mime_parts, env);
+ msg_ctx->mime_parts = NULL;
+ }
+ msg_ctx->mime_parts = mime_parts;
+}
diff --git a/src/core/context/op_ctx.c b/src/core/context/op_ctx.c
new file mode 100644
index 0000000..30f0e3b
--- /dev/null
+++ b/src/core/context/op_ctx.c
@@ -0,0 +1,420 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <axis2_op_ctx.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_op.h>
+#include <axis2_const.h>
+#include <axutil_hash.h>
+
+struct axis2_op_ctx
+{
+
+ /** base context struct */
+ axis2_ctx_t *base;
+
+ /** parent of operation context is a service context instance */
+ struct axis2_svc_ctx *parent;
+
+ /** message context map */
+ axis2_msg_ctx_t *msg_ctx_array[AXIS2_WSDL_MESSAGE_LABEL_MAX];
+
+ /**
+ * the operation of which this is a running instance. The MEP of this
+ * operation must be one of the 8 predefined ones in WSDL 2.0.
+ */
+ axis2_op_t *op;
+
+ /** operation Message Exchange Pattern (MEP) */
+ int op_mep;
+
+ /** is complete? */
+ axis2_bool_t is_complete;
+
+ /** the global message_id -> op_ctx map which is stored in
+ * the axis2_conf_ctx. We are caching it here for faster access.
+ */
+ axutil_hash_t *op_ctx_map;
+
+ /** op qname */
+ axutil_qname_t *op_qname;
+
+ /** service qname */
+ axutil_qname_t *svc_qname;
+ /* mutex to synchronize the read/write operations */
+ axutil_thread_mutex_t *mutex;
+ axis2_bool_t response_written;
+ axis2_bool_t is_in_use;
+
+ int ref;
+};
+
+AXIS2_EXTERN axis2_op_ctx_t *AXIS2_CALL
+axis2_op_ctx_create(
+ const axutil_env_t * env,
+ axis2_op_t * op,
+ struct axis2_svc_ctx *svc_ctx)
+{
+ axis2_op_ctx_t *op_ctx = NULL;
+ int i = 0;
+
+ op_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_op_ctx_t));
+ if(!op_ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ op_ctx->base = NULL;
+ op_ctx->parent = NULL;
+ op_ctx->op = NULL;
+ op_ctx->op_mep = 0;
+ op_ctx->is_complete = AXIS2_FALSE;
+ op_ctx->is_in_use = AXIS2_FALSE;
+ op_ctx->op_ctx_map = NULL;
+ op_ctx->op_qname = NULL;
+ op_ctx->svc_qname = NULL;
+ op_ctx->response_written = AXIS2_FALSE;
+ op_ctx->mutex = axutil_thread_mutex_create(env->allocator, AXIS2_THREAD_MUTEX_DEFAULT);
+
+ if(!op_ctx->mutex)
+ {
+ axis2_op_ctx_free(op_ctx, env);
+ return NULL;
+ }
+
+ op_ctx->base = axis2_ctx_create(env);
+ if(!(op_ctx->base))
+ {
+ axis2_op_ctx_free(op_ctx, env);
+ return NULL;
+ }
+
+ if(op)
+ {
+ op_ctx->op = op;
+ }
+
+ for(i = 0; i < AXIS2_WSDL_MESSAGE_LABEL_MAX; i++)
+ {
+ op_ctx->msg_ctx_array[i] = NULL;
+ }
+
+ if(op_ctx->op)
+ {
+ op_ctx->op_qname = (axutil_qname_t *)axis2_op_get_qname(op_ctx->op, env);
+ op_ctx->op_mep = axis2_op_get_axis_specific_mep_const(op_ctx->op, env);
+ }
+
+ axis2_op_ctx_set_parent(op_ctx, env, svc_ctx);
+ op_ctx->ref = 1;
+
+ return op_ctx;
+}
+
+AXIS2_EXTERN axis2_ctx_t *AXIS2_CALL
+axis2_op_ctx_get_base(
+ const axis2_op_ctx_t * op_ctx,
+ const axutil_env_t * env)
+{
+ return op_ctx->base;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_op_ctx_free(
+ struct axis2_op_ctx *op_ctx,
+ const axutil_env_t * env)
+{
+ int i = 0;
+ if(--(op_ctx->ref) > 0)
+ {
+ return;
+ }
+ if(op_ctx->is_in_use)
+ {
+ return;
+ }
+
+ if(op_ctx->base)
+ {
+ axis2_ctx_free(op_ctx->base, env);
+ }
+
+ for(i = 0; i < AXIS2_WSDL_MESSAGE_LABEL_MAX; i++)
+ {
+ if(op_ctx->msg_ctx_array[i])
+ {
+ axis2_msg_ctx_free(op_ctx->msg_ctx_array[i], env);
+ op_ctx->msg_ctx_array[i] = NULL;
+ }
+ }
+
+ if(op_ctx->mutex)
+ {
+ axutil_thread_mutex_destroy(op_ctx->mutex);
+ }
+
+ AXIS2_FREE(env->allocator, op_ctx);
+
+ return;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_op_ctx_destroy_mutex(
+ struct axis2_op_ctx *op_ctx,
+ const axutil_env_t * env)
+{
+
+ if(op_ctx->mutex)
+ {
+ axutil_thread_mutex_destroy(op_ctx->mutex);
+ op_ctx->mutex = NULL;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_op_ctx_init(
+ struct axis2_op_ctx *op_ctx,
+ const axutil_env_t * env,
+ struct axis2_conf *conf)
+{
+ int i = 0;
+
+ if(op_ctx->op_qname && op_ctx->svc_qname)
+ {
+ axis2_svc_t *svc = NULL;
+ axis2_char_t *svc_name = NULL;
+
+ svc_name = axutil_qname_get_localpart(op_ctx->svc_qname, env);
+
+ if(svc_name)
+ {
+ svc = axis2_conf_get_svc(conf, env, svc_name);
+
+ if(svc)
+ {
+ op_ctx->op = axis2_svc_get_op_with_qname(svc, env, op_ctx->op_qname);
+ }
+ }
+ }
+
+ for(i = 0; i < AXIS2_WSDL_MESSAGE_LABEL_MAX; i++)
+ {
+ if(op_ctx->msg_ctx_array[i])
+ {
+ axis2_msg_ctx_init(op_ctx->msg_ctx_array[i], env, conf);
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_op_t *AXIS2_CALL
+axis2_op_ctx_get_op(
+ const axis2_op_ctx_t * op_ctx,
+ const axutil_env_t * env)
+{
+ return op_ctx->op;
+}
+
+AXIS2_EXTERN struct axis2_svc_ctx *AXIS2_CALL
+axis2_op_ctx_get_parent(
+ const axis2_op_ctx_t * op_ctx,
+ const axutil_env_t * env)
+{
+ return op_ctx->parent;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_op_ctx_add_msg_ctx(
+ struct axis2_op_ctx * op_ctx,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_msg_ctx_t *out_msg_ctx = NULL;
+ axis2_msg_ctx_t *in_msg_ctx = NULL;
+
+ axutil_thread_mutex_lock(op_ctx->mutex);
+
+ out_msg_ctx = op_ctx->msg_ctx_array[AXIS2_WSDL_MESSAGE_LABEL_OUT];
+ in_msg_ctx = op_ctx->msg_ctx_array[AXIS2_WSDL_MESSAGE_LABEL_IN];
+
+ if(out_msg_ctx && in_msg_ctx)
+ {
+ axutil_thread_mutex_unlock(op_ctx->mutex);
+ return AXIS2_FAILURE;
+ }
+
+ if(!out_msg_ctx)
+ {
+ op_ctx->msg_ctx_array[AXIS2_WSDL_MESSAGE_LABEL_OUT] = msg_ctx;
+ }
+ else
+ {
+ op_ctx->msg_ctx_array[AXIS2_WSDL_MESSAGE_LABEL_IN] = msg_ctx;
+ }
+
+ axutil_thread_mutex_unlock(op_ctx->mutex);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_msg_ctx_t *AXIS2_CALL
+axis2_op_ctx_get_msg_ctx(
+ const axis2_op_ctx_t * op_ctx,
+ const axutil_env_t * env,
+ const axis2_wsdl_msg_labels_t message_id)
+{
+ axutil_thread_mutex_lock(op_ctx->mutex);
+ if(op_ctx->msg_ctx_array)
+ {
+ axis2_msg_ctx_t *rv = NULL;
+ rv = op_ctx->msg_ctx_array[message_id];
+ axutil_thread_mutex_unlock(op_ctx->mutex);
+ return rv;
+ }
+ axutil_thread_mutex_unlock(op_ctx->mutex);
+ return NULL;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_op_ctx_get_is_complete(
+ const axis2_op_ctx_t * op_ctx,
+ const axutil_env_t * env)
+{
+ return op_ctx->is_complete;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_op_ctx_set_complete(
+ struct axis2_op_ctx * op_ctx,
+ const axutil_env_t * env,
+ axis2_bool_t is_complete)
+{
+ op_ctx->is_complete = is_complete;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_op_ctx_is_in_use(
+ const axis2_op_ctx_t * op_ctx,
+ const axutil_env_t * env)
+{
+ return op_ctx->is_in_use;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_op_ctx_set_in_use(
+ struct axis2_op_ctx * op_ctx,
+ const axutil_env_t * env,
+ axis2_bool_t is_in_use)
+{
+ op_ctx->is_in_use = is_in_use;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_op_ctx_cleanup(
+ struct axis2_op_ctx * op_ctx,
+ const axutil_env_t * env)
+{
+ int i = 0;
+
+ for(i = 0; i < AXIS2_WSDL_MESSAGE_LABEL_MAX; i++)
+ {
+ if(op_ctx->msg_ctx_array[i])
+ {
+ axis2_msg_ctx_free(op_ctx->msg_ctx_array[i], env);
+ op_ctx->msg_ctx_array[i] = NULL;
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_op_ctx_set_parent(
+ struct axis2_op_ctx * op_ctx,
+ const axutil_env_t * env,
+ struct axis2_svc_ctx * svc_ctx)
+{
+ if(svc_ctx)
+ {
+ op_ctx->parent = svc_ctx;
+ }
+
+ if(op_ctx->parent) /* that is if there is a service context associated */
+ {
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ conf_ctx = axis2_svc_ctx_get_conf_ctx(op_ctx->parent, env);
+ if(conf_ctx)
+ {
+ op_ctx->op_ctx_map = axis2_conf_ctx_get_op_ctx_map(conf_ctx, env);
+ }
+ op_ctx->svc_qname = (axutil_qname_t *)axis2_svc_get_qname(axis2_svc_ctx_get_svc(
+ op_ctx->parent, env), env);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_msg_ctx_t **AXIS2_CALL
+axis2_op_ctx_get_msg_ctx_map(
+ const axis2_op_ctx_t * op_ctx,
+ const axutil_env_t * env)
+{
+ return (axis2_msg_ctx_t **)(op_ctx->msg_ctx_array);
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_op_ctx_get_response_written(
+ const axis2_op_ctx_t * op_ctx,
+ const axutil_env_t * env)
+{
+ if(op_ctx)
+ return op_ctx->response_written;
+ else
+ return AXIS2_FALSE;
+
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_op_ctx_set_response_written(
+ axis2_op_ctx_t * op_ctx,
+ const axutil_env_t * env,
+ const axis2_bool_t written)
+{
+ if(op_ctx)
+ {
+ op_ctx->response_written = written;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_op_ctx_increment_ref(
+ axis2_op_ctx_t * op_ctx,
+ const axutil_env_t * env)
+{
+ op_ctx->ref++;
+ return AXIS2_SUCCESS;
+}
+
diff --git a/src/core/context/svc_ctx.c b/src/core/context/svc_ctx.c
new file mode 100644
index 0000000..c9e19fe
--- /dev/null
+++ b/src/core/context/svc_ctx.c
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <axis2_svc_ctx.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_const.h>
+#include <axutil_hash.h>
+
+struct axis2_svc_ctx
+{
+
+ /** base context struct */
+ axis2_ctx_t *base;
+
+ /** parent of op context is a service context instance */
+ struct axis2_svc_grp_ctx *parent;
+
+ /** service associated with this service context */
+ axis2_svc_t *svc;
+
+ /** id of the service associated with this context */
+ axis2_char_t *svc_id;
+
+ /** service qname */
+ axutil_qname_t *svc_qname;
+};
+
+AXIS2_EXTERN axis2_svc_ctx_t *AXIS2_CALL
+axis2_svc_ctx_create(
+ const axutil_env_t * env,
+ axis2_svc_t * svc,
+ struct axis2_svc_grp_ctx *svc_grp_ctx)
+{
+ axis2_svc_ctx_t *svc_ctx = NULL;
+
+ svc_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_ctx_t));
+ if(!svc_ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ svc_ctx->base = NULL;
+ svc_ctx->parent = NULL;
+ svc_ctx->svc = NULL;
+ svc_ctx->svc_id = NULL;
+ svc_ctx->svc_qname = NULL;
+
+ svc_ctx->base = axis2_ctx_create(env);
+ if(!(svc_ctx->base))
+ {
+ axis2_svc_ctx_free(svc_ctx, env);
+ return NULL;
+ }
+
+ if(svc)
+ {
+ svc_ctx->svc = svc;
+ svc_ctx->svc_qname = (axutil_qname_t *)axis2_svc_get_qname(svc, env);
+ if(svc_ctx->svc_qname)
+ {
+ svc_ctx->svc_id = axutil_qname_get_localpart(svc_ctx->svc_qname, env);
+ }
+ }
+
+ if(svc_grp_ctx)
+ {
+ svc_ctx->parent = svc_grp_ctx;
+ }
+
+ return svc_ctx;
+}
+
+axis2_ctx_t *AXIS2_CALL
+axis2_svc_ctx_get_base(
+ const axis2_svc_ctx_t * svc_ctx,
+ const axutil_env_t * env)
+{
+ return svc_ctx->base;
+}
+
+struct axis2_svc_grp_ctx *AXIS2_CALL
+axis2_svc_ctx_get_parent(
+ const axis2_svc_ctx_t * svc_ctx,
+ const axutil_env_t * env)
+{
+ return svc_ctx->parent;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_svc_ctx_set_parent(
+ axis2_svc_ctx_t * svc_ctx,
+ const axutil_env_t * env,
+ axis2_svc_grp_ctx_t * parent)
+{
+ svc_ctx->parent = parent;
+ return AXIS2_SUCCESS;
+}
+
+void AXIS2_CALL
+axis2_svc_ctx_free(
+ struct axis2_svc_ctx *svc_ctx,
+ const axutil_env_t * env)
+{
+ if(svc_ctx->base)
+ {
+ axis2_ctx_free(svc_ctx->base, env);
+ }
+
+ AXIS2_FREE(env->allocator, svc_ctx);
+ return;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_svc_ctx_init(
+ struct axis2_svc_ctx * svc_ctx,
+ const axutil_env_t * env,
+ axis2_conf_t * conf)
+{
+ if(svc_ctx->svc_qname)
+ {
+ axis2_char_t *svc_name = axutil_qname_get_localpart(svc_ctx->svc_qname, env);
+ svc_ctx->svc = axis2_conf_get_svc(conf, env, svc_name);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+const axis2_char_t *AXIS2_CALL
+axis2_svc_ctx_get_svc_id(
+ const axis2_svc_ctx_t * svc_ctx,
+ const axutil_env_t * env)
+{
+ return svc_ctx->svc_id;
+}
+
+axis2_svc_t *AXIS2_CALL
+axis2_svc_ctx_get_svc(
+ const axis2_svc_ctx_t * svc_ctx,
+ const axutil_env_t * env)
+{
+ return svc_ctx->svc;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_svc_ctx_set_svc(
+ axis2_svc_ctx_t * svc_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc)
+{
+ AXIS2_PARAM_CHECK(env->error, svc, AXIS2_FAILURE);
+
+ svc_ctx->svc = svc;
+ svc_ctx->svc_qname = (axutil_qname_t *)axis2_svc_get_qname(svc, env);
+ if(svc_ctx->svc_qname)
+ {
+ svc_ctx->svc_id = axutil_qname_get_localpart(svc_ctx->svc_qname, env);
+ }
+ return AXIS2_SUCCESS;
+}
+
+struct axis2_conf_ctx *AXIS2_CALL
+axis2_svc_ctx_get_conf_ctx(
+ const axis2_svc_ctx_t * svc_ctx,
+ const axutil_env_t * env)
+{
+ return axis2_svc_grp_ctx_get_parent(svc_ctx->parent, env);
+}
+
+axis2_op_ctx_t *AXIS2_CALL
+axis2_svc_ctx_create_op_ctx(
+ struct axis2_svc_ctx * svc_ctx,
+ const axutil_env_t * env,
+ const axutil_qname_t * qname)
+{
+ axis2_op_t *op = NULL;
+
+ if(svc_ctx->svc)
+ {
+ op = axis2_svc_get_op_with_qname(svc_ctx->svc, env, qname);
+ return axis2_op_ctx_create(env, op, svc_ctx);
+ }
+
+ return NULL;
+}
+
diff --git a/src/core/context/svc_grp_ctx.c b/src/core/context/svc_grp_ctx.c
new file mode 100644
index 0000000..449c01b
--- /dev/null
+++ b/src/core/context/svc_grp_ctx.c
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <axis2_svc_grp_ctx.h>
+#include <axis2_svc_grp.h>
+#include <axis2_const.h>
+#include <axutil_hash.h>
+
+struct axis2_svc_grp_ctx
+{
+
+ /** base context struct */
+ axis2_ctx_t *base;
+
+ /** parent of service group context is a configuration context instance */
+ struct axis2_conf_ctx *parent;
+
+ /** service group context ID */
+ axis2_char_t *id;
+
+ /** map of service contexts belonging to this service context group */
+ axutil_hash_t *svc_ctx_map;
+
+ /** service group associated with this service group context */
+ axis2_svc_grp_t *svc_grp;
+
+ /** name of the service group associated with this context */
+ axis2_char_t *svc_grp_name;
+};
+
+AXIS2_EXTERN axis2_svc_grp_ctx_t *AXIS2_CALL
+axis2_svc_grp_ctx_create(
+ const axutil_env_t * env,
+ axis2_svc_grp_t * svc_grp,
+ struct axis2_conf_ctx *conf_ctx)
+{
+ axis2_svc_grp_ctx_t *svc_grp_ctx = NULL;
+
+ svc_grp_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_grp_ctx_t));
+ if(!svc_grp_ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ svc_grp_ctx->base = NULL;
+ svc_grp_ctx->parent = NULL;
+ svc_grp_ctx->id = NULL;
+ svc_grp_ctx->svc_ctx_map = NULL;
+ svc_grp_ctx->svc_grp = NULL;
+ svc_grp_ctx->svc_grp_name = NULL;
+
+ svc_grp_ctx->base = axis2_ctx_create(env);
+ if(!(svc_grp_ctx->base))
+ {
+ axis2_svc_grp_ctx_free(svc_grp_ctx, env);
+ return NULL;
+ }
+
+ if(svc_grp)
+ {
+ svc_grp_ctx->svc_grp = svc_grp;
+ svc_grp_ctx->svc_grp_name = (axis2_char_t *)axis2_svc_grp_get_name(svc_grp_ctx->svc_grp,
+ env);
+ svc_grp_ctx->id = axutil_strdup(env, svc_grp_ctx->svc_grp_name);
+ }
+
+ if(conf_ctx)
+ {
+ svc_grp_ctx->parent = conf_ctx;
+ }
+
+ svc_grp_ctx->svc_ctx_map = axutil_hash_make(env);
+ if(!(svc_grp_ctx->svc_ctx_map))
+ {
+ axis2_svc_grp_ctx_free(svc_grp_ctx, env);
+ return NULL;
+ }
+
+ axis2_svc_grp_ctx_fill_svc_ctx_map((svc_grp_ctx), env);
+
+ return svc_grp_ctx;
+}
+
+AXIS2_EXTERN axis2_ctx_t *AXIS2_CALL
+axis2_svc_grp_ctx_get_base(
+ const axis2_svc_grp_ctx_t * svc_grp_ctx,
+ const axutil_env_t * env)
+{
+ return svc_grp_ctx->base;
+}
+
+AXIS2_EXTERN struct axis2_conf_ctx *AXIS2_CALL
+axis2_svc_grp_ctx_get_parent(
+ const axis2_svc_grp_ctx_t * svc_grp_ctx,
+ const axutil_env_t * env)
+{
+ return svc_grp_ctx->parent;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_svc_grp_ctx_free(
+ struct axis2_svc_grp_ctx *svc_grp_ctx,
+ const axutil_env_t * env)
+{
+ if(svc_grp_ctx->id)
+ {
+ AXIS2_FREE(env->allocator, svc_grp_ctx->id);
+ }
+
+ if(svc_grp_ctx->base)
+ {
+ axis2_ctx_free(svc_grp_ctx->base, env);
+ }
+
+ if(svc_grp_ctx->svc_ctx_map)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ for(hi = axutil_hash_first(svc_grp_ctx->svc_ctx_map, env); hi; hi = axutil_hash_next(env,
+ hi))
+ {
+ axutil_hash_this(hi, NULL, NULL, &val);
+ if(val)
+ {
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ svc_ctx = (axis2_svc_ctx_t *)val;
+ axis2_svc_ctx_free(svc_ctx, env);
+ }
+ }
+
+ axutil_hash_free(svc_grp_ctx->svc_ctx_map, env);
+ svc_grp_ctx->base = NULL;
+ }
+
+ AXIS2_FREE(env->allocator, svc_grp_ctx);
+
+ return;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_svc_grp_ctx_init(
+ struct axis2_svc_grp_ctx * svc_grp_ctx,
+ const axutil_env_t * env,
+ axis2_conf_t * conf)
+{
+ if(svc_grp_ctx->svc_grp_name)
+ {
+ svc_grp_ctx->svc_grp = axis2_conf_get_svc_grp(conf, env, svc_grp_ctx->svc_grp_name);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
+axis2_svc_grp_ctx_get_id(
+ const axis2_svc_grp_ctx_t * svc_grp_ctx,
+ const axutil_env_t * env)
+{
+ return svc_grp_ctx->id;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_svc_grp_ctx_set_id(
+ struct axis2_svc_grp_ctx * svc_grp_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * id)
+{
+ if(svc_grp_ctx->id)
+ {
+ AXIS2_FREE(env->allocator, svc_grp_ctx->id);
+ svc_grp_ctx->id = NULL;
+ }
+
+ if(id)
+ {
+ svc_grp_ctx->id = axutil_strdup(env, id);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_svc_ctx_t *AXIS2_CALL
+axis2_svc_grp_ctx_get_svc_ctx(
+ const axis2_svc_grp_ctx_t * svc_grp_ctx,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_name)
+{
+ return (axis2_svc_ctx_t *)axutil_hash_get(svc_grp_ctx->svc_ctx_map, svc_name,
+ AXIS2_HASH_KEY_STRING);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_svc_grp_ctx_fill_svc_ctx_map(
+ struct axis2_svc_grp_ctx * svc_grp_ctx,
+ const axutil_env_t * env)
+{
+ axutil_hash_index_t *hi = NULL;
+ void *next_svc = NULL;
+
+ if(svc_grp_ctx->svc_grp)
+ {
+ axutil_hash_t *service_map = axis2_svc_grp_get_all_svcs(svc_grp_ctx->svc_grp, env);
+ if(service_map)
+ {
+ for(hi = axutil_hash_first(service_map, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axutil_hash_this(hi, NULL, NULL, &next_svc);
+ if(next_svc)
+ {
+ axis2_svc_t *svc = NULL;
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axis2_char_t *svc_name = NULL;
+ svc = (axis2_svc_t *)next_svc;
+ svc_ctx = axis2_svc_ctx_create(env, svc, svc_grp_ctx);
+ svc_name = axutil_qname_get_localpart(axis2_svc_get_qname(svc, env), env);
+ if(svc_name)
+ axutil_hash_set(svc_grp_ctx->svc_ctx_map, svc_name, AXIS2_HASH_KEY_STRING,
+ svc_ctx);
+ }
+ }
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_svc_grp_t *AXIS2_CALL
+axis2_svc_grp_ctx_get_svc_grp(
+ const axis2_svc_grp_ctx_t * svc_grp_ctx,
+ const axutil_env_t * env)
+{
+ return svc_grp_ctx->svc_grp;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_svc_grp_ctx_get_svc_ctx_map(
+ const axis2_svc_grp_ctx_t * svc_grp_ctx,
+ const axutil_env_t * env)
+{
+ return svc_grp_ctx->svc_ctx_map;
+}
+