Beispiel #1
0
AXIS2_EXTERN axis2_callback_t *AXIS2_CALL
axis2_callback_create(
    const axutil_env_t * env)
{
    axis2_callback_t *callback = NULL;

    AXIS2_ENV_CHECK(env, NULL);

    callback = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_t));
    if (!callback)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create callback.");
        return NULL;
    }

    callback->complete = AXIS2_FALSE;
    callback->envelope = NULL;
    callback->error = AXIS2_ERROR_NONE;
    callback->data = NULL;
    callback->mutex = NULL;
    callback->on_complete = axis2_callback_on_complete;
    callback->on_error = axis2_callback_on_error;

    callback->mutex = axutil_thread_mutex_create(env->allocator,
                                                 AXIS2_THREAD_MUTEX_DEFAULT);
    return callback;
}
Beispiel #2
0
AXIS2_EXTERN axis2_transport_receiver_t *AXIS2_CALL
axis2_udp_receiver_create(
    const axutil_env_t * env,
    const axis2_char_t * repo,
    const int port,
	axis2_char_t *multicast_group)
{
	axis2_udp_receiver_impl_t *receiver = NULL;

	receiver = (axis2_udp_receiver_impl_t *) AXIS2_MALLOC(env->allocator, sizeof(axis2_udp_receiver_impl_t));
	if (!receiver)
	{
		AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
		return NULL;
	}
	receiver->is_multicast = AXIS2_FALSE;
	receiver->conf_ctx = NULL;
	receiver->conf_ctx_private = NULL;
	receiver->port = port;
	receiver->udp_receiver.ops = &udp_transport_recvr_ops;
	receiver->multicast_group = multicast_group; 
	receiver->socket = AXIS2_INVALID_SOCKET;
	receiver->send_socket = AXIS2_INVALID_SOCKET;
	receiver->owns_socket = AXIS2_TRUE;
	receiver->max_packet_size = AXIS2_UDP_PACKET_MAX_SIZE;
	if (multicast_group)
	{
		receiver->is_multicast = AXIS2_TRUE;
	}
	receiver->mutex = axutil_thread_mutex_create(env->allocator,
                                                 AXIS2_THREAD_MUTEX_DEFAULT);
	/* 
	 * We are creating the receiver in two instances. When we create the receiver from the server 
	 * we create the conf context. If we are creating the receiver while creating the conf we are 
	 * not creating the conf as conf is already there.
	 */
	if (repo)
	{
		receiver->conf_ctx_private = axis2_build_conf_ctx(env, repo);
		if (!receiver->conf_ctx_private)
		{
			AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, 
                             "unable to create private configuration context for repo path %s", repo);
            axis2_udp_receiver_free((axis2_transport_receiver_t *) receiver,
                                   env);
            return NULL;
		}
		receiver->conf_ctx = receiver->conf_ctx_private;
	}
	axutil_thread_mutex_lock(receiver->mutex);
	return &(receiver->udp_receiver);
}
Beispiel #3
0
AXIS2_EXTERN service_admin_counter_t* AXIS2_CALL
service_admin_counter_create(
    const axutil_env_t *env,
    const axis2_char_t *svc_name,
    const axis2_char_t *op_name)
{
    service_admin_counter_t *counter = NULL;
    
    counter =  (service_admin_counter_t *)AXIS2_MALLOC(env->allocator, 
            sizeof(service_admin_counter_t));
	
    if(!counter)
	{
		AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        return NULL;
	}
    counter->count = 0;
    counter->last_counts = axutil_hash_make(env);
    if(!counter->last_counts)
    {
        service_admin_counter_free(counter, env);
    }
    counter->mutex = axutil_thread_mutex_create(env->allocator, AXIS2_THREAD_MUTEX_DEFAULT);

    if(!counter->mutex)
    {
        service_admin_counter_free(counter, env);
        return NULL;
    }
    if(svc_name)
    {
        counter->svc_name = axutil_strdup(env, svc_name);
    }
    if(op_name)
    {
        counter->op_name = axutil_strdup(env, op_name);
    }

	return counter;
}
Beispiel #4
0
AXIS2_EXTERN axutil_log_t *AXIS2_CALL
axutil_log_create_default(
    axutil_allocator_t *allocator)
{
    axutil_log_impl_t *log_impl;

    if (!allocator)
        return NULL;

    log_impl = (axutil_log_impl_t *) AXIS2_MALLOC(allocator,
                   sizeof(axutil_log_impl_t));

    if (!log_impl)
        return NULL;

    log_impl->mutex =
        axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT);

    if (!log_impl->mutex)
    {
        fprintf(stderr, "cannot create log mutex \n");
        return NULL;
    }

    axutil_thread_mutex_lock(log_impl->mutex);
    log_impl->file_name = NULL;
    log_impl->log.size = AXUTIL_LOG_FILE_SIZE;
    log_impl->stream = stderr;
    axutil_thread_mutex_unlock(log_impl->mutex);
    /* by default, log is enabled */
    log_impl->log.enabled = 1;
    log_impl->log.level = AXIS2_LOG_LEVEL_DEBUG;

    log_impl->log.ops = &axutil_log_ops_var;

    return &(log_impl->log);
}
Beispiel #5
0
AXIS2_EXTERN axis2_svc_t *AXIS2_CALL
axis2_svc_create(
    const axutil_env_t * env)
{
    axis2_svc_t *svc = NULL;

    svc = (axis2_svc_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_t));
    if(!svc)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
        return NULL;
    }

    svc->parent = NULL;
    svc->axis_svc_name = NULL;
    svc->filename = NULL;
    svc->svc_desc = NULL;
    svc->wsdl_path = NULL;
    svc->folder_path = NULL;
    svc->last_update = 0;
    svc->param_container = NULL;
    svc->flow_container = NULL;
    svc->op_alias_map = NULL;
    svc->op_action_map = NULL;
    svc->op_rest_map = NULL;
    svc->module_list = NULL;
    svc->ns_map = NULL;
    svc->ns_count = 0;
    svc->schema_list = NULL;
    svc->schema_mapping_table = NULL;
    svc->schema_loc_adjusted = AXIS2_FALSE;
    svc->custom_schema_name_prefix = NULL;
    svc->custom_schema_name_suffix = NULL;
    svc->schema_target_ns = NULL;
    svc->schema_target_ns_prefix = NULL;
    svc->target_ns = NULL;
    svc->target_ns_prefix = NULL;
    svc->sc_calc_count = 0;
    svc->impl_class = NULL;
    svc->qname = NULL;
    svc->style = NULL;
    svc->base = NULL;

    svc->param_container = axutil_param_container_create(env);
    if(!svc->param_container)
    {
        axis2_svc_free(svc, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service param container creation failed");
        return NULL;
    }

    svc->flow_container = axis2_flow_container_create(env);
    if(!svc->flow_container)
    {
        axis2_svc_free(svc, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service flow container creation failed");
        return NULL;
    }

    svc->op_alias_map = axutil_hash_make(env);
    if(!svc->op_alias_map)
    {
        axis2_svc_free(svc, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service operation alias map creation failed");
        return NULL;
    }

    svc->op_action_map = axutil_hash_make(env);
    if(!svc->op_action_map)
    {
        axis2_svc_free(svc, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service operation action map creation failed");
        return NULL;
    }

    svc->op_rest_map = axutil_hash_make(env);
    if(!svc->op_rest_map)
    {
        axis2_svc_free(svc, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service operation rest map creation failed");
        return NULL;
    }

    /** Create module list of default size */
    svc->module_list = axutil_array_list_create(env, 0);
    if(!svc->module_list)
    {
        axis2_svc_free(svc, env);
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service module list creation failed");
        return NULL;
    }

    svc->schema_list = axutil_array_list_create(env, AXIS2_ARRAY_LIST_DEFAULT_CAPACITY);
    if(!svc->schema_list)
    {
        axis2_svc_free(svc, env);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service schema list creation failed");
        return NULL;
    }

    svc->engaged_module_list = axutil_array_list_create(env, AXIS2_ARRAY_LIST_DEFAULT_CAPACITY);
    if(!svc->engaged_module_list)
    {
        axis2_svc_free(svc, env);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service engaged modules list creation failed");
        return NULL;
    }

    svc->schema_loc_adjusted = AXIS2_FALSE;
    if(svc->schema_target_ns_prefix)
    {
        AXIS2_FREE(env->allocator, svc->schema_target_ns_prefix);
        svc->schema_target_ns_prefix = NULL;
    }
    svc->schema_target_ns_prefix = axutil_strdup(env, "ns");

    if(svc->target_ns)
    {
        AXIS2_FREE(env->allocator, svc->target_ns);
        svc->target_ns = NULL;
    }
    svc->target_ns = axutil_strdup(env, "http://ws.apache.org/axis2");

    if(svc->target_ns_prefix)
    {
        AXIS2_FREE(env->allocator, svc->target_ns_prefix);
        svc->target_ns_prefix = NULL;
    }
    svc->target_ns_prefix = axutil_strdup(env, "tns");
    svc->sc_calc_count = 0;

    svc->base = axis2_desc_create(env);
    if(!svc->base)
    {
        axis2_svc_free(svc, env);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service base creation failed");
        return NULL;
    }
    svc->mutex = axutil_thread_mutex_create(env->allocator, AXIS2_THREAD_MUTEX_DEFAULT);
    if(!svc->mutex)
    {
        axis2_svc_free(svc, env);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service mutex creation failed");
        return NULL;
    }
    return svc;
}
Beispiel #6
0
AXIS2_EXTERN axis2_conf_ctx_t *AXIS2_CALL
axis2_conf_ctx_create(
    const axutil_env_t * env,
    axis2_conf_t * conf)
{
    axis2_conf_ctx_t *conf_ctx = NULL;

    conf_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_conf_ctx_t));
    if(!conf_ctx)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory");
        return NULL;
    }

    conf_ctx->base = NULL;
    conf_ctx->conf = NULL;
    conf_ctx->root_dir = NULL;
    conf_ctx->op_ctx_map = NULL;
    conf_ctx->svc_ctx_map = NULL;
    conf_ctx->svc_grp_ctx_map = NULL;
    conf_ctx->mutex = axutil_thread_mutex_create(env->allocator, AXIS2_THREAD_MUTEX_DEFAULT);
    if(!conf_ctx->mutex)
    {
        axis2_conf_ctx_free(conf_ctx, env);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not create thread mutex");
        return NULL;
    }

    if(conf)
        conf_ctx->conf = conf;

    conf_ctx->base = axis2_ctx_create(env);
    if(!(conf_ctx->base))
    {
        axis2_conf_ctx_free(conf_ctx, env);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not create base context");
        return NULL;
    }

    conf_ctx->op_ctx_map = axutil_hash_make(env);
    if(!(conf_ctx->op_ctx_map))
    {
        axis2_conf_ctx_free(conf_ctx, env);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not create operation context map");
        return NULL;
    }

    conf_ctx->svc_ctx_map = axutil_hash_make(env);
    if(!(conf_ctx->svc_ctx_map))
    {
        axis2_conf_ctx_free(conf_ctx, env);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not create service context map");
        return NULL;
    }

    conf_ctx->svc_grp_ctx_map = axutil_hash_make(env);
    if(!(conf_ctx->svc_grp_ctx_map))
    {
        axis2_conf_ctx_free(conf_ctx, env);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Could not create service group context map");
        return NULL;
    }

    return conf_ctx;
}
Beispiel #7
0
AXIS2_EXTERN axutil_log_t *AXIS2_CALL
axutil_log_create(
    axutil_allocator_t *allocator,
    axutil_log_ops_t *ops,
    const axis2_char_t *stream_name)
{
    axutil_log_impl_t *log_impl;
    axis2_char_t *path_home;
    axis2_char_t log_file_name[AXUTIL_LOG_FILE_NAME_SIZE];
    axis2_char_t log_dir[AXUTIL_LOG_FILE_NAME_SIZE];
    axis2_char_t tmp_filename[AXUTIL_LOG_FILE_NAME_SIZE];

    if (!allocator)
        return NULL;

    log_impl = (axutil_log_impl_t *) AXIS2_MALLOC(allocator,
                   sizeof(axutil_log_impl_t));

    if (!log_impl)
        return NULL;

    log_impl->mutex =
        axutil_thread_mutex_create(allocator, AXIS2_THREAD_MUTEX_DEFAULT);

    if (!log_impl->mutex)
    {
        fprintf(stderr, "cannot create log mutex \n");
        return NULL;
    }

#ifndef WIN32
    signal(SIGXFSZ, SIG_IGN);
#endif

    /* default log file is axis2.log */
    if (stream_name)
        AXIS2_SNPRINTF(tmp_filename, AXUTIL_LOG_FILE_NAME_SIZE, "%s", stream_name);
    else
        AXIS2_SNPRINTF(tmp_filename, AXUTIL_LOG_FILE_NAME_SIZE, "%s", "axis2.log");

    /* we write all logs to AXIS2C_HOME/logs if it is set otherwise
     * to the working dir
     */
    if (stream_name && !(axutil_rindex(stream_name, AXIS2_PATH_SEP_CHAR)))
    {
        path_home = AXIS2_GETENV("AXIS2C_HOME");
        if (path_home)
        {
            AXIS2_SNPRINTF(log_dir, AXUTIL_LOG_FILE_NAME_SIZE, "%s%c%s", 
                path_home, AXIS2_PATH_SEP_CHAR, "logs");
            if (AXIS2_SUCCESS ==
                axutil_file_handler_access(log_dir, AXIS2_F_OK))
            {
                AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, 
                    "%s%c%s", log_dir, AXIS2_PATH_SEP_CHAR, tmp_filename);
            }
            else
            {
                fprintf(stderr, "log folder %s does not exist - log file %s "\
                    "is written to . dir\n", log_dir, tmp_filename);
                AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", 
                    tmp_filename);
            }
        }
        else
        {
            fprintf(stderr,
                "AXIS2C_HOME is not set - log is written to . dir\n");
            AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", 
                tmp_filename);
        }
    }
    else
    {
        AXIS2_SNPRINTF(log_file_name, AXUTIL_LOG_FILE_NAME_SIZE, "%s", 
            tmp_filename);
    }
    log_impl->file_name = AXIS2_MALLOC(allocator, AXUTIL_LOG_FILE_NAME_SIZE);
    log_impl->log.size = AXUTIL_LOG_FILE_SIZE;
    sprintf(log_impl->file_name, "%s", log_file_name);

    axutil_thread_mutex_lock(log_impl->mutex);

    log_impl->stream = axutil_file_handler_open(log_file_name, "a+");
    axutil_log_impl_rotate((axutil_log_t *) log_impl);

    axutil_thread_mutex_unlock(log_impl->mutex);

    if (!log_impl->stream)
        log_impl->stream = stderr;

    /* by default, log is enabled */
    log_impl->log.enabled = 1;
    log_impl->log.level = AXIS2_LOG_LEVEL_DEBUG;

    if (ops)
    {
        log_impl->log.ops = ops;
    }
    else
    {
        log_impl->log.ops = &axutil_log_ops_var;
    }

    return &(log_impl->log);
}