summaryrefslogtreecommitdiffstats
path: root/src/core/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/engine')
-rw-r--r--src/core/engine/Makefile.am47
-rw-r--r--src/core/engine/addr_disp.c255
-rw-r--r--src/core/engine/axis2_disp_checker.h105
-rw-r--r--src/core/engine/conf.c1835
-rw-r--r--src/core/engine/ctx_handler.c204
-rw-r--r--src/core/engine/disp.c185
-rw-r--r--src/core/engine/disp_checker.c284
-rw-r--r--src/core/engine/engine.c915
-rw-r--r--src/core/engine/handler.c133
-rw-r--r--src/core/engine/phase.c1275
-rw-r--r--src/core/engine/req_uri_disp.c206
-rw-r--r--src/core/engine/rest_disp.c350
-rw-r--r--src/core/engine/soap_action_disp.c155
-rw-r--r--src/core/engine/soap_body_disp.c231
14 files changed, 6180 insertions, 0 deletions
diff --git a/src/core/engine/Makefile.am b/src/core/engine/Makefile.am
new file mode 100644
index 0000000..7b9598c
--- /dev/null
+++ b/src/core/engine/Makefile.am
@@ -0,0 +1,47 @@
+lib_LTLIBRARIES=libaxis2_engine.la
+
+libaxis2_engine_la_SOURCES= ../transport/transport_receiver.c handler.c \
+ conf.c \
+ phase.c \
+ disp_checker.c \
+ addr_disp.c \
+ rest_disp.c \
+ req_uri_disp.c \
+ disp.c \
+ soap_action_disp.c \
+ soap_body_disp.c \
+ ctx_handler.c \
+ engine.c
+
+libaxis2_engine_la_LDFLAGS = -version-info $(VERSION_NO)
+
+libaxis2_engine_la_LIBADD=$(top_builddir)/src/core/description/libaxis2_description.la \
+ $(top_builddir)/src/core/receivers/libaxis2_receivers.la \
+ $(top_builddir)/src/core/deployment/libaxis2_deployment.la \
+ $(top_builddir)/src/core/context/libaxis2_context.la \
+ $(top_builddir)/src/core/addr/libaxis2_addr.la \
+ $(top_builddir)/src/core/clientapi/libaxis2_clientapi.la \
+ $(top_builddir)/src/core/phaseresolver/libaxis2_phaseresolver.la \
+ $(top_builddir)/src/core/util/libaxis2_core_utils.la \
+ $(top_builddir)/util/src/libaxutil.la \
+ $(top_builddir)/neethi/src/libneethi.la \
+ $(top_builddir)/axiom/src/om/libaxis2_axiom.la
+libaxis2_engine_la_LIBADD+=$(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
+ $(top_builddir)/src/core/transport/http/util/libaxis2_http_util.la
+
+
+INCLUDES = -I$(top_builddir)/include \
+ -I$(top_builddir)/src/wsdl \
+ -I$(top_builddir)/src/core/description \
+ -I$(top_builddir)/src/core/engine \
+ -I$(top_builddir)/src/core/phaseresolver \
+ -I$(top_builddir)/src/core/deployment \
+ -I$(top_builddir)/src/core/context \
+ -I$(top_builddir)/src/core/util \
+ -I$(top_builddir)/src/core/clientapi \
+ -I$(top_builddir)/util/include \
+ -I$(top_builddir)/neethi/include \
+ -I$(top_builddir)/axiom/include
+
+EXTRA_DIST=axis2_disp_checker.h
+
diff --git a/src/core/engine/addr_disp.c b/src/core/engine/addr_disp.c
new file mode 100644
index 0000000..a928e7a
--- /dev/null
+++ b/src/core/engine/addr_disp.c
@@ -0,0 +1,255 @@
+/*
+ * 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_disp.h>
+#include <axis2_handler_desc.h>
+#include <axutil_string.h>
+#include <axis2_relates_to.h>
+#include <axis2_svc.h>
+#include <axis2_const.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_addr.h>
+#include <axutil_utils.h>
+
+const axis2_char_t *AXIS2_ADDR_DISP_NAME = "addressing_based_dispatcher";
+
+static axis2_status_t AXIS2_CALL axis2_addr_disp_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx *msg_ctx);
+
+static axis2_svc_t *AXIS2_CALL axis2_addr_disp_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env);
+
+static axis2_op_t *AXIS2_CALL axis2_addr_disp_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc);
+
+axis2_disp_t *AXIS2_CALL
+axis2_addr_disp_create(
+ const axutil_env_t * env)
+{
+ axis2_disp_t *disp = NULL;
+ axis2_handler_t *handler = NULL;
+ axutil_string_t *name = NULL;
+
+ name = axutil_string_create_const(env, (axis2_char_t **)&AXIS2_ADDR_DISP_NAME);
+ if(!name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ disp = axis2_disp_create(env, name);
+ if(!disp)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ axutil_string_free(name, env);
+ return NULL;
+ }
+
+ handler = axis2_disp_get_base(disp, env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ axutil_string_free(name, env);
+ return NULL;
+ }
+
+ axis2_handler_set_invoke(handler, env, axis2_addr_disp_invoke);
+
+ axutil_string_free(name, env);
+
+ return disp;
+}
+
+static axis2_svc_t *AXIS2_CALL
+axis2_addr_disp_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_svc_t *svc = NULL;
+
+ if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ return NULL;
+
+ endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);
+
+ if(endpoint_ref)
+ {
+ const axis2_char_t *address = NULL;
+
+ address = axis2_endpoint_ref_get_address(endpoint_ref, env);
+ if(address)
+ {
+ axis2_char_t **url_tokens = NULL;
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Checking for service using WSA enpoint address : %s", address);
+
+ if((axutil_strcmp(AXIS2_WSA_ANONYMOUS_URL, address) == 0) || (axutil_strcmp(
+ AXIS2_WSA_NAMESPACE_SUBMISSION, address) == 0))
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Endpoint address cannot be the same as WSA namespace : %s", address);
+ return NULL;
+ }
+
+ url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);
+
+ if(url_tokens)
+ {
+ if(url_tokens[0])
+ {
+ axis2_conf_ctx_t *conf_ctx = NULL;
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ axis2_conf_t *conf = NULL;
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ if(conf)
+ {
+ svc = axis2_conf_get_svc(conf, env, url_tokens[0]);
+
+ if(svc)
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Service found using WSA enpoint address");
+ }
+ }
+ }
+ AXIS2_FREE(env->allocator, url_tokens[0]);
+ }
+ if(url_tokens[1])
+ {
+ AXIS2_FREE(env->allocator, url_tokens[1]);
+ }
+ AXIS2_FREE(env->allocator, url_tokens);
+ url_tokens = NULL;
+ }
+ }
+ }
+
+ return svc;
+}
+
+static axis2_op_t *AXIS2_CALL
+axis2_addr_disp_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc)
+{
+ const axis2_char_t *action = NULL;
+ axutil_qname_t *name = NULL;
+ axis2_op_t *op = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+ AXIS2_PARAM_CHECK(env->error, svc, NULL);
+
+ if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ return NULL;
+
+ action = axis2_msg_ctx_get_wsa_action(msg_ctx, env);
+
+ if(action)
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Checking for operation using WSA Action : %s",
+ action);
+
+ name = axutil_qname_create(env, action, NULL, NULL);
+ op = axis2_svc_get_op_with_qname(svc, env, name);
+ if(op)
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Operation found using WSA Action");
+ axutil_qname_free(name, env);
+ }
+
+ return op;
+}
+
+static axis2_status_t AXIS2_CALL
+axis2_addr_disp_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx *msg_ctx)
+{
+ axis2_relates_to_t *relates_to = NULL;
+
+ relates_to = axis2_msg_ctx_get_relates_to(msg_ctx, env);
+
+ /** first check if we can dispatch using the relates_to */
+ if(relates_to)
+ {
+ const axis2_char_t *relates_to_value = NULL;
+ relates_to_value = axis2_relates_to_get_value(relates_to, env);
+ if(relates_to_value && axutil_strcmp(relates_to_value, "") != 0)
+ {
+ axis2_conf_ctx_t *conf_ctx = NULL;
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ axis2_op_ctx_t *op_ctx = NULL;
+ const axis2_char_t *msg_id = axis2_msg_ctx_get_msg_id(msg_ctx, env);
+ op_ctx = axis2_conf_ctx_get_op_ctx(conf_ctx, env, msg_id);
+ if(op_ctx)
+ {
+ axis2_op_t *op = NULL;
+ op = axis2_op_ctx_get_op(op_ctx, env);
+ if(op)
+ {
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axis2_msg_ctx_set_op_ctx(msg_ctx, env, op_ctx);
+ axis2_msg_ctx_set_op(msg_ctx, env, op);
+ axis2_op_register_op_ctx(op, env, msg_ctx, op_ctx);
+
+ svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
+ if(svc_ctx)
+ {
+ axis2_svc_t *svc = NULL;
+ axis2_svc_grp_ctx_t *svc_grp_ctx = NULL;
+ axis2_msg_ctx_set_svc_ctx(msg_ctx, env, svc_ctx);
+ svc = axis2_svc_ctx_get_svc(svc_ctx, env);
+ if(svc)
+ {
+ axis2_msg_ctx_set_svc(msg_ctx, env, svc);
+ }
+ svc_grp_ctx = axis2_svc_ctx_get_parent(svc_ctx, env);
+ if(svc_grp_ctx)
+ {
+ axutil_string_t *svc_grp_ctx_id_str = axutil_string_create(env,
+ axis2_svc_grp_ctx_get_id(svc_grp_ctx, env));
+ 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);
+ }
+ return AXIS2_SUCCESS;
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ axis2_msg_ctx_set_find_svc(msg_ctx, env, axis2_addr_disp_find_svc);
+ axis2_msg_ctx_set_find_op(msg_ctx, env, axis2_addr_disp_find_op);
+
+ return axis2_disp_find_svc_and_op(handler, env, msg_ctx);
+}
+
diff --git a/src/core/engine/axis2_disp_checker.h b/src/core/engine/axis2_disp_checker.h
new file mode 100644
index 0000000..a93ac51
--- /dev/null
+++ b/src/core/engine/axis2_disp_checker.h
@@ -0,0 +1,105 @@
+
+/*
+* 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.
+*/
+
+#ifndef AXIS2_DISP_CHECKER_H
+#define AXIS2_DISP_CHECKER_H
+
+/**
+ * @defgroup axis2_disp_checker dispatcher checker
+ * @ingroup axis2_engine
+ * dispatcher checker is responsible of checking the status of the dispatchers.
+ * @{
+ */
+
+/**
+ * @file axis2_disp_checker.h
+ */
+
+#include <axis2_defines.h>
+#include <axutil_string.h>
+#include <axis2_handler.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /** Type name for struct axis2_disp_checker */
+ typedef struct axis2_disp_checker axis2_disp_checker_t;
+
+ /**
+ * Gets the base handler.
+ * @param disp_checker pointer to dispatcher checker
+ * @param env pointer to environment struct
+ * @return pointer to base handler, returns a reference not a cloned copy
+ */
+ AXIS2_EXTERN axis2_handler_t *AXIS2_CALL
+ axis2_disp_checker_get_base(
+ const axis2_disp_checker_t * disp_checker,
+ const axutil_env_t * env);
+
+ /**
+ * Gets QName.
+ * @param disp_checker pointer to dispatcher checker
+ * @param env pointer to environment struct
+ * @return returns a pointer to the QName, returns a reference not a
+ * cloned copy
+ */
+ AXIS2_EXTERN axutil_string_t *AXIS2_CALL
+ axis2_disp_checker_get_name(
+ const axis2_disp_checker_t * disp_checker,
+ const axutil_env_t * env);
+
+ /**
+ * Sets QName.
+ * @param disp_checker pointer to dispatcher checker
+ * @param env pointer to environment struct
+ * @param name pointer to QName. A clone would be created within the method
+ * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axis2_disp_checker_set_name(
+ axis2_disp_checker_t * disp_checker,
+ const axutil_env_t * env,
+ const axutil_string_t * name);
+
+ /**
+ * Frees dispatcher checker.
+ * @param disp_checker pointer to dispatcher checker
+ * @param env pointer to environment struct
+ * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+ */
+ AXIS2_EXTERN void AXIS2_CALL
+ axis2_disp_checker_free(
+ axis2_disp_checker_t * disp_checker,
+ const axutil_env_t * env);
+
+ /**
+ * Creates a dispatcher checker struct instance.
+ * @param env pointer to environment struct
+ * @return pointer to newly created dispatcher checker struct
+ */
+ AXIS2_EXTERN axis2_disp_checker_t *AXIS2_CALL
+ axis2_disp_checker_create(
+ const axutil_env_t * env);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIS2_DISP_CHECKER_H */
diff --git a/src/core/engine/conf.c b/src/core/engine/conf.c
new file mode 100644
index 0000000..6e81392
--- /dev/null
+++ b/src/core/engine/conf.c
@@ -0,0 +1,1835 @@
+/*
+ * 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 <string.h>
+#include <axis2_disp.h>
+#include "axis2_disp_checker.h"
+#include <axis2_conf.h>
+#include <axutil_dir_handler.h>
+#include <axis2_dep_engine.h>
+#include <axis2_arch_reader.h>
+#include <axis2_core_utils.h>
+
+struct axis2_conf
+{
+ axutil_hash_t *svc_grps;
+ axis2_transport_in_desc_t *transports_in[AXIS2_TRANSPORT_ENUM_MAX];
+ axis2_transport_out_desc_t *transports_out[AXIS2_TRANSPORT_ENUM_MAX];
+
+ /**
+ * All the modules already engaged can be found here.
+ */
+ axutil_array_list_t *engaged_module_list;
+
+ /*To store all the available modules (including version) */
+ axutil_hash_t *all_modules;
+
+ /*To store mapping between default version to module name */
+ axutil_hash_t *name_to_version_map;
+ axutil_array_list_t *out_phases;
+ axutil_array_list_t *in_fault_phases;
+ axutil_array_list_t *out_fault_phases;
+
+ /* All the system specific phases are stored here */
+ axutil_array_list_t *in_phases_upto_and_including_post_dispatch;
+
+ axis2_phases_info_t *phases_info;
+ axutil_hash_t *all_svcs;
+ axutil_hash_t *all_init_svcs;
+ axutil_hash_t *msg_recvs;
+ axutil_hash_t *faulty_svcs;
+ axutil_hash_t *faulty_modules;
+ axis2_char_t *axis2_repo;
+ axis2_char_t *axis2_xml;
+ axis2_dep_engine_t *dep_engine;
+ axutil_array_list_t *handlers;
+ axis2_bool_t enable_mtom;
+ /*This is used in rampart */
+ axis2_bool_t enable_security;
+
+ /** Configuration parameter container */
+ axutil_param_container_t *param_container;
+
+ /** Base description struct */
+ axis2_desc_t *base;
+
+ /** Mark whether conf is built using axis2 XML*/
+ axis2_bool_t axis2_flag;
+
+#if 0
+/* this seemed to be not used after 1.6.0 */
+/* This is a hack to keep rampart_context at client side */
+void *security_context;
+#endif
+};
+
+AXIS2_EXTERN axis2_conf_t *AXIS2_CALL
+axis2_conf_create(
+ const axutil_env_t * env)
+{
+ axis2_conf_t *conf = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ axis2_phase_t *phase = NULL;
+ int i = 0;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ conf = (axis2_conf_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_conf_t));
+ if(!conf)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
+ return NULL;
+ }
+
+ memset((void *)conf, 0, sizeof(axis2_conf_t));
+
+ conf->param_container = (axutil_param_container_t *)axutil_param_container_create(env);
+ if(!conf->param_container)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating parameter container failed");
+ return NULL;
+ }
+
+ conf->svc_grps = axutil_hash_make(env);
+ if(!conf->svc_grps)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating service group map failed");
+ return NULL;
+ }
+
+ for(i = 0; i < AXIS2_TRANSPORT_ENUM_MAX; i++)
+ {
+ conf->transports_in[i] = NULL;
+ }
+
+ for(i = 0; i < AXIS2_TRANSPORT_ENUM_MAX; i++)
+ {
+ conf->transports_out[i] = NULL;
+ }
+
+ conf->engaged_module_list = axutil_array_list_create(env, 0);
+ if(!conf->engaged_module_list)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating engaged module list failed");
+ return NULL;
+ }
+
+ conf->handlers = axutil_array_list_create(env, 0);
+ if(!conf->handlers)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating handler list failed");
+ return NULL;
+ }
+
+ conf->in_phases_upto_and_including_post_dispatch = axutil_array_list_create(env, 0);
+ if(!conf->in_phases_upto_and_including_post_dispatch)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Creating in phases list upto and including post dispatch failed");
+ return NULL;
+ }
+ else
+ {
+ axis2_disp_t *uri_dispatch = NULL;
+ axis2_disp_t *addr_dispatch = NULL;
+
+ phase = axis2_phase_create(env, AXIS2_PHASE_TRANSPORT_IN);
+ if(!phase)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase %s failed",
+ AXIS2_PHASE_TRANSPORT_IN);
+ return NULL;
+ }
+
+ /* In case of using security we need to find the service/operation parameters before the
+ * dispatch phase. This is required to give parameters to the security inflow.*/
+ uri_dispatch = axis2_req_uri_disp_create(env);
+ if(uri_dispatch)
+ {
+ axis2_handler_t *handler = NULL;
+ handler = axis2_disp_get_base(uri_dispatch, env);
+ axis2_disp_free(uri_dispatch, env);
+ axis2_phase_add_handler_at(phase, env, 0, handler);
+ axutil_array_list_add(conf->handlers, env, axis2_handler_get_handler_desc(handler, env));
+ }
+
+ addr_dispatch = axis2_addr_disp_create(env);
+ if(addr_dispatch)
+ {
+ axis2_handler_t *handler = NULL;
+ handler = axis2_disp_get_base(addr_dispatch, env);
+ axis2_disp_free(addr_dispatch, env);
+ axis2_phase_add_handler_at(phase, env, 1, handler);
+ axutil_array_list_add(conf->handlers, env, axis2_handler_get_handler_desc(handler, env));
+ }
+
+ status
+ = axutil_array_list_add(conf->in_phases_upto_and_including_post_dispatch, env, phase);
+ if(AXIS2_SUCCESS != status)
+ {
+ axis2_conf_free(conf, env);
+ axis2_phase_free(phase, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Adding phase %s into in phases upto and including post dispatch list failed",
+ AXIS2_PHASE_TRANSPORT_IN);
+ return NULL;
+ }
+
+ phase = axis2_phase_create(env, AXIS2_PHASE_PRE_DISPATCH);
+ if(!phase)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase %s failed",
+ AXIS2_PHASE_PRE_DISPATCH);
+ return NULL;
+ }
+
+ status
+ = axutil_array_list_add(conf->in_phases_upto_and_including_post_dispatch, env, phase);
+ if(AXIS2_SUCCESS != status)
+ {
+ axis2_conf_free(conf, env);
+ axis2_phase_free(phase, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Adding phase %s into in phases upto and including post dispatch list failed",
+ AXIS2_PHASE_PRE_DISPATCH);
+ return NULL;
+ }
+ }
+
+ conf->all_svcs = axutil_hash_make(env);
+ if(!conf->all_svcs)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating all services map failed");
+ return NULL;
+ }
+
+ conf->all_init_svcs = axutil_hash_make(env);
+ if(!conf->all_init_svcs)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating all init services map failed");
+ return NULL;
+ }
+
+ conf->msg_recvs = axutil_hash_make(env);
+ if(!conf->msg_recvs)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating message receivers map failed.");
+ return NULL;
+ }
+
+ conf->faulty_svcs = axutil_hash_make(env);
+ if(!conf->faulty_svcs)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating fault services map failed");
+ return NULL;
+ }
+
+ conf->faulty_modules = axutil_hash_make(env);
+ if(!conf->faulty_modules)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating fault modules map failed");
+ return NULL;
+ }
+
+ conf->all_modules = axutil_hash_make(env);
+ if(!conf->all_modules)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating all modules map failed");
+ return NULL;
+ }
+
+ conf->name_to_version_map = axutil_hash_make(env);
+ if(!conf->name_to_version_map)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating name to version map failed");
+ return NULL;
+ }
+
+ conf->base = axis2_desc_create(env);
+ if(!conf->base)
+ {
+ axis2_conf_free(conf, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Creating Axis2 configuration base description failed");
+ return NULL;
+ }
+
+ return conf;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_conf_free(
+ axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ int i = 0;
+
+ if(!conf)
+ {
+ /* nothing to free */
+ return;
+ }
+
+ if(conf->param_container)
+ {
+ axutil_param_container_free(conf->param_container, env);
+ }
+
+ if(conf->svc_grps)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ for(hi = axutil_hash_first(conf->svc_grps, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axis2_svc_grp_t *svc_grp = NULL;
+ axutil_hash_this(hi, NULL, NULL, &val);
+ svc_grp = (axis2_svc_grp_t *)val;
+ if(svc_grp)
+ {
+ axis2_svc_grp_free(svc_grp, env);
+ }
+ }
+ axutil_hash_free(conf->svc_grps, env);
+ }
+
+ for(i = 0; i < AXIS2_TRANSPORT_ENUM_MAX; i++)
+ {
+ if(conf->transports_in[i])
+ {
+ axis2_transport_in_desc_free(conf->transports_in[i], env);
+ }
+ }
+
+ for(i = 0; i < AXIS2_TRANSPORT_ENUM_MAX; i++)
+ {
+ if(conf->transports_out[i])
+ {
+ axis2_transport_out_desc_free(conf->transports_out[i], env);
+ }
+ }
+
+ if(conf->dep_engine)
+ {
+ axis2_dep_engine_free(conf->dep_engine, env);
+ }
+
+ if(conf->all_modules)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ for(hi = axutil_hash_first(conf->all_modules, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axis2_module_desc_t *module_desc = NULL;
+ axutil_hash_this(hi, NULL, NULL, &val);
+ module_desc = (axis2_module_desc_t *)val;
+ if(module_desc)
+ {
+ axis2_module_desc_free(module_desc, env);
+ }
+ }
+ axutil_hash_free(conf->all_modules, env);
+ }
+
+ if(conf->name_to_version_map)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ for(hi = axutil_hash_first(conf->name_to_version_map, env); hi; hi = axutil_hash_next(env,
+ hi))
+ {
+ axis2_char_t *module_ver = NULL;
+ axutil_hash_this(hi, NULL, NULL, &val);
+ module_ver = (axis2_char_t *)val;
+ if(module_ver)
+ {
+ AXIS2_FREE(env->allocator, module_ver);
+ }
+ }
+ axutil_hash_free(conf->name_to_version_map, env);
+ }
+
+ if(conf->engaged_module_list)
+ {
+ for(i = 0; i < axutil_array_list_size(conf->engaged_module_list, env); i++)
+ {
+ axutil_qname_t *module_desc_qname = NULL;
+ module_desc_qname = (axutil_qname_t *)axutil_array_list_get(conf->engaged_module_list,
+ env, i);
+ if(module_desc_qname)
+ {
+ axutil_qname_free(module_desc_qname, env);
+ }
+ }
+ axutil_array_list_free(conf->engaged_module_list, env);
+ }
+
+ if(conf->out_phases)
+ {
+ for(i = 0; i < axutil_array_list_size(conf->out_phases, env); i++)
+ {
+ axis2_phase_t *phase = NULL;
+ phase = (axis2_phase_t *)axutil_array_list_get(conf->out_phases, env, i);
+ if(phase)
+ {
+ axis2_phase_free(phase, env);
+ }
+ }
+ axutil_array_list_free(conf->out_phases, env);
+ }
+
+ if(conf->in_fault_phases)
+ {
+ for(i = 0; i < axutil_array_list_size(conf->in_fault_phases, env); i++)
+ {
+ axis2_phase_t *phase = NULL;
+ phase = (axis2_phase_t *)axutil_array_list_get(conf->in_fault_phases, env, i);
+ if(phase)
+ {
+ axis2_phase_free(phase, env);
+ }
+ }
+ axutil_array_list_free(conf->in_fault_phases, env);
+ }
+
+ if(conf->out_fault_phases)
+ {
+ for(i = 0; i < axutil_array_list_size(conf->out_fault_phases, env); i++)
+ {
+ axis2_phase_t *phase = NULL;
+ phase = (axis2_phase_t *)axutil_array_list_get(conf->out_fault_phases, env, i);
+ if(phase)
+ {
+ axis2_phase_free(phase, env);
+ }
+ }
+ axutil_array_list_free(conf->out_fault_phases, env);
+ }
+
+ if(conf->in_phases_upto_and_including_post_dispatch)
+ {
+ for(i = 0; i < axutil_array_list_size(conf-> in_phases_upto_and_including_post_dispatch,
+ env); i++)
+ {
+ axis2_phase_t *phase = NULL;
+ phase = (axis2_phase_t *)axutil_array_list_get(
+ conf-> in_phases_upto_and_including_post_dispatch, env, i);
+ if(phase)
+ {
+ axis2_phase_free(phase, env);
+ }
+ }
+ axutil_array_list_free(conf-> in_phases_upto_and_including_post_dispatch, env);
+ }
+
+ if(conf->all_svcs)
+ {
+ axutil_hash_free(conf->all_svcs, env);
+ }
+
+ if(conf->all_init_svcs)
+ {
+ axutil_hash_free(conf->all_init_svcs, env);
+ }
+
+ if(conf->msg_recvs)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ for(hi = axutil_hash_first(conf->msg_recvs, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axis2_msg_recv_t *msg_recv = NULL;
+ axutil_hash_this(hi, NULL, NULL, &val);
+ msg_recv = (axis2_msg_recv_t *)val;
+ if(msg_recv)
+ {
+ axis2_msg_recv_free(msg_recv, env);
+ msg_recv = NULL;
+ }
+ }
+ axutil_hash_free(conf->msg_recvs, env);
+ }
+
+ if(conf->faulty_svcs)
+ {
+ axutil_hash_free(conf->faulty_svcs, env);
+ }
+
+ if(conf->faulty_modules)
+ {
+ axutil_hash_index_t *hi = NULL;
+ void *val = NULL;
+ for(hi = axutil_hash_first(conf->faulty_modules, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ axis2_module_desc_t *module_desc = NULL;
+ axutil_hash_this(hi, NULL, NULL, &val);
+ module_desc = (axis2_module_desc_t *)val;
+ if(module_desc)
+ {
+ axis2_module_desc_free(module_desc, env);
+ }
+ }
+ axutil_hash_free(conf->faulty_modules, env);
+ }
+
+ if(conf->handlers)
+ {
+ int i = 0;
+ for(i = 0; i < axutil_array_list_size(conf->handlers, env); i++)
+ {
+ axis2_handler_desc_t *handler_desc = NULL;
+ handler_desc = (axis2_handler_desc_t *)axutil_array_list_get(conf->handlers, env, i);
+ if(handler_desc)
+ {
+ axis2_handler_desc_free(handler_desc, env);
+ }
+ }
+ axutil_array_list_free(conf->handlers, env);
+ }
+
+ if(conf->axis2_repo)
+ {
+ AXIS2_FREE(env->allocator, conf->axis2_repo);
+ }
+
+ if(conf->base)
+ {
+ axis2_desc_free(conf->base, env);
+ }
+
+ if(conf->axis2_xml)
+ {
+ AXIS2_FREE(env->allocator, conf->axis2_xml);
+ }
+
+ AXIS2_FREE(env->allocator, conf);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_add_svc_grp(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_svc_grp_t * svc_grp)
+{
+ axutil_hash_t *svcs = NULL;
+ axutil_hash_index_t *index_i = NULL;
+ axis2_char_t *svc_name = NULL;
+ const axis2_char_t *svc_grp_name = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, svc_grp, AXIS2_FAILURE);
+
+ svcs = axis2_svc_grp_get_all_svcs(svc_grp, env);
+ if(!conf->all_svcs)
+ {
+ conf->all_svcs = axutil_hash_make(env);
+ if(!conf->all_svcs)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating all services map failed");
+ return AXIS2_FAILURE;
+ }
+ }
+
+ index_i = axutil_hash_first(svcs, env);
+ while(index_i)
+ {
+ void *value = NULL;
+ axis2_svc_t *desc = NULL;
+ axis2_svc_t *temp_svc = NULL;
+ const axutil_qname_t *svc_qname = NULL;
+
+ axutil_hash_this(index_i, NULL, NULL, &value);
+ desc = (axis2_svc_t *)value;
+ svc_qname = axis2_svc_get_qname(desc, env);
+ svc_name = axutil_qname_get_localpart(svc_qname, env);
+ temp_svc = axutil_hash_get(conf->all_svcs, svc_name, AXIS2_HASH_KEY_STRING);
+
+ /* No two service names deployed in the engine can be same */
+ if(temp_svc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_TWO_SVCS_CANNOT_HAVE_SAME_NAME, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "There is already a service called %s in the "
+ "all services list of axis2 configuration.", svc_name);
+ return AXIS2_FAILURE;
+ }
+
+ index_i = axutil_hash_next(env, index_i);
+ }
+
+ svcs = axis2_svc_grp_get_all_svcs(svc_grp, env);
+ index_i = axutil_hash_first(svcs, env);
+
+ while(index_i)
+ {
+ void *value = NULL;
+ axis2_svc_t *desc = NULL;
+
+ axutil_hash_this(index_i, NULL, NULL, &value);
+ desc = (axis2_svc_t *)value;
+ svc_name = axutil_qname_get_localpart(axis2_svc_get_qname(desc, env), env);
+ axutil_hash_set(conf->all_svcs, svc_name, AXIS2_HASH_KEY_STRING, desc);
+ index_i = axutil_hash_next(env, index_i);
+ }
+
+ svc_grp_name = axis2_svc_grp_get_name(svc_grp, env);
+ if(!conf->svc_grps)
+ {
+ conf->svc_grps = axutil_hash_make(env);
+ if(!conf->svc_grps)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating service group map failed");
+ return AXIS2_FAILURE;
+ }
+ }
+
+ axutil_hash_set(conf->svc_grps, svc_grp_name, AXIS2_HASH_KEY_STRING, svc_grp);
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_svc_grp_t *AXIS2_CALL
+axis2_conf_get_svc_grp(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_grp_name)
+{
+ AXIS2_PARAM_CHECK(env->error, svc_grp_name, NULL);
+
+ if(!conf->svc_grps)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_CONF, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Axis2 configuration does not contain a service group map");
+ return NULL;
+ }
+ return (axis2_svc_grp_t *)(axutil_hash_get(conf->svc_grps, svc_grp_name, AXIS2_HASH_KEY_STRING));
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_conf_get_all_svc_grps(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->svc_grps;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_add_svc(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_svc_t * svc)
+{
+ axis2_phase_resolver_t *phase_resolver = NULL;
+ axis2_svc_grp_t *svc_grp = NULL;
+ const axis2_char_t *svc_grp_name = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ AXIS2_PARAM_CHECK(env->error, svc, AXIS2_FAILURE);
+
+ /* We need to first create a service group with the same name as the
+ * service and make it the parent of service */
+ svc_grp_name = axis2_svc_get_name(svc, env);
+ if(!svc_grp_name)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service has no name set");
+ return AXIS2_FAILURE;
+ }
+
+ svc_grp = axis2_svc_grp_create(env);
+ if(!svc_grp)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Creating service group as parent of service %s failed", svc_grp_name);
+ return AXIS2_FAILURE;
+ }
+
+ status = axis2_svc_grp_set_name(svc_grp, env, svc_grp_name);
+ if(AXIS2_SUCCESS != status)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting name to service group failed");
+ return status;
+ }
+
+ status = axis2_svc_grp_set_parent(svc_grp, env, conf);
+ if(AXIS2_SUCCESS != status)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Setting parent to service group %s failed",
+ svc_grp_name);
+ return status;
+ }
+
+ phase_resolver = axis2_phase_resolver_create_with_config_and_svc(env, conf, svc);
+ if(!phase_resolver)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase resolver failed for service %s",
+ axis2_svc_get_name(svc, env));
+ return AXIS2_FAILURE;
+ }
+
+ status = axis2_phase_resolver_build_execution_chains_for_svc(phase_resolver, env);
+ axis2_phase_resolver_free(phase_resolver, env);
+ if(AXIS2_SUCCESS != status)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Building chains failed within phase resolver "
+ "for service %s", axis2_svc_get_name(svc, env));
+ return status;
+ }
+
+ status = axis2_svc_grp_add_svc(svc_grp, env, svc);
+ if(AXIS2_SUCCESS != status)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Adding service %s to service group %s failed",
+ svc_grp_name, svc_grp_name);
+ return status;
+ }
+
+ status = axis2_conf_add_svc_grp(conf, env, svc_grp);
+ return status;
+}
+
+AXIS2_EXTERN axis2_svc_t *AXIS2_CALL
+axis2_conf_get_svc(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_name)
+{
+ AXIS2_PARAM_CHECK(env->error, svc_name, NULL);
+
+ return axutil_hash_get(conf->all_svcs, svc_name, AXIS2_HASH_KEY_STRING);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_remove_svc(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axis2_char_t * svc_name)
+{
+ AXIS2_PARAM_CHECK(env->error, svc_name, AXIS2_FAILURE);
+
+ axutil_hash_set(conf->all_svcs, svc_name, AXIS2_HASH_KEY_STRING, NULL);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_add_param(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axutil_param_t * param)
+{
+ axis2_status_t status = AXIS2_FAILURE;
+ axis2_char_t *param_name = axutil_param_get_name(param, env);
+
+ AXIS2_PARAM_CHECK(env->error, param, AXIS2_FAILURE);
+
+ if(axis2_conf_is_param_locked(conf, env, param_name))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PARAMETER_LOCKED_CANNOT_OVERRIDE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Parameter %s is locked for Axis2 configuration",
+ param_name);
+ return AXIS2_FAILURE;
+ }
+ else
+ {
+ status = axutil_param_container_add_param(conf->param_container, env, param);
+ }
+ return status;
+}
+
+AXIS2_EXTERN axutil_param_t *AXIS2_CALL
+axis2_conf_get_param(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axis2_char_t * name)
+{
+ AXIS2_PARAM_CHECK(env->error, name, NULL);
+
+ if(!conf->param_container)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_PARAM_CONTAINER, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Param container is not set in axis2 configuraion");
+ return NULL;
+ }
+
+ return axutil_param_container_get_param(conf->param_container, env, name);
+
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_conf_get_all_params(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return axutil_param_container_get_params(conf->param_container, env);
+
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_conf_is_param_locked(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axis2_char_t * param_name)
+{
+ axutil_param_t *param = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FALSE);
+
+ param = axis2_conf_get_param(conf, env, param_name);
+ return (param && axutil_param_is_locked(param, env));
+}
+
+AXIS2_EXTERN axis2_transport_in_desc_t *AXIS2_CALL
+axis2_conf_get_transport_in(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const AXIS2_TRANSPORT_ENUMS trans_enum)
+{
+ return (axis2_transport_in_desc_t *)conf->transports_in[trans_enum];
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_add_transport_in(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_transport_in_desc_t * transport,
+ const AXIS2_TRANSPORT_ENUMS trans_enum)
+{
+ AXIS2_PARAM_CHECK(env->error, transport, AXIS2_FAILURE);
+
+ conf->transports_in[trans_enum] = transport;
+
+ return AXIS2_SUCCESS;
+
+}
+
+AXIS2_EXTERN axis2_transport_out_desc_t *AXIS2_CALL
+axis2_conf_get_transport_out(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const AXIS2_TRANSPORT_ENUMS trans_enum)
+{
+ return conf->transports_out[trans_enum];
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_add_transport_out(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_transport_out_desc_t * transport,
+ const AXIS2_TRANSPORT_ENUMS trans_enum)
+{
+ AXIS2_PARAM_CHECK(env->error, transport, AXIS2_FAILURE);
+
+ conf->transports_out[trans_enum] = transport;
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_transport_in_desc_t **AXIS2_CALL
+axis2_conf_get_all_in_transports(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return (axis2_transport_in_desc_t **)conf->transports_in;
+}
+
+AXIS2_EXTERN axis2_module_desc_t *AXIS2_CALL
+axis2_conf_get_module(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axutil_qname_t * qname)
+{
+ axis2_char_t *name = NULL;
+ axis2_module_desc_t *ret = NULL;
+ axis2_char_t *module_name = NULL;
+ axutil_qname_t *mod_qname = NULL;
+ const axis2_char_t *def_mod_ver = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, qname, NULL);
+
+ name = axutil_qname_to_string((axutil_qname_t *)qname, env);
+ ret = (axis2_module_desc_t *)axutil_hash_get(conf->all_modules, name, AXIS2_HASH_KEY_STRING);
+ if(ret)
+ {
+ return ret;
+ }
+ module_name = axutil_qname_get_localpart(qname, env);
+ if(!module_name)
+ {
+ return NULL;
+ }
+ def_mod_ver = axis2_conf_get_default_module_version(conf, env, module_name);
+ mod_qname = axis2_core_utils_get_module_qname(env, name, def_mod_ver);
+ if(!mod_qname)
+ {
+ return NULL;
+ }
+ name = axutil_qname_to_string(mod_qname, env);
+ ret = (axis2_module_desc_t *)axutil_hash_get(conf->all_modules, name, AXIS2_HASH_KEY_STRING);
+ axutil_qname_free(mod_qname, env);
+ mod_qname = NULL;
+ return ret;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_conf_get_all_engaged_modules(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->engaged_module_list;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_conf_get_in_phases_upto_and_including_post_dispatch(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->in_phases_upto_and_including_post_dispatch;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_conf_get_out_flow(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->out_phases;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_conf_get_in_fault_flow(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->in_fault_phases;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_conf_get_out_fault_flow(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->out_fault_phases;
+}
+
+AXIS2_EXTERN axis2_transport_out_desc_t **AXIS2_CALL
+axis2_conf_get_all_out_transports(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return (axis2_transport_out_desc_t **)conf->transports_out;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_conf_get_all_faulty_svcs(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->faulty_svcs;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_conf_get_all_faulty_modules(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->faulty_modules;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_conf_get_all_svcs(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ /*axutil_hash_t *sgs = NULL;
+ axutil_hash_index_t *index_i = NULL;
+ axutil_hash_index_t *index_j = NULL;
+ void *value = NULL;
+ void *value2 = NULL;
+ axis2_svc_grp_t *axis_svc_grp = NULL;
+ axutil_hash_t *svcs = NULL;
+ axis2_svc_t *svc = NULL;
+ axis2_char_t *svc_name = NULL;
+ */
+
+ /* Do we need to do all the following of retrieving all service groups and
+ * then add all services from each group to conf->all_svcs and then finally
+ * return conf->all_svcs?. We have already done this when
+ * adding each service group to the conf, so just returning conf->all_svcs
+ * here would be enough - Damitha */
+ /*sgs = axis2_conf_get_all_svc_grps(conf, env);
+ index_i = axutil_hash_first(sgs, env);
+ while(index_i)
+ {
+ axutil_hash_this(index_i, NULL, NULL, &value);
+ axis_svc_grp = (axis2_svc_grp_t *)value;
+ svcs = axis2_svc_grp_get_all_svcs(axis_svc_grp, env);
+ index_j = axutil_hash_first(svcs, env);
+ while(index_j)
+ {
+ axutil_hash_this(index_j, NULL, NULL, &value2);
+ svc = (axis2_svc_t *)value2;
+ svc_name = axutil_qname_get_localpart(axis2_svc_get_qname(svc, env), env);
+ axutil_hash_set(conf->all_svcs, svc_name, AXIS2_HASH_KEY_STRING, svc);
+
+ index_j = axutil_hash_next(env, index_j);
+ }
+
+ index_i = axutil_hash_next(env, index_i);
+ }*/
+ return conf->all_svcs;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_conf_get_all_svcs_to_load(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ axutil_hash_t *sgs = NULL;
+ axutil_hash_index_t *index_i = NULL;
+ axutil_hash_index_t *index_j = NULL;
+ void *value = NULL;
+ void *value2 = NULL;
+ axis2_svc_grp_t *axis_svc_grp = NULL;
+ axutil_hash_t *svcs = NULL;
+ axis2_svc_t *svc = NULL;
+ axis2_char_t *svc_name = NULL;
+
+ sgs = axis2_conf_get_all_svc_grps(conf, env);
+ index_i = axutil_hash_first(sgs, env);
+ while(index_i)
+ {
+ axutil_hash_this(index_i, NULL, NULL, &value);
+ axis_svc_grp = (axis2_svc_grp_t *)value;
+ svcs = axis2_svc_grp_get_all_svcs(axis_svc_grp, env);
+ index_j = axutil_hash_first(svcs, env);
+ while(index_j)
+ {
+ axutil_param_t *param = NULL;
+ axutil_hash_this(index_j, NULL, NULL, &value2);
+ svc = (axis2_svc_t *)value2;
+ svc_name = axutil_qname_get_localpart(axis2_svc_get_qname(svc, env), env);
+ param = axis2_svc_get_param(svc, env, AXIS2_LOAD_SVC_STARTUP);
+ if(param)
+ {
+ axutil_hash_set(conf->all_init_svcs, svc_name, AXIS2_HASH_KEY_STRING, svc);
+ }
+
+ index_j = axutil_hash_next(env, index_j);
+ }
+
+ index_i = axutil_hash_next(env, index_i);
+ }
+ return conf->all_init_svcs;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_conf_is_engaged(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axutil_qname_t * module_name)
+{
+ const axutil_qname_t *def_mod_qname = NULL;
+ axis2_module_desc_t *def_mod = NULL;
+ int i = 0;
+ int size = 0;
+
+ AXIS2_PARAM_CHECK(env->error, module_name, AXIS2_FALSE);
+
+ def_mod
+ = axis2_conf_get_default_module(conf, env, axutil_qname_get_localpart(module_name, env));
+ if(def_mod)
+ {
+ def_mod_qname = axis2_module_desc_get_qname(def_mod, env);
+ }
+
+ size = axutil_array_list_size(conf->engaged_module_list, env);
+ for(i = 0; i < size; i++)
+ {
+ axutil_qname_t *qname = NULL;
+ qname = (axutil_qname_t *)axutil_array_list_get(conf->engaged_module_list, env, i);
+ if(axutil_qname_equals(module_name, env, qname) || (def_mod_qname && axutil_qname_equals(
+ def_mod_qname, env, qname)))
+ {
+ return AXIS2_TRUE;
+ }
+ }
+
+ return AXIS2_FALSE;
+}
+
+AXIS2_EXTERN axis2_phases_info_t *AXIS2_CALL
+axis2_conf_get_phases_info(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->phases_info;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_phases_info(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_phases_info_t * phases_info)
+{
+ AXIS2_PARAM_CHECK(env->error, phases_info, AXIS2_FAILURE);
+
+ if(conf->phases_info)
+ {
+ axis2_phases_info_free(phases_info, env);
+ conf->phases_info = NULL;
+ }
+ conf->phases_info = phases_info;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_add_msg_recv(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axis2_char_t * key,
+ axis2_msg_recv_t * msg_recv)
+{
+ AXIS2_PARAM_CHECK(env->error, key, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_recv, AXIS2_FAILURE);
+ if(!conf->msg_recvs)
+ {
+ conf->msg_recvs = axutil_hash_make(env);
+ if(!conf->msg_recvs)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating message receiver map failed");
+ return AXIS2_FAILURE;
+ }
+ }
+ axutil_hash_set(conf->msg_recvs, key, AXIS2_HASH_KEY_STRING, msg_recv);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_msg_recv_t *AXIS2_CALL
+axis2_conf_get_msg_recv(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_char_t * key)
+{
+ return (axis2_msg_recv_t *)axutil_hash_get(conf->msg_recvs, key, AXIS2_HASH_KEY_STRING);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_out_phases(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axutil_array_list_t * out_phases)
+{
+ AXIS2_PARAM_CHECK(env->error, out_phases, AXIS2_FAILURE);
+
+ if(conf->out_phases)
+ {
+ axutil_array_list_free(conf->out_phases, env);
+ conf->out_phases = NULL;
+ }
+ conf->out_phases = out_phases;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_conf_get_out_phases(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->out_phases;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_in_fault_phases(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axutil_array_list_t * list)
+{
+ AXIS2_PARAM_CHECK(env->error, list, AXIS2_FAILURE);
+
+ if(conf->in_fault_phases)
+ {
+ axutil_array_list_free(conf->in_fault_phases, env);
+ conf->in_fault_phases = NULL;
+ }
+ conf->in_fault_phases = list;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_out_fault_phases(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axutil_array_list_t * list)
+{
+ AXIS2_PARAM_CHECK(env->error, list, AXIS2_FAILURE);
+
+ if(conf->out_fault_phases)
+ {
+ axutil_array_list_free(conf->out_fault_phases, env);
+ conf->out_fault_phases = NULL;
+ }
+ conf->out_fault_phases = list;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_conf_get_all_modules(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->all_modules;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_add_module(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_module_desc_t * module)
+{
+ const axutil_qname_t *module_qname = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, module, AXIS2_FAILURE);
+
+ axis2_module_desc_set_parent(module, env, conf);
+
+ module_qname = axis2_module_desc_get_qname(module, env);
+ if(module_qname)
+ {
+ axis2_char_t *module_name = NULL;
+ module_name = axutil_qname_to_string((axutil_qname_t *)module_qname, env);
+ axutil_hash_set(conf->all_modules, module_name, AXIS2_HASH_KEY_STRING, module);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_default_dispatchers(
+ axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ axis2_phase_t *dispatch = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ axis2_disp_t *rest_dispatch = NULL;
+ axis2_disp_t *soap_action_based_dispatch = NULL;
+ axis2_disp_t *soap_msg_body_based_dispatch = NULL;
+ axis2_handler_t *handler = NULL;
+ axis2_phase_t *post_dispatch = NULL;
+ axis2_disp_checker_t *disp_checker = NULL;
+
+ dispatch = axis2_phase_create(env, AXIS2_PHASE_DISPATCH);
+ if(!dispatch)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase %s failed", AXIS2_PHASE_DISPATCH);
+ return AXIS2_FAILURE;
+ }
+
+ rest_dispatch = axis2_rest_disp_create(env);
+ if(!rest_dispatch)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating rest dispatcher failed");
+ return AXIS2_FAILURE;
+ }
+
+ handler = axis2_disp_get_base(rest_dispatch, env);
+ axis2_disp_free(rest_dispatch, env);
+ axis2_phase_add_handler_at(dispatch, env, 0, handler);
+ axutil_array_list_add(conf->handlers, env, axis2_handler_get_handler_desc(handler, env));
+
+ soap_msg_body_based_dispatch = axis2_soap_body_disp_create(env);
+ if(!soap_msg_body_based_dispatch)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating soap body based dispatcher failed");
+ return AXIS2_FAILURE;
+ }
+
+ handler = axis2_disp_get_base(soap_msg_body_based_dispatch, env);
+ axis2_disp_free(soap_msg_body_based_dispatch, env);
+ axis2_phase_add_handler_at(dispatch, env, 1, handler);
+ axutil_array_list_add(conf->handlers, env, axis2_handler_get_handler_desc(handler, env));
+
+ soap_action_based_dispatch = axis2_soap_action_disp_create(env);
+ if(!soap_action_based_dispatch)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating soap action based dispatcher failed");
+ return AXIS2_FAILURE;
+ }
+
+ handler = axis2_disp_get_base(soap_action_based_dispatch, env);
+ axis2_disp_free(soap_action_based_dispatch, env);
+ axis2_phase_add_handler_at(dispatch, env, 2, handler);
+ axutil_array_list_add(conf->handlers, env, axis2_handler_get_handler_desc(handler, env));
+
+ status
+ = axutil_array_list_add(conf-> in_phases_upto_and_including_post_dispatch, env, dispatch);
+ if(AXIS2_SUCCESS != status)
+ {
+ axis2_phase_free(dispatch, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Adding dispatcher into in phases upto and including post dispatch list failed");
+ return status;
+ }
+
+ post_dispatch = axis2_phase_create(env, AXIS2_PHASE_POST_DISPATCH);
+ if(!post_dispatch)
+ {
+ axis2_phase_free(dispatch, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase %s failed",
+ AXIS2_PHASE_POST_DISPATCH);
+ return AXIS2_FAILURE;
+ }
+
+ disp_checker = axis2_disp_checker_create(env);
+ handler = axis2_disp_checker_get_base(disp_checker, env);
+ axis2_disp_checker_free(disp_checker, env);
+ axis2_phase_add_handler_at(post_dispatch, env, 0, handler);
+ axutil_array_list_add(conf->handlers, env, axis2_handler_get_handler_desc(handler, env));
+ handler = axis2_ctx_handler_create(env, NULL);
+ axis2_phase_add_handler_at(post_dispatch, env, 1, handler);
+ axutil_array_list_add(conf->handlers, env, axis2_handler_get_handler_desc(handler, env));
+
+ status = axutil_array_list_add(conf-> in_phases_upto_and_including_post_dispatch, env,
+ post_dispatch);
+ if(AXIS2_SUCCESS != status)
+ {
+ axis2_phase_free(dispatch, env);
+ axis2_phase_free(post_dispatch, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Adding post dispatcher into in phases upto and including post dispatch list failed");
+ return status;
+ }
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_dispatch_phase(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_phase_t * dispatch)
+{
+ axis2_status_t status = AXIS2_FAILURE;
+ axis2_handler_t *handler = NULL;
+ axis2_phase_t *post_dispatch = NULL;
+ axis2_disp_checker_t *disp_checker = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, dispatch, AXIS2_FAILURE);
+
+ status
+ = axutil_array_list_add(conf-> in_phases_upto_and_including_post_dispatch, env, dispatch);
+ if(AXIS2_FAILURE == status)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Adding dispatcher into in phases upto and including post dispatch list failed");
+ return AXIS2_FAILURE;
+ }
+
+ post_dispatch = axis2_phase_create(env, AXIS2_PHASE_POST_DISPATCH);
+ if(!post_dispatch)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase %s failed",
+ AXIS2_PHASE_POST_DISPATCH);
+ axis2_phase_free(dispatch, env);
+ return AXIS2_FAILURE;
+ }
+
+ disp_checker = axis2_disp_checker_create(env);
+
+ handler = axis2_disp_checker_get_base(disp_checker, env);
+ axis2_phase_add_handler_at(post_dispatch, env, 0, handler);
+
+ status = axutil_array_list_add(conf-> in_phases_upto_and_including_post_dispatch, env,
+ post_dispatch);
+ if(AXIS2_FAILURE == status)
+ {
+ axis2_phase_free(dispatch, env);
+ axis2_phase_free(post_dispatch, env);
+ axis2_disp_checker_free(disp_checker, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Adding post dispatcher into in phases upto and including post dispatch list failed");
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_SUCCESS;
+}
+
+/**
+ * For each module reference qname stored in dep_engine this function is called.
+ * All module_desc instances are stored in axis2_conf. So each module_desc
+ * is retrieved from there by giving module_qname and engaged globally by
+ * calling phase_resolvers engage_module_globally function. Modules are added
+ * to axis2_conf's engaged module list.
+ */
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_engage_module(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axutil_qname_t * module_ref)
+{
+ axis2_module_desc_t *module_desc = NULL;
+ axis2_bool_t is_new_module = AXIS2_FALSE;
+ axis2_bool_t to_be_engaged = AXIS2_TRUE;
+ axis2_dep_engine_t *dep_engine = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ axis2_char_t *file_name = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, module_ref, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE);
+
+ module_desc = axis2_conf_get_module(conf, env, module_ref);
+ if(!module_desc)
+ {
+ axutil_file_t *file = NULL;
+ const axis2_char_t *repos_path = NULL;
+ axis2_arch_file_data_t *file_data = NULL;
+ axis2_char_t *temp_path1 = NULL;
+ axis2_char_t *temp_path2 = NULL;
+ axis2_char_t *temp_path3 = NULL;
+ axis2_char_t *path = NULL;
+ axutil_param_t *module_dir_param = NULL;
+ axis2_char_t *module_dir = NULL;
+ axis2_bool_t flag;
+ axis2_char_t *axis2_xml = NULL;
+
+ file_name = axutil_qname_get_localpart(module_ref, env);
+ file = (axutil_file_t *)axis2_arch_reader_create_module_arch(env, file_name);
+ /* This flag is to check whether conf is built using axis2
+ * xml configuration file instead of a repository. */
+ flag = axis2_conf_get_axis2_flag(conf, env);
+
+ if(!flag)
+ {
+ repos_path = axis2_conf_get_repo(conf, env);
+ temp_path1 = axutil_stracat(env, repos_path, AXIS2_PATH_SEP_STR);
+ temp_path2 = axutil_stracat(env, temp_path1, AXIS2_MODULE_FOLDER);
+ temp_path3 = axutil_stracat(env, temp_path2, AXIS2_PATH_SEP_STR);
+ path = axutil_stracat(env, temp_path3, file_name);
+ AXIS2_FREE(env->allocator, temp_path1);
+ AXIS2_FREE(env->allocator, temp_path2);
+ AXIS2_FREE(env->allocator, temp_path3);
+ }
+ else
+ {
+ /**
+ * This case is to obtain module path from the axis2.xml
+ */
+ axis2_xml = (axis2_char_t *)axis2_conf_get_axis2_xml(conf, env);
+ module_dir_param = axis2_conf_get_param(conf, env, AXIS2_MODULE_DIR);
+
+ if(module_dir_param)
+ {
+ module_dir = (axis2_char_t *)axutil_param_get_value(module_dir_param, env);
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "moduleDir parameter not available in axis2.xml.");
+
+ return AXIS2_FAILURE;
+ }
+
+ temp_path1 = axutil_strcat(env, module_dir, AXIS2_PATH_SEP_STR, NULL);
+ path = axutil_strcat(env, temp_path1, file_name, NULL);
+ }
+
+ axutil_file_set_path(file, env, path);
+ file_data = axis2_arch_file_data_create_with_type_and_file(env, AXIS2_MODULE, file);
+ if(!flag)
+ {
+ dep_engine = axis2_dep_engine_create_with_repos_name(env, repos_path);
+ }
+ else
+ {
+ dep_engine = axis2_dep_engine_create_with_axis2_xml(env, axis2_xml);
+ }
+
+ axis2_dep_engine_set_current_file_item(dep_engine, env, file_data);
+
+ /* this module_dir set the path of the module directory
+ * Pertaining to this module. This value will use inside the
+ * axis2_dep_engine_build_module function
+ */
+
+ axis2_dep_engine_set_module_dir(dep_engine, env, path);
+
+ if(path)
+ {
+ AXIS2_FREE(env->allocator, path);
+ }
+
+ if(file_data)
+ {
+ axis2_arch_file_data_free(file_data, env);
+ }
+
+ module_desc = axis2_dep_engine_build_module(dep_engine, env, file, conf);
+ axutil_file_free(file, env);
+ is_new_module = AXIS2_TRUE;
+ }
+
+ if(module_desc)
+ {
+ int size = 0;
+ int i = 0;
+ const axutil_qname_t *module_qname = NULL;
+
+ size = axutil_array_list_size(conf->engaged_module_list, env);
+ module_qname = axis2_module_desc_get_qname(module_desc, env);
+ for(i = 0; i < size; i++)
+ {
+ axutil_qname_t *qname = NULL;
+
+ qname = (axutil_qname_t *)axutil_array_list_get(conf->engaged_module_list, env, i);
+ if(axutil_qname_equals(module_qname, env, qname))
+ {
+ to_be_engaged = AXIS2_FALSE;
+ }
+ }
+ }
+ else
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_MODULE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Either module description not set or building"
+ "module description failed for module %s", file_name);
+
+ return AXIS2_FAILURE;
+ }
+
+ if(to_be_engaged)
+ {
+ axis2_phase_resolver_t *phase_resolver = NULL;
+ axutil_qname_t *module_qref_l = NULL;
+ const axutil_qname_t *module_qname = NULL;
+ axis2_char_t *module_name = NULL;
+
+ module_qname = axis2_module_desc_get_qname(module_desc, env);
+ module_name = axutil_qname_get_localpart(module_qname, env);
+ phase_resolver = axis2_phase_resolver_create_with_config(env, conf);
+ if(!phase_resolver)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ status = axis2_phase_resolver_engage_module_globally(phase_resolver, env, module_desc);
+ axis2_phase_resolver_free(phase_resolver, env);
+ if(!status)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Engaging module %s globally failed",
+ module_name);
+ return status;
+ }
+ module_qref_l = axutil_qname_clone((axutil_qname_t *)module_qname, env);
+ status = axutil_array_list_add(conf->engaged_module_list, env, module_qref_l);
+ }
+
+ if(is_new_module)
+ {
+ status = axis2_conf_add_module(conf, env, module_desc);
+ }
+
+ return status;
+}
+
+AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
+axis2_conf_get_repo(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->axis2_repo;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_repo(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_char_t * repos_path)
+{
+ if(conf->axis2_repo)
+ {
+ AXIS2_FREE(env->allocator, conf->axis2_repo);
+ conf->axis2_repo = NULL;
+ }
+ conf->axis2_repo = axutil_strdup(env, repos_path);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
+axis2_conf_get_axis2_xml(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return axutil_strdup(env, conf->axis2_xml);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_axis2_xml(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_char_t * axis2_xml)
+{
+ AXIS2_PARAM_CHECK(env->error, axis2_xml, AXIS2_FAILURE);
+ conf->axis2_xml = axutil_strdup(env, axis2_xml);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_dep_engine(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_dep_engine_t * dep_engine)
+{
+ conf->dep_engine = dep_engine;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
+axis2_conf_get_default_module_version(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axis2_char_t * module_name)
+{
+ axutil_hash_t *def_ver_map = NULL;
+ AXIS2_PARAM_CHECK(env->error, module_name, NULL);
+
+ def_ver_map = conf->name_to_version_map;
+ if(!def_ver_map)
+ {
+ return NULL;
+ }
+ return axutil_hash_get(def_ver_map, module_name, AXIS2_HASH_KEY_STRING);
+}
+
+AXIS2_EXTERN axis2_module_desc_t *AXIS2_CALL
+axis2_conf_get_default_module(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axis2_char_t * module_name)
+{
+ axis2_module_desc_t *ret_mod = NULL;
+ axis2_char_t *mod_name = NULL;
+ const axis2_char_t *mod_ver = NULL;
+ axutil_hash_t *all_modules = NULL;
+ axutil_qname_t *mod_qname = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, module_name, NULL);
+
+ all_modules = conf->all_modules;
+ mod_ver = axis2_conf_get_default_module_version(conf, env, module_name);
+
+ if(!mod_ver)
+ {
+ mod_name = axutil_strdup(env, module_name);
+ }
+ else
+ {
+ axis2_char_t *tmp_name = NULL;
+ tmp_name = axutil_stracat(env, module_name, "-");
+ mod_name = axutil_stracat(env, tmp_name, mod_ver);
+ AXIS2_FREE(env->allocator, tmp_name);
+ }
+ mod_qname = axutil_qname_create(env, mod_name, NULL, NULL);
+ AXIS2_FREE(env->allocator, mod_name);
+ mod_name = NULL;
+
+ if(!mod_qname)
+ {
+ return NULL;
+ }
+ ret_mod = (axis2_module_desc_t *)axutil_hash_get(all_modules, axutil_qname_to_string(mod_qname,
+ env), AXIS2_HASH_KEY_STRING);
+
+ return ret_mod;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_add_default_module_version(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axis2_char_t * module_name,
+ const axis2_char_t * module_version)
+{
+ axutil_hash_t *name_to_ver_map = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, module_name, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, module_version, AXIS2_FAILURE);
+ /*
+ * If we already have a default module version we don't put
+ * it again
+ */
+ name_to_ver_map = conf->name_to_version_map;
+
+ if(!axutil_hash_get(name_to_ver_map, module_name, AXIS2_HASH_KEY_STRING))
+ {
+ axis2_char_t *new_entry = axutil_strdup(env, module_version);
+ if(!new_entry)
+ {
+ return AXIS2_FAILURE;
+ }
+ axutil_hash_set(name_to_ver_map, module_name, AXIS2_HASH_KEY_STRING, new_entry);
+ return AXIS2_SUCCESS;
+ }
+ return AXIS2_FAILURE;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_engage_module_with_version(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ const axis2_char_t * module_name,
+ const axis2_char_t * version_id)
+{
+ axutil_qname_t *module_qname = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ AXIS2_PARAM_CHECK(env->error, module_name, AXIS2_FAILURE);
+
+ module_qname = axis2_core_utils_get_module_qname(env, module_name, version_id);
+ if(!module_qname)
+ {
+ return AXIS2_FAILURE;
+ }
+ status = axis2_conf_engage_module(conf, env, module_qname);
+ axutil_qname_free(module_qname, env);
+ return status;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_conf_get_enable_mtom(
+ axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->enable_mtom;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_enable_mtom(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_bool_t enable_mtom)
+{
+ conf->enable_mtom = enable_mtom;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_conf_get_axis2_flag(
+ axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->axis2_flag;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_axis2_flag(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_bool_t axis2_flag)
+{
+ conf->axis2_flag = axis2_flag;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_conf_get_enable_security(
+ axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->enable_security;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_enable_security(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ axis2_bool_t enable_security)
+{
+ AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE);
+
+ conf->enable_security = enable_security;
+ return AXIS2_SUCCESS;
+}
+
+#if 0
+/* this seemed to be not used after 1.6.0 */
+AXIS2_EXTERN void *AXIS2_CALL
+axis2_conf_get_security_context(
+ axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->security_context;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_conf_set_security_context(
+ axis2_conf_t * conf,
+ const axutil_env_t * env,
+ void *security_context)
+{
+ AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE);
+
+ conf->security_context = (void *) security_context;
+ return AXIS2_SUCCESS;
+}
+#endif
+
+AXIS2_EXTERN axutil_param_container_t *AXIS2_CALL
+axis2_conf_get_param_container(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->param_container;
+}
+
+AXIS2_EXTERN axis2_desc_t *AXIS2_CALL
+axis2_conf_get_base(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->base;
+}
+
+AXIS2_EXTERN axutil_array_list_t * AXIS2_CALL
+axis2_conf_get_handlers(
+ const axis2_conf_t * conf,
+ const axutil_env_t * env)
+{
+ return conf->handlers;
+}
+
diff --git a/src/core/engine/ctx_handler.c b/src/core/engine/ctx_handler.c
new file mode 100644
index 0000000..4cafaf5
--- /dev/null
+++ b/src/core/engine/ctx_handler.c
@@ -0,0 +1,204 @@
+/*
+ * 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_handler_desc.h>
+#include <axutil_string.h>
+#include <axis2_svc.h>
+#include <axis2_conf_ctx.h>
+
+const axis2_char_t *AXIS2_CTX_HANDLER_NAME = "context_handler";
+
+/**
+ * By the time the control comes to this handler, the dispatching must have
+ * happened so that the message context contains the service group, service and
+ * operation. This will then try to find the contexts for service group, service
+ * and the operation.
+ */
+
+axis2_status_t AXIS2_CALL
+axis2_ctx_handler_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx *msg_ctx);
+
+axis2_handler_t *AXIS2_CALL
+axis2_ctx_handler_create(
+ const axutil_env_t * env,
+ const axutil_string_t * string)
+{
+ axis2_handler_t *handler = NULL;
+ axis2_handler_desc_t *handler_desc = NULL;
+ axutil_string_t *handler_string = NULL;
+
+ if(string)
+ {
+ handler_string = axutil_string_clone((axutil_string_t *)string, env);
+ if(!(handler_string))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ }
+ else
+ {
+ /* create default string */
+ handler_string = axutil_string_create_const(env, (axis2_char_t **)&AXIS2_CTX_HANDLER_NAME);
+ if(!handler_string)
+ {
+ return NULL;
+ }
+ }
+
+ handler = axis2_handler_create(env);
+ if(!handler)
+ {
+ return NULL;
+ }
+
+ /* handler desc of base handler */
+ handler_desc = axis2_handler_desc_create(env, handler_string);
+ axutil_string_free(handler_string, env);
+ if(!handler_desc)
+ {
+ axis2_handler_free(handler, env);
+ return NULL;
+ }
+
+ axis2_handler_init(handler, env, handler_desc);
+
+ /* set the base struct's invoke op */
+ axis2_handler_set_invoke(handler, env, axis2_ctx_handler_invoke);
+
+ return handler;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_ctx_handler_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx)
+{
+ axis2_op_t *op = NULL;
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_svc_grp_ctx_t *svc_grp_ctx = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_ctx_handler_invoke");
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ svc_ctx = axis2_msg_ctx_get_svc_ctx(msg_ctx, env);
+
+ if(op_ctx && svc_ctx)
+ {
+ svc_grp_ctx = axis2_svc_ctx_get_parent(svc_ctx, env);
+ if(svc_grp_ctx)
+ {
+ axutil_string_t *svc_grp_ctx_id_str = axutil_string_create(env,
+ axis2_svc_grp_ctx_get_id(svc_grp_ctx, env));
+ 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);
+ }
+ return AXIS2_SUCCESS;
+ }
+
+ op = axis2_msg_ctx_get_op(msg_ctx, env);
+ if(op)
+ {
+ op_ctx = axis2_op_find_existing_op_ctx(op, env, msg_ctx);
+ }
+
+ if(op_ctx)
+ {
+ axis2_op_register_op_ctx(op, env, msg_ctx, op_ctx);
+ svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
+ if(svc_ctx)
+ {
+ axutil_string_t *svc_grp_ctx_id_str = NULL;
+ const axis2_char_t *grp_ctx_id = NULL;
+
+ svc_grp_ctx = axis2_svc_ctx_get_parent(svc_ctx, env);
+ axis2_msg_ctx_set_svc_ctx(msg_ctx, env, svc_ctx);
+ axis2_msg_ctx_set_svc_grp_ctx(msg_ctx, env, svc_grp_ctx);
+ grp_ctx_id = axis2_svc_grp_ctx_get_id(svc_grp_ctx, env);
+ svc_grp_ctx_id_str = axutil_string_create(env, 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);
+ }
+
+ return AXIS2_SUCCESS;
+ }
+ else if(op) /* 2. if no op_ctx, create new op_ctx */
+ {
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_bool_t use_pools = AXIS2_FALSE;
+ axutil_param_t *param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_PERSIST_OP_CTX);
+
+ use_pools = (param && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, axutil_param_get_value(param,
+ env)));
+
+ if(use_pools)
+ {
+ axutil_allocator_switch_to_global_pool(env->allocator);
+ }
+ op_ctx = axis2_op_ctx_create(env, op, NULL);
+ if(!op_ctx)
+ {
+ axis2_char_t *op_name = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Could not create Operation context for operatoin %s", op_name);
+
+ return AXIS2_FAILURE;
+ }
+
+ axis2_msg_ctx_set_op_ctx(msg_ctx, env, op_ctx);
+
+ axis2_op_register_op_ctx(op, env, msg_ctx, op_ctx);
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ if(!use_pools)
+ {
+ axutil_allocator_switch_to_global_pool(env->allocator);
+ }
+
+ svc_grp_ctx = axis2_conf_ctx_fill_ctxs(conf_ctx, env, msg_ctx);
+
+ if(!use_pools)
+ {
+ axutil_allocator_switch_to_local_pool(env->allocator);
+ }
+ }
+
+ if(use_pools)
+ {
+ axutil_allocator_switch_to_local_pool(env->allocator);
+ }
+ }
+
+ if(!svc_grp_ctx && (axis2_msg_ctx_get_server_side(msg_ctx, env)))
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service group context not found");
+ return AXIS2_FAILURE;
+ }
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_ctx_handler_invoke");
+
+ return AXIS2_SUCCESS;
+}
+
diff --git a/src/core/engine/disp.c b/src/core/engine/disp.c
new file mode 100644
index 0000000..51cb56d
--- /dev/null
+++ b/src/core/engine/disp.c
@@ -0,0 +1,185 @@
+/*
+ * 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_disp.h>
+#include <axis2_handler_desc.h>
+#include <axutil_string.h>
+#include <axis2_relates_to.h>
+#include <axis2_svc.h>
+#include <axis2_const.h>
+#include <axis2_msg_ctx.h>
+
+const axis2_char_t *AXIS2_DISP_NAME = "abstract_dispatcher";
+
+struct axis2_disp
+{
+
+ /** base class, inherits from handler */
+ axis2_handler_t *base;
+
+ /** phase name */
+ axutil_string_t *name;
+
+ /** derived struct */
+ void *derived; /* deep copy */
+ int derived_type;
+};
+
+axis2_disp_t *AXIS2_CALL
+axis2_disp_create(
+ const axutil_env_t * env,
+ const axutil_string_t * name)
+{
+ axis2_disp_t *disp = NULL;
+ axis2_handler_desc_t *handler_desc = NULL;
+
+ disp = AXIS2_MALLOC(env->allocator, sizeof(axis2_disp_t));
+ if(!disp)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ disp->name = NULL;
+ disp->base = NULL;
+
+ if(name)
+ {
+ disp->name = axutil_string_clone((axutil_string_t *)name, env);
+ if(!(disp->name))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ axis2_disp_free(disp, env);
+ return NULL;
+ }
+ }
+ else
+ {
+ /* create default name */
+ disp->name = axutil_string_create_const(env, (axis2_char_t **)&AXIS2_DISP_NAME);
+ if(!(disp->name))
+ {
+ axis2_disp_free(disp, env);
+ return NULL;
+ }
+ }
+
+ disp->base = axis2_handler_create(env);
+ if(!disp->base)
+ {
+ axis2_disp_free(disp, env);
+ return NULL;
+ }
+
+ /* handler desc of base handler */
+ handler_desc = axis2_handler_desc_create(env, disp->name);
+ if(!handler_desc)
+ {
+ axis2_disp_free(disp, env);
+ return NULL;
+ }
+
+ axis2_handler_init(disp->base, env, handler_desc);
+
+ return disp;
+}
+
+axis2_handler_t *AXIS2_CALL
+axis2_disp_get_base(
+ const axis2_disp_t * disp,
+ const axutil_env_t * env)
+{
+ return disp->base;
+}
+
+axutil_string_t *AXIS2_CALL
+axis2_disp_get_name(
+ const axis2_disp_t * disp,
+ const axutil_env_t * env)
+{
+ return disp->name;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_disp_set_name(
+ struct axis2_disp * disp,
+ const axutil_env_t * env,
+ axutil_string_t * name)
+{
+ if(disp->name)
+ {
+ axutil_string_free(disp->name, env);
+ }
+
+ if(name)
+ {
+ disp->name = axutil_string_clone(name, env);
+ if(!(disp->name))
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_disp_find_svc_and_op(
+ struct axis2_handler * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx)
+{
+ axis2_svc_t *axis_service = NULL;
+ axis2_op_t *op = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ axis_service = axis2_msg_ctx_get_svc(msg_ctx, env);
+
+ if(!axis_service)
+ {
+ axis_service = axis2_msg_ctx_find_svc(msg_ctx, env);
+ if(axis_service)
+ {
+ axis2_msg_ctx_set_svc(msg_ctx, env, axis_service);
+ }
+ }
+ op = axis2_msg_ctx_get_op(msg_ctx, env);
+ if(!op)
+ {
+ op = axis2_msg_ctx_find_op(msg_ctx, env, axis_service);
+
+ if(op)
+ {
+ axis2_msg_ctx_set_op(msg_ctx, env, op);
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+void AXIS2_CALL
+axis2_disp_free(
+ struct axis2_disp *disp,
+ const axutil_env_t * env)
+{
+ if(disp->name)
+ {
+ axutil_string_free(disp->name, env);
+ }
+ AXIS2_FREE(env->allocator, disp);
+ return;
+}
+
diff --git a/src/core/engine/disp_checker.c b/src/core/engine/disp_checker.c
new file mode 100644
index 0000000..b668a9a
--- /dev/null
+++ b/src/core/engine/disp_checker.c
@@ -0,0 +1,284 @@
+/*
+ * 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_disp_checker.h"
+#include <axis2_handler_desc.h>
+#include <axutil_string.h>
+#include <axis2_relates_to.h>
+#include <axis2_svc.h>
+#include <axis2_const.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_op_ctx.h>
+#include <axis2_svc_ctx.h>
+#include <axis2_endpoint_ref.h>
+#include <axiom_soap.h>
+#include <axiom.h>
+
+const axis2_char_t *AXIS2_DISP_CHECKER_NAME = "dispatch_post_conditions_evaluator";
+
+struct axis2_disp_checker
+{
+
+ /** base class, inherits from handler */
+ axis2_handler_t *base;
+
+ /** phase name */
+ axutil_string_t *name;
+};
+
+axis2_status_t AXIS2_CALL
+axis2_disp_checker_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx);
+
+axis2_disp_checker_t *AXIS2_CALL
+axis2_disp_checker_create(
+ const axutil_env_t * env)
+{
+ axis2_disp_checker_t *disp_checker = NULL;
+ axis2_handler_desc_t *handler_desc = NULL;
+
+ disp_checker = AXIS2_MALLOC(env->allocator, sizeof(axis2_disp_checker_t));
+ if(!disp_checker)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ disp_checker->name = NULL;
+ disp_checker->base = NULL;
+
+ /* create default name */
+ disp_checker->name = axutil_string_create_const(env, (axis2_char_t **)&AXIS2_DISP_CHECKER_NAME);
+
+ if(!(disp_checker->name))
+ {
+ axis2_disp_checker_free(disp_checker, env);
+ return NULL;
+ }
+
+ disp_checker->base = axis2_handler_create(env);
+ if(!disp_checker->base)
+ {
+ axis2_disp_checker_free(disp_checker, env);
+ return NULL;
+ }
+ axis2_handler_set_invoke(disp_checker->base, env, axis2_disp_checker_invoke);
+
+ /* handler desc of base handler */
+ handler_desc = axis2_handler_desc_create(env, disp_checker->name);
+ if(!handler_desc)
+ {
+ axis2_disp_checker_free(disp_checker, env);
+ return NULL;
+ }
+
+ axis2_handler_init(disp_checker->base, env, handler_desc);
+ return disp_checker;
+}
+
+axis2_handler_t *AXIS2_CALL
+axis2_disp_checker_get_base(
+ const axis2_disp_checker_t * disp_checker,
+ const axutil_env_t * env)
+{
+ return disp_checker->base;
+}
+
+axutil_string_t *AXIS2_CALL
+axis2_disp_checker_get_name(
+ const axis2_disp_checker_t * disp_checker,
+ const axutil_env_t * env)
+{
+ return disp_checker->name;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_disp_checker_set_name(
+ axis2_disp_checker_t * disp_checker,
+ const axutil_env_t * env,
+ const axutil_string_t * name)
+{
+ if(disp_checker->name)
+ {
+ axutil_string_free(disp_checker->name, env);
+ disp_checker->name = NULL;
+ }
+
+ if(name)
+ {
+ disp_checker->name = axutil_string_clone((axutil_string_t *)name, env);
+ if(!(disp_checker->name))
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+void AXIS2_CALL
+axis2_disp_checker_free(
+ axis2_disp_checker_t * disp_checker,
+ const axutil_env_t * env)
+{
+ if(disp_checker->name)
+ {
+ axutil_string_free(disp_checker->name, env);
+ }
+
+ AXIS2_FREE(env->allocator, disp_checker);
+
+ return;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_disp_checker_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_op_t *op = NULL;
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_svc_t *svc = NULL;
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ const axis2_char_t *address = NULL;
+ axiom_soap_fault_t *soap_fault;
+ axiom_soap_envelope_t *soap_envelope;
+ axiom_soap_body_t *soap_body;
+ int soap_version = AXIOM_SOAP12;
+ axis2_char_t *fault_code = NULL;
+
+ axis2_char_t exception[1024];
+ axis2_char_t *wsa_action;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ /*if is client side, no point in proceeding */
+ if(!(axis2_msg_ctx_get_server_side(msg_ctx, env)))
+ return AXIS2_SUCCESS;
+
+ op = axis2_msg_ctx_get_op(msg_ctx, env);
+
+ if(!op)
+ {
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if(op_ctx)
+ {
+ axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
+ if(op)
+ axis2_msg_ctx_set_op(msg_ctx, env, op);
+ }
+ }
+
+ svc = axis2_msg_ctx_get_svc(msg_ctx, env);
+
+ if(!svc)
+ {
+ svc_ctx = axis2_msg_ctx_get_svc_ctx(msg_ctx, env);
+ if(svc_ctx)
+ {
+ axis2_svc_t *tsvc = axis2_svc_ctx_get_svc(svc_ctx, env);
+ if(tsvc)
+ axis2_msg_ctx_set_svc(msg_ctx, env, tsvc);
+ }
+ }
+ endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);
+
+ if(endpoint_ref)
+ {
+ address = axis2_endpoint_ref_get_address(endpoint_ref, env);
+ }
+
+ svc = axis2_msg_ctx_get_svc(msg_ctx, env);
+ if(!svc)
+ {
+ AXIS2_LOG_INFO(env->log, "Service Not found. Endpoint reference is : %s",
+ (address) ? address : "NULL");
+ if(axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
+ {
+ soap_version = AXIOM_SOAP11;
+fault_code =
+ AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
+ AXIOM_SOAP11_FAULT_CODE_RECEIVER;
+ }
+ else
+ {
+ fault_code =
+ AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
+ AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER;
+
+ }
+
+ soap_envelope =
+ axiom_soap_envelope_create_default_soap_envelope(env, soap_version);
+ soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
+ soap_fault =
+ axiom_soap_fault_create_default_fault(env, soap_body, fault_code,
+ "Service Not Found",
+ soap_version);
+
+ wsa_action = (axis2_char_t *)axis2_msg_ctx_get_wsa_action (msg_ctx,
+ env);
+ sprintf (exception, "Service Not Found, Endpoint referance address is %s and wsa\
+ actions is %s", address, wsa_action);
+
+ axiom_soap_fault_set_exception (soap_fault, env, exception);
+ axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, soap_envelope);
+ return AXIS2_FAILURE;
+}
+
+op = axis2_msg_ctx_get_op(msg_ctx, env);
+if (!op)
+{
+ AXIS2_LOG_INFO(env->log,
+ "Operation Not found. Endpoint reference is : %s",
+ (address) ? address : "NULL");
+ if (axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
+ {
+ soap_version = AXIOM_SOAP11;
+ fault_code =
+ AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
+ AXIOM_SOAP11_FAULT_CODE_RECEIVER;
+ }
+ else
+ {
+ fault_code =
+ AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
+ AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER;
+ }
+
+ soap_envelope =
+ axiom_soap_envelope_create_default_soap_envelope(env, soap_version);
+ soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
+ soap_fault =
+ axiom_soap_fault_create_default_fault(env, soap_body, fault_code,
+ "Operation Not Found",
+ soap_version);
+
+ wsa_action = (axis2_char_t *)axis2_msg_ctx_get_wsa_action (msg_ctx,
+ env);
+ sprintf (exception, "Operation Not Found, Endpoint referance address is %s and wsa\
+ actions is %s", address, wsa_action);
+
+ axiom_soap_fault_set_exception (soap_fault, env, exception);
+ axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, soap_envelope);
+ return AXIS2_FAILURE;
+}
+return AXIS2_SUCCESS;
+}
+
diff --git a/src/core/engine/engine.c b/src/core/engine/engine.c
new file mode 100644
index 0000000..a098ea1
--- /dev/null
+++ b/src/core/engine/engine.c
@@ -0,0 +1,915 @@
+/*
+ * 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_engine.h>
+#include <axis2_const.h>
+#include <axutil_hash.h>
+#include <axiom_soap_const.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_body.h>
+#include <axiom_soap_fault.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_transport_sender.h>
+#include <axis2_addr.h>
+#include <axutil_uuid_gen.h>
+
+struct axis2_engine
+{
+ /** Configuration context */
+ axis2_conf_ctx_t *conf_ctx;
+};
+
+axis2_status_t
+axis2_engine_check_must_understand_headers(
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx);
+
+AXIS2_EXTERN axis2_engine_t * AXIS2_CALL
+axis2_engine_create(
+ const axutil_env_t * env,
+ axis2_conf_ctx_t * conf_ctx)
+{
+ axis2_engine_t *engine = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ engine = AXIS2_MALLOC(env->allocator, sizeof(axis2_engine_t));
+ if(!engine)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
+ return NULL;
+ }
+
+ engine->conf_ctx = NULL;
+
+ if(conf_ctx)
+ {
+ engine->conf_ctx = conf_ctx;
+ }
+
+ return engine;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_engine_free(
+ axis2_engine_t * engine,
+ const axutil_env_t * env)
+{
+ AXIS2_FREE(env->allocator, engine);
+ return;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_engine_send(
+ axis2_engine_t * engine,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_status_t status = AXIS2_SUCCESS;
+ axis2_op_ctx_t *op_ctx = NULL;
+ axutil_array_list_t *phases = NULL;
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_conf_t *conf = NULL;
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "axis2_engine_send start");
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ /* Find and invoke the phases */
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if(op_ctx)
+ {
+ axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
+ if(op)
+ {
+ phases = axis2_op_get_out_flow(op, env);
+ }
+ }
+
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ /* Message has paused, so rerun it from the position it stopped.
+ The handler which paused the message will be the first one to resume
+ invocation
+ */
+ status = axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
+ if(status != AXIS2_SUCCESS)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Resuming invocation of phases failed");
+ return status;
+ }
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ if(conf)
+ {
+ axutil_array_list_t *global_out_phase = axis2_conf_get_out_phases(conf, env);
+ if(global_out_phase)
+ {
+ axis2_engine_invoke_phases(engine, env, global_out_phase, msg_ctx);
+ }
+ }
+ }
+ }
+ else
+ {
+ status = axis2_engine_invoke_phases(engine, env, phases, msg_ctx);
+ if(status != AXIS2_SUCCESS)
+ {
+ return status;
+ }
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ if(conf)
+ {
+ axutil_array_list_t *global_out_phase = axis2_conf_get_out_phases(conf, env);
+ if(global_out_phase)
+ {
+ axis2_engine_invoke_phases(engine, env, global_out_phase, msg_ctx);
+ }
+ }
+ }
+ }
+
+ if(!(axis2_msg_ctx_is_paused(msg_ctx, env)))
+ {
+ /* Write the message to wire */
+ axis2_transport_sender_t *transport_sender = NULL;
+ axis2_transport_out_desc_t *transport_out = axis2_msg_ctx_get_transport_out_desc(msg_ctx,
+ env);
+
+ if(transport_out)
+ {
+ transport_sender = axis2_transport_out_desc_get_sender(transport_out, env);
+ if(!transport_sender)
+ return AXIS2_FAILURE;
+
+ status = AXIS2_TRANSPORT_SENDER_INVOKE(transport_sender, env, msg_ctx);
+ if(status != AXIS2_SUCCESS)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport sender invoke failed");
+ return status;
+ }
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport out is not set in message context");
+ return AXIS2_FAILURE;
+ }
+ }
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "axis2_engine_send end successfully");
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_engine_receive(
+ axis2_engine_t * engine,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_conf_t *conf = NULL;
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_op_t *op = NULL;
+ axutil_array_list_t *pre_calculated_phases = NULL;
+ axutil_array_list_t *op_specific_phases = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_receive");
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+
+ pre_calculated_phases = axis2_conf_get_in_phases_upto_and_including_post_dispatch(conf, env);
+
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ /* The message has paused, so re-run them from the position they stopped. */
+ axis2_engine_resume_invocation_phases(engine, env, pre_calculated_phases, msg_ctx);
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Message context is paused. So return here.");
+ return AXIS2_SUCCESS;
+ }
+
+ /* Resume op specific phases */
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if(op_ctx)
+ {
+ op = axis2_op_ctx_get_op(op_ctx, env);
+ op_specific_phases = axis2_op_get_in_flow(op, env);
+ axis2_engine_resume_invocation_phases(engine, env, op_specific_phases, msg_ctx);
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Message context is paused. So return here.");
+ return AXIS2_SUCCESS;
+ }
+ }
+ }
+ else
+ {
+ status = axis2_engine_invoke_phases(engine, env, pre_calculated_phases, msg_ctx);
+ if(status != AXIS2_SUCCESS)
+ {
+ if(axis2_msg_ctx_get_server_side(msg_ctx, env))
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invoking pre-calculated phases failed");
+ return status;
+ }
+ }
+
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Message context is paused. So return here.");
+ return AXIS2_SUCCESS;
+ }
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if(op_ctx)
+ {
+ op = axis2_op_ctx_get_op(op_ctx, env);
+ op_specific_phases = axis2_op_get_in_flow(op, env);
+ status = axis2_engine_invoke_phases(engine, env, op_specific_phases, msg_ctx);
+ if(status != AXIS2_SUCCESS)
+ {
+ axis2_char_t *op_name = NULL;
+ op_name = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Invoking operation specific phases failed for operation %s", op_name);
+ return status;
+ }
+
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Message context is paused. So return here.");
+ return AXIS2_SUCCESS;
+ }
+ }
+ }
+
+ if((axis2_msg_ctx_get_server_side(msg_ctx, env)) && !(axis2_msg_ctx_is_paused(msg_ctx, env)))
+ {
+ axis2_msg_recv_t *receiver = NULL;
+
+ status = axis2_engine_check_must_understand_headers(env, msg_ctx);
+ if(status != AXIS2_SUCCESS)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Check for must understand headers failed");
+ return status;
+ }
+
+ /* Invoke the message receivers */
+ if(!op)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Operation not found");
+ return AXIS2_FAILURE;
+ }
+ receiver = axis2_op_get_msg_recv(op, env);
+ if(!receiver)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Message receiver not set in operation description");
+ return AXIS2_FAILURE;
+ }
+ status = axis2_msg_recv_receive(receiver, env, msg_ctx, axis2_msg_recv_get_derived(
+ receiver, env));
+ }
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_receive");
+
+ return status;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_engine_send_fault(
+ axis2_engine_t * engine,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_status_t status = AXIS2_SUCCESS;
+ axutil_array_list_t *phases = NULL;
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_conf_t *conf = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if(op_ctx)
+ {
+ axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
+ if(op)
+ {
+ phases = axis2_op_get_fault_out_flow(op, env);
+ }
+ }
+
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ /* Message has paused, so rerun it from the position it stopped.
+ The handler which paused the message will be the first one to resume
+ invocation
+ */
+ status = axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
+ if(status != AXIS2_SUCCESS)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Resuming invoking the phases failed");
+ return status;
+ }
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ if(conf)
+ {
+ axutil_array_list_t *global_out_fault_phase = axis2_conf_get_out_fault_flow(conf,
+ env);
+ if(global_out_fault_phase)
+ {
+ axis2_engine_invoke_phases(engine, env, global_out_fault_phase, msg_ctx);
+ }
+ }
+ }
+ }
+ else
+ {
+ status = axis2_engine_invoke_phases(engine, env, phases, msg_ctx);
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ if(conf)
+ {
+ axutil_array_list_t *global_out_fault_phase = axis2_conf_get_out_fault_flow(conf,
+ env);
+ if(global_out_fault_phase)
+ {
+ axis2_engine_invoke_phases(engine, env, global_out_fault_phase, msg_ctx);
+ }
+ }
+ }
+ }
+
+ if(!(axis2_msg_ctx_is_paused(msg_ctx, env)))
+ {
+ /* Write the message to wire */
+ axis2_transport_sender_t *transport_sender = NULL;
+ axis2_transport_out_desc_t *transport_out = axis2_msg_ctx_get_transport_out_desc(msg_ctx,
+ env);
+
+ if(transport_out)
+ {
+ transport_sender = axis2_transport_out_desc_get_sender(transport_out, env);
+
+ if(transport_sender)
+ {
+ AXIS2_TRANSPORT_SENDER_INVOKE(transport_sender, env, msg_ctx);
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport sender not found");
+ return AXIS2_FAILURE;
+ }
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport out is not set in message context");
+ return AXIS2_FAILURE;
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_engine_receive_fault(
+ axis2_engine_t * engine,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_op_ctx_t *op_ctx = NULL;
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_receive_fault");
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+
+ if(!op_ctx)
+ {
+ /* If we do not have an op context that means this may be an incoming
+ dual channel response. So try to dispatch the service */
+ axis2_conf_ctx_t *conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ axis2_conf_t *conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ if(conf)
+ {
+ axutil_array_list_t *phases =
+ axis2_conf_get_in_phases_upto_and_including_post_dispatch(conf, env);
+ if(phases)
+ {
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
+ }
+ else
+ {
+ axis2_engine_invoke_phases(engine, env, phases, msg_ctx);
+ }
+ }
+ }
+ }
+ }
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ /* Find and execute the fault in flow handlers */
+ if(op_ctx)
+ {
+ axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
+ axutil_array_list_t *phases = axis2_op_get_fault_in_flow(op, env);
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
+ }
+ else
+ {
+ axis2_engine_invoke_phases(engine, env, phases, msg_ctx);
+ }
+ }
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_receive_fault");
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_msg_ctx_t * AXIS2_CALL
+axis2_engine_create_fault_msg_ctx(
+ axis2_engine_t * engine,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * processing_context,
+ const axis2_char_t * code_value,
+ const axis2_char_t * reason_text)
+{
+ axis2_msg_ctx_t *fault_ctx = NULL;
+ axis2_endpoint_ref_t *fault_to = NULL;
+ axis2_endpoint_ref_t *reply_to = NULL;
+ axutil_stream_t *stream = NULL;
+ axiom_soap_envelope_t *envelope = NULL;
+ const axis2_char_t *wsa_action = NULL;
+ const axis2_char_t *msg_id = NULL;
+ axis2_relates_to_t *relates_to = NULL;
+ axis2_char_t *msg_uuid = NULL;
+ axis2_msg_info_headers_t *msg_info_headers = NULL;
+ axis2_bool_t doing_rest = AXIS2_FALSE;
+
+ AXIS2_PARAM_CHECK(env->error, processing_context, NULL);
+
+ if(axis2_msg_ctx_get_process_fault(processing_context, env))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_PROCESSING_FAULT_ALREADY,
+ AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating fault message contex failed");
+ return NULL;
+ }
+
+ fault_ctx = axis2_msg_ctx_create(env, engine->conf_ctx, axis2_msg_ctx_get_transport_in_desc(
+ processing_context, env), axis2_msg_ctx_get_transport_out_desc(processing_context, env));
+
+ axis2_msg_ctx_set_process_fault(fault_ctx, env, AXIS2_TRUE);
+
+ fault_to = axis2_msg_ctx_get_fault_to(processing_context, env);
+ if(fault_to)
+ {
+ const axis2_char_t *address = axis2_endpoint_ref_get_address(fault_to, env);
+ if(!address)
+ {
+ fault_to = NULL;
+ }
+ else if(axutil_strcmp(AXIS2_WSA_NONE_URL, address) == 0 || axutil_strcmp(
+ AXIS2_WSA_NONE_URL_SUBMISSION, address) == 0)
+ {
+ reply_to = axis2_msg_ctx_get_reply_to(processing_context, env);
+ if(reply_to)
+ {
+ axis2_msg_ctx_set_fault_to(fault_ctx, env, reply_to);
+ }
+ else
+ {
+ axis2_msg_ctx_set_fault_to(fault_ctx, env, fault_to);
+ }
+ }
+ else
+ {
+ axis2_msg_ctx_set_fault_to(fault_ctx, env, fault_to);
+ }
+
+ }
+
+ stream = axis2_msg_ctx_get_transport_out_stream(processing_context, env);
+
+ if(stream)
+ {
+ axis2_msg_ctx_set_transport_out_stream(fault_ctx, env, stream);
+ }
+
+ if(!fault_to && !stream)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NOWHERE_TO_SEND_FAULT, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Soap fault target destination not found");
+ return NULL;
+ }
+
+ /* Set WSA action */
+ msg_info_headers = axis2_msg_ctx_get_msg_info_headers(processing_context, env);
+ if(msg_info_headers)
+ {
+ wsa_action = axis2_msg_info_headers_get_action(msg_info_headers, env);
+ if(wsa_action)
+ {
+ /*
+ We have to use the action set by user,
+ cannot use the default always.
+ wsa_action = "http://www.w3.org/2005/08/addressing/fault"; */
+ axis2_msg_ctx_set_wsa_action(fault_ctx, env, wsa_action);
+ }
+ }
+
+ /* Set relates to */
+ msg_id = axis2_msg_ctx_get_msg_id(processing_context, env);
+
+ /* we can create with default Relates to namespace.
+ Actual namespace based on addressing version will be created in addressing out handler */
+ relates_to = axis2_relates_to_create(env, msg_id,
+ AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE);
+ axis2_msg_ctx_set_relates_to(fault_ctx, env, relates_to);
+
+ /* Set msg id */
+ msg_uuid = axutil_uuid_gen(env);
+ axis2_msg_ctx_set_message_id(fault_ctx, env, msg_uuid);
+ if(msg_uuid)
+ {
+ AXIS2_FREE(env->allocator, msg_uuid);
+ msg_uuid = NULL;
+ }
+
+ /** Copy the property map from the current message context to the newly created fault message
+ context. */
+ {
+ axis2_ctx_t *ctx = axis2_msg_ctx_get_base(processing_context, env);
+ axis2_ctx_t *fault_base_ctx = axis2_msg_ctx_get_base(fault_ctx, env);
+
+ if(ctx && fault_ctx)
+ {
+ axis2_ctx_set_property_map(fault_base_ctx, env, axis2_ctx_get_property_map(ctx, env));
+ }
+
+ }
+
+
+ axis2_msg_ctx_set_op_ctx(fault_ctx, env, axis2_msg_ctx_get_op_ctx(processing_context, env));
+ axis2_msg_ctx_set_process_fault(fault_ctx, env, AXIS2_TRUE);
+ axis2_msg_ctx_set_server_side(fault_ctx, env, AXIS2_TRUE);
+
+ envelope = axis2_msg_ctx_get_fault_soap_envelope(processing_context, env);
+
+ if(!envelope)
+ {
+ if(axis2_msg_ctx_get_is_soap_11(processing_context, env))
+ {
+ envelope = axiom_soap_envelope_create_default_soap_fault_envelope(env, code_value,
+ reason_text, AXIOM_SOAP11, NULL, NULL);
+
+ }
+ else
+ {
+ envelope = axiom_soap_envelope_create_default_soap_fault_envelope(env, code_value,
+ reason_text, AXIOM_SOAP12, NULL, NULL);
+ }
+
+ if(!envelope)
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Creating default soap envelope failed");
+ return NULL;
+ }
+ }
+
+ doing_rest = axis2_msg_ctx_get_doing_rest(processing_context, env);
+ axis2_msg_ctx_set_doing_rest(fault_ctx, env, doing_rest);
+
+ axis2_msg_ctx_set_soap_envelope(fault_ctx, env, envelope);
+ axis2_msg_ctx_set_out_transport_info(fault_ctx, env, axis2_msg_ctx_get_out_transport_info(
+ processing_context, env));
+ return fault_ctx;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_engine_invoke_phases(
+ axis2_engine_t * engine,
+ const axutil_env_t * env,
+ axutil_array_list_t * phases,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ int i = 0;
+ int count = 0;
+ axis2_status_t status = AXIS2_SUCCESS;
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_invoke_phases");
+ AXIS2_PARAM_CHECK(env->error, phases, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ if(phases)
+ count = axutil_array_list_size(phases, env);
+ for(i = 0; (i < count && !(axis2_msg_ctx_is_paused(msg_ctx, env))); i++)
+ {
+ axis2_phase_t *phase = (axis2_phase_t *)axutil_array_list_get(phases, env, i);
+
+ status = axis2_phase_invoke(phase, env, msg_ctx);
+
+ if(status != AXIS2_SUCCESS)
+ {
+ const axis2_char_t *phase_name = axis2_phase_get_name(phase, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invoking phase %s failed", phase_name);
+ return status;
+ }
+ }
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "End:axis2_engine_invoke_phases");
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_engine_resume_invocation_phases(
+ axis2_engine_t * engine,
+ const axutil_env_t * env,
+ axutil_array_list_t * phases,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ int i = 0;
+ int count = 0;
+ axis2_bool_t found_match = AXIS2_FALSE;
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_resume_invocation_phases");
+ AXIS2_PARAM_CHECK(env->error, phases, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_FALSE);
+
+ count = axutil_array_list_size(phases, env);
+
+ for(i = 0; i < count && !(axis2_msg_ctx_is_paused(msg_ctx, env)); i++)
+ {
+ axis2_phase_t *phase = (axis2_phase_t *)axutil_array_list_get(phases, env, i);
+ const axis2_char_t *phase_name = axis2_phase_get_name(phase, env);
+ const axis2_char_t *paused_phase_name = axis2_msg_ctx_get_paused_phase_name(msg_ctx, env);
+ /* Skip invoking handlers until we find the paused phase */
+ if(phase_name && paused_phase_name && 0 == axutil_strcmp(phase_name, paused_phase_name))
+ {
+ int paused_handler_i = -1;
+ found_match = AXIS2_TRUE;
+
+ paused_handler_i = axis2_msg_ctx_get_current_handler_index(msg_ctx, env);
+ /* Invoke the paused handler and rest of the handlers of the paused
+ * phase */
+ axis2_phase_invoke_start_from_handler(phase, env, paused_handler_i, msg_ctx);
+ }
+ else
+ {
+ /* Now we have found the paused phase and invoked the rest of the
+ * handlers of that phase, invoke all the phases after that */
+ if(found_match)
+ {
+ axis2_phase_invoke(phase, env, msg_ctx);
+ }
+ }
+ }
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "End:axis2_engine_resume_invocation_phases");
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN const axis2_char_t * AXIS2_CALL
+axis2_engine_get_receiver_fault_code(
+ const axis2_engine_t * engine,
+ const axutil_env_t * env,
+ const axis2_char_t * soap_namespace)
+{
+ if(axutil_strcmp(AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI, soap_namespace))
+ return AXIOM_SOAP12_FAULT_CODE_RECEIVER;
+ return AXIOM_SOAP11_FAULT_CODE_RECEIVER;
+}
+
+axis2_status_t
+axis2_engine_check_must_understand_headers(
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_soap_header_t *soap_header = NULL;
+ axutil_hash_t *header_block_ht = NULL;
+ axutil_hash_index_t *hash_index = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+ if(!soap_envelope)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Soap envelope not found in message context");
+ return AXIS2_FAILURE;
+ }
+
+ soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
+ if(!soap_header)
+ return AXIS2_SUCCESS;
+
+ header_block_ht = axiom_soap_header_get_all_header_blocks(soap_header, env);
+ if(!header_block_ht)
+ return AXIS2_SUCCESS;
+
+ for(hash_index = axutil_hash_first(header_block_ht, env); hash_index; hash_index
+ = axutil_hash_next(env, hash_index))
+ {
+ void *hb = NULL;
+ axiom_soap_header_block_t *header_block = NULL;
+ axis2_char_t *role = NULL;
+
+ axutil_hash_this(hash_index, NULL, NULL, &hb);
+ header_block = (axiom_soap_header_block_t *)hb;
+
+ if(header_block)
+ {
+ if(axiom_soap_header_block_is_processed(header_block, env)
+ || !axiom_soap_header_block_get_must_understand(header_block, env))
+ {
+ continue;
+ }
+
+ /* If this header block is not targeted to me then its not my
+ problem. Currently this code only supports the "next" role; we
+ need to fix this to allow the engine/service to be in one or more
+ additional roles and then to check that any headers targeted for
+ that role too have been dealt with. */
+ role = axiom_soap_header_block_get_role(header_block, env);
+
+ if(axis2_msg_ctx_get_is_soap_11(msg_ctx, env) != AXIS2_TRUE)
+ {
+ /* SOAP 1.2 */
+ if(!role || axutil_strcmp(role, AXIOM_SOAP12_SOAP_ROLE_NEXT) != 0)
+ {
+ axiom_soap_envelope_t *temp_env =
+ axiom_soap_envelope_create_default_soap_fault_envelope(env,
+ "soapenv:MustUnderstand", "Header not understood", AXIOM_SOAP12, NULL,
+ NULL);
+ axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, temp_env);
+ axis2_msg_ctx_set_wsa_action(msg_ctx, env,
+ "http://www.w3.org/2005/08/addressing/fault");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Must understand soap fault occured");
+ return AXIS2_FAILURE;
+ }
+ }
+ else
+ {
+ /* SOAP 1.1 */
+ if(!role || axutil_strcmp(role, AXIOM_SOAP11_SOAP_ACTOR_NEXT) != 0)
+ {
+ axiom_soap_envelope_t *temp_env =
+ axiom_soap_envelope_create_default_soap_fault_envelope(env,
+ "soapenv:MustUnderstand", "Header not understood", AXIOM_SOAP11, NULL,
+ NULL);
+ axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, temp_env);
+ axis2_msg_ctx_set_wsa_action(msg_ctx, env,
+ "http://www.w3.org/2005/08/addressing/fault");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Must understand soap fault occured");
+ return AXIS2_FAILURE;
+ }
+
+ }
+
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_engine_resume_receive(
+ axis2_engine_t * engine,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_status_t status = AXIS2_FAILURE;
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_conf_t *conf = NULL;
+ axutil_array_list_t *phases = NULL;
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_resume_receive");
+ /* Find and invoke the phases */
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ phases = axis2_conf_get_in_phases_upto_and_including_post_dispatch(conf, env);
+
+ axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
+ /* Invoking the message receiver */
+ if(axis2_msg_ctx_get_server_side(msg_ctx, env) && !axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ /* Invoke the message receivers */
+ axis2_op_ctx_t *op_ctx = NULL;
+
+ status = axis2_engine_check_must_understand_headers(env, msg_ctx);
+
+ if(status != AXIS2_SUCCESS)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Checking for must understand headers failed");
+ return status;
+ }
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if(op_ctx)
+ {
+ axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
+ if(op)
+ {
+ axis2_msg_recv_t *receiver = NULL;
+ receiver = axis2_op_get_msg_recv(op, env);
+ if(!receiver)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Message receiver not set in operation description");
+ return AXIS2_FAILURE;
+ }
+ status = axis2_msg_recv_receive(receiver, env, msg_ctx, axis2_msg_recv_get_derived(
+ receiver, env));
+ }
+ }
+ }
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_resume_receive");
+ return status;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_engine_resume_send(
+ axis2_engine_t * engine,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_op_ctx_t *op_ctx = NULL;
+ axutil_array_list_t *phases = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_resume_send");
+ /* Invoke the phases */
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if(op_ctx)
+ {
+ axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
+ if(op)
+ {
+ phases = axis2_op_get_out_flow(op, env);
+ }
+ }
+ axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
+
+ /* Invoking transport sender */
+ if(!axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ /* Write the message to the wire */
+ axis2_transport_out_desc_t *transport_out = NULL;
+ axis2_transport_sender_t *sender = NULL;
+ transport_out = axis2_msg_ctx_get_transport_out_desc(msg_ctx, env);
+ if(transport_out)
+ {
+ sender = axis2_transport_out_desc_get_sender(transport_out, env);
+ if(sender)
+ {
+ status = AXIS2_TRANSPORT_SENDER_INVOKE(sender, env, msg_ctx);
+ }
+ }
+ }
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_resume_send");
+ return status;
+}
+
diff --git a/src/core/engine/handler.c b/src/core/engine/handler.c
new file mode 100644
index 0000000..e9edf24
--- /dev/null
+++ b/src/core/engine/handler.c
@@ -0,0 +1,133 @@
+/*
+ * 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_handler.h>
+#include <axis2_handler_desc.h>
+
+struct axis2_handler
+{
+
+ /** handler description. This is a reference, hence a shallow copy. */
+ axis2_handler_desc_t *handler_desc;
+
+ /**
+ * Invoke is called to do the actual work assigned to the handler.
+ * The phase that owns the handler is responsible for calling invoke
+ * on top of the handler. Those structs that implement the interface
+ * of the handler should implement the logic for invoke and assign the
+ * respective function pointer to invoke operation.
+ * @param handler pointer to handler
+ * @param env pointer to environment struct
+ * @param msg_ctx pointer to message context
+ * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+ */
+ axis2_status_t(AXIS2_CALL * invoke)(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx);
+};
+
+AXIS2_EXTERN axis2_handler_t *AXIS2_CALL
+axis2_handler_create(
+ const axutil_env_t * env)
+{
+ axis2_handler_t *handler = NULL;
+
+ handler = AXIS2_MALLOC(env->allocator, sizeof(axis2_handler_t));
+ if(!handler)
+ {
+ AXIS2_ERROR_SET_ERROR_NUMBER(env->error, AXIS2_ERROR_NO_MEMORY);
+ AXIS2_ERROR_SET_STATUS_CODE(env->error, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ handler->handler_desc = NULL;
+
+ return handler;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_handler_free(
+ axis2_handler_t * handler,
+ const axutil_env_t * env)
+{
+ AXIS2_FREE(env->allocator, handler);
+ return;
+}
+
+AXIS2_EXTERN const axutil_string_t *AXIS2_CALL
+axis2_handler_get_name(
+ const axis2_handler_t * handler,
+ const axutil_env_t * env)
+{
+ if(!(handler->handler_desc))
+ return NULL;
+
+ return axis2_handler_desc_get_name(handler->handler_desc, env);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_handler_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx)
+{
+ return handler->invoke(handler, env, msg_ctx);
+}
+
+AXIS2_EXTERN axutil_param_t *AXIS2_CALL
+axis2_handler_get_param(
+ const axis2_handler_t * handler,
+ const axutil_env_t * env,
+ const axis2_char_t * name)
+{
+ if(!(handler->handler_desc))
+ return NULL;
+
+ return axis2_handler_desc_get_param(handler->handler_desc, env, name);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_handler_init(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ axis2_handler_desc_t * handler_desc)
+{
+ handler->handler_desc = handler_desc;
+ axis2_handler_desc_set_handler(handler_desc, env, handler);
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_handler_desc_t *AXIS2_CALL
+axis2_handler_get_handler_desc(
+ const axis2_handler_t * handler,
+ const axutil_env_t * env)
+{
+ return handler->handler_desc;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_handler_set_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ AXIS2_HANDLER_INVOKE func)
+{
+ handler->invoke = func;
+ return AXIS2_SUCCESS;
+}
+
diff --git a/src/core/engine/phase.c b/src/core/engine/phase.c
new file mode 100644
index 0000000..a37ff95
--- /dev/null
+++ b/src/core/engine/phase.c
@@ -0,0 +1,1275 @@
+/*
+ * 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 <axutil_string.h>
+#include <axis2_phase.h>
+#include <axutil_array_list.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_const.h>
+
+static axis2_status_t
+axis2_phase_add_unique(
+ const axutil_env_t * env,
+ axutil_array_list_t * list,
+ axis2_handler_t * handler);
+
+static axis2_status_t
+axis2_phase_remove_unique(
+ const axutil_env_t * env,
+ axutil_array_list_t * list,
+ axis2_handler_t * handler);
+
+struct axis2_phase
+{
+
+ /** phase name */
+ axis2_char_t *name;
+
+ /** array list of handlers */
+ axutil_array_list_t *handlers;
+
+ /** first handler of phase */
+ axis2_handler_t *first_handler;
+
+ /** first handler of phase set? */
+ axis2_bool_t first_handler_set;
+
+ /** last handler of phase */
+ axis2_handler_t *last_handler;
+
+ /** last handler of phase set? */
+ axis2_bool_t last_handler_set;
+
+ /**
+ * handler_first and handler_last are the same handler
+ * that is for this phase there is only one handler
+ */
+ axis2_bool_t is_one_handler;
+
+ int ref;
+};
+
+AXIS2_EXTERN axis2_phase_t *AXIS2_CALL
+axis2_phase_create(
+ const axutil_env_t * env,
+ const axis2_char_t * phase_name)
+{
+ axis2_phase_t *phase = NULL;
+
+ phase = AXIS2_MALLOC(env->allocator, sizeof(axis2_phase_t));
+ if(!phase)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
+ return NULL;
+ }
+
+ phase->name = NULL;
+ phase->handlers = NULL;
+ phase->first_handler = NULL;
+ phase->first_handler_set = AXIS2_FALSE;
+ phase->last_handler = NULL;
+ phase->last_handler_set = AXIS2_FALSE;
+ phase->is_one_handler = AXIS2_FALSE;
+ phase->ref = 1;
+
+ phase->handlers = axutil_array_list_create(env, 10);
+ if(!(phase->handlers))
+ {
+
+ /** error is already set by last method array list container create */
+ axis2_phase_free(phase, env);
+ return NULL;
+ }
+
+ if(phase_name)
+ {
+ phase->name = axutil_strdup(env, phase_name);
+ if(!(phase->name))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
+ axis2_phase_free(phase, env);
+ return NULL;
+ }
+ }
+
+ return phase;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_add_handler_at(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ const int index,
+ axis2_handler_t * handler)
+{
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "axis2_handler_t *%s added to the index %d of the phase %s", axutil_string_get_buffer(
+ axis2_handler_get_name(handler, env), env), index, phase->name);
+
+ return axutil_array_list_add_at(phase->handlers, env, index, handler);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_add_handler(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_t * handler)
+{
+ AXIS2_LOG_INFO(env->log, "Handler %s added to phase %s", axutil_string_get_buffer(
+ axis2_handler_get_name(handler, env), env), phase->name);
+
+ return axis2_phase_add_unique(env, phase->handlers, handler);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_remove_handler(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_t * handler)
+{
+ AXIS2_LOG_INFO(env->log, "Handler %s romoved from phase %s", axutil_string_get_buffer(
+ axis2_handler_get_name(handler, env), env), phase->name);
+
+ return axis2_phase_remove_unique(env, phase->handlers, handler);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_invoke(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ int index = 0, size = 0;
+ axis2_status_t status = AXIS2_SUCCESS;
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_phase_invoke");
+ axis2_msg_ctx_set_paused_phase_name(msg_ctx, env, phase->name);
+ if(phase->first_handler)
+ {
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ AXIS2_LOG_INFO(env->log, "Message context is paused in the phase %s", phase->name);
+ return AXIS2_SUCCESS;
+ }
+ else
+ {
+ const axis2_char_t *handler_name = axutil_string_get_buffer(axis2_handler_get_name(
+ phase->first_handler, env), env);
+ AXIS2_LOG_INFO(env->log, "Invoke the first handler %s within the phase %s",
+ handler_name, phase->name);
+
+ status = axis2_handler_invoke(phase->first_handler, env, msg_ctx);
+ if(!status)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Handler %s invoke failed within phase %s",
+ handler_name, phase->name);
+ return status;
+ }
+ }
+ }
+ /* Invoking the rest of handlers except first_handler and last_handler */
+ size = axutil_array_list_size(phase->handlers, env);
+ while(index < size)
+ {
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ break;
+ }
+ else
+ {
+ axis2_handler_t *handler = (axis2_handler_t *)axutil_array_list_get(phase->handlers,
+ env, index);
+ if(handler)
+ {
+ const axis2_char_t *handler_name = axutil_string_get_buffer(axis2_handler_get_name(
+ handler, env), env);
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Invoke the handler %s within the phase %s", handler_name, phase->name);
+
+ /* Test code. This is used when valgrind is used to find leaks in Axis2/C modules.*/
+ /*if(!axutil_strcmp(handler_name, "SandeshaGlobalInHandler") || !axutil_strcmp(
+ handler_name, "SandeshaInHandler"))
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "dam_handler_name %s. dam_phase_name %s", handler_name, phase->name);
+ if(!axutil_strcmp(handler_name, "SandeshaGlobalInHandler"))
+ {
+ status = sandesha2_global_in_handler_invoke(phase->first_handler, env, msg_ctx);
+ }
+ if(!axutil_strcmp(handler_name, "SandeshaInHandler"))
+ {
+ status = sandesha2_in_handler_invoke(phase->first_handler, env, msg_ctx);
+ }
+ }
+ else*/
+ status = axis2_handler_invoke(handler, env, msg_ctx);
+ if(!status)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler %s invoke failed within phase %s", handler_name, phase->name);
+ return status;
+ }
+ /* index increment should be done after the invoke function. If the invocation
+ failed this handler is taken care of and no need to revoke again */
+ index++;
+ axis2_msg_ctx_set_current_handler_index(msg_ctx, env, index);
+ }
+ }
+ }
+
+ /* If phase last handler is there invoke it here */
+ if(phase->last_handler)
+ {
+ if(axis2_msg_ctx_is_paused(msg_ctx, env))
+ {
+ AXIS2_LOG_INFO(env->log, "Message context is paused in the phase %s", phase->name);
+ return AXIS2_SUCCESS;
+ }
+ else
+ {
+ const axis2_char_t *handler_name = axutil_string_get_buffer(axis2_handler_get_name(
+ phase->last_handler, env), env);
+ AXIS2_LOG_INFO(env->log, "Invoke the last handler %s within the phase %s",
+ handler_name, phase->name);
+
+ status = axis2_handler_invoke(phase->last_handler, env, msg_ctx);
+ if(!status)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler %s invoke failed within phase %s", handler_name, phase->name);
+ return status;
+ }
+ }
+ }
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_phase_invoke");
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
+axis2_phase_get_name(
+ const axis2_phase_t * phase,
+ const axutil_env_t * env)
+{
+ return phase->name;
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+axis2_phase_get_handler_count(
+ const axis2_phase_t * phase,
+ const axutil_env_t * env)
+{
+ return axutil_array_list_size(phase->handlers, env);
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+_axis2_phase_get_before_after(
+ axis2_handler_t * handler,
+ const axutil_env_t * env)
+{
+ const axis2_char_t *before = NULL, *after = NULL;
+ axis2_handler_desc_t *handler_desc = NULL;
+ axis2_phase_rule_t *rules = NULL;
+ const axis2_char_t *name = axutil_string_get_buffer(axis2_handler_get_name(handler, env), env);
+
+ handler_desc = axis2_handler_get_handler_desc(handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler description is not set for the Handler %s", name);
+ return AXIS2_FAILURE;
+ }
+
+ rules = axis2_handler_desc_get_rules(handler_desc, env);
+ if(!rules)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler rules are not set for the Handler Description %s", name);
+ return AXIS2_FAILURE;
+ }
+
+ before = axis2_phase_rule_get_before(rules, env);
+ after = axis2_phase_rule_get_after(rules, env);
+
+ if(before && after)
+ {
+ if(!axutil_strcmp(before, after))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_BEFORE_AFTER_HANDLERS_SAME, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Both before and after handlers cannot be the same");
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_PHASE_BOTH_BEFORE_AFTER;
+ }
+ else if(before)
+ {
+ return AXIS2_PHASE_BEFORE;
+ }
+ else if(after)
+ {
+ return AXIS2_PHASE_AFTER;
+ }
+ else
+ {
+ return AXIS2_PHASE_ANYWHERE;
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_set_first_handler(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_t * handler)
+{
+ const axis2_char_t *handler_name = axutil_string_get_buffer(
+ axis2_handler_get_name(handler, env), env);
+ const axis2_char_t *phase_name = axis2_phase_get_name(phase, env);
+ if(phase->first_handler_set)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PHASE_FIRST_HANDLER_ALREADY_SET, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "First handler of phase already set, so cannot set handler %s "
+ "in to the phase %s as first handler", handler_name, phase_name);
+ return AXIS2_FAILURE;
+ }
+ else
+ {
+ if(_axis2_phase_get_before_after(handler, env) != AXIS2_PHASE_ANYWHERE)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_PHASE_FIRST_HANDLER, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Invalid first handler %s set for the Phase %s", handler_name, phase_name);
+ return AXIS2_FAILURE;
+ }
+ phase->first_handler = handler;
+ phase->first_handler_set = AXIS2_TRUE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_set_last_handler(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_t * handler)
+{
+ const axis2_char_t *handler_name = axutil_string_get_buffer(
+ axis2_handler_get_name(handler, env), env);
+ const axis2_char_t *phase_name = axis2_phase_get_name(phase, env);
+ if(phase->last_handler_set)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PHASE_LAST_HANDLER_ALREADY_SET, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Last handler of phase already set, so cannot set handler %s "
+ "in to the phase %s as last handler", handler_name, phase_name);
+ return AXIS2_FAILURE;
+ }
+ else
+ {
+ if(_axis2_phase_get_before_after(handler, env) != AXIS2_PHASE_ANYWHERE)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_PHASE_LAST_HANDLER, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid last handler %s set for the Phase %s",
+ handler_name, phase_name);
+ return AXIS2_FAILURE;
+ }
+ phase->last_handler = handler;
+ phase->last_handler_set = AXIS2_TRUE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_add_handler_desc(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_desc_t * handler_desc)
+{
+ axis2_phase_rule_t *rules = NULL;
+ axis2_handler_t *handler = NULL;
+ axis2_status_t status = AXIS2_SUCCESS;
+ axis2_bool_t first = AXIS2_FALSE, last = AXIS2_FALSE;
+ const axis2_char_t *handler_desc_name = axutil_string_get_buffer(axis2_handler_desc_get_name(
+ handler_desc, env), env);
+ if(phase->is_one_handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_PHASE_ADD_HANDLER_INVALID, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Only one handler allowed for phase %s, adding handler %s is not "
+ "allowed", phase->name, handler_desc_name);
+ return AXIS2_FAILURE;
+ }
+ else
+ {
+ rules = axis2_handler_desc_get_rules(handler_desc, env);
+ if(!rules)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler rules are not set for the Hanlder Description %s "
+ "within phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ first = axis2_phase_rule_is_first(rules, env);
+ last = axis2_phase_rule_is_last(rules, env);
+
+ if(first && last)
+ {
+ if(axutil_array_list_size(phase->handlers, env) > 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_RULES, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Invalid handler rules, so unable to add handler %s to "
+ "phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ handler = axis2_handler_desc_get_handler(handler_desc, env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler is not set for the Handler Description %s "
+ "within phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ /*status = axutil_array_list_add(phase->handlers, env, handler); */
+ status = axis2_phase_add_unique(env, phase->handlers, handler);
+ if(status)
+ phase->is_one_handler = AXIS2_TRUE;
+ return status;
+ }
+ else if(first)
+ {
+ handler = axis2_handler_desc_get_handler(handler_desc, env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler is not set for the Handler Description %s "
+ "within phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+ return axis2_phase_set_first_handler(phase, env, handler);
+ }
+ else if(last)
+ {
+ handler = axis2_handler_desc_get_handler(handler_desc, env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler is not set for the Handler Description %s "
+ "within phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+ return axis2_phase_set_last_handler(phase, env, handler);
+ }
+ else
+ {
+ handler = axis2_handler_desc_get_handler(handler_desc, env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler is not set for the Handler Description %s "
+ "within phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ return axis2_phase_insert_handler_desc(phase, env, handler_desc);
+ }
+ }
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+_axis2_phase_is_valid_before(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_t * handler)
+{
+ axis2_phase_rule_t *rules = NULL;
+ axis2_handler_desc_t *handler_desc = NULL;
+ const axis2_char_t *first_handler_name = NULL, *before = NULL;
+
+ if(phase->first_handler)
+ {
+ handler_desc = axis2_handler_get_handler_desc(phase->first_handler, env);
+ if(!handler_desc)
+ return AXIS2_TRUE;
+
+ first_handler_name = axutil_string_get_buffer(
+ axis2_handler_desc_get_name(handler_desc, env), env);
+
+ if(!first_handler_name)
+ return AXIS2_TRUE;
+
+ handler_desc = axis2_handler_get_handler_desc(handler, env);
+ if(!handler_desc)
+ return AXIS2_TRUE;
+
+ rules = axis2_handler_desc_get_rules(handler_desc, env);
+ if(!rules)
+ return AXIS2_TRUE;
+
+ before = axis2_phase_rule_get_before(rules, env);
+ if(!before)
+ return AXIS2_TRUE;
+
+ if(!axutil_strcmp(first_handler_name, before))
+ return AXIS2_FALSE;
+ else
+ return AXIS2_TRUE;
+
+ }
+ return AXIS2_TRUE;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+_axis2_phase_is_valid_after(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_t * handler)
+{
+ axis2_phase_rule_t *rules = NULL;
+ axis2_handler_desc_t *handler_desc = NULL;
+ const axis2_char_t *last_handler_name = NULL, *after = NULL;
+
+ if(phase->last_handler)
+ {
+ handler_desc = axis2_handler_get_handler_desc(phase->last_handler, env);
+ if(!handler_desc)
+ return AXIS2_TRUE;
+
+ last_handler_name = axutil_string_get_buffer(
+ axis2_handler_desc_get_name(handler_desc, env), env);
+
+ if(!last_handler_name)
+ return AXIS2_TRUE;
+
+ handler_desc = axis2_handler_get_handler_desc(handler, env);
+ if(!handler_desc)
+ return AXIS2_TRUE;
+
+ rules = axis2_handler_desc_get_rules(handler_desc, env);
+ if(!rules)
+ return AXIS2_TRUE;
+
+ after = axis2_phase_rule_get_after(rules, env);
+ if(!after)
+ return AXIS2_TRUE;
+
+ if(!axutil_strcmp(last_handler_name, after))
+ return AXIS2_FALSE;
+ else
+ return AXIS2_TRUE;
+
+ }
+ return AXIS2_TRUE;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_insert_before(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_t * handler)
+{
+ axis2_phase_rule_t *rules = NULL;
+ axis2_handler_desc_t *handler_desc = NULL;
+ const axis2_char_t *handler_name = NULL, *before = NULL;
+ int i = 0;
+ int size = 0;
+ const axis2_char_t *name = axutil_string_get_buffer(axis2_handler_get_name(handler, env), env);
+ const axis2_char_t *handler_desc_name = NULL;
+
+ handler_desc = axis2_handler_get_handler_desc(handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler description is not set in the handler %s within phase %s", name, phase->name);
+ return AXIS2_FAILURE;
+ }
+ handler_desc_name = axutil_string_get_buffer(axis2_handler_desc_get_name(handler_desc, env),
+ env);
+
+ rules = axis2_handler_desc_get_rules(handler_desc, env);
+ if(!rules)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler rules are not set in the handler description %s within "
+ "phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ before = axis2_phase_rule_get_before(rules, env);
+ if(!before)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Rule `before` is not set in the handler rules for handler %s "
+ "within phase %s", name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ if(phase->last_handler)
+ {
+ const axis2_char_t *last_handler_name = axutil_string_get_buffer(axis2_handler_get_name(
+ phase->last_handler, env), env);
+ handler_desc = axis2_handler_get_handler_desc(phase->last_handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler description is not set in the last handler %s of "
+ "phase %s", last_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ handler_name
+ = axutil_string_get_buffer(axis2_handler_desc_get_name(handler_desc, env), env);
+ if(!handler_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler name is not set in the handler description for "
+ "last handler %s within phase %s", last_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ if(!axutil_strcmp(before, handler_name))
+ {
+ /*return axutil_array_list_add(phase->handlers, env, handler); */
+ return axis2_phase_add_unique(env, phase->handlers, handler);
+ }
+ }
+
+ size = axutil_array_list_size(phase->handlers, env);
+
+ for(i = 0; i < size; i++)
+ {
+ axis2_handler_t *temp_handler = (axis2_handler_t *)axutil_array_list_get(phase->handlers,
+ env, i);
+ if(temp_handler)
+ {
+ const axis2_char_t *temp_handler_name = axutil_string_get_buffer(
+ axis2_handler_get_name(temp_handler, env), env);
+ handler_desc = axis2_handler_get_handler_desc(temp_handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler Description is not set for the Handler %s "
+ "within phase %s", temp_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ handler_name = axutil_string_get_buffer(axis2_handler_desc_get_name(handler_desc, env),
+ env);
+ if(!handler_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler name is not set in the handler description for "
+ "handler %s within phase %s", temp_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ if(!axutil_strcmp(before, handler_name))
+ {
+ return axutil_array_list_add_at(phase->handlers, env, i, handler);
+ }
+ }
+ }
+ /* add as the last handler */
+ /* return axutil_array_list_add(phase->handlers, env, handler); */
+ return axis2_phase_add_unique(env, phase->handlers, handler);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_insert_after(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_t * handler)
+{
+ axis2_phase_rule_t *rules = NULL;
+ axis2_handler_desc_t *handler_desc = NULL;
+ const axis2_char_t *handler_name = NULL;
+ const axis2_char_t *after = NULL;
+ int i = 0;
+ int size = 0;
+ const axis2_char_t *name = axutil_string_get_buffer(axis2_handler_get_name(handler, env), env);
+ const axis2_char_t *handler_desc_name = NULL;
+
+ handler_desc = axis2_handler_get_handler_desc(handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler description is not set in the handler %s within phase %s", name, phase->name);
+ return AXIS2_FAILURE;
+ }
+ handler_desc_name = axutil_string_get_buffer(axis2_handler_desc_get_name(handler_desc, env),
+ env);
+ rules = axis2_handler_desc_get_rules(handler_desc, env);
+ if(!rules)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler rules are not set in the handler description %s within "
+ "phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ after = axis2_phase_rule_get_after(rules, env);
+ if(!after)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Rule `after` is not set in the handler rules for handler desc "
+ "%s within phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ if(phase->first_handler)
+ {
+ const axis2_char_t *first_handler_name = axutil_string_get_buffer(axis2_handler_get_name(
+ phase->first_handler, env), env);
+ handler_desc = axis2_handler_get_handler_desc(phase->first_handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler description is not set in the first handler %s "
+ "within phase %s", first_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ handler_name
+ = axutil_string_get_buffer(axis2_handler_desc_get_name(handler_desc, env), env);
+ if(!handler_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler name is not set in the handler description for "
+ "handler %s within phase %s", name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ if(!axutil_strcmp(after, handler_name))
+ {
+ return axutil_array_list_add_at(phase->handlers, env, 0, handler);
+ }
+ }
+
+ size = axutil_array_list_size(phase->handlers, env);
+
+ for(i = 0; i < size; i++)
+ {
+ axis2_handler_t *temp_handler = (axis2_handler_t *)axutil_array_list_get(phase->handlers,
+ env, i);
+ if(temp_handler)
+ {
+ const axis2_char_t *temp_handler_name = axutil_string_get_buffer(
+ axis2_handler_get_name(temp_handler, env), env);
+ handler_desc = axis2_handler_get_handler_desc(temp_handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler description is not set in the handler %s within"
+ " phase %s", temp_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ handler_name = axutil_string_get_buffer(axis2_handler_desc_get_name(handler_desc, env),
+ env);
+ if(!handler_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler name is not set in the handler description %s "
+ "within phase %s", temp_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ if(!axutil_strcmp(after, handler_name))
+ {
+ if(i == (size - 1))
+ {
+ return axis2_phase_add_unique(env, phase->handlers, handler);
+ }
+ else
+ return axutil_array_list_add_at(phase->handlers, env, i + 1, handler);
+ }
+ }
+ }
+
+ if(size > 0)
+ return axutil_array_list_add_at(phase->handlers, env, 0, handler);
+ else
+ {
+ return axis2_phase_add_unique(env, phase->handlers, handler);
+ }
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_insert_before_and_after(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_t * handler)
+{
+ int before = -1;
+ int after = -1;
+ axis2_phase_rule_t *rules = NULL;
+ axis2_handler_desc_t *handler_desc = NULL;
+ const axis2_char_t *before_handler_name = NULL, *after_handler_name = NULL, *after_name = NULL,
+ *before_name = NULL, *handler_name = NULL;
+ int i = 0;
+ int size = 0;
+ const axis2_char_t *name = axutil_string_get_buffer(axis2_handler_get_name(handler, env), env);
+ const axis2_char_t *handler_desc_name = NULL;
+
+ handler_desc = axis2_handler_get_handler_desc(handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler description is not set in the handler %s within phase %s", name, phase->name);
+ return AXIS2_FAILURE;
+ }
+ handler_desc_name = axutil_string_get_buffer(axis2_handler_desc_get_name(handler_desc, env),
+ env);
+
+ rules = axis2_handler_desc_get_rules(handler_desc, env);
+ if(!rules)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler rules are not set in the handler description %s within "
+ "phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ before_name = axis2_phase_rule_get_before(rules, env);
+ if(!before_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Rule `before` is not set in the handler rules for handler desc "
+ " %s within phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ after_name = axis2_phase_rule_get_after(rules, env);
+ if(!after_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Rule `after` is not set in the handler rules for handler desc "
+ "%s within phase %s", handler_desc_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ if(phase->first_handler)
+ {
+ const axis2_char_t *first_handler_name = axutil_string_get_buffer(axis2_handler_get_name(
+ phase->first_handler, env), env);
+ handler_desc = axis2_handler_get_handler_desc(phase->first_handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler description is not set in the first handler %s "
+ "within phase %s", first_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ before_handler_name = axutil_string_get_buffer(axis2_handler_desc_get_name(handler_desc,
+ env), env);
+ if(!before_handler_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler name is not set in the handler description for the "
+ "first handler %s within phase %s", first_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+ }
+
+ if(phase->last_handler)
+ {
+ const axis2_char_t *last_handler_name = axutil_string_get_buffer(axis2_handler_get_name(
+ phase->last_handler, env), env);
+ handler_desc = axis2_handler_get_handler_desc(phase->last_handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler description is not set in the last handler %s "
+ "within phase %s", last_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ after_handler_name = axutil_string_get_buffer(
+ axis2_handler_desc_get_name(handler_desc, env), env);
+ if(!after_handler_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler name is not set in the handler description for the "
+ "last handler %s within phase %s", last_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+ }
+
+ if(before_handler_name && after_handler_name)
+ {
+ if(!axutil_strcmp(before_handler_name, before_name) && !axutil_strcmp(after_handler_name,
+ after_name))
+ {
+ return axis2_phase_add_unique(env, phase->handlers, handler);
+ }
+ }
+
+ if(after_handler_name)
+ {
+ if(!axutil_strcmp(after_handler_name, after_name))
+ after = 0;
+ }
+
+ size = axutil_array_list_size(phase->handlers, env);
+
+ if(after_handler_name)
+ {
+ if(!axutil_strcmp(before_handler_name, before_name))
+ before = size;
+ }
+
+ for(i = 0; i < size; i++)
+ {
+ axis2_handler_t *temp_handler = (axis2_handler_t *)axutil_array_list_get(phase->handlers,
+ env, i);
+ if(temp_handler)
+ {
+ const axis2_char_t *temp_handler_name = axutil_string_get_buffer(
+ axis2_handler_get_name(temp_handler, env), env);
+ handler_desc = axis2_handler_get_handler_desc(temp_handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler Description is not set for the Handler %s "
+ "within phase %s", temp_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ handler_name = axutil_string_get_buffer(axis2_handler_desc_get_name(handler_desc, env),
+ env);
+ if(!handler_name)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler name is not set in the handler Description for "
+ "handler %s within phase %s", temp_handler_name, phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ if(!axutil_strcmp(handler_name, after_name))
+ after = i;
+ if(!axutil_strcmp(handler_name, before_name))
+ before = i;
+ }
+
+ if((after >= 0) && (before >= 0))
+ {
+ /*both the before and after indexes have been found */
+ if(after > before)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Both the before and after indexes have been found and "
+ "`after` comes before `before` which is wrong within "
+ "phase %s", phase->name);
+ return AXIS2_FAILURE;
+ }
+ else
+ {
+ if(after + 1 < size)
+ {
+ return axutil_array_list_add_at(phase->handlers, env, after + 1, handler);
+ }
+ else
+ {
+ return axis2_phase_add_unique(env, phase->handlers, handler);
+ }
+ }
+ }
+ }
+ return axis2_phase_add_unique(env, phase->handlers, handler);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_insert_handler_desc(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_desc_t * handler_desc)
+{
+ int type = 0;
+ axis2_handler_t *handler = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ const axis2_char_t *handler_desc_name = axutil_string_get_buffer(axis2_handler_desc_get_name(
+ handler_desc, env), env);
+ const axis2_char_t *handler_name = NULL;
+ handler = axis2_handler_desc_get_handler(handler_desc, env);
+
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Handler is not set in the handler description %s",
+ handler_desc_name);
+ return AXIS2_FAILURE;
+ }
+ handler_name = axutil_string_get_buffer(axis2_handler_get_name(handler, env), env);
+
+ if(!_axis2_phase_is_valid_after(phase, env, handler))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Invalid Handler State for the handler %s within the phase %s", handler_name,
+ phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ if(!_axis2_phase_is_valid_before(phase, env, handler))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Invalid Handler State for the handler %s within the phase %s", handler_name,
+ phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ type = _axis2_phase_get_before_after(handler, env);
+
+ switch(type)
+ {
+ case 0: /*AXIS2_BOTH_BEFORE_AFTER: */
+ status = axis2_phase_insert_before_and_after(phase, env, handler);
+ break;
+ case 1: /*AXIS2_BEFORE: */
+ status = axis2_phase_insert_before(phase, env, handler);
+ break;
+ case 2: /*AXIS2_AFTER: */
+ status = axis2_phase_insert_after(phase, env, handler);
+ break;
+ case 3: /*AXIS2_ANYWHERE: */
+ status = axis2_phase_add_unique(env, phase->handlers, handler);
+ break;
+ default:
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler description %s insertion failed within the phase %s", handler_desc_name,
+ phase->name);
+ status = AXIS2_FAILURE;
+ break;
+ }
+ return status;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_phase_get_all_handlers(
+ const axis2_phase_t * phase,
+ const axutil_env_t * env)
+{
+ return phase->handlers;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_invoke_start_from_handler(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ const int paused_handler_index,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ int i = 0, size = 0;
+ axis2_status_t status = AXIS2_SUCCESS;
+
+ axis2_msg_ctx_set_paused_phase_name(msg_ctx, env, phase->name);
+
+ size = axutil_array_list_size(phase->handlers, env);
+ for(i = paused_handler_index; i < size; i++)
+ {
+ axis2_handler_t *handler =
+ (axis2_handler_t *)axutil_array_list_get(phase->handlers, env, i);
+ if(handler)
+ {
+ const axis2_char_t *handler_name = axutil_string_get_buffer(axis2_handler_get_name(
+ handler, env), env);
+ int index = -1;
+
+ axis2_handler_desc_t *handler_desc = axis2_handler_get_handler_desc(handler, env);
+ if(!handler_desc)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Invalid Handler State for the handler %s within phase %s", handler_name,
+ phase->name);
+ return AXIS2_FAILURE;
+ }
+
+ axis2_handler_invoke(handler, env, msg_ctx);
+ index = axis2_msg_ctx_get_current_handler_index(msg_ctx, env);
+ axis2_msg_ctx_set_current_handler_index(msg_ctx, env, (index + 1));
+ }
+ }
+ return status;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_phase_free(
+ axis2_phase_t * phase,
+ const axutil_env_t * env)
+{
+ if(--(phase->ref) > 0)
+ {
+ return;
+ }
+
+ if(phase->name)
+ {
+ AXIS2_FREE(env->allocator, phase->name);
+ }
+
+ if(phase->handlers)
+ {
+ axutil_array_list_free(phase->handlers, env);
+ }
+ AXIS2_FREE(env->allocator, phase);
+ return;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_remove_handler_desc(
+ axis2_phase_t * phase,
+ const axutil_env_t * env,
+ axis2_handler_desc_t * handler_desc)
+{
+ axis2_handler_t *handler;
+ const axis2_char_t *handler_desc_name = axutil_string_get_buffer(axis2_handler_desc_get_name(
+ handler_desc, env), env);
+ handler = axis2_handler_desc_get_handler(handler_desc, env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Handler is not set in the Handler Description %s within phase %s", handler_desc_name,
+ phase->name);
+ return AXIS2_FAILURE;
+ }
+ return axis2_phase_remove_unique(env, phase->handlers, handler);
+}
+
+static axis2_status_t
+axis2_phase_add_unique(
+ const axutil_env_t * env,
+ axutil_array_list_t * list,
+ axis2_handler_t * handler)
+{
+ int i = 0, size = 0;
+ axis2_bool_t add_handler = AXIS2_TRUE;
+ const axutil_string_t *handler_name = NULL;
+
+ handler_name = axis2_handler_get_name(handler, env);
+ size = axutil_array_list_size(list, env);
+ for(i = 0; i < size; i++)
+ {
+ axis2_handler_t *obj = NULL;
+ const axutil_string_t *obj_name = NULL;
+
+ obj = (axis2_handler_t *)axutil_array_list_get(list, env, i);
+ obj_name = axis2_handler_get_name(obj, env);
+ if(obj == handler)
+ {
+ add_handler = AXIS2_FALSE;
+ break;
+ }
+ else if(!axutil_strcmp(axutil_string_get_buffer(handler_name, env),
+ axutil_string_get_buffer(obj_name, env)))
+ {
+ add_handler = AXIS2_FALSE;
+ break;
+ }
+ }
+ if(add_handler)
+ axutil_array_list_add(list, env, handler);
+ return AXIS2_SUCCESS;
+}
+
+static axis2_status_t
+axis2_phase_remove_unique(
+ const axutil_env_t * env,
+ axutil_array_list_t * list,
+ axis2_handler_t * handler)
+{
+ int i = 0, size = 0;
+ axis2_bool_t remove_handler = AXIS2_FALSE;
+ const axutil_string_t *handler_name = NULL;
+
+ handler_name = axis2_handler_get_name(handler, env);
+ size = axutil_array_list_size(list, env);
+ for(i = 0; i < size; i++)
+ {
+ axis2_handler_t *obj = NULL;
+ const axutil_string_t *obj_name = NULL;
+
+ obj = (axis2_handler_t *)axutil_array_list_get(list, env, i);
+ obj_name = axis2_handler_get_name(obj, env);
+ if(obj == handler)
+ {
+ remove_handler = AXIS2_TRUE;
+ break;
+ }
+ else if(!axutil_strcmp(axutil_string_get_buffer(handler_name, env),
+ axutil_string_get_buffer(obj_name, env)))
+ {
+ remove_handler = AXIS2_TRUE;
+ break;
+ }
+ }
+ if(remove_handler)
+ axutil_array_list_remove(list, env, i);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_phase_increment_ref(
+ axis2_phase_t * phase,
+ const axutil_env_t * env)
+{
+ phase->ref++;
+ return AXIS2_SUCCESS;
+}
+
diff --git a/src/core/engine/req_uri_disp.c b/src/core/engine/req_uri_disp.c
new file mode 100644
index 0000000..dbc89b7
--- /dev/null
+++ b/src/core/engine/req_uri_disp.c
@@ -0,0 +1,206 @@
+/*
+ * 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_disp.h>
+#include <axis2_handler_desc.h>
+#include <axutil_string.h>
+#include <axis2_relates_to.h>
+#include <axis2_svc.h>
+#include <axis2_const.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_addr.h>
+#include <axutil_utils.h>
+
+const axis2_char_t *AXIS2_REQ_URI_DISP_NAME = "request_uri_based_dispatcher";
+
+axis2_status_t AXIS2_CALL
+axis2_req_uri_disp_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx *msg_ctx);
+
+axis2_svc_t *AXIS2_CALL axis2_req_uri_disp_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env);
+
+axis2_op_t *AXIS2_CALL axis2_req_uri_disp_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc);
+
+AXIS2_EXTERN axis2_disp_t *AXIS2_CALL
+axis2_req_uri_disp_create(
+ const axutil_env_t * env)
+{
+ axis2_disp_t *disp = NULL;
+ axis2_handler_t *handler = NULL;
+ axutil_string_t *name = NULL;
+
+ name = axutil_string_create_const(env, (axis2_char_t **)&AXIS2_REQ_URI_DISP_NAME);
+
+ disp = axis2_disp_create(env, name);
+ if(!disp)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ handler = axis2_disp_get_base(disp, env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ axis2_handler_set_invoke(handler, env, axis2_req_uri_disp_invoke);
+
+ axutil_string_free(name, env);
+
+ return disp;
+}
+
+axis2_svc_t *AXIS2_CALL
+axis2_req_uri_disp_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_svc_t *svc = NULL;
+
+ if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ return NULL;
+
+ endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);
+
+ if(endpoint_ref)
+ {
+ const axis2_char_t *address = NULL;
+
+ address = axis2_endpoint_ref_get_address(endpoint_ref, env);
+ if(address)
+ {
+ axis2_char_t **url_tokens = NULL;
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Checking for service using target endpoint address : %s", address);
+
+ url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);
+
+ if(url_tokens)
+ {
+ if(url_tokens[0])
+ {
+ axis2_conf_ctx_t *conf_ctx = NULL;
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ axis2_conf_t *conf = NULL;
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ if(conf)
+ {
+ svc = axis2_conf_get_svc(conf, env, url_tokens[0]);
+ if(svc)
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Service found using target endpoint address");
+ }
+ }
+ AXIS2_FREE(env->allocator, url_tokens[0]);
+
+ if(url_tokens[1])
+ {
+ AXIS2_FREE(env->allocator, url_tokens[1]);
+ }
+
+ }
+ AXIS2_FREE(env->allocator, url_tokens);
+ url_tokens = NULL;
+ }
+ }
+ }
+
+ return svc;
+}
+
+axis2_op_t *AXIS2_CALL
+axis2_req_uri_disp_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc)
+{
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_op_t *op = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, svc, NULL);
+
+ if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ return NULL;
+
+ endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);
+
+ if(endpoint_ref)
+ {
+ const axis2_char_t *address = NULL;
+
+ address = axis2_endpoint_ref_get_address(endpoint_ref, env);
+ if(address)
+ {
+ axis2_char_t **url_tokens = NULL;
+
+ url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);
+
+ if(url_tokens)
+ {
+ if(url_tokens[1])
+ {
+ axutil_qname_t *op_qname = NULL;
+ AXIS2_LOG_DEBUG(
+ env->log,
+ AXIS2_LOG_SI,
+ "Checking for operation using \
+ target endpoint uri fragment : %s",
+ url_tokens[1]);
+ op_qname = axutil_qname_create(env, url_tokens[1], NULL, NULL);
+ op = axis2_svc_get_op_with_name(svc, env, axutil_qname_get_localpart(op_qname,
+ env));
+ axutil_qname_free(op_qname, env);
+ if(op)
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Operation found using target endpoint uri fragment");
+ }
+ if(url_tokens[0])
+ AXIS2_FREE(env->allocator, url_tokens[0]);
+ if(url_tokens[1])
+ AXIS2_FREE(env->allocator, url_tokens[1]);
+ AXIS2_FREE(env->allocator, url_tokens);
+ }
+ }
+ }
+
+ return op;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_req_uri_disp_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx)
+{
+ axis2_msg_ctx_set_find_svc(msg_ctx, env, axis2_req_uri_disp_find_svc);
+ axis2_msg_ctx_set_find_op(msg_ctx, env, axis2_req_uri_disp_find_op);
+ return axis2_disp_find_svc_and_op(handler, env, msg_ctx);
+}
+
diff --git a/src/core/engine/rest_disp.c b/src/core/engine/rest_disp.c
new file mode 100644
index 0000000..4782568
--- /dev/null
+++ b/src/core/engine/rest_disp.c
@@ -0,0 +1,350 @@
+/*
+ * 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_disp.h>
+#include <axis2_handler_desc.h>
+#include <axutil_string.h>
+#include <axis2_relates_to.h>
+#include <axis2_svc.h>
+#include <axis2_const.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_addr.h>
+#include <axutil_utils.h>
+#include <axiom_soap_builder.h>
+#include <axiom_soap_body.h>
+#include <axiom_soap_const.h>
+#include <axis2_http_transport.h>
+#include <axis2_core_utils.h>
+
+
+const axis2_char_t *AXIS2_REST_DISP_NAME = "rest_dispatcher";
+
+axis2_status_t AXIS2_CALL
+axis2_rest_disp_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx *msg_ctx);
+
+axis2_svc_t *AXIS2_CALL axis2_rest_disp_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env);
+
+axis2_op_t *AXIS2_CALL axis2_rest_disp_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc);
+
+axis2_op_t *AXIS2_CALL
+axis2_rest_disp_get_rest_op_with_method_and_location(
+ const axis2_svc_t * svc,
+ const axutil_env_t * env,
+ const axis2_char_t * method,
+ const axis2_char_t * location,
+ int * param_count,
+ axis2_char_t **** params);
+
+AXIS2_EXTERN axis2_disp_t *AXIS2_CALL
+axis2_rest_disp_create(
+ const axutil_env_t * env)
+{
+ axis2_disp_t *disp = NULL;
+ axis2_handler_t *handler = NULL;
+ axutil_string_t *name = NULL;
+
+ name = axutil_string_create_const(env, (axis2_char_t **)&AXIS2_REST_DISP_NAME);
+
+ disp = axis2_disp_create(env, name);
+ if(!disp)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ handler = axis2_disp_get_base(disp, env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ axis2_handler_set_invoke(handler, env, axis2_rest_disp_invoke);
+
+ axutil_string_free(name, env);
+
+ return disp;
+}
+
+axis2_svc_t *AXIS2_CALL
+axis2_rest_disp_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_svc_t *svc = NULL;
+
+ if(!axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ return NULL;
+
+ endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);
+
+ if(endpoint_ref)
+ {
+ const axis2_char_t *address = NULL;
+
+ address = axis2_endpoint_ref_get_address(endpoint_ref, env);
+ if(address)
+ {
+ axis2_char_t **url_tokens = NULL;
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Checking for service using target endpoint address : %s", address);
+
+ url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);
+
+ if(url_tokens)
+ {
+ if(url_tokens[0])
+ {
+ axis2_conf_ctx_t *conf_ctx = NULL;
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ axis2_conf_t *conf = NULL;
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ if(conf)
+ {
+ svc = axis2_conf_get_svc(conf, env, url_tokens[0]);
+ if(svc)
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Service found using target endpoint address");
+ }
+ }
+ AXIS2_FREE(env->allocator, url_tokens[0]);
+
+ if(url_tokens[1])
+ {
+ AXIS2_FREE(env->allocator, url_tokens[1]);
+ }
+
+ }
+ AXIS2_FREE(env->allocator, url_tokens);
+ url_tokens = NULL;
+ }
+ }
+ }
+
+ return svc;
+}
+
+axis2_op_t *AXIS2_CALL
+axis2_rest_disp_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc)
+{
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_op_t *op = NULL;
+ axiom_soap_envelope_t *soap_env = NULL;
+ axiom_soap_body_t *soap_body = NULL;
+ axiom_element_t *body_child = NULL;
+ axiom_node_t *body_child_node = NULL;
+ axiom_node_t *body_element_node = NULL;
+ axis2_bool_t soap_env_exists = AXIS2_TRUE;
+ int i = 0;
+
+ axutil_array_list_t *param_keys = NULL;
+ axutil_array_list_t *param_values = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, svc, NULL);
+
+ if(!axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ return NULL;
+
+ endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);
+
+ if(endpoint_ref)
+ {
+ const axis2_char_t *address = NULL;
+
+ address = axis2_endpoint_ref_get_address(endpoint_ref, env);
+ if(address)
+ {
+ axis2_char_t **url_tokens = NULL;
+
+ url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);
+
+ if(url_tokens)
+ {
+ if(url_tokens[0])
+ {
+ axis2_char_t *location = NULL;
+
+ location = strstr(address, url_tokens[0]);
+ if(location)
+ {
+ const axis2_char_t *method = NULL;
+
+ location += strlen(url_tokens[0]);
+ param_keys = axutil_array_list_create(env, 10);
+ if(!param_keys)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "No memory. Cannot create the live rest parameter maps");
+ return NULL;
+ }
+ param_values = axutil_array_list_create(env, 10);
+
+ if(!param_values)
+ {
+ axutil_array_list_free(param_keys, env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "No memory. Cannot create the live rest parameter maps");
+ return NULL;
+ }
+ method = axis2_msg_ctx_get_rest_http_method(msg_ctx, env);
+ op = axis2_core_utils_get_rest_op_with_method_and_location(svc, env,
+ method, location, param_keys, param_values);
+ }
+ }
+ if(url_tokens[0])
+ AXIS2_FREE(env->allocator, url_tokens[0]);
+ if(url_tokens[1])
+ AXIS2_FREE(env->allocator, url_tokens[1]);
+ AXIS2_FREE(env->allocator, url_tokens);
+ }
+ }
+ }
+
+ if(!op)
+ {
+ if(param_keys)
+ {
+ for(i = 0; i < axutil_array_list_size(param_keys, env); i++)
+ {
+ void *value = axutil_array_list_get(param_keys, env, i);
+ AXIS2_FREE(env->allocator, value);
+ }
+ axutil_array_list_free(param_keys, env);
+ }
+ if(param_values)
+ {
+ for(i = 0; i < axutil_array_list_size(param_values, env); i++)
+ {
+ void *value = axutil_array_list_get(param_values, env, i);
+ AXIS2_FREE(env->allocator, value);
+ }
+ axutil_array_list_free(param_values, env);
+ }
+ return NULL;
+ }
+
+ soap_env = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+
+ if(!soap_env)
+ {
+ soap_env_exists = AXIS2_FALSE;
+ soap_env = axiom_soap_envelope_create_default_soap_envelope(env, AXIOM_SOAP11);
+ }
+ if(soap_env)
+ {
+ soap_body = axiom_soap_envelope_get_body(soap_env, env);
+ }
+ if(!soap_body)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, AXIS2_FAILURE);
+
+ if(param_keys)
+ {
+ for(i = 0; i < axutil_array_list_size(param_keys, env); i++)
+ {
+ void *value = axutil_array_list_get(param_keys, env, i);
+ AXIS2_FREE(env->allocator, value);
+ }
+ axutil_array_list_free(param_keys, env);
+ }
+ if(param_values)
+ {
+ for(i = 0; i < axutil_array_list_size(param_values, env); i++)
+ {
+ void *value = axutil_array_list_get(param_values, env, i);
+ AXIS2_FREE(env->allocator, value);
+ }
+ axutil_array_list_free(param_values, env);
+ }
+ return NULL;
+ }
+
+ body_element_node = axiom_soap_body_get_base_node(soap_body, env);
+
+ if(body_element_node)
+ {
+ body_child_node = axiom_node_get_first_child(body_element_node, env);
+ }
+
+ if(!body_child_node)
+ {
+ body_child = axiom_element_create_with_qname(env, NULL, axis2_op_get_qname(op, env),
+ &body_child_node);
+ axiom_soap_body_add_child(soap_body, env, body_child_node);
+ }
+
+ if(param_keys && param_values)
+ {
+ for(i = 0; i < axutil_array_list_size(param_keys, env); i++)
+ {
+ axis2_char_t *param_key = NULL;
+ axis2_char_t *param_value = NULL;
+
+ axiom_node_t *node = NULL;
+ axiom_element_t *element = NULL;
+
+ param_key = axutil_array_list_get(param_keys, env, i);
+ param_value = axutil_array_list_get(param_values, env, i);
+
+ element = axiom_element_create(env, NULL, param_key, NULL, &node);
+ axiom_element_set_text(element, env, param_value, node);
+ axiom_node_add_child(body_child_node, env, node);
+
+ AXIS2_FREE(env->allocator, param_key);
+ AXIS2_FREE(env->allocator, param_value);
+ }
+
+ axutil_array_list_free(param_keys, env);
+ axutil_array_list_free(param_values, env);
+ }
+
+ if(!soap_env_exists)
+ {
+ axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_env);
+ }
+
+ return op;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_rest_disp_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx)
+{
+ axis2_msg_ctx_set_find_svc(msg_ctx, env, axis2_rest_disp_find_svc);
+ axis2_msg_ctx_set_find_op(msg_ctx, env, axis2_rest_disp_find_op);
+ return axis2_disp_find_svc_and_op(handler, env, msg_ctx);
+}
+
diff --git a/src/core/engine/soap_action_disp.c b/src/core/engine/soap_action_disp.c
new file mode 100644
index 0000000..10d6fa4
--- /dev/null
+++ b/src/core/engine/soap_action_disp.c
@@ -0,0 +1,155 @@
+/*
+ * 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_disp.h>
+#include <axis2_handler_desc.h>
+#include <axutil_string.h>
+#include <axis2_relates_to.h>
+#include <axis2_svc.h>
+#include <axis2_const.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_addr.h>
+#include <axutil_utils.h>
+
+const axis2_char_t *AXIS2_SOAP_ACTION_DISP_NAME = "soap_action_based_dispatcher";
+
+axis2_status_t AXIS2_CALL
+axis2_soap_action_disp_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx *msg_ctx);
+
+axis2_svc_t *AXIS2_CALL axis2_soap_action_disp_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env);
+
+axis2_op_t *AXIS2_CALL axis2_soap_action_disp_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc);
+
+axis2_disp_t *AXIS2_CALL
+axis2_soap_action_disp_create(
+ const axutil_env_t * env)
+{
+ axis2_disp_t *disp = NULL;
+ axis2_handler_t *handler = NULL;
+ axutil_string_t *name = NULL;
+
+ name = axutil_string_create_const(env, (axis2_char_t **)&AXIS2_SOAP_ACTION_DISP_NAME);
+
+ disp = axis2_disp_create(env, name);
+ if(!disp)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ handler = axis2_disp_get_base(disp, env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ axis2_handler_set_invoke(handler, env, axis2_soap_action_disp_invoke);
+
+ axutil_string_free(name, env);
+
+ return disp;
+}
+
+axis2_svc_t *AXIS2_CALL
+axis2_soap_action_disp_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ return NULL;
+
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Checking for service using SOAPAction is not implemented");
+ return NULL;
+}
+
+axis2_op_t *AXIS2_CALL
+axis2_soap_action_disp_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc)
+{
+ const axis2_char_t *action = NULL;
+ axutil_qname_t *name = NULL;
+ axis2_op_t *op = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, svc, NULL);
+
+ if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ return NULL;
+
+ action = axutil_string_get_buffer(axis2_msg_ctx_get_soap_action(msg_ctx, env), env);
+
+ if(action)
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Checking for operation using SOAPAction : %s",
+ action);
+
+ if(!op)
+ {
+ const axis2_char_t *op_name = NULL;
+ op_name = axutil_rindex(action, '/');
+
+ if(op_name)
+ {
+ op_name += 1;
+ }
+ else
+ {
+ op_name = action;
+ }
+
+ if(op_name)
+ {
+ op = axis2_svc_get_op_with_name(svc, env, op_name);
+ }
+ }
+
+ if(!op)
+ {
+ name = axutil_qname_create(env, action, NULL, NULL);
+ op = axis2_svc_get_op_with_qname(svc, env, name);
+ axutil_qname_free(name, env);
+ }
+
+ if(op)
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Operation found using SOAPAction");
+ }
+ return op;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_soap_action_disp_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx)
+{
+ axis2_msg_ctx_set_find_svc(msg_ctx, env, axis2_soap_action_disp_find_svc);
+ axis2_msg_ctx_set_find_op(msg_ctx, env, axis2_soap_action_disp_find_op);
+
+ return axis2_disp_find_svc_and_op(handler, env, msg_ctx);
+}
+
diff --git a/src/core/engine/soap_body_disp.c b/src/core/engine/soap_body_disp.c
new file mode 100644
index 0000000..702a988
--- /dev/null
+++ b/src/core/engine/soap_body_disp.c
@@ -0,0 +1,231 @@
+/*
+ * 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_disp.h>
+#include <axis2_handler_desc.h>
+#include <axutil_string.h>
+#include <axis2_svc.h>
+#include <axis2_const.h>
+#include <axis2_conf_ctx.h>
+#include <axutil_utils.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_body.h>
+
+const axis2_char_t *AXIS2_SOAP_MESSAGE_BODY_DISP_NAME = "soap_message_body_based_dispatcher";
+
+axis2_status_t AXIS2_CALL
+axis2_soap_body_disp_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx *msg_ctx);
+
+axis2_svc_t *AXIS2_CALL axis2_soap_body_disp_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env);
+
+axis2_op_t *AXIS2_CALL axis2_soap_body_disp_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc);
+
+axis2_disp_t *AXIS2_CALL
+axis2_soap_body_disp_create(
+ const axutil_env_t * env)
+{
+ axis2_disp_t *disp = NULL;
+ axis2_handler_t *handler = NULL;
+ axutil_string_t *name = NULL;
+
+ name = axutil_string_create_const(env, (axis2_char_t **)&AXIS2_SOAP_MESSAGE_BODY_DISP_NAME);
+
+ disp = axis2_disp_create(env, name);
+ if(!disp)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ handler = axis2_disp_get_base(disp, env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_HANDLER_STATE, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ axis2_handler_set_invoke(handler, env, axis2_soap_body_disp_invoke);
+
+ axutil_string_free(name, env);
+
+ return disp;
+}
+
+axis2_svc_t *AXIS2_CALL
+axis2_soap_body_disp_find_svc(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env)
+{
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axis2_svc_t *svc = NULL;
+
+ if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ return NULL;
+
+ soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+ if(soap_envelope)
+ {
+ axiom_soap_body_t *soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
+ if(soap_body)
+ {
+ axiom_node_t *body_node = axiom_soap_body_get_base_node(soap_body, env);
+ if(body_node)
+ {
+ axiom_node_t *body_first_child_node = axiom_node_get_first_element(body_node, env);
+
+ if(body_first_child_node)
+ {
+ if(axiom_node_get_node_type(body_first_child_node, env) == AXIOM_ELEMENT)
+ {
+ axiom_element_t *element = NULL;
+ element = (axiom_element_t *)axiom_node_get_data_element(
+ body_first_child_node, env);
+ if(element)
+ {
+ axiom_namespace_t *ns = axiom_element_get_namespace(element, env,
+ body_first_child_node);
+ if(ns)
+ {
+ axis2_char_t *uri = axiom_namespace_get_uri(ns, env);
+ if(uri)
+ {
+ axis2_char_t **url_tokens = NULL;
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Checking for service "
+ "using SOAP message body's "
+ "first child's namespace "
+ "URI : %s", uri);
+
+ url_tokens = axutil_parse_request_url_for_svc_and_op(env, uri);
+
+ if(url_tokens)
+ {
+ if(url_tokens[0])
+ {
+ axis2_conf_ctx_t *conf_ctx = NULL;
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ axis2_conf_t *conf = NULL;
+ conf = axis2_conf_ctx_get_conf(conf_ctx, env);
+ if(conf)
+ {
+ svc = axis2_conf_get_svc(conf, env,
+ url_tokens[0]);
+ if(svc)
+ AXIS2_LOG_DEBUG(env-> log, AXIS2_LOG_SI,
+ "Service found "
+ "using SOAP message"
+ "body's first "
+ "child's namespace URI");
+ }
+ }
+ AXIS2_FREE(env->allocator, url_tokens[0]);
+ }
+
+ AXIS2_FREE(env->allocator, url_tokens);
+ url_tokens = NULL;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return svc;
+}
+
+axis2_op_t *AXIS2_CALL
+axis2_soap_body_disp_find_op(
+ axis2_msg_ctx_t * msg_ctx,
+ const axutil_env_t * env,
+ axis2_svc_t * svc)
+{
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axis2_op_t *op = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, svc, NULL);
+
+ if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ return NULL;
+
+ soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+ if(soap_envelope)
+ {
+ axiom_soap_body_t *soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
+ if(soap_body)
+ {
+ axiom_node_t *body_node = axiom_soap_body_get_base_node(soap_body, env);
+ if(body_node)
+ {
+ axiom_node_t *body_first_child_node = axiom_node_get_first_element(body_node, env);
+
+ if(body_first_child_node)
+ {
+ if(axiom_node_get_node_type(body_first_child_node, env) == AXIOM_ELEMENT)
+ {
+ axiom_element_t *element = NULL;
+ element = (axiom_element_t *)axiom_node_get_data_element(
+ body_first_child_node, env);
+ if(element)
+ {
+ axis2_char_t *element_name = axiom_element_get_localname(element, env);
+ if(element_name)
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Checking for operation using SOAP message"
+ "body's first child's local name : %s", element_name);
+
+ op = axis2_svc_get_op_with_name(svc, env, element_name);
+
+ if(op)
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
+ "Operation found using SOAP message "
+ "body's first child's local name");
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return op;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_soap_body_disp_invoke(
+ axis2_handler_t * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx)
+{
+ axis2_msg_ctx_set_find_svc(msg_ctx, env, axis2_soap_body_disp_find_svc);
+ axis2_msg_ctx_set_find_op(msg_ctx, env, axis2_soap_body_disp_find_op);
+ return axis2_disp_find_svc_and_op(handler, env, msg_ctx);
+}
+