axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r496574 - in /webservices/axis2/trunk/c/axiom: include/axiom_element.h src/om/om_element.c src/om/om_stax_builder.c
Date Tue, 16 Jan 2007 02:13:41 GMT
Author: samisa
Date: Mon Jan 15 18:13:41 2007
New Revision: 496574

URL: http://svn.apache.org/viewvc?view=rev&rev=496574
Log:
Some fixes to builder to improve performance - really added some caching

Modified:
    webservices/axis2/trunk/c/axiom/include/axiom_element.h
    webservices/axis2/trunk/c/axiom/src/om/om_element.c
    webservices/axis2/trunk/c/axiom/src/om/om_stax_builder.c

Modified: webservices/axis2/trunk/c/axiom/include/axiom_element.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/include/axiom_element.h?view=diff&rev=496574&r1=496573&r2=496574
==============================================================================
--- webservices/axis2/trunk/c/axiom/include/axiom_element.h (original)
+++ webservices/axis2/trunk/c/axiom/include/axiom_element.h Mon Jan 15 18:13:41 2007
@@ -107,6 +107,12 @@
             const axis2_env_t *env,
             axiom_node_t *node,
             axiom_namespace_t * ns);
+
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axiom_element_declare_namespace_shallow(axiom_element_t *om_element,
+            const axis2_env_t *env,
+            axiom_namespace_t *ns);
+            
     /**
      * Finds a namespace using qname
      * Start to find from the given node and go up the hierarchy.
@@ -260,6 +266,11 @@
             const axis2_env_t *env,
             axiom_namespace_t *ns,
             axiom_node_t *node);
+
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axiom_element_set_namespace_shallow(axiom_element_t *om_element,
+            const axis2_env_t *env,
+            axiom_namespace_t *ns);
     /**
      * get  the attribute list of the element 
      * @param om_element om element

Modified: webservices/axis2/trunk/c/axiom/src/om/om_element.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/om/om_element.c?view=diff&rev=496574&r1=496573&r2=496574
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/om/om_element.c (original)
+++ webservices/axis2/trunk/c/axiom/src/om/om_element.c Mon Jan 15 18:13:41 2007
@@ -320,6 +320,53 @@
 }
 
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axiom_element_declare_namespace_shallow(axiom_element_t *om_element,
+        const axis2_env_t *env,
+        axiom_namespace_t *ns)
+{
+    axis2_char_t *prefix = NULL;
+    axis2_char_t *uri    = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+    if (!ns || !om_element)
+    {
+        AXIS2_ERROR_SET(env->error,
+                AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+
+        return AXIS2_FAILURE;
+    }
+
+    uri = AXIOM_NAMESPACE_GET_URI(ns, env);
+    prefix = AXIOM_NAMESPACE_GET_PREFIX(ns, env);
+
+    if (!(om_element->namespaces))
+    {
+        om_element->namespaces = axis2_hash_make(env);
+        if (!(om_element->namespaces))
+            return AXIS2_FAILURE;
+    }
+    if (prefix)
+    {
+        axis2_hash_set(om_element->namespaces,
+                prefix, AXIS2_HASH_KEY_STRING, ns);
+    }
+    else
+    {
+        axis2_char_t *key = NULL;
+        key = AXIS2_MALLOC(env->allocator, sizeof(char) * 10);
+        memset(key, 0, sizeof(char)*10);
+        om_element->next_ns_prefix_number++;
+        sprintf(key, "axis2ns%d", om_element->next_ns_prefix_number);
+        axis2_hash_set(om_element->namespaces, key,
+                AXIS2_HASH_KEY_STRING,  ns);
+    }
+    axiom_namespace_increment_ref(ns, env);
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axiom_element_declare_namespace(axiom_element_t *om_element,
         const axis2_env_t *env,
         axiom_node_t *node,
@@ -800,6 +847,15 @@
     {
         om_element->ns = om_ns;
     }
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axiom_element_set_namespace_shallow(axiom_element_t *om_element,
+        const axis2_env_t *env,
+        axiom_namespace_t *ns)
+{
+    om_element->ns = ns;
     return AXIS2_SUCCESS;
 }
 

Modified: webservices/axis2/trunk/c/axiom/src/om/om_stax_builder.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/om/om_stax_builder.c?view=diff&rev=496574&r1=496573&r2=496574
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/om/om_stax_builder.c (original)
+++ webservices/axis2/trunk/c/axiom/src/om/om_stax_builder.c Mon Jan 15 18:13:41 2007
@@ -46,6 +46,7 @@
     int current_event;
 
     int element_level;
+    axis2_hash_t *declared_namespaces;
 };
 
 AXIS2_EXTERN axiom_stax_builder_t * AXIS2_CALL
@@ -75,6 +76,8 @@
     om_builder->root_node = NULL;
     om_builder->element_level = 0;
 
+    om_builder->declared_namespaces = axis2_hash_make(env);
+
     om_builder->document = axiom_document_create(env, NULL, om_builder);
     if (!om_builder->document)
     {
@@ -268,7 +271,7 @@
     axis2_status_t status = AXIS2_SUCCESS;
     int namespace_count = 0;
     axiom_namespace_t *om_ns = NULL;
-    axiom_namespace_t *temp_ns = NULL;
+    /*axiom_namespace_t *temp_ns = NULL;*/
     /* temp values */
     axis2_char_t *temp_prefix = NULL;
     axis2_char_t *temp_ns_prefix = NULL;
