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 da...@apache.org on 2007/06/11 07:34:45 UTC

svn commit: r546019 - in /webservices/axis2/trunk/c: include/axis2_conf.h src/core/deployment/conf_init.c src/core/engine/conf.c

Author: damitha
Date: Sun Jun 10 22:34:45 2007
New Revision: 546019

URL: http://svn.apache.org/viewvc?view=rev&rev=546019
Log:
I have implemented the functionlity for initiliasing services at the
load time of the axis2c engine.

Modified:
    webservices/axis2/trunk/c/include/axis2_conf.h
    webservices/axis2/trunk/c/src/core/deployment/conf_init.c
    webservices/axis2/trunk/c/src/core/engine/conf.c

Modified: webservices/axis2/trunk/c/include/axis2_conf.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_conf.h?view=diff&rev=546019&r1=546018&r2=546019
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_conf.h (original)
+++ webservices/axis2/trunk/c/include/axis2_conf.h Sun Jun 10 22:34:45 2007
@@ -382,6 +382,19 @@
     axis2_conf_get_all_svcs(const axis2_conf_t *conf,
         const axutil_env_t *env);
 
+    /**        
+     * Gets all the list of services that need to be loaded into configuration
+     * at the start up of the axis2 engine.
+     * @param conf pointer to conf struct
+     * @param env pointer to environment struct
+     * @return a pointer to the hash table of services. Returns a 
+     * reference, not a cloned copy
+     */
+    AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+    axis2_conf_get_all_init_svcs(
+        const axis2_conf_t *conf,
+        const axutil_env_t *env);
+
     /**
      * Checks is the named module is engaged.
      * @param conf pointer to conf struct

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?view=diff&rev=546019&r1=546018&r2=546019
==============================================================================
--- webservices/axis2/trunk/c/src/core/deployment/conf_init.c (original)
+++ webservices/axis2/trunk/c/src/core/deployment/conf_init.c Sun Jun 10 22:34:45 2007
@@ -21,6 +21,7 @@
 #include <axis2_const.h>
 #include <axutil_error.h>
 #include <axutil_allocator.h>
+#include <axutil_class_loader.h>
 #include <axis2_dep_engine.h>
 #include <axis2_module.h>
 
@@ -28,6 +29,11 @@
 axis2_init_modules(const axutil_env_t *env,
     axis2_conf_ctx_t *conf_ctx);
 
+static axis2_status_t AXIS2_CALL
+axis2_init_services(
+    const axutil_env_t *env,
+    axis2_conf_ctx_t *conf_ctx);
+
 axis2_status_t AXIS2_CALL
 axis2_init_transports(const axutil_env_t *env,
     axis2_conf_ctx_t *conf_ctx);
@@ -67,6 +73,7 @@
     axis2_phase_resolver_build_chains(phase_resolver, env);
 
     axis2_init_modules(env, conf_ctx);
+    axis2_init_services(env, conf_ctx);
     axis2_init_transports(env, conf_ctx);
 
     axis2_phase_resolver_free(phase_resolver, env);
@@ -113,6 +120,7 @@
     axis2_phase_resolver_build_chains(phase_resolver, env);
 
     axis2_init_modules(env, conf_ctx);
+    axis2_init_services(env, conf_ctx);
     axis2_init_transports(env, conf_ctx);
 
     axis2_phase_resolver_free(phase_resolver, env);
@@ -152,6 +160,60 @@
                         {
                             AXIS2_MODULE_INIT(mod, env, conf_ctx, mod_desc);
                         }
+                    }
+                }
+            }
+        }
+        status = AXIS2_SUCCESS;
+    }
+
+    return status;
+}
+
+static axis2_status_t AXIS2_CALL
+axis2_init_services(
+    const axutil_env_t *env,
+    axis2_conf_ctx_t *conf_ctx)
+{
+    axis2_conf_t *conf = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
+
+    conf =  axis2_conf_ctx_get_conf(conf_ctx, env);
+    if (conf)
+    {
+        axutil_hash_t *svc_map =  axis2_conf_get_all_init_svcs(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_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;
+                        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);
+                            return AXIS2_FAILURE;
+                        }
+                        axutil_allocator_switch_to_global_pool(env->allocator);
+                        axutil_class_loader_init(env);
+                        impl_class = axutil_class_loader_create_dll(env, impl_info_param);
+                        axis2_svc_set_impl_class(svc_desc, env, impl_class);
+                        AXIS2_SVC_SKELETON_INIT((axis2_svc_skeleton_t *)impl_class, env);
+                        axutil_allocator_switch_to_local_pool(env->allocator);
                     }
                 }
             }

Modified: webservices/axis2/trunk/c/src/core/engine/conf.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/engine/conf.c?view=diff&rev=546019&r1=546018&r2=546019
==============================================================================
--- webservices/axis2/trunk/c/src/core/engine/conf.c (original)
+++ webservices/axis2/trunk/c/src/core/engine/conf.c Sun Jun 10 22:34:45 2007
@@ -44,6 +44,7 @@
     axutil_array_list_t *in_phases_upto_and_including_post_dispatch;
     axis2_phases_info_t *phases_info;
     axutil_hash_t *all_svcs;
+    axutil_hash_t *all_init_svcs;
     axutil_hash_t *msg_recvs;
     axutil_hash_t *faulty_svcs;
     axutil_hash_t *faulty_modules;
@@ -91,6 +92,7 @@
     conf->out_fault_phases = NULL;
     conf->phases_info = NULL;
     conf->all_svcs = NULL;
+    conf->all_init_svcs = NULL;
     conf->msg_recvs = NULL;
     conf->faulty_svcs = NULL;
     conf->faulty_modules = NULL;
@@ -221,6 +223,14 @@
         return NULL;
     }
 
+    conf->all_init_svcs = axutil_hash_make(env);
+    if (! conf->all_init_svcs)
+    {
+        axis2_conf_free(conf, env);
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+    }
+
     conf->msg_recvs = axutil_hash_make(env);
     if (! conf->msg_recvs)
     {
@@ -432,6 +442,11 @@
     {
         axutil_hash_free(conf->all_svcs, env);
     }
+    
+    if (conf->all_init_svcs)
+    {
+        axutil_hash_free(conf->all_init_svcs, env);
+    }
 
     if (conf->msg_recvs)
     {
@@ -963,6 +978,51 @@
         index_i = axutil_hash_next(env, index_i);
     }
     return conf->all_svcs;
+}
+
+AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+axis2_conf_get_all_init_svcs(
+    const axis2_conf_t *conf,
+    const axutil_env_t *env)
+{
+    axutil_hash_t *sgs = NULL;
+    axutil_hash_index_t *index_i = NULL;
+    axutil_hash_index_t *index_j = NULL;
+    void *value = NULL;
+    void *value2 = NULL;
+    axis2_svc_grp_t *axis_svc_grp = NULL;
+    axutil_hash_t *svcs = NULL;
+    axis2_svc_t *svc = NULL;
+    axis2_char_t *svc_name = NULL;
+
+    AXIS2_ENV_CHECK(env, NULL);
+
+    sgs = axis2_conf_get_all_svc_grps(conf, env);
+    index_i = axutil_hash_first(sgs, env);
+    while (index_i)
+    {
+        axutil_hash_this(index_i, NULL, NULL, &value);
+        axis_svc_grp = (axis2_svc_grp_t *) value;
+        svcs =  axis2_svc_grp_get_all_svcs(axis_svc_grp, env);
+        index_j = axutil_hash_first(svcs, env);
+        while (index_j)
+        {
+            axutil_param_t *param = NULL;
+            axutil_hash_this(index_j, NULL, NULL, &value2);
+            svc = (axis2_svc_t *) value2;
+            svc_name = 
+                axutil_qname_get_localpart(axis2_svc_get_qname(svc, env), env);
+            param = axis2_svc_get_param(svc, env, "Axis2InitService");
+            if(param)
+                axutil_hash_set(conf->all_init_svcs, svc_name,
+                    AXIS2_HASH_KEY_STRING, svc);
+
+            index_j = axutil_hash_next(env, index_j);
+        }
+
+        index_i = axutil_hash_next(env, index_i);
+    }
+    return conf->all_init_svcs;
 }
 
 AXIS2_EXTERN axis2_bool_t AXIS2_CALL



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org