axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject svn commit: r419810 - in /webservices/axis2/trunk/c/woden: include/woden_resolver.h src/builder/resolver.c
Date Fri, 07 Jul 2006 05:27:50 GMT
Author: damitha
Date: Thu Jul  6 22:27:49 2006
New Revision: 419810

URL: http://svn.apache.org/viewvc?rev=419810&view=rev
Log:
Added new files

Added:
    webservices/axis2/trunk/c/woden/include/woden_resolver.h
    webservices/axis2/trunk/c/woden/src/builder/resolver.c

Added: webservices/axis2/trunk/c/woden/include/woden_resolver.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/woden/include/woden_resolver.h?rev=419810&view=auto
==============================================================================
--- webservices/axis2/trunk/c/woden/include/woden_resolver.h (added)
+++ webservices/axis2/trunk/c/woden/include/woden_resolver.h Thu Jul  6 22:27:49 2006
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+#ifndef WODEN_RESOLVER_H
+#define WODEN_RESOLVER_H
+
+/**
+ * @file woden_resolver.h
+ * @brief Woden Wsdl Reader Interface
+ * Implements the wsdl_resolver behaviour for AXIOM-based parsing.
+ * 
+ */
+
+#include <woden.h>
+#include <axiom_document.h>
+#include <axiom_node.h>
+
+/** @defgroup woden_resolver Woden Wsdl Reader
+  * @ingroup woden
+  * @{
+  */
+
+typedef union woden_resolver_base woden_resolver_base_t;
+typedef struct woden_resolver woden_resolver_t;
+typedef struct woden_resolver_ops woden_resolver_ops_t;
+
+#define WODEN_WSDL10 10
+#define WODEN_WSDL20 20
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct woden_resolver_ops
+{
+   /** 
+     * Deallocate memory
+     * @return status code
+     */
+    axis2_status_t (AXIS2_CALL *
+    free) (
+            void *resolver,
+            const axis2_env_t *env);
+ 
+    void *(AXIS2_CALL *
+    read) (
+            void *resolver,
+            const axis2_env_t *env,
+            axiom_document_t *om_doc,
+            const axis2_char_t *doc_base_uri);
+
+    int (AXIS2_CALL *
+    get_spec) (
+            void *resolver,
+            const axis2_env_t *env);
+
+   
+};
+
+struct woden_resolver
+{
+    woden_resolver_ops_t *ops;
+};
+
+AXIS2_EXTERN woden_resolver_t * AXIS2_CALL
+woden_resolver_create(
+        const axis2_env_t *env);
+
+#define WODEN_RESOLVER_FREE(resolver, env) \
+      (((woden_resolver_t *) resolver)->ops->free(resolver, env))
+
+#define WODEN_RESOLVER_READ(resolver, env, om_doc, doc_base_uri) \
+      (((woden_resolver_t *) resolver)->ops->\
+      read (resolver, env, om_doc, doc_base_uri))
+
+#define WODEN_RESOLVER_GET_SPEC(resolver, env) \
+      (((woden_resolver_t *) resolver)->ops->\
+       get_spec(resolver, env))
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+#endif /* WODEN_RESOLVER_H */

