You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sh...@apache.org on 2009/09/01 13:52:02 UTC

svn commit: r809985 - in /webservices/axis2/trunk/c/src/core/deployment: conf_init.c dep_engine.c

Author: shankar
Date: Tue Sep  1 11:52:02 2009
New Revision: 809985

URL: http://svn.apache.org/viewvc?rev=809985&view=rev
Log:
code formatting + refactor 

Modified:
    webservices/axis2/trunk/c/src/core/deployment/conf_init.c
    webservices/axis2/trunk/c/src/core/deployment/dep_engine.c

Modified: webservices/axis2/trunk/c/src/core/deployment/conf_init.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/deployment/conf_init.c?rev=809985&r1=809984&r2=809985&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/deployment/conf_init.c (original)
+++ webservices/axis2/trunk/c/src/core/deployment/conf_init.c Tue Sep  1 11:52:02 2009
@@ -32,7 +32,8 @@
     const axutil_env_t * env,
     axis2_conf_ctx_t * conf_ctx);
 
-static axis2_status_t AXIS2_CALL axis2_load_services(
+static axis2_status_t AXIS2_CALL
+axis2_load_services(
     const axutil_env_t * env,
     axis2_conf_ctx_t * conf_ctx);
 
@@ -41,30 +42,21 @@
     const axutil_env_t * env,
     axis2_conf_ctx_t * conf_ctx);
 
-AXIS2_EXTERN axis2_conf_ctx_t *AXIS2_CALL
-axis2_build_conf_ctx(
+static axis2_conf_ctx_t *AXIS2_CALL
+axis2_build_conf_ctx_with_dep_engine(
     const axutil_env_t * env,
-    const axis2_char_t * repo_name)
+    axis2_dep_engine_t *dep_engine,
+    axis2_char_t *is_server_side)
 {
     axis2_conf_ctx_t *conf_ctx = NULL;
-    axis2_dep_engine_t *dep_engine = NULL;
     axis2_conf_t *conf = NULL;
     axutil_property_t *property = NULL;
     axis2_ctx_t *conf_ctx_base = NULL;
-    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_build_conf_ctx");
-    dep_engine = axis2_dep_engine_create_with_repos_name(env, repo_name);
-    if(!dep_engine)
-    {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-            "Creating deployment engine failed for repository %s", repo_name);
-        return NULL;
-    }
 
     conf = axis2_dep_engine_load(dep_engine, env);
     if(!conf)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-            "Loading deployment engine failed for repository %s.", repo_name);
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Loading deployment engine failed");
         axis2_dep_engine_free(dep_engine, env);
         return NULL;
     }
@@ -78,13 +70,45 @@
     }
 
     conf_ctx_base = axis2_conf_ctx_get_base(conf_ctx, env);
-    property = axutil_property_create_with_args(env, 2, 0, 0, AXIS2_VALUE_TRUE);
+    property = axutil_property_create_with_args(env, 2, 0, 0, is_server_side);
     axis2_ctx_set_property(conf_ctx_base, env, AXIS2_IS_SVR_SIDE, property);
 
     axis2_init_modules(env, conf_ctx);
-    axis2_load_services(env, conf_ctx);
     axis2_init_transports(env, conf_ctx);
 
+    if(!axutil_strcmp(is_server_side, AXIS2_VALUE_TRUE))
+    {
+        axis2_load_services(env, conf_ctx);
+    }
+
+    return conf_ctx;
+}
+
+AXIS2_EXTERN axis2_conf_ctx_t *AXIS2_CALL
+axis2_build_conf_ctx(
+    const axutil_env_t * env,
+    const axis2_char_t * repo_name)
+{
+    axis2_conf_ctx_t *conf_ctx = NULL;
+    axis2_dep_engine_t *dep_engine = NULL;
+
+    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_build_conf_ctx");
+    dep_engine = axis2_dep_engine_create_with_repos_name(env, repo_name);
+    if(!dep_engine)
+    {
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+            "Creating deployment engine failed for repository %s", repo_name);
+        return NULL;
+    }
+
+    conf_ctx = axis2_build_conf_ctx_with_dep_engine(env, dep_engine, AXIS2_VALUE_TRUE);
+    if(!conf_ctx)
+    {
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+            "Loading configuration context failed for repository %s.", repo_name);
+        return NULL;
+    }
+
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_build_conf_ctx");
     return conf_ctx;
 }
