You are viewing a plain text version of this content. The canonical link for it is here.
Posted to savan-dev@ws.apache.org by da...@apache.org on 2009/03/18 10:14:33 UTC

svn commit: r755520 - in /webservices/savan/trunk/c/samples: client/subscriber/subscriber.c server/weather/services.xml server/weather/weather.c server/weather/weather.h server/weather/weather_skeleton.c

Author: damitha
Date: Wed Mar 18 09:14:32 2009
New Revision: 755520

URL: http://svn.apache.org/viewvc?rev=755520&view=rev
Log:
Updated the samples

Modified:
    webservices/savan/trunk/c/samples/client/subscriber/subscriber.c
    webservices/savan/trunk/c/samples/server/weather/services.xml
    webservices/savan/trunk/c/samples/server/weather/weather.c
    webservices/savan/trunk/c/samples/server/weather/weather.h
    webservices/savan/trunk/c/samples/server/weather/weather_skeleton.c

Modified: webservices/savan/trunk/c/samples/client/subscriber/subscriber.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/samples/client/subscriber/subscriber.c?rev=755520&r1=755519&r2=755520&view=diff
==============================================================================
--- webservices/savan/trunk/c/samples/client/subscriber/subscriber.c (original)
+++ webservices/savan/trunk/c/samples/client/subscriber/subscriber.c Wed Mar 18 09:14:32 2009
@@ -121,9 +121,8 @@
                 "2 renew\n"\
                 "3 get status\n"\
                 "4 unsubscribe\n"\
-                "5 start weather event source\n"\
-                "6 stop weather event source\n"\
-                "7 quit\n\n");
+                "5 Generate event from weather event source\n"\
+                "6 quit\n\n");
 
         scanf("%d", &action);
 
@@ -191,20 +190,11 @@
         else if(5 == action)
         {
             axis2_options_set_action(options, env,
-                "http://ws.apache.org/axis2/c/savan/samples/weather/start");
+                "http://ws.apache.org/axis2/c/savan/samples/weather/send");
             endpoint_ref = axis2_options_get_to(options, env);
             axis2_endpoint_ref_set_address(endpoint_ref, env, address);
             axis2_svc_client_remove_all_headers(svc_client, env);
-            event_source_handle_lifecycle((axutil_env_t*)env, svc_client, address, "start");
-        }
-        else if(6 == action)
-        {
-            axis2_options_set_action(options, env,
-                "http://ws.apache.org/axis2/c/savan/samples/weather/stop");
-            endpoint_ref = axis2_options_get_to(options, env);
-            axis2_endpoint_ref_set_address(endpoint_ref, env, address);
-            axis2_svc_client_remove_all_headers(svc_client, env);
-            event_source_handle_lifecycle((axutil_env_t*)env, svc_client, address, "stop");
+            event_source_handle_lifecycle((axutil_env_t*)env, svc_client, address, "send");
         }
         else if(7 == action)
         {

Modified: webservices/savan/trunk/c/samples/server/weather/services.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/samples/server/weather/services.xml?rev=755520&r1=755519&r2=755520&view=diff
==============================================================================
--- webservices/savan/trunk/c/samples/server/weather/services.xml (original)
+++ webservices/savan/trunk/c/samples/server/weather/services.xml Wed Mar 18 09:14:32 2009
@@ -7,10 +7,7 @@
    <module ref="savan"/>
    <parameter name="TopicURL" locked="xsd:false">http://localhost:9090/axis2/services/weather</parameter>
 
-   <operation name="start">
-           <parameter name="wsamapping" >http://ws.apache.org/axis2/c/savan/samples/weather/start</parameter>
-   </operation>
-   <operation name="stop">
-           <parameter name="wsamapping" >http://ws.apache.org/axis2/c/savan/samples/weather/stop</parameter>
+   <operation name="send">
+           <parameter name="wsamapping" >http://ws.apache.org/axis2/c/savan/samples/weather/send</parameter>
    </operation>
 </service>

Modified: webservices/savan/trunk/c/samples/server/weather/weather.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/samples/server/weather/weather.c?rev=755520&r1=755519&r2=755520&view=diff
==============================================================================
--- webservices/savan/trunk/c/samples/server/weather/weather.c (original)
+++ webservices/savan/trunk/c/samples/server/weather/weather.c Wed Mar 18 09:14:32 2009
@@ -26,30 +26,17 @@
         axis2_char_t *text);
 
 axiom_node_t *
