Hi all,

I have done some changes to axis2_enviroment_t. Please read and give your
comments.

Currently we are facing following problems with the environment

1. Currently some functions return axis2_status_t (status code) and some other return types. We need a conventions as to which functions return status codes and which return types
       Following convention is adapted
* Functions which are getters , creaters, makers should always return what they are supposed to give and create * All the other functions should return the status code.(AXIS2_SUCCESS or error_number other wise

2. In case of returning types we again face the problem of return NULL. Returning NULL from a function
       could happen in two instances.
           1 error situation
           2 as a flag (for example to indicate that a iteration is over)
When the person who call the application receives null he should know whether NULL indicate a flag or error.
        To facilitate that inside the function, if error situation
                env->error_number is set
               env->status_code is set to AXIS2_FAILURE
               and return NULL
         if NULL is returned as flag set env->status_code to AXIS2_SUCCESS

3. if env passed to a function is null, application does not handle it and crash.
       solution:
               We need to handle two cases.
               if function return status code then

                           return AXIS2_ERROR_ENVIRONMENT_IS_NULL;
else if function return type We make the environment as an out parameter so that if the environment received in a function is null then a default environment is created and set

                    env->error_number = AXIS2_ERROR_ENVIRONMENT_IS_NULL;
                    env->status_code = AXIS2_FAILURE
Then we return NULL from the application. Note that although we created a default environment structure it is not used to proceed the application normally. it is just used to handle the error situation (that env is null)

Then the user who call the application should handle it as following
                           axis2_env_t *env;
/* Suppose user did properly initialized env here */
                          ........................
                          .........................
                           /* But here he  mistakenly make env to n ull */
                           env = NULL;
                           /*Now he call an axis2 mock function called
                            * test_function
                            */
                           char *msg = test_function(&env);
int status = axis2_environment_check_status(env);
                           if(AXIS2_SUCCESS == status)
                                    /* Proceed normally */
                           else if(AXIS2_FAILURE == status)
char* msg = env->get_error_message(env->error_number);


 4.  Currenly environment can be created as following
        axis2_environment_create (allocator,  error, stream, log);
        if user use this as following
         axis2_environment_create (allocator, NULL, NULL, NULL);
then default error, stream and log are creatd and used through out the Axis2. This behaviour is changed now. Axis2 need allocator error and stream for its correct functionlity. but log may be null. But still Axis2 should not create the default error and stream. if allocator, stream or error is null, axis2 should
        set status_code to AXIS2_FAILURE and set some error_number.
So now user of axis2 can use two create functions
         axis2_environment_create (allocator, error, stream)
         axis2_environment_create_with_log(allocator, error, stream, log)

if log is set env->enable_log = AXIS2_TRUE is set. Axis 2 will check this
        flag when writing log.

cheers
damitha

Reply via email to