@@ -300,14 +303,9 @@
 
             status = AXIOM_ELEMENT_DECLARE_NAMESPACE(om_ele, env, node, om_ns);
 
-            temp_ns = AXIOM_ELEMENT_FIND_DECLARED_NAMESPACE(om_ele, env, temp_ns_uri, NULL);
-            /*
-            if(temp_ns)
-            {
-               AXIOM_ELEMENT_SET_NAMESPACE (om_ele, env, om_ns, node); 
-            } 
-            */
-            if (!temp_ns)
+            /*temp_ns = AXIOM_ELEMENT_FIND_DECLARED_NAMESPACE(om_ele, env, temp_ns_uri, NULL);*/
+            
+            if (!status)
             {
                 AXIOM_NAMESPACE_FREE(om_ns, env);
                 om_ns = NULL;
@@ -316,17 +314,22 @@
         else
         {
             axiom_element_t *om_ele = NULL;
+            axis2_char_t *prefix = NULL;
             om_ele = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env);
 
             om_ns = axiom_namespace_create(env, temp_ns_uri, temp_ns_prefix);
             if (!om_ns || !om_ele)
                 return AXIS2_FAILURE;
 
-            status = AXIOM_ELEMENT_DECLARE_NAMESPACE(om_ele, env, node, om_ns);
+            /*status = AXIOM_ELEMENT_DECLARE_NAMESPACE(om_ele, env, node, om_ns);*/
+
+            status = axiom_element_declare_namespace_shallow(om_ele, env, om_ns);
             /*
              temp_ns = AXIOM_ELEMENT_FIND_DECLARED_NAMESPACE(om_ele, 
                              env, temp_ns_uri,temp_ns_prefix);
             */
+            prefix = AXIOM_NAMESPACE_GET_PREFIX(om_ns, env);
+            axis2_hash_set(om_builder->declared_namespaces, prefix, AXIS2_HASH_KEY_STRING,
om_ns);
         }
         AXIOM_XML_READER_XML_FREE(om_builder->parser, env, temp_ns_prefix);
         AXIOM_XML_READER_XML_FREE(om_builder->parser, env, temp_ns_uri);
@@ -340,16 +343,19 @@
     temp_prefix = AXIOM_XML_READER_GET_PREFIX(om_builder->parser, env);
     if (temp_prefix)
     {
-        om_ns = AXIOM_ELEMENT_FIND_NAMESPACE(
+        /*om_ns = AXIOM_ELEMENT_FIND_NAMESPACE(
                     (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env),
-                    env, node, NULL, temp_prefix);
+                    env, node, NULL, temp_prefix);*/
+        om_ns = axis2_hash_get(om_builder->declared_namespaces, temp_prefix, AXIS2_HASH_KEY_STRING);
 
         if (om_ns)
         {
             axiom_element_t *om_ele = NULL;
             om_ele = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env);
+            /*if (om_ele)
+                AXIOM_ELEMENT_SET_NAMESPACE(om_ele, env, om_ns, node);*/
             if (om_ele)
-                AXIOM_ELEMENT_SET_NAMESPACE(om_ele, env, om_ns, node);
+                axiom_element_set_namespace_shallow(om_ele, env, om_ns);
         }
         else
         {
@@ -725,6 +731,13 @@
         AXIOM_XML_READER_FREE(om_builder->parser, env);
         om_builder->parser = NULL;
     }
+
+    if (om_builder->declared_namespaces)
+    {
+        axis2_hash_free(om_builder->declared_namespaces, env);
+        om_builder->declared_namespaces = NULL;
+    }
+    
     if (om_builder->document)
     {
         AXIOM_DOCUMENT_FREE(om_builder->document, env);



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


Mime
View raw message