Added: webservices/axis2/trunk/c/woden/src/builder/resolver.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/woden/src/builder/resolver.c?rev=419810&view=auto
==============================================================================
--- webservices/axis2/trunk/c/woden/src/builder/resolver.c (added)
+++ webservices/axis2/trunk/c/woden/src/builder/resolver.c Thu Jul  6 22:27:49 2006
@@ -0,0 +1,272 @@
+/*
+ * 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 <woden_resolver.h>
+#include <woden_reader.h>
+#include <woden_wsdl10_reader.h>
+#include <woden_schema_constants.h>
+#include <woden_qname_util.h>
+#include <axis2_uri.h>
+
+#include "../wsdl20/woden_constants.h"
+#include "../wsdl10/woden_wsdl10_constants.h"
+#include "../util/woden_om_util.h"
+
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axiom_attribute.h>
+#include <axiom_child_element_iterator.h>
+#include <axiom_namespace.h>
+#include <axiom_text.h>
+#include <axiom_document.h>
+#include <axiom_stax_builder.h>
+#include <axiom_xml_reader.h>
+#include <axiom_util.h>
+#include <axis2_utils.h>
+
+
+typedef struct woden_resolver_impl woden_resolver_impl_t;
+
+/** 
+ * @brief Woden Wsdl Reader Struct Impl
+ *   Woden Wsdl Reader  
+ */ 
+struct woden_resolver_impl
+{
+    woden_resolver_t resolver;
+
+    axiom_document_t *om_doc;
+    axiom_node_t *root_node;
+    int spec;
+};
+
+#define INTF_TO_IMPL(resolver) ((woden_resolver_impl_t *) resolver)
+
+axis2_status_t AXIS2_CALL 
+woden_resolver_free(
+        void *resolver,
+        const axis2_env_t *env);
+
+void *AXIS2_CALL
+woden_resolver_read(
+        void *resolver,
+        const axis2_env_t *env,
+        axiom_document_t *om_doc,
+        const axis2_char_t *doc_base_uri);
+
+int AXIS2_CALL
+woden_resolver_get_spec(
+        void *resolver,
+        const axis2_env_t *env);
+
+/* Parse the attributes and child elements of the <description> element.
+ * As per the WSDL 2.0 spec, the child elements must be in the 
+ * following order if present:
+ * <documentation>
+ * <import> <include> or WSDL extension elements in any order
+ * <types>
+ * <interface> <binding> <service> or WSDL extension elements in any order.
+ * TODO validate that the elements are in correct order
+ */ 
+static void *
+yomu(
+        void *resolver,
+        const axis2_env_t *env,
+        axiom_node_t *desc_el_node,
+        const axis2_char_t *doc_base_uri);
+
+/* ************************************************************
+ *  Utility/helper methods
+ * ************************************************************/
+
+/**
+ * Check the actual element encountered against the expected qname
+ * 
+ * @param el actual element encountered
+ * @param qname expected element's qname
+ */
+static axis2_status_t
+check_element_qname(
+        void *resolver,
+        const axis2_env_t *env,
+        axiom_node_t *el_node,
+        axis2_qname_t *qname);
+    
+static woden_resolver_t *
+create(
+        const axis2_env_t *env)
+{
+    woden_resolver_impl_t *resolver_impl = NULL;
+   
+    AXIS2_ENV_CHECK(env, NULL);
+    resolver_impl = AXIS2_MALLOC(env->allocator, 
+                    sizeof(woden_resolver_impl_t));
+
+    resolver_impl->root_node = NULL;
+    resolver_impl->om_doc = NULL;
+    resolver_impl->spec = 0;
+    
+    resolver_impl->resolver.ops = AXIS2_MALLOC(env->allocator, 
+                    sizeof(woden_resolver_ops_t));
+    
+    resolver_impl->resolver.ops->free = woden_resolver_free;
+    resolver_impl->resolver.ops->read = woden_resolver_read;
+    resolver_impl->resolver.ops->get_spec = woden_resolver_get_spec;
+
+    return &(resolver_impl->resolver);
+}
+
+AXIS2_EXTERN woden_resolver_t * AXIS2_CALL
+woden_resolver_create(
+        const axis2_env_t *env)
+{
+    woden_resolver_impl_t *resolver_impl = NULL;
+   
+    AXIS2_ENV_CHECK(env, NULL);
+    resolver_impl = (woden_resolver_impl_t *) create(env);
+
+    return &(resolver_impl->resolver);
+}
+
+axis2_status_t AXIS2_CALL
+woden_resolver_free(
+        void *resolver,
+        const axis2_env_t *env)
+{
+    woden_resolver_impl_t *resolver_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    resolver_impl = INTF_TO_IMPL(resolver);
+
+    if((&(resolver_impl->resolver))->ops)
+    {
+        AXIS2_FREE(env->allocator, (&(resolver_impl->resolver))->ops);
+        (&(resolver_impl->resolver))->ops = NULL;
+    }
+
+    if(resolver_impl)
+    {
+        AXIS2_FREE(env->allocator, resolver_impl);
+        resolver_impl = NULL;
+    }
+    return AXIS2_SUCCESS;
+}
+
+/* ************************************************************
+ *  API public methods
+ * ************************************************************/
+void *AXIS2_CALL
+woden_resolver_read(
+        void *resolver,
+        const axis2_env_t *env,
+        axiom_document_t *om_doc,
+        const axis2_char_t *doc_base_uri)
+{
+    woden_resolver_impl_t *resolver_impl = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, om_doc, AXIS2_FAILURE);
+    resolver_impl = INTF_TO_IMPL(resolver);
+        
+    /* TODO add WSDL locator for resolving URIs */
+    resolver_impl->om_doc = om_doc;
+    resolver_impl->root_node = AXIOM_DOCUMENT_GET_ROOT_ELEMENT(om_doc, env);         
  
