axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nand...@apache.org
Subject svn commit: r744043 - in /webservices/axis2/trunk/c: include/axis2_msg_recv.h src/core/receivers/msg_recv.c src/core/transport/http/server/apache2/apache2_worker.c
Date Fri, 13 Feb 2009 09:05:29 GMT
Author: nandika
Date: Fri Feb 13 09:05:29 2009
New Revision: 744043

URL: http://svn.apache.org/viewvc?rev=744043&view=rev
Log:
axis2_msg_recv updated with addition of a service loading function

Modified:
    webservices/axis2/trunk/c/include/axis2_msg_recv.h
    webservices/axis2/trunk/c/src/core/receivers/msg_recv.c
    webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c

Modified: webservices/axis2/trunk/c/include/axis2_msg_recv.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_msg_recv.h?rev=744043&r1=744042&r2=744043&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_msg_recv.h (original)
+++ webservices/axis2/trunk/c/include/axis2_msg_recv.h Fri Feb 13 09:05:29 2009
@@ -49,6 +49,7 @@
 #include <axis2_msg_ctx.h>
 #include <axis2_op_ctx.h>
 #include <axis2_svr_callback.h>
+#include <axis2_svc.h>
 
     struct axis2_msg_ctx;
 
@@ -71,6 +72,12 @@
             struct axis2_msg_ctx * in_msg_ctx,
             void *callback_recv_param);
 
+	typedef axis2_status_t(
+		AXIS2_CALL * AXIS2_MSG_RECV_LOAD_AND_INIT_SVC)(
+			axis2_msg_recv_t *msg_recv,
+			const axutil_env_t *env,
+			struct axis2_svc *svc);
+
     /**
      * Deallocate memory
      * @param msg_recv pinter to message receiver
@@ -86,7 +93,7 @@
      * This method is called from axis2_engine_receive method. This method's
      * actual implementation is decided from the create method of the 
      * extended message receiver object. There depending on the synchronous or
-     * asynchronous type, receive metho is assigned with the synchronous or
+     * asynchronous type, receive method is assigned with the synchronous or
      * asynchronous implementation of receive.
      * @see raw_xml_in_out_msg_recv_create method where receive is assigned
      * to receive_sync
@@ -121,7 +128,7 @@
     /**
      * this will create a new service skeleton object
      * @param msg_recv pointer to message receiver
-     * @param env pointer to enviornment struct
+     * @param env pointer to environment struct
      * @param msg_ctx pointer to message context
      * @return service skeleton object
      */
@@ -150,7 +157,7 @@
      * Set the application scope
      * @param msg_recv pointer to message receiver
      * @param env pointer to environment struct
-     * @param scope ointer to scope
+     * @param scope pointer to scope
      * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
      */
     AXIS2_EXTERN axis2_status_t AXIS2_CALL
@@ -162,7 +169,7 @@
     /**
      * Get the application scope
      * @param msg_recv pointer to message receiver
-     * @env pointer to enviornment struct
+     * @env pointer to environment struct
      * @return scope
      */
     AXIS2_EXTERN axis2_char_t *AXIS2_CALL
@@ -207,6 +214,18 @@
         const axutil_env_t * env,
         AXIS2_MSG_RECV_RECEIVE func);
 
+	AXIS2_EXPORT axis2_status_t AXIS2_CALL
+	axis2_msg_recv_set_load_and_init_svc(
+		axis2_msg_recv_t *msg_recv,
+		const axutil_env_t *env,
+		AXIS2_MSG_RECV_LOAD_AND_INIT_SVC func);
+
+	AXIS2_EXPORT axis2_status_t AXIS2_CALL
+	axis2_msg_recv_load_and_init_svc(
+		axis2_msg_recv_t *msg_recv,
+		const axutil_env_t *env,
+		struct axis2_svc *svc);
+
     /**
      * Create new message receiver object. usually this will be called from the
      * extended message receiver object.

Modified: webservices/axis2/trunk/c/src/core/receivers/msg_recv.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/receivers/msg_recv.c?rev=744043&r1=744042&r2=744043&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/receivers/msg_recv.c (original)
+++ webservices/axis2/trunk/c/src/core/receivers/msg_recv.c Fri Feb 13 09:05:29 2009
@@ -52,7 +52,7 @@
      * This method is called from axis2_engine_receive method. This method's
      * actual implementation is decided from the create method of the 
      * extended message receiver object. There depending on the synchronous or
-     * asynchronous type, receive metho is assigned with the synchronous or
+     * asynchronous type, receive method is assigned with the synchronous or
      * asynchronous implementation of receive.
      * @see raw_xml_in_out_msg_recv_create method where receive is assigned
      * to receive_sync
@@ -67,14 +67,81 @@
     const axutil_env_t * env,
     struct axis2_msg_ctx * in_msg_ctx,
     void *callback_recv_param);
+
+	axis2_status_t(
+	AXIS2_CALL *load_and_init_svc)(
+	axis2_msg_recv_t *msg_recv,
+	const axutil_env_t *env,
+	struct axis2_svc *svc);
+
 };
 
-static axis2_status_t AXIS2_CALL axis2_msg_recv_receive_impl(
+static axis2_status_t AXIS2_CALL 
+axis2_msg_recv_receive_impl(
     axis2_msg_recv_t * msg_recv,
     const axutil_env_t * env,
     axis2_msg_ctx_t * msg_ctx,
     void *callback_recv_param);
 
+static axis2_status_t AXIS2_CALL
+axis2_msg_recv_load_and_init_svc_impl(
+	axis2_msg_recv_t *msg_recv,
+	const axutil_env_t *env,
+	struct axis2_svc *svc)
+{
+	axutil_param_t *impl_info_param = NULL;
+	void *impl_class = NULL;
+
+	AXIS2_ENV_CHECK(env, NULL);
+
+	if (!svc)
+	{
+		return AXIS2_FAILURE;
+	}
+
+	impl_class = axis2_svc_get_impl_class(svc, env);
+	if (impl_class)
+	{
+		return AXIS2_SUCCESS;
+	}
+	/* When we load the DLL we have to make sure that only one thread will load it */
+	axutil_thread_mutex_lock(axis2_svc_get_mutex(svc, env));
+	/* If more than one thread tries to acquires the lock, first thread loads the DLL. 
+	Others should not load the DLL */
+	impl_class = axis2_svc_get_impl_class(svc, env);
+	if (impl_class)
+	{
+		axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
+		return AXIS2_SUCCESS;
+	}
+	impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
+	if (!impl_info_param)
+	{
+		AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC,
+			AXIS2_FAILURE);
+		axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
+		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_LOG_DEBUG(env->log, AXIS2_LOG_SI, "loading the services from msg_recv_load_and_init_svc");
+
+	if (impl_class)
+	{
+		AXIS2_SVC_SKELETON_INIT((axis2_svc_skeleton_t *) impl_class, env);
+	}
+
+	axis2_svc_set_impl_class(svc, env, impl_class);
+
+	axutil_allocator_switch_to_local_pool(env->allocator);
+	axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
+	return AXIS2_SUCCESS;
+}
+
 AXIS2_EXPORT axis2_msg_recv_t *AXIS2_CALL
 axis2_msg_recv_create(
     const axutil_env_t * env)