-axis2_weather_start(
+axis2_weather_send(
         const axutil_env_t *env, 
         axiom_node_t *node)
 {
 	axiom_node_t *ret_node = NULL;
 
-    ret_node = build_om_programatically(env, "Weather event source started successfully");
+    ret_node = build_om_programatically(env, "Weather event source generated event successfully");
 
     return ret_node;
 }
 
-axiom_node_t *
-axis2_weather_stop(
-        const axutil_env_t *env, 
-        axiom_node_t *node)
-{
-	axiom_node_t *ret_node = NULL;
-
-    ret_node = build_om_programatically(env, "Weather event source stopped successfully");
-
-    return ret_node;
-}
-
-
 /* Builds the response content */
 axiom_node_t *
 build_om_programatically(

Modified: webservices/savan/trunk/c/samples/server/weather/weather.h
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/samples/server/weather/weather.h?rev=755520&r1=755519&r2=755520&view=diff
==============================================================================
--- webservices/savan/trunk/c/samples/server/weather/weather.h (original)
+++ webservices/savan/trunk/c/samples/server/weather/weather.h Wed Mar 18 09:14:32 2009
@@ -20,12 +20,7 @@
 #include <axiom_node.h>
 
 axiom_node_t *
-axis2_weather_start(
-        const axutil_env_t *env, 
-        axiom_node_t *node);
-
-axiom_node_t *
-axis2_weather_stop(
+axis2_weather_send(
         const axutil_env_t *env, 
         axiom_node_t *node);
 

Modified: webservices/savan/trunk/c/samples/server/weather/weather_skeleton.c
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/c/samples/server/weather/weather_skeleton.c?rev=755520&r1=755519&r2=755520&view=diff
==============================================================================
--- webservices/savan/trunk/c/samples/server/weather/weather_skeleton.c (original)
+++ webservices/savan/trunk/c/samples/server/weather/weather_skeleton.c Wed Mar 18 09:14:32 2009
@@ -53,12 +53,7 @@
           const axutil_env_t *env);
 
 static void
-start_weather_thread(
-    const axutil_env_t *env,
-    axis2_conf_t *conf);
-
-static void
-stop_weather_thread(
+send_weather_event(
     const axutil_env_t *env,
     axis2_conf_t *conf);
 
@@ -72,11 +67,6 @@
 weather_on_fault(axis2_svc_skeleton_t *svc_skeli, 
     const axutil_env_t *env, axiom_node_t *node);
 
-static void * AXIS2_THREAD_FUNC
-weather_worker_func(
-    axutil_thread_t *thrd,
-    void* data);
-
 static const axis2_svc_skeleton_ops_t weather_skeleton_ops_var = {
     weather_init,
     weather_invoke,
@@ -116,8 +106,7 @@
      * the array list of functions 
      */
 
-    axutil_array_list_add(svc_skeleton->func_array, env, "start");
-    axutil_array_list_add(svc_skeleton->func_array, env, "stop");
+    axutil_array_list_add(svc_skeleton->func_array, env, "send");
 
     /* Any initialization stuff of service should go here */
 
@@ -131,7 +120,7 @@
     axis2_conf_t *conf)
 {
     weather_init(svc_skeleton, env);
-    /*start_weather_thread(env, conf); */
+    /*send_weather_event(env, conf); */
     return AXIS2_SUCCESS;
 }
 
@@ -168,15 +157,10 @@
                 AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "op_name:%s", op_name);
                 if (op_name)
                 {
-                    if (axutil_strcmp(op_name, "start") == 0)
-                    {
-                        start_weather_thread(env, conf); 
-                        return axis2_weather_start(env, node);
-                    }
-                    if (axutil_strcmp(op_name, "stop") == 0)
+                    if (axutil_strcmp(op_name, "send") == 0)
                     {
-                        stop_weather_thread(env, conf); 
-                        return axis2_weather_stop(env, node);
+                        send_weather_event(env, conf); 
+                        return axis2_weather_send(env, node);
                     }
                 }
             }
@@ -189,48 +173,6 @@
     return NULL;
 }
 
