Ejemplo n.º 1
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);
}
Ejemplo n.º 2
0
AXIS2_EXTERN axis2_transport_receiver_t *AXIS2_CALL
axis2_xmpp_server_create(
    const axutil_env_t *env,
    const axis2_char_t *repo,
    const int port,
    int use_sasl,
    int use_tls,
    int subscribe)
{
    axis2_xmpp_server_impl_t *impl = NULL;
    AXIS2_ENV_CHECK(env, NULL);

    impl = (axis2_xmpp_server_impl_t *)AXIS2_MALLOC
            (env->allocator, sizeof(axis2_xmpp_server_impl_t));

    if (!impl)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        return NULL;
    }

    impl->svr_thread = NULL;
    impl->conf_ctx = NULL;
    impl->conf_ctx_private = NULL;
    impl->port = port;
    impl->use_sasl = use_sasl;
    impl->use_tls = use_tls;
    impl->subscribe = subscribe;


    if (repo)
    {
        /**
         * We first create a private conf ctx which is owned by this server
         * we only free this private conf context. We should never free the
         * impl->conf_ctx because it may belong to any other object
         * which may lead to double free
         */
        impl->conf_ctx_private = axis2_build_conf_ctx(env, repo);
        if (!impl->conf_ctx_private)
        {
            axis2_xmpp_server_free((axis2_transport_receiver_t *) impl, env);
            return NULL;
        }
        impl->conf_ctx = impl->conf_ctx_private;
    }

    impl->xmpp_server.ops = &xmpp_transport_receiver_ops_var;

    return &(impl->xmpp_server);
}
Ejemplo n.º 3
0
AXIS2_EXTERN axis2_transport_receiver_t *AXIS2_CALL
axis2_tcp_server_create(
    const axutil_env_t * env,
    const axis2_char_t * repo,
    const int port)
{
    axis2_tcp_server_impl_t *server_impl = NULL;
    AXIS2_ENV_CHECK(env, NULL);

    server_impl = (axis2_tcp_server_impl_t *) AXIS2_MALLOC
        (env->allocator, sizeof(axis2_tcp_server_impl_t));

    if (!server_impl)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        return NULL;
    }

    server_impl->svr_thread = NULL;
    server_impl->conf_ctx = NULL;
    server_impl->conf_ctx_private = NULL;
    server_impl->port = port;

    server_impl->tcp_server.ops = &tcp_transport_receiver_ops_var;

    if (repo)
    {

        /**
         * We first create a private conf ctx which is owned by this server
         * we only free this private conf context. We should never free the
         * server_impl->conf_ctx because it may own to any other object which
         * may lead to double free
         */
        server_impl->conf_ctx_private = axis2_build_conf_ctx(env, repo);
        if (!server_impl->conf_ctx_private)
        {
            axis2_tcp_server_free((axis2_transport_receiver_t *) server_impl,
                                  env);
            return NULL;
        }
        server_impl->conf_ctx = server_impl->conf_ctx_private;
    }
    return &(server_impl->tcp_server);
}
Ejemplo n.º 4
0
AXIS2_EXTERN axis2_transport_receiver_t* AXIS2_CALL
axis2_amqp_receiver_create(
    const axutil_env_t* env,
    const axis2_char_t* repo,
    const axis2_char_t* qpid_broker_ip,
    int qpid_broker_port)
{
    AXIS2_ENV_CHECK(env, NULL);

    axis2_amqp_receiver_resource_pack_t* receiver_resource_pack = NULL;

    receiver_resource_pack = (axis2_amqp_receiver_resource_pack_t*)AXIS2_MALLOC(env->allocator,
        sizeof(axis2_amqp_receiver_resource_pack_t));

    if(!receiver_resource_pack)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        return NULL;
    }

    receiver_resource_pack->receiver.ops = &amqp_receiver_ops;
    receiver_resource_pack->qpid_receiver = NULL;
    receiver_resource_pack->conf_ctx = NULL;
    receiver_resource_pack->conf_ctx_private = NULL;

    if(repo)
    {
        /**
         * 1. We first create a private conf ctx which is owned by this server
         * 	  we only free this private conf context. We should never free the
         *    receiver_impl->conf_ctx because it may be owned by any other object which
         *    may lead to double free.
         *
         * 2. The Qpid broker IP and port are set in conf_ctx at two different places.
         * 	  If the repo is specified, they are set here. Otherwise, they are set
         * 	  in axis2_amqp_receiver_init method.
         */
        axutil_property_t* property = NULL;
        const axis2_char_t* broker_ip = NULL;
        int* broker_port = (int*)AXIS2_MALLOC(env->allocator, sizeof(int));
        *broker_port = AXIS2_QPID_NULL_CONF_INT;

        receiver_resource_pack->conf_ctx_private = axis2_build_conf_ctx(env, repo);
        if(!receiver_resource_pack->conf_ctx_private)
        {
            axis2_amqp_receiver_free((axis2_transport_receiver_t *)receiver_resource_pack, env);
            return NULL;
        }

        /* Set broker IP */
        broker_ip = qpid_broker_ip ? qpid_broker_ip : AXIS2_QPID_DEFAULT_BROKER_IP;
        property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
            (void*)broker_ip);
        axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx_private, env,
            AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP, property);

        /* Set broker port */
        *broker_port = (qpid_broker_port != AXIS2_QPID_NULL_CONF_INT) ? qpid_broker_port
            : AXIS2_QPID_DEFAULT_BROKER_PORT;
        property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
            (void*)broker_port);
        axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx_private, env,
            AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT, property);

        receiver_resource_pack->conf_ctx = receiver_resource_pack->conf_ctx_private;
    }

    return &(receiver_resource_pack->receiver);
}