@@ -94,6 +161,7 @@
 
     msg_recv->scope = axutil_strdup(env, "app*");
     msg_recv->derived = NULL;
+	msg_recv->load_and_init_svc = axis2_msg_recv_load_and_init_svc_impl;
     msg_recv->receive = axis2_msg_recv_receive_impl;
     return msg_recv;
 }
@@ -150,7 +218,7 @@
 	{
 		/* When we load the DLL we have to make sure that only one thread will load it */
 		axutil_thread_mutex_lock(axis2_svc_get_mutex(svc, env));
-		/* If more than one thread tries to acuire the lock, first thread loads the DLL. 
+		/* If more than one thread tries to acquires the lock, first thread loads the DLL. 
 		Others should not load the DLL */
 		impl_class = axis2_svc_get_impl_class(svc, env);
 		if (impl_class)
@@ -381,7 +449,7 @@
 
     /* Reset the out message context to avoid double freeing at http worker. For example
if this is
      * not done here both in and out message context will try to free the transport out stream

-     * which will result in memeory corruption.
+     * which will result in memory corruption.
      */
     if (!axis2_msg_ctx_is_paused(out_msg_ctx, env) &&
         !axis2_msg_ctx_is_keep_alive(out_msg_ctx, env))
@@ -451,3 +519,22 @@
 {
     return msg_recv->receive(msg_recv, env, msg_ctx, callback_recv_param);
 }
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_set_load_and_init_svc(
+	 axis2_msg_recv_t *msg_recv,
+	 const axutil_env_t *env,
+	 AXIS2_MSG_RECV_LOAD_AND_INIT_SVC func)
+{
+	msg_recv->load_and_init_svc = func;
+	return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_load_and_init_svc(
+	 axis2_msg_recv_t *msg_recv,
+	 const axutil_env_t *env,
+	 struct axis2_svc *svc)
+{
+	return msg_recv->load_and_init_svc(msg_recv, env, svc);
+}

Modified: webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c?rev=744043&r1=744042&r2=744043&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c Fri
Feb 13 09:05:29 2009
@@ -122,7 +122,8 @@
 			hi; hi = axutil_hash_next(env, hi))
 	{
 		void *impl_class = NULL;
-		axutil_param_t *impl_info_param = NULL;
+		axis2_msg_recv_t *msg_recv = NULL;
+		axutil_hash_t *ops_hash = NULL;
 
 		axutil_hash_this(hi, NULL, NULL, &svc);
 		if (!svc)
@@ -130,16 +131,23 @@
 		impl_class = axis2_svc_get_impl_class(svc, env);
 		if (impl_class)
 			continue;
-		impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
-		if (!impl_info_param)
-			continue;
-
-		axutil_class_loader_init(env);
-		impl_class = axutil_class_loader_create_dll(env, impl_info_param);
-		axis2_svc_set_impl_class(svc, env, impl_class);
-		if (impl_class)
+		ops_hash  = axis2_svc_get_all_ops(svc, env);
+		if(ops_hash)
 		{
-			AXIS2_SVC_SKELETON_INIT((axis2_svc_skeleton_t *) impl_class, env);
+			axutil_hash_index_t *op_hi = NULL;
+			void *op = NULL;
+			op_hi = axutil_hash_first(ops_hash, env);
+			if(op_hi)
+			{
+				axutil_hash_this(op_hi, NULL, NULL, &op);
+				if(op)
+				{
+					msg_recv = axis2_op_get_msg_recv(op,env);
+					if(msg_recv)
+						axis2_msg_recv_load_and_init_svc(msg_recv, env, svc);
+				}
+			}
+
 		}
 	}
 



Mime
View raw message