axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r368633 - in /webservices/axis2/trunk/c/modules/core/transport/http/server: ./ Makefile.am http_server.c http_server_main.c http_svr_thread.c
Date Fri, 13 Jan 2006 08:22:22 GMT
Author: samisa
Date: Fri Jan 13 00:22:16 2006
New Revision: 368633

URL: http://svn.apache.org/viewcvs?rev=368633&view=rev
Log:
Added serverside functionality

Added:
    webservices/axis2/trunk/c/modules/core/transport/http/server/
    webservices/axis2/trunk/c/modules/core/transport/http/server/Makefile.am
    webservices/axis2/trunk/c/modules/core/transport/http/server/http_server.c
    webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c
    webservices/axis2/trunk/c/modules/core/transport/http/server/http_svr_thread.c

Added: webservices/axis2/trunk/c/modules/core/transport/http/server/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/server/Makefile.am?rev=368633&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/server/Makefile.am (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/server/Makefile.am Fri Jan 13 00:22:16
2006
@@ -0,0 +1,30 @@
+prgbindir=$(prefix)/bin/
+prgbin_PROGRAMS = axis2_http_server
+SUBDIRS =
+AM_CPPFLAGS = $(CPPFLAGS) -g -pthread
+axis2_http_server_SOURCES = http_svr_thread.c\
+                            http_server.c\
+                            http_server_main.c
+
+axis2_http_server_LDADD   =  $(LDFLAGS)  -laxis2_util -laxis2_http_transport -laxis2_context
-laxis2_addr -laxis2_om -laxis2_engine -laxis2_description -laxis2_soap -laxis2_wsdl -laxis2_phaseresolver
-laxis2_deployment -laxis2_libxml2 -lxml2\
+-L$(top_builddir)/modules/util/.libs\
+-L$(top_builddir)/modules/wsdl/.libs\
+-L$(top_builddir)/modules/core/description/.libs\
+-L$(top_builddir)/modules/core/deployment/.libs\
+-L$(top_builddir)/modules/core/transport/.libs\
+-L$(top_builddir)/modules/xml/om/.libs\
+-L$(top_builddir)/modules/xml/parser/libxml2/.libs\
+-L$(top_builddir)/modules/xml/soap/.libs\
+-L$(LIBXML2_LIB) $(LIBXML2_LIBNAME) \
+-L$(GUTHTHILA_LIB) $(GUTHTHILA_LIBNAME)
+                    
+INCLUDES =  -I$(top_builddir)/include \
+            -I$(top_builddir)/modules/util\
+            -I$(top_builddir)/modules/wsdl\
+            -I$(top_builddir)/modules/core/description\
+            -I$(top_builddir)/modules/core/deployment\
+            -I$(top_builddir)/modules/core/transport\
+            -I$(top_builddir)/modules/xml/om\
+            -I$(top_builddir)/modules/xml/parser\
+            -I$(top_builddir)/modules/xml/soap\
+            -I$(top_builddir)/modules/platforms

Added: webservices/axis2/trunk/c/modules/core/transport/http/server/http_server.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/server/http_server.c?rev=368633&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/server/http_server.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/server/http_server.c Fri Jan 13
00:22:16 2006
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include <axis2_http_server.h>
+#include <axis2_http_transport.h>
+#include <axis2_http_svr_thread.h>
+#include <axis2_transport_in_desc.h>
+#include <axis2_param_container.h>
+#include <axis2_url.h>
+#include <axis2_conf_init.h>
+
+/** 
+ * @brief HTTP Client struct impl
+ *	Axis2 HTTP Client impl  
+ */
+typedef struct axis2_http_server_impl axis2_http_server_impl_t;  
+  
+struct axis2_http_server_impl
+{
+	axis2_http_server_t http_server;
+	axis2_http_svr_thread_t *svr_thread;
+	int port;
+	axis2_conf_ctx_t* conf_ctx;
+};
+
+#define AXIS2_INTF_TO_IMPL(http_server) \
+                ((axis2_http_server_impl_t *)(http_server))
+
+/***************************** Function servers *******************************/
+axis2_status_t AXIS2_CALL 
+axis2_http_server_init(axis2_http_server_t *server, axis2_env_t **env,
+						axis2_conf_ctx_t *conf_ctx, 
+						axis2_transport_in_desc_t *in_desc);
+axis2_status_t AXIS2_CALL 
+axis2_http_server_start(axis2_http_server_t *server, axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_stop(axis2_http_server_t *server, axis2_env_t **env);
+
+axis2_conf_ctx_t* AXIS2_CALL 
+axis2_http_server_get_conf_ctx (axis2_http_server_t *server, axis2_env_t **env);
+
+axis2_endpoint_ref_t* AXIS2_CALL 
+axis2_http_server_get_reply_to_epr(axis2_http_server_t *server, 
+						axis2_env_t **env, axis2_char_t *svc_name);
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_server_is_running (axis2_http_server_t *server, axis2_env_t **env);						
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_free (axis2_http_server_t *server, axis2_env_t **env);
+
+/***************************** End of function servers ************************/
+
+AXIS2_DECLARE(axis2_http_server_t *) 
+axis2_http_server_create (axis2_env_t **env, axis2_char_t *repo, int port)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+            
+    axis2_http_server_impl_t *server_impl = 
+                        (axis2_http_server_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(axis2_http_server_impl_t));
+	
+    if(NULL == 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->port = port;
+		
+    server_impl->http_server.ops = AXIS2_MALLOC((*env)->allocator,
+						sizeof(axis2_http_server_ops_t));
+    if(NULL == server_impl->http_server.ops)
+	{
+		axis2_http_server_free((axis2_http_server_t*) server_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    server_impl->conf_ctx = build_conf_ctx(env, repo);
+	if(NULL == server_impl->conf_ctx)
+	{
+		axis2_http_server_free((axis2_http_server_t*) server_impl, env);
+        return NULL;		
+	}
+    server_impl->http_server.ops->init = axis2_http_server_init;                  
     
+    server_impl->http_server.ops->start = axis2_http_server_start;
+    server_impl->http_server.ops->stop = axis2_http_server_stop;
+	server_impl->http_server.ops->get_conf_ctx = axis2_http_server_get_conf_ctx;
+	server_impl->http_server.ops->get_reply_to_epr = 
+						axis2_http_server_get_reply_to_epr;
+	server_impl->http_server.ops->is_running = 
+						axis2_http_server_is_running;
+	server_impl->http_server.ops->free = axis2_http_server_free;
+                        
+	return &(server_impl->http_server);
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_free (axis2_http_server_t *server, axis2_env_t **env)
+{
+	axis2_http_server_impl_t *server_impl = NULL;
+	AXIS2_FUNC_PARAM_CHECK(server, env, AXIS2_FAILURE);
+    server_impl = AXIS2_INTF_TO_IMPL(server);
+    if(NULL != server_impl->svr_thread)
+	{
+		AXIS2_HTTP_SVR_THREAD_DESTROY(server_impl->svr_thread, env);
+		AXIS2_HTTP_SVR_THREAD_FREE(server_impl->svr_thread, env);
+		server_impl->svr_thread = NULL;
+	}
+	if(NULL != server_impl->conf_ctx)
+	{
+		AXIS2_CONF_CTX_FREE(server_impl->conf_ctx, env);
+		server_impl->conf_ctx = NULL;
+	}
+	if(NULL != server->ops)
+	{
+        AXIS2_FREE((*env)->allocator, server->ops);
+    }
+	AXIS2_FREE((*env)->allocator, server_impl);
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_init(axis2_http_server_t *server, axis2_env_t **env,
+						axis2_conf_ctx_t *conf_ctx, 
+						axis2_transport_in_desc_t *in_desc)
+{
+    axis2_http_server_impl_t *server_impl = NULL;
+	axis2_char_t *port_str = NULL;
+	
+	AXIS2_FUNC_PARAM_CHECK(server, env, AXIS2_FAILURE);
+    server_impl = AXIS2_INTF_TO_IMPL(server);
+	
+	server_impl->conf_ctx = conf_ctx;
+	port_str = (axis2_char_t*)AXIS2_PARAM_CONTAINER_GET_PARAM(
+						in_desc->param_container, env, "port");
+	if(NULL != port_str)
+	{
+		server_impl->port = atoi(port_str);
+	}
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_start(axis2_http_server_t *server, axis2_env_t **env)
+{
+
+	axis2_http_server_impl_t *server_impl = NULL;
+	axis2_http_worker_t *worker = NULL;
+    AXIS2_FUNC_PARAM_CHECK(server, env, AXIS2_FAILURE);
+		
+	server_impl = AXIS2_INTF_TO_IMPL(server);
+	server_impl->svr_thread = axis2_http_svr_thread_create(env, 
+						server_impl->port);
+	if(NULL == server_impl->svr_thread)
+	{
+		return AXIS2_FAILURE;
+	}
+	worker = axis2_http_worker_create(env, server_impl->conf_ctx);
+	if(NULL == worker)
+	{
+		AXIS2_HTTP_SVR_THREAD_FREE(server_impl->svr_thread, env);
+		return AXIS2_FAILURE;
+	}
+	AXIS2_LOG_WRITE((*env)->log, "[Axis2]Starting HTTP server thread\n", 
+						AXIS2_LOG_INFO);
+	AXIS2_HTTP_SVR_THREAD_SET_WORKER(server_impl->svr_thread, env, worker);
+	AXIS2_HTTP_SVR_THREAD_RUN(server_impl->svr_thread, env);
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_server_stop(axis2_http_server_t *server, axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(server, env, AXIS2_FAILURE);
+	
+	AXIS2_LOG_WRITE((*env)->log, "[Axis2]Terminating HTTP server thread\n", 
+						AXIS2_LOG_INFO);
+	if(NULL != AXIS2_INTF_TO_IMPL(server)->svr_thread)
+	{
+		AXIS2_HTTP_SVR_THREAD_DESTROY(AXIS2_INTF_TO_IMPL(server)->svr_thread, 
+						env);
+	}
+	AXIS2_LOG_WRITE((*env)->log, "[Axis2]Successfully terminated  HTTP server\
+						thread\n", AXIS2_LOG_INFO);
+	return AXIS2_SUCCESS;
+}
+
+axis2_conf_ctx_t* AXIS2_CALL 
+axis2_http_server_get_conf_ctx (axis2_http_server_t *server, axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(server, env, NULL);
+	return AXIS2_INTF_TO_IMPL(server)->conf_ctx;
+}
+
+axis2_endpoint_ref_t* AXIS2_CALL 
+axis2_http_server_get_reply_to_epr(axis2_http_server_t *server, 
+						axis2_env_t **env, axis2_char_t *svc_name)
+{
+	axis2_endpoint_ref_t *epr = NULL;
+	axis2_char_t *host_address = NULL;
+	axis2_char_t *svc_path = NULL;
+	axis2_url_t *url = NULL;
+    AXIS2_FUNC_PARAM_CHECK(server, env, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, svc_name, NULL);
+	
+	host_address = "127.0.0.1"; /* TODO : get from axis2.xml */
+	svc_path = AXIS2_STRACAT("/axis2/services/", svc_name, env);
+	url = axis2_url_create(env, "http", host_address, 
+						AXIS2_INTF_TO_IMPL(server)->port, svc_path);
+	AXIS2_FREE((*env)->allocator, svc_path);
+	if(NULL == url)
+	{
+		return NULL;
+	}
+	epr = axis2_endpoint_ref_create(env, AXIS2_URL_TO_EXTERNAL_FORM(url, env));
+	AXIS2_URL_FREE(url, env);
+	return epr;
+}
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_server_is_running (axis2_http_server_t *server, axis2_env_t **env)
+{
+	axis2_http_server_impl_t *server_impl = NULL;
+    AXIS2_FUNC_PARAM_CHECK(server, env, AXIS2_FAILURE);
+    
+	server_impl = AXIS2_INTF_TO_IMPL(server);
+	if(NULL == server_impl->svr_thread)
+	{
+		return AXIS2_FALSE;
+	}
+	else
+	{
+		return AXIS2_HTTP_SVR_THREAD_IS_RUNNING(server_impl->svr_thread, env);
+	}
+	return AXIS2_FALSE;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c?rev=368633&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/server/http_server_main.c Fri Jan
13 00:22:16 2006
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include <axis2_http_server.h>
+#include <axis2_http_transport.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <axis2_error_default.h>
+#include <axis2_log_default.h>
+
+/***************************** Function servers *******************************/
+axis2_env_t* init_syetem_env(axis2_allocator_t *allocator);
+void system_exit(axis2_allocator_t *allocator, axis2_env_t *env, int status);
+/***************************** End of function servers ************************/
+axis2_env_t* init_syetem_env(axis2_allocator_t *allocator)
+{
+	axis2_error_t *error = axis2_error_create(allocator);
+	axis2_log_t *log = axis2_log_create(allocator, NULL);
+	return axis2_env_create_with_error_log(allocator, error, log);
+}
+
+void system_exit(axis2_allocator_t *allocator, axis2_env_t *env, int status)
+{
+	if(NULL != env)
+	{
+		axis2_env_free(env);
+	}
+	if(NULL != allocator)
+	{
+		free(allocator);
+	}
+	_exit(status);
+}
+
+int main(int argc, char *argv[])
+{
+	axis2_allocator_t *allocator = NULL;
+	axis2_env_t *env = NULL;
+	axis2_http_server_t *server = NULL;
+	char tmp_str[512];
+	int port = -1;
+	
+	if(argc != 3)
+	{
+		printf("%s <port> <repo location>\n", argv[0]);
+		exit(0);
+	}
+	port = atoi(argv[1]);
+	allocator = axis2_allocator_init(NULL);
+	if(NULL == allocator)
+	{
+		printf("[Axis2]Startup FAILED due to memory allocation failure\n");
+		system_exit(NULL, NULL, -1);
+	}
+	env = init_syetem_env(allocator);
+	
+	printf("[Axis2]Starting Axis2 HTTP server....\n");
+	AXIS2_LOG_WRITE(env->log, "[Axis2]Starting Axis2 HTTP server....\n", 
+						AXIS2_LOG_INFO);
+	sprintf(tmp_str, "[Axis2]Server port : %d\n", port);
+	printf(tmp_str);
+	AXIS2_LOG_WRITE(env->log, tmp_str, AXIS2_LOG_INFO);
+	sprintf(tmp_str, "[Axis2]Repo location : %s\n", argv[2]);
+	printf(tmp_str);
+	AXIS2_LOG_WRITE(env->log, tmp_str, AXIS2_LOG_INFO);
+	
+	server = axis2_http_server_create(&env, argv[2], port);
+	if(NULL == server)
+	{
+		sprintf(tmp_str, "[Axis2]Server creation failed: Error code: %d\n", 
+						env->error->error_number);
+		printf(tmp_str);
+		AXIS2_LOG_WRITE(env->log, tmp_str, AXIS2_LOG_INFO);
+		system_exit(allocator, env, -1);
+		
+	}
+	AXIS2_HTTP_SERVER_START(server, &env);
+	return 0;
+}

Added: webservices/axis2/trunk/c/modules/core/transport/http/server/http_svr_thread.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/server/http_svr_thread.c?rev=368633&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/server/http_svr_thread.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/server/http_svr_thread.c Fri Jan
13 00:22:16 2006
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
+#include <axis2_http_svr_thread.h>
+#include <axis2_http_transport.h>
+#include <axis2_string.h>
+#include <axis2_network_handler.h>
+#include <axis2_http_simple_request.h>
+#include <axis2_simple_http_svr_conn.h>
+#include <axis2_url.h>
+
+
+/** 
+ * @brief HTTP Server Thread struct impl
+ *	Axis2 HTTP Server Thread impl  
+ */
+typedef struct axis2_http_svr_thread_impl axis2_http_svr_thread_impl_t;  
+  
+struct axis2_http_svr_thread_impl
+{
+	axis2_http_svr_thread_t svr_thread;
+	int listen_socket;
+	axis2_bool_t stopped;
+	axis2_http_worker_t *worker;
+	int port;
+};
+
+#define AXIS2_INTF_TO_IMPL(http_svr_thread) \
+                ((axis2_http_svr_thread_impl_t *)(http_svr_thread))
+
+/***************************** Function svr_threads *******************************/
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_run(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env);
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_destroy(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env);
+int AXIS2_CALL 
+axis2_http_svr_thread_get_local_port
+						(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env);
+axis2_bool_t AXIS2_CALL 
+axis2_http_svr_thread_is_running(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env);
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_set_worker(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env, axis2_http_worker_t *worker);
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_free (axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env);					
+
+/***************************** End of function svr_threads ************************/
+
+axis2_http_svr_thread_t* AXIS2_CALL
+axis2_http_svr_thread_create (axis2_env_t **env, int port)
+{
+    AXIS2_ENV_CHECK(env, NULL);
+            
+    axis2_http_svr_thread_impl_t *svr_thread_impl = 
+                        (axis2_http_svr_thread_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(
+						axis2_http_svr_thread_impl_t));
+	
+    if(NULL == svr_thread_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+	svr_thread_impl->worker = NULL;
+	svr_thread_impl->listen_socket = -1;
+	svr_thread_impl->stopped = AXIS2_FALSE;
+	svr_thread_impl->port = port;
+	
+    svr_thread_impl->svr_thread.ops = AXIS2_MALLOC((*env)->allocator,
+						sizeof(axis2_http_svr_thread_ops_t));
+    if(NULL == svr_thread_impl->svr_thread.ops)
+	{
+		axis2_http_svr_thread_free((axis2_http_svr_thread_t*) svr_thread_impl, 
+						env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+    svr_thread_impl->svr_thread.ops->run = axis2_http_svr_thread_run;             
          
+    svr_thread_impl->svr_thread.ops->destroy = 
+						axis2_http_svr_thread_destroy;
+    svr_thread_impl->svr_thread.ops->get_local_port = 
+						axis2_http_svr_thread_get_local_port;
+	svr_thread_impl->svr_thread.ops->is_running = 
+						axis2_http_svr_thread_is_running;
+	svr_thread_impl->svr_thread.ops->set_worker = 
+						axis2_http_svr_thread_set_worker;
+    svr_thread_impl->svr_thread.ops->free = axis2_http_svr_thread_free;
+                        
+	return &(svr_thread_impl->svr_thread);
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_free (axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env)
+{
+	axis2_http_svr_thread_impl_t *svr_thread_impl = NULL;
+	AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_FAILURE);
+    svr_thread_impl = AXIS2_INTF_TO_IMPL(svr_thread);
+	
+    if(NULL != svr_thread_impl->worker)
+    {
+        AXIS2_URL_FREE(svr_thread_impl->worker, env);
+        svr_thread_impl->worker = NULL;
+    }
+    if(-1 != svr_thread_impl->listen_socket)
+    {
+        axis2_network_handler_close_socket(env, svr_thread_impl->listen_socket);
+        svr_thread_impl->listen_socket = -1;
+    }
+	svr_thread_impl->stopped = AXIS2_TRUE;
+    if(NULL != svr_thread->ops)
+        AXIS2_FREE((*env)->allocator, svr_thread->ops);
+    
+	AXIS2_FREE((*env)->allocator, AXIS2_INTF_TO_IMPL(svr_thread));
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_run(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env)
+{
+    axis2_http_svr_thread_impl_t *svr_thread_impl = NULL;
+	
+	AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_FAILURE);
+    svr_thread_impl = AXIS2_INTF_TO_IMPL(svr_thread);
+	
+	while(AXIS2_FALSE == svr_thread_impl->stopped)
+	{
+		int socket = -1;
+		axis2_simple_http_svr_conn_t *svr_conn = NULL;
+		axis2_http_simple_request_t *request = NULL;
+		socket = axis2_network_handler_svr_socket_accept(env, 
+						svr_thread_impl->listen_socket);
+		if(NULL == svr_thread_impl->worker)
+		{
+			continue;
+		}
+		svr_conn = axis2_simple_http_svr_conn_create(env, socket);
+		request = AXIS2_SIMPLE_HTTP_SVR_CONN_READ_REQUEST(svr_conn, env);
+		axis2_http_worker_t *tmp = NULL;
+		AXIS2_HTTP_WORKER_PROCESS_REQUEST(tmp, env, svr_conn, request);
+		/* TODO log */
+	}
+	
+    return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_destroy(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env)
+{
+	axis2_http_svr_thread_impl_t *svr_thread_impl = NULL;
+		
+    AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_CRTICAL_FAILURE);
+	
+	svr_thread_impl = AXIS2_INTF_TO_IMPL(svr_thread);
+	if(AXIS2_TRUE == svr_thread_impl->stopped)
+	{
+		return AXIS2_SUCCESS;
+	}
+	svr_thread_impl->stopped = AXIS2_TRUE;
+	/* TODO log*/
+	if(svr_thread_impl->listen_socket)
+	{
+		axis2_network_handler_close_socket(env, svr_thread_impl->listen_socket);
+		svr_thread_impl->listen_socket = -1;
+	}
+	/* TODO: stop all the chiled threads */
+	return AXIS2_SUCCESS;
+}
+
+
+int AXIS2_CALL 
+axis2_http_svr_thread_get_local_port
+						(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_CRTICAL_FAILURE);
+    return AXIS2_INTF_TO_IMPL(svr_thread)->port;
+}
+
+axis2_bool_t AXIS2_CALL 
+axis2_http_svr_thread_is_running(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_FAILURE);
+	return AXIS2_INTF_TO_IMPL(svr_thread)->port;
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_http_svr_thread_set_worker(axis2_http_svr_thread_t *svr_thread, 
+						axis2_env_t **env, axis2_http_worker_t *worker)
+{
+    AXIS2_FUNC_PARAM_CHECK(svr_thread, env, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, worker, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(svr_thread)->worker = worker;
+	return AXIS2_SUCCESS;
+}



Mime
View raw message