From 0425aadc78680e53000fd0108b540d6eca048516 Mon Sep 17 00:00:00 2001 From: gmcdonald Date: Sat, 13 Feb 2010 01:32:03 +0000 Subject: Moving axis svn, part of TLP move INFRA-2441 git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68 --- src/core/engine/disp.c | 185 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 src/core/engine/disp.c (limited to 'src/core/engine/disp.c') 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 +#include +#include +#include +#include +#include +#include + +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; +} + -- cgit v1.1-32-gdbae