+    if(!resolver_impl->root_node)
+        return AXIS2_FAILURE;
+    return yomu(resolver, env, resolver_impl->root_node, doc_base_uri);
+}
+
+int AXIS2_CALL
+woden_resolver_get_spec(
+        void *resolver,
+        const axis2_env_t *env)
+{
+    woden_resolver_impl_t *resolver_impl = NULL;
+    
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    resolver_impl = INTF_TO_IMPL(resolver);
+
+    return resolver_impl->spec;
+}
+
+static void *
+yomu(
+        void *resolver,
+        const axis2_env_t *env,
+        axiom_node_t *desc_el_node,
+        const axis2_char_t *doc_base_uri)
+{
+    woden_resolver_impl_t *resolver_impl = NULL;
+    axis2_qname_t *qname = NULL;
+    axis2_bool_t check = AXIS2_FALSE;
+    void *desc = NULL;
+
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK(env->error, desc_el_node, AXIS2_FAILURE);
+    resolver_impl = INTF_TO_IMPL(resolver);
+
+    qname = axis2_qname_create_from_string(env, WODEN_Q_ELEM_DESCRIPTION);
+    check = check_element_qname(resolver, env, desc_el_node, qname);
+    if(AXIS2_TRUE == check)
+    {
+        woden_reader_t *reader = NULL;
+        
+        resolver_impl->spec = WODEN_WSDL20;
+        reader = woden_reader_create(env);
+        desc = WODEN_READER_READ_WSDL(reader, env, resolver_impl->root_node, 
+                doc_base_uri); 
+
+    }
+    AXIS2_QNAME_FREE(qname, env);
+    qname = axis2_qname_create_from_string(env, WODEN_WSDL10_Q_ELEM_DEFINITIONS);
+    check = check_element_qname(resolver, env, desc_el_node, qname);
+    if(AXIS2_TRUE == check)
+    {
+        woden_wsdl10_reader_t *reader = NULL;
+        
+        resolver_impl->spec = WODEN_WSDL10;
+        reader = woden_wsdl10_reader_create(env);
+        desc = WODEN_WSDL10_READER_READ_WSDL(reader, env, resolver_impl->root_node, 
+                doc_base_uri); 
+    }
+    return desc;
+}
+
+/* ************************************************************
+ *  Utility/helper methods
+ * ************************************************************/
+
+/**
+ * Check the actual element encountered against the expected qname
+ * 
+ * @param el actual element encountered
+ * @param qname expected element's qname
+ */
+static axis2_status_t
+check_element_qname(
+        void *resolver,
+        const axis2_env_t *env,
+        axiom_node_t *el_node,
+        axis2_qname_t *qname)
+{
+    if(AXIS2_TRUE != axis2_qname_util_matches(env, qname, el_node))
+    {
+        /* TODO woden_wsdl_exc_set_location(wsdl_exc, env, xpath);*/
+        return AXIS2_FAILURE;
+    }
+    return AXIS2_SUCCESS;
+}
+    



---------------------------------------------------------------------
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