@@ -96,7 +120,6 @@
 {
     axis2_conf_ctx_t *conf_ctx = NULL;
     axis2_dep_engine_t *dep_engine = NULL;
-    axis2_conf_t *conf = NULL;
 
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_build_conf_ctx_with_file");
     dep_engine = axis2_dep_engine_create_with_axis2_xml(env, file);
@@ -108,30 +131,14 @@
         return NULL;
     }
 
-    conf = axis2_dep_engine_load(dep_engine, env);
-
-    if(!conf)
-    {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-            "Loading deployment engine failed for given Axis2 configuration "
-                "file(axis2.xml)");
-        axis2_dep_engine_free(dep_engine, env);
-        return NULL;
-    }
-
-    axis2_conf_set_dep_engine(conf, env, dep_engine);
-
-    conf_ctx = axis2_conf_ctx_create(env, conf);
+    conf_ctx = axis2_build_conf_ctx_with_dep_engine(env, dep_engine, AXIS2_VALUE_TRUE);
     if(!conf_ctx)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating Axis2 configuration context failed");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+            "Loading configuration context failed for given Axis2 configuration %s.", file);
         return NULL;
     }
 
-    axis2_init_modules(env, conf_ctx);
-    axis2_load_services(env, conf_ctx);
-    axis2_init_transports(env, conf_ctx);
-
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_build_conf_ctx_with_file");
     return conf_ctx;
 }
@@ -143,12 +150,8 @@
 {
     axis2_conf_ctx_t *conf_ctx = NULL;
     axis2_dep_engine_t *dep_engine = NULL;
-    axis2_conf_t *conf = NULL;
-    axutil_property_t *property = NULL;
-    axis2_ctx_t *conf_ctx_base = NULL;
 
     axis2_status_t status;
-    unsigned int len = 0;
 
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_build_client_conf_ctx");
     /* Building conf using axis2.xml, in that case we check whether
@@ -159,6 +162,8 @@
     status = axutil_file_handler_access(axis2_home, AXIS2_R_OK);
     if(status == AXIS2_SUCCESS)
     {
+        unsigned int len = 0;
+
         len = (int)strlen(axis2_home);
         /* We are sure that the difference lies within the int range */
         if((len >= 9) && !strcmp((axis2_home + (len - 9)), "axis2.xml"))
@@ -184,28 +189,14 @@
             "Creating deployment engine for client repository %s failed.", axis2_home);
         return NULL;
     }
-    conf = axis2_dep_engine_load_client(dep_engine, env, axis2_home);
-    if(!conf)
-    {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-            "Loading deployment engine failed for client repository %s", axis2_home);
-        axis2_dep_engine_free(dep_engine, env);
-        return NULL;
-    }
-    axis2_conf_set_dep_engine(conf, env, dep_engine);
 
-    conf_ctx = axis2_conf_ctx_create(env, conf);
+    conf_ctx = axis2_build_conf_ctx_with_dep_engine(env, dep_engine, AXIS2_VALUE_FALSE);
     if(!conf_ctx)
     {
-        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating Axis2 configuration context failed");
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+            "Loading configuration context failed for repository %s.", axis2_home);
         return NULL;
     }
-    conf_ctx_base = axis2_conf_ctx_get_base(conf_ctx, env);
-    property = axutil_property_create_with_args(env, 2, 0, 0, AXIS2_VALUE_FALSE);
-    axis2_ctx_set_property(conf_ctx_base, env, AXIS2_IS_SVR_SIDE, property);
-
-    axis2_init_modules(env, conf_ctx);
-    axis2_init_transports(env, conf_ctx);
 
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_build_client_conf_ctx");
     return conf_ctx;