-static void
-start_weather_thread(
-    const axutil_env_t *env,
-    axis2_conf_t *conf)
-{
-
-	axutil_thread_t *worker_thread = NULL;
-	weather_data_t *data = NULL;
-
-    /* Invoke the business logic.
-     * Depending on the function name invoke the correct impl method.
-     */
-
-    data = AXIS2_MALLOC(env->allocator, sizeof(weather_data_t));
-    data->env = (axutil_env_t*)env;
-    data->conf = conf;
-    
-    worker_thread = axutil_thread_pool_get_thread(env->thread_pool,
-        weather_worker_func, (void*)data);
-    if(! worker_thread)
-    {
-        return;
-    }
-    axutil_thread_pool_thread_detach(env->thread_pool, worker_thread);
-}
-
-static void
-stop_weather_thread(
-    const axutil_env_t *env,
-    axis2_conf_t *conf)
-{
-    axis2_svc_t *svc = NULL;
-    axutil_param_t *param = NULL;
-    
-    svc = axis2_conf_get_svc(conf, env, WEATHER);
-    param = axis2_svc_get_param(svc, env, WEATHER_STATUS);
-    if(param)
-    {
-        axutil_param_set_value(param, env, axutil_strdup(env, AXIS2_VALUE_FALSE));
-    }
-}
-
 /* On fault, handle the fault */
 axiom_node_t* AXIS2_CALL
 weather_on_fault(axis2_svc_skeleton_t *svc_skeli, 
@@ -269,63 +211,33 @@
     return AXIS2_SUCCESS; 
 }
 
-static void * AXIS2_THREAD_FUNC
-weather_worker_func(
-    axutil_thread_t *thrd,
-    void* data)
+static void
+send_weather_event(
+    const axutil_env_t *env,
+    axis2_conf_t *conf)
 {
-    axutil_env_t *main_env = NULL;
-    axutil_env_t *env = NULL;
     axiom_namespace_t *test_ns = NULL;
     axiom_element_t* test_elem = NULL;
     axiom_node_t *test_node = NULL;
     axiom_element_t* test_elem1 = NULL;
     axiom_node_t *test_node1 = NULL;
-    axis2_conf_t *conf = NULL;
     axis2_svc_t *svc = NULL;
-    axis2_char_t *value = AXIS2_VALUE_TRUE;
-    axutil_param_t *param = NULL;
-    
-    weather_data_t *mydata = (weather_data_t*)data;
-    main_env = mydata->env;
-    conf = mydata->conf;
+    savan_publishing_client_t *pub_client = NULL;
     
-    env = axutil_init_thread_env(main_env);
-
     svc = axis2_conf_get_svc(conf, env, WEATHER);
-    param = axutil_param_create(env, WEATHER_STATUS, axutil_strdup(env, AXIS2_VALUE_TRUE));
-    if(!param)
-    {
-        AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
-    axis2_svc_add_param(svc, env, param);
-    while(!axutil_strcmp(value, AXIS2_VALUE_TRUE))
-    {
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Inside while loop");
-        {
-            savan_publishing_client_t *pub_client = NULL;
 
-            pub_client = savan_publishing_client_create(env, conf, svc);
-            /* Build a payload and pass it to the savan publishing client */ 
-            test_ns = axiom_namespace_create (env, "http://www.wso2.com/savan/c/weather", "weather");
-            test_elem = axiom_element_create(env, NULL, "weather", test_ns, &test_node);
-            test_elem1 = axiom_element_create(env, test_node, "weather_report", NULL, &test_node1);
-
-			axiom_element_set_text(test_elem1, env, "sunny day", test_node1);
-
-            savan_publishing_client_publish(pub_client, env, test_node, NULL);
-            savan_publishing_client_free(pub_client, env);
-            param = axis2_svc_get_param(svc, env, WEATHER_STATUS);
-            if(param)
-            {
-                value = axutil_param_get_value(param, env);
-                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] value:%s", value);
-            }
-        }
-        AXIS2_SLEEP(5);
-    }
-    return NULL;
+    pub_client = savan_publishing_client_create(env, conf, svc);
+    /* Build a payload and pass it to the savan publishing client */ 
+    test_ns = axiom_namespace_create (env, "http://www.wso2.com/savan/c/weather", "weather");
+    test_elem = axiom_element_create(env, NULL, "weather", test_ns, &test_node);
+    test_elem1 = axiom_element_create(env, test_node, "weather_report", NULL, &test_node1);
+
+    axiom_element_set_text(test_elem1, env, "sunny day", test_node1);
+
+    savan_publishing_client_publish(pub_client, env, test_node, NULL);
+    savan_publishing_client_free(pub_client, env);
+    
+    return;
 }
 
 /**