axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manj...@apache.org
Subject svn commit: r662330 - in /webservices/axis2/branches/c/post_1_4_mtom/c/samples: ./ client/mtom/ client/mtom/resources/ mtom_caching_callback/ server/ server/mtom/
Date Mon, 02 Jun 2008 05:53:10 GMT
Author: manjula
Date: Sun Jun  1 22:53:10 2008
New Revision: 662330

URL: http://svn.apache.org/viewvc?rev=662330&view=rev
Log:
Adding a sample callabck and modifying client and server.

Added:
    webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/
    webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/Makefile.am
    webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/mtom_caching_callback.c
Modified:
    webservices/axis2/branches/c/post_1_4_mtom/c/samples/Makefile.am
    webservices/axis2/branches/c/post_1_4_mtom/c/samples/client/mtom/mtom_client.c
    webservices/axis2/branches/c/post_1_4_mtom/c/samples/client/mtom/resources/Makefile.am
    webservices/axis2/branches/c/post_1_4_mtom/c/samples/configure.ac
    webservices/axis2/branches/c/post_1_4_mtom/c/samples/server/axis2.xml
    webservices/axis2/branches/c/post_1_4_mtom/c/samples/server/mtom/mtom.c

Modified: webservices/axis2/branches/c/post_1_4_mtom/c/samples/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/samples/Makefile.am?rev=662330&r1=662329&r2=662330&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/samples/Makefile.am (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/samples/Makefile.am Sun Jun  1 22:53:10 2008
@@ -1,4 +1,4 @@
-SUBDIRS = server client user_guide
+SUBDIRS = server client user_guide mtom_caching_callback 
 
 dist-hook:
 	rm -rf `find $(distdir)/ -type d -name .svn`

Modified: webservices/axis2/branches/c/post_1_4_mtom/c/samples/client/mtom/mtom_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/samples/client/mtom/mtom_client.c?rev=662330&r1=662329&r2=662330&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/samples/client/mtom/mtom_client.c (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/samples/client/mtom/mtom_client.c Sun Jun
 1 22:53:10 2008
@@ -235,8 +235,15 @@
         data_handler = axiom_text_get_data_handler(axiom_text, env);
 
         /*axiom_data_handler_set_file_name(data_handler, env, (axis2_char_t *)to_save_name);*/
-        axiom_data_handler_set_file_name(data_handler, env, "test");
-        axiom_data_handler_write_to(data_handler, env);
+        if(axiom_data_handler_get_cached) 
+        {
+            printf("Attachmrnt is cached.\n");    
+        }   
+        else
+        {
+            axiom_data_handler_set_file_name(data_handler, env, "test");
+            axiom_data_handler_write_to(data_handler, env);
+        }
     }else if(axiom_node_get_node_type(res_om_node, env) == AXIOM_ELEMENT){
         res_om_ele = axiom_node_get_data_element(res_om_node, env);
         printf("Base64 String received \n\n\n %s \n\n", axiom_element_get_text(res_om_ele,
env, res_om_node));

Modified: webservices/axis2/branches/c/post_1_4_mtom/c/samples/client/mtom/resources/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/samples/client/mtom/resources/Makefile.am?rev=662330&r1=662329&r2=662330&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/samples/client/mtom/resources/Makefile.am
(original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/samples/client/mtom/resources/Makefile.am
Sun Jun  1 22:53:10 2008
@@ -1,4 +1,3 @@
 samplesdir=$(prefix)/bin/samples/resources
 samples_DATA=axis2.jpg 
-EXTRA_DIST=axis2.jpg
-
+EXTRA_DIST=axis2.jpg 

Modified: webservices/axis2/branches/c/post_1_4_mtom/c/samples/configure.ac
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/samples/configure.ac?rev=662330&r1=662329&r2=662330&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/samples/configure.ac (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/samples/configure.ac Sun Jun  1 22:53:10
2008
@@ -138,6 +138,7 @@
     client/yahoo/Makefile \
     user_guide/Makefile \
     user_guide/clients/Makefile \
+    mtom_caching_callback/Makefile
     ])
     
 AC_OUTPUT

Added: webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/Makefile.am?rev=662330&view=auto
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/Makefile.am
(added)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/Makefile.am
Sun Jun  1 22:53:10 2008
@@ -0,0 +1,8 @@
+prglibdir=$(prefix)/bin/mtom_caching_callabck
+prglib_LTLIBRARIES = libmtom_caching_callback.la 
+libmtom_caching_callback_la_SOURCES = 
+libmtom_caching_callback_la_LIBADD  = $(LDFLAGS) \
+						   		-L$(AXIS2C_HOME)/lib \
+								-laxutil
+
+INCLUDES = -I @AXIS2INC@

Added: webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/mtom_caching_callback.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/mtom_caching_callback.c?rev=662330&view=auto
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/mtom_caching_callback.c
(added)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/samples/mtom_caching_callback/mtom_caching_callback.c
Sun Jun  1 22:53:10 2008
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 <stdio.h>
+#include <axutil_string.h>
+#include <axutil_utils.h>
+#include <axiom_caching_callback.h>
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+caching_callback_free(axiom_caching_callback_t *caching_callback,
+								const axutil_env_t* env)
+{
+	if (caching_callback)
+	{
+		if (caching_callback->ops)
+		{
+			AXIS2_FREE(env->allocator, caching_callback->ops);
+		}
+		AXIS2_FREE(env->allocator, caching_callback);
+	}
+	return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN void* AXIS2_CALL
+caching_callback_init_handler(axiom_caching_callback_t *caching_callback, 
+                              const axutil_env_t* env)
+{
+    FILE *fp = NULL;
+    fp = fopen("/tmp/attachment", "a+");
+    return (void *)fp;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+caching_callback_cache(axiom_caching_callback_t *caching_callback, 
+            const axutil_env_t* env,
+            axis2_char_t *buf,
+            int buf_len,
+            void* handler)
+{
+    int len = 0;
+    FILE *fp = (FILE *)handler;
+
+    len = fwrite(buf, 1, buf_len, fp);
+    if(len < 0)
+    {
+        return AXIS2_FAILURE;
+    }
+    else
+    {
+        return AXIS2_SUCCESS;
+    }
+}
+
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+caching_callback_close_handler(axiom_caching_callback_t *caching_callback, 
+            const axutil_env_t* env,
+            void* handler)
+{
+    axis2_status_t status = AXIS2_FAILURE;
+
+    if(fclose((FILE *)handler) == 0)
+    {
+        status = AXIS2_SUCCESS;
+    }
+    return status;
+}
+
+
+/**
+ * Following block distinguish the exposed part of the dll.
+ */
+AXIS2_EXPORT int
+axis2_get_instance(axiom_caching_callback_t **inst,
+        const axutil_env_t *env)
+{
+    axiom_caching_callback_t* caching_callback = NULL;
+
+    caching_callback = AXIS2_MALLOC(env->allocator,
+            sizeof(axiom_caching_callback_t));
+
+    caching_callback->ops = AXIS2_MALLOC(
+                env->allocator, sizeof(axiom_caching_callback_ops_t));
+
+    /*assign function pointers*/
+
+    caching_callback->ops->init_handler = caching_callback_init_handler;
+    caching_callback->ops->cache = caching_callback_cache;
+    caching_callback->ops->close_handler = caching_callback_close_handler;
+    caching_callback->ops->free = caching_callback_free;
+
+    *inst = caching_callback;
+
+    if (!(*inst))
+    {
+        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+            "Cannot load the caching callback");
+        return AXIS2_FAILURE;
+    }
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int axis2_remove_instance(axiom_caching_callback_t *inst,
+        const axutil_env_t *env)
+{
+    axis2_status_t status = AXIS2_FAILURE;
+    if (inst)
+    {
+        status = AXIOM_CACHING_CALLBACK_FREE(inst, env);
+    }
+    return status;
+}

Modified: webservices/axis2/branches/c/post_1_4_mtom/c/samples/server/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/samples/server/axis2.xml?rev=662330&r1=662329&r2=662330&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/samples/server/axis2.xml (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/samples/server/axis2.xml Sun Jun  1 22:53:10
2008
@@ -6,9 +6,9 @@
     <!--parameter name="enableMTOM" locked="false">true</parameter-->
 
     <!-- Set the suitable size for optimum memory usage when sending large attachments
-->
-    <!--parameter name="MTOMChunkBufferSize" locked="false">10</parameter-->
-    <!--parameter name="MTOMMaxChunkBuffers" locked="false">1000</parameter-->
-    
+    <!--parameter name="MTOMBufferSize" locked="false">10</parameter-->
+    <!--parameter name="MTOMMaxBuffers" locked="false">1000</parameter-->
+    <!--parameter name="MTOMCachingCallback" locked="false">/path/to/your/caching_callabck</parameter-->
     <!-- Enable REST -->
     <parameter name="enableREST" locked="false">true</parameter>
 

Modified: webservices/axis2/branches/c/post_1_4_mtom/c/samples/server/mtom/mtom.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/samples/server/mtom/mtom.c?rev=662330&r1=662329&r2=662330&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/samples/server/mtom/mtom.c (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/samples/server/mtom/mtom.c Sun Jun  1 22:53:10
2008
@@ -100,9 +100,9 @@
                     axiom_text_t *bin_text = (axiom_text_t *)
                         axiom_node_get_data_element(binary_node, env);
                     data_handler = axiom_text_get_data_handler(bin_text, env);
-                    if (data_handler)
+                    if (data_handler && !axiom_data_handler_get_cached(data_handler,
env))
                     {
-                        /*axiom_data_handler_t *data_handler_res = NULL;
+                        axiom_data_handler_t *data_handler_res = NULL;
                         axis2_byte_t *input_buff = NULL;
                         axis2_byte_t *buff = NULL;
                         int buff_len = 0;
@@ -117,21 +117,33 @@
                         
                         data_handler_res = axiom_data_handler_create(env, NULL, NULL);
                         
-                        buff = AXIS2_MALLOC(env->allocator, sizeof(axis2_byte_t)*buff_len);*/
-	/*		if (!buff)
-			  {
-			    AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
-					     "malloc failed, not enough memory");
-			    return AXIS2_FAILURE;
-			  }*/
+                        buff = AXIS2_MALLOC(env->allocator, sizeof(axis2_byte_t)*buff_len);
 
-                        /*memcpy(buff, input_buff, buff_len);*/
+            			if (!buff)
+			            {
+			                AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
+					        "malloc failed, not enough memory");
+			                return AXIS2_FAILURE;
+			            }
 
-                        /*axiom_data_handler_set_binary_data(data_handler_res, env, buff,
buff_len);
+                        memcpy(buff, input_buff, buff_len);
+
+                        axiom_data_handler_set_binary_data(data_handler_res, env, buff, buff_len);
+
+                        axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE);
+                        ret_node = build_response2(env, data_handler_res);
+                    }
+                    else if(data_handler && axiom_data_handler_get_cached(data_handler,
env))
+                    {
+                        axiom_data_handler_t *data_handler_res = NULL;
+
+                        data_handler_res = axiom_data_handler_create(env, "/tmp/attachment",
NULL);
 
                         axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE);
-                        ret_node = build_response2(env, data_handler_res);*/
+                        ret_node = build_response2(env, data_handler_res);
+
                     }
+
                     else if (axiom_node_get_node_type(binary_node, env) == AXIOM_TEXT) /*
attachment has come by value, as non-optimized binary */
                     {
                         int plain_binary_len = 0;



Mime
View raw message