@@ -266,70 +257,71 @@
 {
     axis2_conf_t *conf = NULL;
     axis2_status_t status = AXIS2_FAILURE;
+    axutil_hash_t *svc_map = NULL;
 
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_load_services");
     AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
 
     conf = axis2_conf_ctx_get_conf(conf_ctx, env);
-    if(conf)
+    if(!conf)
+    {
+        AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "Retrieving Axis2 configuration from Axis2 "
+            "configuration context failed, Loading services failed");
+        return status;
+    }
+
+    svc_map = axis2_conf_get_all_svcs_to_load(conf, env);
+    if(svc_map)
     {
-        axutil_hash_t *svc_map = axis2_conf_get_all_svcs_to_load(conf, env);
-        if(svc_map)
+        axutil_hash_index_t *hi = NULL;
+        void *svc = NULL;
+        for(hi = axutil_hash_first(svc_map, env); hi; hi = axutil_hash_next(env, hi))
         {
-            axutil_hash_index_t *hi = NULL;
-            void *svc = NULL;
-            for(hi = axutil_hash_first(svc_map, env); hi; hi = axutil_hash_next(env, hi))
+            axis2_svc_t *svc_desc = NULL;
+            axutil_param_t *impl_info_param = NULL;
+            void *impl_class = NULL;
+            const axis2_char_t *svc_name = NULL;
+
+            axutil_hash_this(hi, NULL, NULL, &svc);
+            if(!svc)
             {
-                axutil_hash_this(hi, NULL, NULL, &svc);
-                if(svc)
-                {
-                    axis2_svc_t *svc_desc = (axis2_svc_t *)svc;
-                    if(svc_desc)
-                    {
-                        axutil_param_t *impl_info_param = NULL;
-                        void *impl_class = NULL;
-                        const axis2_char_t *svc_name = axis2_svc_get_name(svc_desc, env);
-                        impl_info_param = axis2_svc_get_param(svc_desc, env, AXIS2_SERVICE_CLASS);
+                continue;
+            }
 
-                        if(!impl_info_param)
-                        {
-                            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC,
-                                AXIS2_FAILURE);
-                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-                                "Invalid state of the service %s", svc_name);
-                            return AXIS2_FAILURE;
-                        }
-                        axutil_class_loader_init(env);
-                        impl_class = axutil_class_loader_create_dll(env, impl_info_param);
-                        if(!impl_class)
-                        {
-                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-                                "Service %s could not be loaded", svc_name);
-                            return AXIS2_FAILURE;
-                        }
+            svc_desc = (axis2_svc_t *)svc;
+            if(!svc_desc)
+            {
+                continue;
+            }
 
-                        axis2_svc_set_impl_class(svc_desc, env, impl_class);
-                        status = AXIS2_SVC_SKELETON_INIT_WITH_CONF(
-                            (axis2_svc_skeleton_t *)impl_class, env, conf);
-                        if(!status)
-                        {
-                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
-                                "Initialization failed for the service %s. "
-                                    "Check the service's init_with_conf() "
-                                    "function for errors and retry", svc_name);
-                        }
-                    }
-                }
+            svc_name = axis2_svc_get_name(svc_desc, env);
+            impl_info_param = axis2_svc_get_param(svc_desc, env, AXIS2_SERVICE_CLASS);
+
+            if(!impl_info_param)
+            {
+                AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
+                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invalid state of the service %s", svc_name);
+                return AXIS2_FAILURE;
+            }
+            axutil_class_loader_init(env);
+            impl_class = axutil_class_loader_create_dll(env, impl_info_param);
+            if(!impl_class)
+            {
+                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service %s could not be loaded", svc_name);
+                return AXIS2_FAILURE;
+            }
+
+            axis2_svc_set_impl_class(svc_desc, env, impl_class);
+            if(AXIS2_SVC_SKELETON_INIT_WITH_CONF((axis2_svc_skeleton_t *)impl_class, env, conf)
+                != AXIS2_SUCCESS)
+            {
+                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Initialization failed for the service %s. "
+                    "Check the service's init_with_conf() function for errors and retry", svc_name);
             }
         }
-        status = AXIS2_SUCCESS;
-    }
-    else
-    {
-        AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI,
-            "Retrieving Axis2 configuration from Axis2 configuration context "
-                "failed, Loading services failed");
     }
+    status = AXIS2_SUCCESS;
+
     AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_load_services");
     return status;
 }
@@ -364,7 +356,6 @@
                     status = axis2_transport_receiver_init(listener, env, conf_ctx,
                         transport_in_map[i]);
                 }
-
             }
         }
 
@@ -380,7 +371,6 @@
                     status = AXIS2_TRANSPORT_SENDER_INIT(sender, env, conf_ctx,
                         transport_out_map[i]);
                 }
-
             }
         }
         status = AXIS2_SUCCESS;

Modified: webservices/axis2/trunk/c/src/core/deployment/dep_engine.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/deployment/dep_engine.c?rev=809985&r1=809984&r2=809985&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/deployment/dep_engine.c (original)
+++ webservices/axis2/trunk/c/src/core/deployment/dep_engine.c Tue Sep  1 11:52:02 2009
@@ -713,15 +713,12 @@
     if(!dep_engine->conf_name)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_PATH_TO_CONFIG_CAN_NOT_BE_NULL, AXIS2_FAILURE);
-
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
             "Path to axis2 configuration file is NULL. Unable to continue");
-
         return NULL;
     }
 
     dep_engine->conf = axis2_conf_create(env);
-
     if(!dep_engine->conf)
     {
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Allocation to configuration failed");
@@ -736,7 +733,6 @@
 
     dep_engine->conf_builder = axis2_conf_builder_create_with_file_and_dep_engine_and_conf(env,
         dep_engine->conf_name, dep_engine, dep_engine->conf);
-
     if(!(dep_engine->conf_builder))
     {
         axis2_conf_free(dep_engine->conf, env);
@@ -747,7 +743,6 @@
     /* Populate the axis2 configuration from reading axis2.xml.
      */
     status = axis2_conf_builder_populate_conf(dep_engine->conf_builder, env);
-
     if(AXIS2_SUCCESS != status)
     {
         axis2_conf_free(dep_engine->conf, env);
@@ -777,15 +772,12 @@
 
     dep_engine->repos_listener = axis2_repos_listener_create_with_folder_name_and_dep_engine(env,
         dep_engine->folder_name, dep_engine);
-
     if(!dep_engine->repos_listener)
     {
         axis2_conf_free(dep_engine->conf, env);
         dep_engine->conf = NULL;
-
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
             "dep_engine repos listener creation failed, folder name is %s", dep_engine->folder_name);
-
         return NULL;
     }
 
@@ -794,16 +786,13 @@
         dep_engine->conf, env), dep_engine->conf);
 
     status = axis2_dep_engine_validate_system_predefined_phases(dep_engine, env);
-
     if(AXIS2_SUCCESS != status)
     {
         axis2_repos_listener_free(dep_engine->repos_listener, env);
         axis2_conf_free(dep_engine->conf, env);
         dep_engine->conf = NULL;
-
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MODULE_VALIDATION_FAILED, AXIS2_FAILURE);
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Validating system predefined phases failed");
-
         return NULL;
     }
 
@@ -813,17 +802,15 @@
         axis2_repos_listener_free(dep_engine->repos_listener, env);
         axis2_conf_free(dep_engine->conf, env);
         dep_engine->conf = NULL;
-
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
             "Setting phases info into Axis2 Configuration failed");
-
         return NULL;
     }
 
     out_fault_phases = axis2_phases_info_get_op_out_faultphases(dep_engine->phases_info, env);
     if(out_fault_phases)
     {
-        axis2_conf_set_out_fault_phases(dep_engine->conf, env, out_fault_phases);
+        status = axis2_conf_set_out_fault_phases(dep_engine->conf, env, out_fault_phases);
     }
 
     if(AXIS2_SUCCESS != status)
@@ -831,10 +818,8 @@
         axis2_repos_listener_free(dep_engine->repos_listener, env);
         axis2_conf_free(dep_engine->conf, env);
         dep_engine->conf = NULL;
-
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
             "Setting out fault phases into Axis2 Configuratin failed");
-
         return NULL;
     }
 
@@ -844,7 +829,6 @@
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "dep engine failed to engaged_modules");
         axis2_conf_free(dep_engine->conf, env);
         dep_engine->conf = NULL;
-
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_MODULE_VALIDATION_FAILED, AXIS2_FAILURE);
         return NULL;
     }