You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by na...@apache.org on 2006/09/01 14:46:04 UTC
svn commit: r439295 [12/15] - in /webservices/axis2/trunk/c: tools/
tools/codegen/ tools/codegen/include/ tools/codegen/samples/
tools/codegen/samples/client/ tools/codegen/samples/client/calculator/
tools/codegen/samples/client/interop_test_svc/ tools...
Added: webservices/axis2/trunk/c/tools/codegen/src/wsdl/emitter/emitter.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/codegen/src/wsdl/emitter/emitter.c?rev=439295&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/codegen/src/wsdl/emitter/emitter.c (added)
+++ webservices/axis2/trunk/c/tools/codegen/src/wsdl/emitter/emitter.c Fri Sep 1 05:45:57 2006
@@ -0,0 +1,880 @@
+/*
+ * 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 <w2c_emitter_protected.h>
+
+#include <woden_wsdl10_desc.h>
+#include <woden_wsdl10_svc.h>
+#include <woden_wsdl10_endpoint.h>
+#include <woden_ext_element.h>
+#include <woden_wsdl10_soap_module.h>
+#include <woden_wsdl10_soap_address_exts.h>
+
+#include <axis2_qname.h>
+
+#include <woden_desc.h>
+#include <woden_svc.h>
+#include <woden_endpoint.h>
+#include <woden_element_decl.h>
+#include <woden_interface.h>
+#include <woden_binding.h>
+#include <woden_interface_element.h>
+#include <woden_interface_op_element.h>
+#include <woden_endpoint_element.h>
+#include <woden_interface_msg_ref.h>
+#include <woden_wsdl10_interface_msg_ref.h>
+#include <woden_wsdl10_interface_msg_ref_element.h>
+#include <woden_binding_element.h>
+#include <woden_binding_op.h>
+#include <woden_wsdl10_binding_op.h>
+#include <woden_binding_op.h>
+#include <woden_interface_op.h>
+#include <woden_interface.h>
+#include <woden_direction.h>
+#include <woden_soap_binding_exts.h>
+#include <woden_wsdl10_soap_binding_exts.h>
+#include <woden_soap_binding_op_exts.h>
+#include <woden_wsdl10_soap_binding_op_exts.h>
+
+#include <w2c_typemapper.h>
+#include <w2c_cmdline_option_consts.h>
+#include <w2c_xslt_utils.h>
+
+/***************************Function implementation****************************/
+
+w2c_emitter_impl_t*
+w2c_emitter_create_impl( const axis2_env_t *env)
+{
+ w2c_emitter_impl_t *emitter_impl = NULL;
+ AXIS2_ENV_CHECK(env, NULL);
+
+ emitter_impl =
+ AXIS2_MALLOC (env->allocator, sizeof(w2c_emitter_impl_t));
+
+ if(NULL == emitter_impl)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ w2c_emitter_init(emitter_impl, env );
+
+ return emitter_impl;
+}
+
+axis2_status_t
+w2c_emitter_init( w2c_emitter_impl_t *emitter_impl,
+ const axis2_env_t *env)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ if(NULL == emitter_impl)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ emitter_impl-> config = NULL;
+ emitter_impl-> loader = NULL;
+ emitter_impl-> desc = NULL;
+ emitter_impl-> name_maker_func = NULL;
+ emitter_impl-> qname2name_maker = NULL;
+ emitter_impl-> resolver = woden_resolver_create(env);
+ axiom_element_create(env, NULL, "class", NULL, &(emitter_impl->common_node));
+
+ emitter_impl->emitter.ops =
+ AXIS2_MALLOC (env->allocator, sizeof(w2c_emitter_ops_t));
+ if(NULL == emitter_impl->emitter.ops)
+ {
+ w2c_emitter_free(&(emitter_impl->emitter), env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+
+ emitter_impl->emitter.ops->free = w2c_emitter_free;
+ emitter_impl->emitter.ops->set_config = w2c_emitter_set_config;
+ emitter_impl->emitter.ops->emit_stub = w2c_emitter_emit_stub;
+ emitter_impl->emitter.ops->emit_skel = w2c_emitter_emit_skel;
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+w2c_emitter_free(w2c_emitter_t *emitter,
+ const axis2_env_t *env)
+{
+ w2c_emitter_impl_t *emitter_impl = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ emitter_impl = W2C_INTF_TO_IMPL(emitter);
+
+ if ( emitter_impl-> desc)
+ {
+ if (WODEN_RESOLVER_GET_SPEC( emitter_impl-> resolver, env )
+ == WODEN_WSDL10 )
+ {
+ WODEN_WSDL10_DESC_FREE ( emitter_impl-> desc, env);
+ }
+ else if (WODEN_RESOLVER_GET_SPEC( emitter_impl-> resolver, env)
+ == WODEN_WSDL20 )
+ {
+ WODEN_DESC_FREE ( emitter_impl-> desc, env);
+ }
+ }
+ if ( emitter_impl-> resolver )
+ {
+ WODEN_RESOLVER_FREE( emitter_impl-> resolver, env);
+ }
+ if ( emitter_impl-> common_node )
+ {
+ AXIOM_NODE_FREE_TREE_TREE ( emitter_impl-> common_node, env );
+ }
+ if(emitter->ops)
+ {
+ AXIS2_FREE(env->allocator, emitter->ops);
+ emitter->ops = NULL;
+ }
+ if(emitter_impl)
+ {
+ AXIS2_FREE(env->allocator, emitter_impl);
+ emitter_impl = NULL;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+w2c_emitter_set_config(w2c_emitter_t *emitter,
+ const axis2_env_t *env,
+ w2c_engine_configuration_t *config,
+ w2c_config_property_loader_t *loader)
+{
+ w2c_emitter_impl_t *emitter_impl = NULL;
+ axis2_status_t status = AXIS2_SUCCESS;
+ W2C_EMITTER_NAME_MAKER name_maker_func = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ emitter_impl = W2C_INTF_TO_IMPL(emitter);
+ emitter_impl-> config = config;
+ emitter_impl-> loader = loader;
+
+ name_maker_func =(W2C_EMITTER_NAME_MAKER)
+ W2C_ENGINE_CONFIGURATION_GET_NAMEMAKER_FUNC( config, env);
+ emitter_impl-> qname2name_maker = W2C_ENGINE_CONFIGURATION_GET_QNAME2NAME( config, env);
+
+ if ( NULL == name_maker_func )
+ {
+ emitter_impl-> name_maker_func = w2c_emitter_default_namemaker;
+ }
+ else
+ {
+ emitter_impl-> name_maker_func = name_maker_func;
+ }
+
+
+ status = w2c_emitter_parse_wsdl( emitter_impl, env);
+ if ( AXIS2_FAILURE == status )
+ {
+ w2c_messages_print_n_log_error( env,
+ "emitter.errorParsingWSDL");
+ return AXIS2_FAILURE;
+ }
+
+ status = w2c_emitter_load_services ( emitter_impl, env,
+ emitter_impl-> common_node );
+ if ( AXIS2_FAILURE == status )
+ {
+ w2c_messages_print_n_log_error( env,
+ "emitter.errorLoadingServices");
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_SUCCESS;
+}
+
+/* these 2 functions would be overriden */
+
+axis2_status_t AXIS2_CALL
+w2c_emitter_emit_stub(w2c_emitter_t *emitter,
+ const axis2_env_t *env)
+{
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+w2c_emitter_emit_skel(w2c_emitter_t *emitter,
+ const axis2_env_t *env)
+{
+ return AXIS2_SUCCESS;
+}
+
+/* implementations for protected functions */
+
+axis2_status_t
+w2c_emitter_write_class(w2c_emitter_impl_t *emitter_impl,
+ const axis2_env_t *env,
+ axiom_node_t *root,
+ w2c_writer_t *writer)
+{
+ axis2_char_t *package_name = NULL;
+ axis2_char_t *file_name = NULL;
+ axiom_element_t *root_ele = NULL;
+ axis2_status_t status = AXIS2_SUCCESS;
+ axis2_char_t *full_path = NULL;
+
+ if ( NULL == writer )
+ {
+ return AXIS2_FAILURE;
+ }
+
+ status = W2C_WRITER_INITIALIZE( writer, env, emitter_impl->loader,
+ emitter_impl->config );
+ if ( AXIS2_FAILURE == status)
+ {
+ w2c_messages_print_n_log_error( env,
+ "writer.templateLoadFailed");
+ return AXIS2_FAILURE;
+ }
+ root_ele = AXIOM_NODE_GET_DATA_ELEMENT( root, env);
+
+ package_name = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME
+ ( root_ele, env, "package");
+ file_name = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME
+ ( root_ele, env, "name");
+ full_path = W2C_WRITER_CREATE_OUT_FILE ( writer, env, package_name, file_name);
+ if ( NULL == full_path )
+ {
+ return AXIS2_FAILURE;
+ }
+ W2C_ENGINE_CONFIGURATION_ADD_FILENAME( emitter_impl-> config, env,
+ full_path);
+ W2C_WRITER_PARSE ( writer, env, root );
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t
+w2c_emitter_parse_wsdl( w2c_emitter_impl_t *emitter_impl,
+ const axis2_env_t *env)
+{
+ axiom_document_t *om_doc = NULL;
+ axis2_char_t *doc_base_uri = NULL;
+ axis2_char_t *axis2c_home = NULL;
+ void *desc = NULL;
+ axis2_char_t *filename = NULL;
+
+
+ filename =
+ W2C_ENGINE_CONFIGURATION_GET_WSDL_URI ( emitter_impl-> config, env);
+
+ om_doc = get_root_element_from_filename(env, filename);
+ if ( NULL == om_doc )
+ {
+ return AXIS2_FAILURE;
+ }
+ axis2c_home = AXIS2_GETENV("AXIS2C_HOME");
+ doc_base_uri = AXIS2_STRACAT (axis2c_home, "/woden/", env);
+
+ desc = (void *)WODEN_RESOLVER_READ(emitter_impl-> resolver , env, om_doc,
+ doc_base_uri);
+ /* freee existing desc ) */
+ if ( emitter_impl-> desc )
+ {
+ if (WODEN_RESOLVER_GET_SPEC( emitter_impl-> resolver, env )
+ == WODEN_WSDL10 )
+ {
+ WODEN_WSDL10_DESC_FREE ( emitter_impl-> desc, env);
+ }
+ else if (WODEN_RESOLVER_GET_SPEC( emitter_impl-> resolver, env)
+ == WODEN_WSDL20 )
+ {
+ WODEN_DESC_FREE ( emitter_impl-> desc, env);
+ }
+ }
+ emitter_impl-> desc = desc ;
+
+ AXIS2_FREE ( env-> allocator, doc_base_uri);
+ return AXIS2_SUCCESS;
+}
+
+axiom_document_t*
+get_root_element_from_filename(
+ const axis2_env_t *env,
+ axis2_char_t *filename)
+{
+ axiom_xml_reader_t *reader = NULL;
+ axiom_stax_builder_t *om_builder = NULL;
+ axiom_document_t *doc = NULL;
+
+ reader = axiom_xml_reader_create_for_file(env, filename, NULL);
+ if ( NULL == reader )
+ {
+ return NULL;
+ }
+ om_builder = axiom_stax_builder_create(env, reader);
+ doc = axiom_document_create(env, NULL, om_builder);
+ AXIOM_DOCUMENT_BUILD_ALL(doc, env);
+
+ return doc;
+}
+
+axis2_qname_t*
+w2c_emitter_pick_service_name ( w2c_emitter_impl_t *emitter_impl,
+ const axis2_env_t *env)
+{
+ axis2_array_list_t *svc_list = NULL;
+ void *svc = NULL;
+ axis2_qname_t *svc_qname = NULL;
+
+ if (WODEN_RESOLVER_GET_SPEC( emitter_impl-> resolver,env )
+ == WODEN_WSDL10 )
+ {
+ svc_list =
+ WODEN_WSDL10_DESC_ELEMENT_GET_SVC_ELEMENTS(emitter_impl->desc, env);
+ if (svc_list)
+ {
+ svc = AXIS2_ARRAY_LIST_GET(svc_list, env, 0);
+ if (svc)
+ {
+ svc_qname = WODEN_WSDL10_SVC_GET_QNAME(svc, env);
+ }
+ }
+ }
+ if (WODEN_RESOLVER_GET_SPEC( emitter_impl-> resolver, env )
+ == WODEN_WSDL20 )
+ {
+ svc_list =
+ WODEN_DESC_ELEMENT_GET_SVC_ELEMENTS(emitter_impl->desc, env);
+ if (svc_list)
+ {
+ svc = AXIS2_ARRAY_LIST_GET(svc_list, env, 0);
+ if (svc)
+ {
+ svc_qname = WODEN_SVC_GET_QNAME(svc, env);
+ }
+ }
+ }
+ return svc_qname;
+}
+
+
+axis2_status_t
+w2c_emitter_load_services( w2c_emitter_impl_t *emitter_impl,
+ const axis2_env_t *env,
+ axiom_node_t *root)
+{
+ axis2_status_t status = AXIS2_FAILURE;
+
+ if (WODEN_RESOLVER_GET_SPEC( emitter_impl-> resolver,env )
+ == WODEN_WSDL10 )
+ {
+ status = w2c_emitter_load_services_wsdl1( emitter_impl, env, root);
+ }
+ else if (WODEN_RESOLVER_GET_SPEC( emitter_impl-> resolver, env )
+ == WODEN_WSDL20 )
+ {
+ status = w2c_emitter_load_services_wsdl2( emitter_impl, env, root);
+ }
+
+ return status;
+}
+
+axis2_status_t
+w2c_emitter_load_services_wsdl1( w2c_emitter_impl_t *emitter_impl,
+ const axis2_env_t *env,
+ axiom_node_t *root)
+{
+ axis2_array_list_t *svc_list = NULL;
+ woden_wsdl10_svc_t *svc = NULL;
+ axis2_qname_t* svc_qname = NULL;
+
+ axis2_array_list_t *endpoint_list = NULL;
+ woden_wsdl10_endpoint_t *endpoint = NULL;
+ axis2_char_t *address = NULL;
+ axis2_qname_t *ext_type_l = NULL;
+ axis2_qname_t *ext_type = NULL;
+ int size = 0;
+ axis2_array_list_t *ext_elements = NULL;
+ void *soap_address = NULL;
+ axis2_uri_t *soap_address_uri = NULL;
+ axiom_node_t *endpoint_node = NULL;
+ void *ext_element = NULL;
+
+ woden_binding_t *binding = NULL;
+ axis2_char_t *binding_style = NULL;
+
+ int j = 0;
+ axis2_array_list_t *binding_ops_list = NULL;
+ int binding_ops_count = 0;
+ void *binding_op = NULL;
+
+ int i = 0;
+ void* interface_op = NULL;
+ axis2_qname_t *op_qname = NULL;
+ axis2_char_t *local_part = NULL;
+ axis2_char_t *ns = NULL;
+ axiom_node_t *method = NULL;
+
+ void *soap_binding_op = NULL;
+ axis2_uri_t *soap_action_uri = NULL;
+ axis2_char_t *soap_action_str = NULL;
+
+ axis2_char_t *given_name = NULL;
+ axis2_char_t *qname_str = NULL;
+
+ /**********************************************************************
+ * extract service(s)
+ **********************************************************************/
+ svc_list = WODEN_WSDL10_DESC_GET_SVCS(emitter_impl-> desc, env);
+
+ /** currently work only for one service */
+ if (AXIS2_ARRAY_LIST_SIZE ( svc_list, env ) < 1 )
+ {
+ /** no need to continue more */
+ return AXIS2_FAILURE;
+ }
+ svc = AXIS2_ARRAY_LIST_GET( svc_list, env, 0 );
+ svc_qname = WODEN_WSDL10_SVC_GET_QNAME( svc, env);
+ ns = AXIS2_QNAME_GET_URI( svc_qname, env);
+ w2c_xslt_utils_add_attribute (env, root, "namespace", ns);
+
+ /**********************************************************************
+ * extract endpoint(s)
+ **********************************************************************/
+ endpoint_list = WODEN_WSDL10_SVC_GET_ENDPOINTS (svc, env);
+
+ /** currently work only for one endpoint*/
+ if (AXIS2_ARRAY_LIST_SIZE ( endpoint_list, env ) < 1 )
+ {
+ return AXIS2_FAILURE; /* no need to continue more */
+ }
+
+ endpoint = AXIS2_ARRAY_LIST_GET( endpoint_list, env, 0 );
+ endpoint = woden_wsdl10_endpoint_to_element_extensible(
+ endpoint, env);
+
+ ext_type_l = axis2_qname_create(env, "address",
+ "http://schemas.xmlsoap.org/wsdl/soap/", NULL);
+ ext_elements = WODEN_ELEMENT_EXTENSIBLE_GET_EXT_ELEMENTS(endpoint,
+ env);
+ if(ext_elements)
+ size = AXIS2_ARRAY_LIST_SIZE(ext_elements, env);
+ else
+ return AXIS2_FAILURE;
+ for(j = 0; j < size; j++)
+ {
+ ext_element = AXIS2_ARRAY_LIST_GET(ext_elements, env, j);
+ ext_type = (axis2_qname_t*)WODEN_EXT_ELEMENT_GET_EXT_TYPE(ext_element, env);
+ if(AXIS2_TRUE == AXIS2_QNAME_EQUALS(ext_type, env, ext_type_l))
+ {
+ ext_element =
+ woden_wsdl10_soap_module_to_soap_module_element (
+ ext_element, env);
+ soap_address =
+ WODEN_WSDL10_SOAP_MODULE_ELEMENT_GET_SOAP_ADDRESS_EXTS(
+ ext_element, env);
+
+ soap_address_uri = WODEN_WSDL10_SOAP_ADDRESS_EXTS_GET_SOAP_ADDRESS(
+ soap_address, env);
+ break;
+ }
+ }
+
+ if(soap_address_uri)
+ {
+ address = AXIS2_URI_TO_STRING(soap_address_uri, env,
+ AXIS2_URI_UNP_OMITUSERINFO);
+ endpoint_node = w2c_xslt_utils_add_child_node(env, "endpoint",
+ root);
+ /** here the endpoint adding */
+ w2c_xslt_utils_add_text ( env, endpoint_node, address);
+ }
+
+ /**********************************************************************
+ * extract bindings(s)
+ **********************************************************************/
+ binding =
+ WODEN_WSDL10_ENDPOINT_GET_BINDING( endpoint, env);
+ binding_style = ""; /* currently hard coded */
+
+ /**********************************************************************
+ * extract binding ops
+ **********************************************************************/
+ binding_ops_list =
+ WODEN_BINDING_GET_BINDING_OPS( binding, env);
+ binding_ops_count =
+ AXIS2_ARRAY_LIST_SIZE( binding_ops_list, env );
+
+ for ( i = 0; i < binding_ops_count; i ++ )
+ {
+ binding_op = AXIS2_ARRAY_LIST_GET ( binding_ops_list, env, i );
+ /**********************************************************************
+ * extract interface ops
+ **********************************************************************/
+ interface_op = WODEN_WSDL10_BINDING_OP_GET_INTERFACE_OP
+ (binding_op, env);
+
+ op_qname = WODEN_INTERFACE_OP_GET_QNAME( interface_op, env);
+ if ( op_qname )
+ {
+ method = w2c_xslt_utils_add_child_node(env, "method",
+ root);
+ local_part= AXIS2_QNAME_GET_LOCALPART(op_qname, env);
+ given_name = W2C_QNAME2NAME_MAKER_SUGGEST_NAME(
+ emitter_impl-> qname2name_maker, env, op_qname);
+ qname_str = AXIS2_QNAME_TO_STRING(op_qname, env);
+ w2c_xslt_utils_add_attribute (env, method, "localpart",
+ local_part);
+ given_name = emitter_impl-> name_maker_func(given_name, env);
+ w2c_xslt_utils_add_attribute(env, method, "name",
+ given_name);
+ w2c_xslt_utils_add_attribute(env, method, "qname",
+ qname_str);
+ AXIS2_FREE( env-> allocator, local_part);
+ ns = AXIS2_QNAME_GET_URI(op_qname, env);
+ w2c_xslt_utils_add_attribute (env, method, "namespace",
+ ns);
+ /** todos */
+ w2c_xslt_utils_add_attribute (env, method, "style",
+ binding_style);
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ /**********************************************************************
+ * extract interface message refs
+ **********************************************************************/
+ w2c_emitter_load_operations( emitter_impl, env, method, interface_op, 1);
+
+ /** get soap action */
+ ext_type_l = axis2_qname_create(env, "operation",
+ "http://schemas.xmlsoap.org/wsdl/soap/", NULL);
+ binding_op = woden_wsdl10_binding_op_to_element_extensible(binding_op, env);
+ ext_elements = WODEN_ELEMENT_EXTENSIBLE_GET_EXT_ELEMENTS(binding_op, env);
+ size = AXIS2_ARRAY_LIST_SIZE( ext_elements, env);
+ for(j=0; j < size; j++)
+ {
+ ext_element = AXIS2_ARRAY_LIST_GET(ext_elements, env, j);
+ ext_type = WODEN_EXT_ELEMENT_GET_EXT_TYPE(ext_element, env);
+ if(AXIS2_TRUE == AXIS2_QNAME_EQUALS(ext_type, env, ext_type_l))
+ {
+ ext_element = woden_wsdl10_soap_module_to_soap_module_element (
+ ext_element, env);
+ soap_binding_op =
+ WODEN_WSDL10_SOAP_MODULE_ELEMENT_GET_SOAP_BINDING_OP_EXTS(
+ ext_element, env);
+ soap_action_uri =
+ WODEN_WSDL10_SOAP_BINDING_OP_EXTS_GET_SOAP_ACTION
+ (soap_binding_op, env);
+ soap_action_str = AXIS2_URI_TO_STRING
+ ( soap_action_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
+ w2c_xslt_utils_add_attribute (env, method, "soapaction", soap_action_str);
+ }
+ }
+ }
+
+ return AXIS2_SUCCESS;
+
+}
+
+axis2_status_t
+w2c_emitter_load_operations( w2c_emitter_impl_t *emitter_impl,
+ const axis2_env_t *env,
+ axiom_node_t *method,
+ void *interface_op, int wsdl_version)
+{
+ axis2_array_list_t *interface_msg_refs = NULL;
+ int msg_refs_size = 0;
+ int j = 0;
+ void *interface_msg_ref = NULL;
+ void *direction = NULL;
+ axis2_char_t *str_direction = NULL;
+ axis2_char_t *in_out = NULL;
+ axis2_bool_t in = AXIS2_FALSE;
+ axis2_bool_t out = AXIS2_FALSE;
+
+ void *msg_ref_ele = NULL;
+ axis2_qname_t *msg_qname = NULL;
+
+ axiom_node_t* input_param = NULL;
+ axiom_node_t* output_param = NULL;
+
+ output_param = w2c_xslt_utils_add_child_node(env, "param",
+ output_param);
+ /*w2c_xslt_utils_add_attribute (env, output_param, "type",
+ "axiom_node_t*");
+ w2c_xslt_utils_add_attribute (env, output_param, "name",
+ "param1"); */
+
+ interface_msg_refs = WODEN_INTERFACE_OP_GET_INTERFACE_MSG_REFS(
+ interface_op, env);
+ if(interface_msg_refs)
+ msg_refs_size = AXIS2_ARRAY_LIST_SIZE(interface_msg_refs, env);
+ for(j = 0; j < msg_refs_size; j++)
+ {
+ interface_msg_ref = AXIS2_ARRAY_LIST_GET(interface_msg_refs, env, j);
+ if( wsdl_version == 1)
+ {
+ direction = WODEN_WSDL10_INTERFACE_MSG_REF_GET_DIRECTION
+ (interface_msg_ref, env);
+ msg_ref_ele= (woden_wsdl10_interface_msg_ref_element_t*)
+ woden_wsdl10_interface_msg_ref_to_interface_msg_ref_element( interface_msg_ref, env);
+ msg_qname = WODEN_WSDL10_INTERFACE_MSG_REF_ELEMENT_GET_MSG_QNAME( msg_ref_ele, env);
+ }
+ else if ( wsdl_version == 2 )
+ {
+ direction = WODEN_INTERFACE_MSG_REF_GET_DIRECTION
+ (interface_msg_ref, env);
+ msg_ref_ele= (woden_interface_msg_ref_element_t*)
+ woden_interface_msg_ref_to_interface_msg_ref_element( interface_msg_ref, env);
+ /*msg_qname = WODEN_INTERFACE_MSG_REF_ELEMENT_GET_MSG_LABEL( msg_ref_ele, env);*/
+ msg_qname = WODEN_INTERFACE_MSG_REF_ELEMENT_GET_ELEMENT_QNAME( msg_ref_ele, env);
+ }
+ str_direction = WODEN_DIRECTION_TO_STRING(direction, env);
+ if(0 == AXIS2_STRCMP(str_direction, "in"))
+ {
+ if (!in) /* for the first in iteration */
+ {
+ input_param = w2c_xslt_utils_add_child_node(env, "input", method);
+ in = AXIS2_TRUE;
+ }
+ w2c_emitter_add_param( emitter_impl, env, input_param, msg_qname);
+ }
+ if(0 == AXIS2_STRCMP(str_direction, "out"))
+ {
+ if (!out)
+ {
+ output_param = w2c_xslt_utils_add_child_node(env, "output",
+ method);
+ out = AXIS2_TRUE;
+ }
+ w2c_emitter_add_param( emitter_impl, env, output_param, msg_qname);
+ }
+ }
+ if ( in && out )
+ {
+ in_out = "12";
+ }
+ if ( in && !out)
+ {
+ in_out = "11";
+ }
+
+ w2c_xslt_utils_add_attribute (env, method, "mep", in_out);
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t
+w2c_emitter_load_services_wsdl2( w2c_emitter_impl_t* emitter_impl,
+ const axis2_env_t* env,
+ axiom_node_t* root)
+{
+ axis2_array_list_t* svc_list = NULL;
+ woden_svc_t* svc = NULL;
+
+ axis2_array_list_t* endpoint_list = NULL;
+ woden_endpoint_t * endpoint = NULL;
+ axis2_uri_t* endpoint_uri = NULL;
+ axis2_char_t* endpoint_uri_str = NULL;
+ axiom_node_t* endpoint_node = NULL;
+
+ woden_binding_t* binding = NULL;
+ axis2_char_t* binding_style = NULL;
+
+ axis2_array_list_t* binding_ops_list = NULL;
+ int binding_ops_count = 0;
+ void* binding_op = NULL;
+
+ void* interface_op = NULL;
+ int i = 0;
+ axis2_qname_t* op_qname = NULL;
+ axis2_char_t* local_part = NULL;
+ axis2_char_t* ns = NULL;
+ axiom_node_t* method = NULL;
+
+ /*void *soap_binding_op = NULL;*/
+ axis2_uri_t *soap_action_uri = NULL;
+ axis2_char_t *soap_action_str = NULL;
+ axis2_qname_t *ext_type_l = NULL;
+ axis2_qname_t *ext_type = NULL;
+ axis2_array_list_t *ext_elements = NULL;
+ void *ext_element = NULL;
+ int size = 0, j = 0;
+
+ axis2_char_t *given_name = NULL;
+ axis2_char_t *qname_str = NULL;
+
+ /**********************************************************************
+ * extract service(s)
+ **********************************************************************/
+ svc_list = WODEN_DESC_GET_SVCS(emitter_impl->desc, env);
+
+ /** currently work only for one service */
+ if (AXIS2_ARRAY_LIST_SIZE ( svc_list, env ) < 1 )
+ {
+ /** no need to continue more */
+ return AXIS2_FAILURE;
+ }
+ svc = AXIS2_ARRAY_LIST_GET( svc_list, env, 0 );
+
+ /**********************************************************************
+ * extract endpoint(s)
+ **********************************************************************/
+ endpoint_list = WODEN_SVC_GET_ENDPOINTS (svc, env);
+
+ /** currently work only for one endpoint*/
+ if (AXIS2_ARRAY_LIST_SIZE ( endpoint_list, env ) < 1 )
+ {
+ return AXIS2_FAILURE; /* no need to continue more */
+ }
+ endpoint = AXIS2_ARRAY_LIST_GET( endpoint_list, env, 0 );
+ endpoint_uri = WODEN_ENDPOINT_GET_ADDRESS( endpoint, env);
+ endpoint_uri_str = AXIS2_URI_TO_STRING ( endpoint_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
+ endpoint_node = w2c_xslt_utils_add_child_node(env, "endpoint",
+ root);
+ /** here the endpoint adding */
+ w2c_xslt_utils_add_text ( env, endpoint_node, endpoint_uri_str );
+
+ /**********************************************************************
+ * extract bindings(s)
+ **********************************************************************/
+ binding =
+ WODEN_ENDPOINT_GET_BINDING( endpoint, env);
+ binding_style = ""; /* currently hard coded */
+
+ /**********************************************************************
+ * extract binding ops
+ **********************************************************************/
+ binding_ops_list =
+ WODEN_BINDING_GET_BINDING_OPS( binding, env);
+ binding_ops_count =
+ AXIS2_ARRAY_LIST_SIZE( binding_ops_list, env );
+
+ for ( i = 0; i < binding_ops_count; i ++ )
+ {
+ binding_op = AXIS2_ARRAY_LIST_GET ( binding_ops_list, env, i );
+ /**********************************************************************
+ * extract interface ops
+ **********************************************************************/
+
+ interface_op = WODEN_BINDING_OP_GET_INTERFACE_OP
+ (binding_op, env);
+ op_qname = WODEN_INTERFACE_OP_GET_QNAME( interface_op, env);
+ if ( op_qname )
+ {
+ method = w2c_xslt_utils_add_child_node(env, "method",
+ root);
+ local_part= AXIS2_QNAME_GET_LOCALPART(op_qname, env);
+ given_name = W2C_QNAME2NAME_MAKER_SUGGEST_NAME(
+ emitter_impl-> qname2name_maker, env, op_qname);
+ qname_str = AXIS2_QNAME_TO_STRING(op_qname, env);
+ w2c_xslt_utils_add_attribute (env, method, "localpart",
+ local_part);
+ given_name = emitter_impl-> name_maker_func(given_name, env);
+ w2c_xslt_utils_add_attribute (env, method, "name",
+ given_name);
+ w2c_xslt_utils_add_attribute (env, method, "qname",
+ qname_str);
+ ns = AXIS2_QNAME_GET_URI(op_qname, env);
+ w2c_xslt_utils_add_attribute (env, method, "namespace",
+ ns);
+ /** todos */
+ w2c_xslt_utils_add_attribute (env, method, "style",
+ binding_style);
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ /**********************************************************************
+ * extract interface message refs
+ **********************************************************************/
+ w2c_emitter_load_operations( emitter_impl, env, method, interface_op, 2);
+
+
+ /** get soap action */
+ ext_type_l = axis2_qname_create(env, "operation",
+ "http://schemas.xmlsoap.org/wsdl/soap/", NULL);
+ binding_op = woden_binding_op_to_element_extensible(binding_op, env);
+ ext_elements = WODEN_ELEMENT_EXTENSIBLE_GET_EXT_ELEMENTS(binding_op, env);
+ size = AXIS2_ARRAY_LIST_SIZE( ext_elements, env);
+ for(j=0; j < size; j++)
+ {
+ ext_element = AXIS2_ARRAY_LIST_GET(ext_elements, env, j);
+ ext_type = WODEN_EXT_ELEMENT_GET_EXT_TYPE(ext_element, env);
+ if(AXIS2_TRUE == AXIS2_QNAME_EQUALS(ext_type, env, ext_type_l))
+ {
+ /*ext_element = woden_soap_module_to_soap_module_element (
+ ext_element, env);
+ soap_binding_op =
+ WODEN_SOAP_MODULE_ELEMENT_GET_SOAP_BINDING_OP_EXTS(
+ ext_element, env);
+ soap_action_uri =
+ WODEN_SOAP_BINDING_OP_EXTS_GET_SOAP_ACTION
+ (soap_binding_op, env); */
+ soap_action_str = AXIS2_URI_TO_STRING
+ ( soap_action_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
+ w2c_xslt_utils_add_attribute (env, method, "soapaction", soap_action_str);
+ }
+ }
+ }
+
+
+ return AXIS2_SUCCESS;
+
+}
+axis2_status_t
+w2c_emitter_add_param( w2c_emitter_impl_t *emitter_impl,
+ const axis2_env_t *env,
+ axiom_node_t *param_direction,
+ axis2_qname_t *msg_qname)
+{
+ axiom_node_t *param = NULL;
+ axis2_char_t *type = NULL;
+ axis2_char_t *name = NULL;
+ w2c_typemapper_t *typemapper = NULL;
+
+ param = w2c_xslt_utils_add_child_node(env, "param",
+ param_direction);
+ typemapper = W2C_ENGINE_CONFIGURATION_GET_TYPEMAPPER(
+ emitter_impl-> config, env);
+ type = W2C_TYPEMAPPER_GET_TYPE_NAME( typemapper, env, msg_qname);
+ if ( NULL == type ) /* this is databinding not present for the message*/
+ {
+ msg_qname = W2C_TYPEMAPPER_GET_DEFAULT_QNAME( typemapper, env);
+ type = W2C_TYPEMAPPER_GET_TYPE_NAME( typemapper, env, msg_qname);
+ }
+ w2c_xslt_utils_add_attribute (env, param, "type", type);
+
+ name = W2C_TYPEMAPPER_GET_PARAMETER_NAME( typemapper, env, msg_qname);
+ w2c_xslt_utils_add_attribute (env, param, "name", name);
+
+ return AXIS2_SUCCESS;
+}
+
+/** do nothing just echo the value*/
+axis2_char_t* w2c_emitter_default_namemaker( axis2_char_t *name,
+ const axis2_env_t *env)
+{
+ return AXIS2_STRDUP( name, env);
+}
+
+axis2_char_t* w2c_emitter_default_qname2name( axis2_qname_t *qname,
+ const axis2_env_t *env)
+{
+ return AXIS2_QNAME_GET_LOCALPART( qname, env);
+}
Added: webservices/axis2/trunk/c/tools/codegen/src/wsdl/emitter/w2c_emitter_protected.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/codegen/src/wsdl/emitter/w2c_emitter_protected.h?rev=439295&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/codegen/src/wsdl/emitter/w2c_emitter_protected.h (added)
+++ webservices/axis2/trunk/c/tools/codegen/src/wsdl/emitter/w2c_emitter_protected.h Fri Sep 1 05:45:57 2006
@@ -0,0 +1,135 @@
+/*
+ * 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 <w2c_emitter.h>
+#include <axis2_array_list.h>
+#include <axis2_string.h>
+#include <w2c_string.h>
+#include <w2c_engine_configuration.h>
+#include <w2c_config_property_loader.h>
+#include <axiom_document.h>
+#include <w2c_writer.h>
+#include <axis2_dll_desc.h>
+#include <w2c_class_loader.h>
+#include <w2c_messages.h>
+#include <woden_reader.h>
+#include <woden_resolver.h>
+#include <w2c_qname2name_maker.h>
+
+#define W2C_EMITTER_CALL_BACK_HANDLER_SUFFIX "CallbackHandler"
+#define W2C_EMITTER_STUB_SUFFIX "Stub"
+#define W2C_EMITTER_TEST_SUFFIX "Test"
+#define W2C_EMITTER_SKELETON_CLASS_SUFFIX "Skeleton"
+#define W2C_EMITTER_SKELETON_INTERFACE_SUFFIX "SkeletonInterface"
+#define W2C_EMITTER_MESSAGE_RECEIVER_SUFFIX "MessageReceiver"
+#define W2C_EMITTER_FAULT_SUFFIX "Exception"
+#define W2C_EMITTER_DATABINDING_SUPPORTER_NAME_SUFFIX "DatabindingSupporter"
+
+#define W2C_EMITTER_SRC_DIR_NAME "src"
+#define W2C_EMITTER_TEST_SRC_DIR_NAME "test"
+#define W2C_EMITTER_RESOURCE_SRC_DIR_NAME "resources"
+
+#define W2C_EMITTER_WRITER_DIR W2C_CLASS_LOADER_WRITER_PATH
+
+typedef axis2_char_t* (*W2C_EMITTER_NAME_MAKER)
+ ( axis2_char_t *name, const axis2_env_t *env);
+
+/**
+ * @brief
+ */
+typedef struct w2c_emitter_impl
+{
+ w2c_emitter_t emitter;
+
+ w2c_engine_configuration_t* config;
+ w2c_config_property_loader_t* loader;
+
+ void* desc;
+ woden_resolver_t* resolver;
+ axiom_node_t* common_node;
+ W2C_EMITTER_NAME_MAKER name_maker_func;
+ w2c_qname2name_maker_t *qname2name_maker;
+} w2c_emitter_impl_t;
+
+
+#define W2C_INTF_TO_IMPL(emitter) \
+ ((w2c_emitter_impl_t *) emitter)
+
+/************************* Function prototypes ********************************/
+
+axis2_status_t AXIS2_CALL
+w2c_emitter_free(w2c_emitter_t *emitter,
+ const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+w2c_emitter_set_config(w2c_emitter_t *emitter,
+ const axis2_env_t* env,
+ w2c_engine_configuration_t* config,
+ w2c_config_property_loader_t* loader );
+
+axis2_status_t AXIS2_CALL
+w2c_emitter_emit_stub(w2c_emitter_t *emitter,
+ const axis2_env_t* env);
+
+axis2_status_t AXIS2_CALL
+w2c_emitter_emit_skel(w2c_emitter_t *emitter,
+ const axis2_env_t* env);
+
+/* implementations for protected functions */
+
+axis2_status_t
+w2c_emitter_write_class(w2c_emitter_impl_t* emitter_impl,
+ const axis2_env_t* env,
+ axiom_node_t* root,
+ w2c_writer_t* writer);
+
+axis2_status_t
+w2c_emitter_init( w2c_emitter_impl_t* emitter_impl,
+ const axis2_env_t *env);
+
+w2c_emitter_impl_t*
+w2c_emitter_create_impl( const axis2_env_t *env);
+
+axiom_document_t*
+get_root_element_from_filename(
+ const axis2_env_t *env,
+ axis2_char_t *filename);
+
+axis2_status_t
+w2c_emitter_parse_wsdl( w2c_emitter_impl_t* emitter_impl,
+ const axis2_env_t* env);
+
+axis2_qname_t*
+w2c_emitter_pick_service_name ( w2c_emitter_impl_t* emitter_impl,
+ const axis2_env_t* env);
+
+axis2_status_t
+w2c_emitter_load_services( w2c_emitter_impl_t* emitter_impl,
+ const axis2_env_t* env,
+ axiom_node_t* doc);
+
+axis2_status_t
+w2c_emitter_add_param( w2c_emitter_impl_t *emitter_impl,
+ const axis2_env_t *env,
+ axiom_node_t *param_direction,
+ axis2_qname_t *msg_qname);
+
+axis2_char_t* w2c_emitter_default_namemaker( axis2_char_t *name,
+ const axis2_env_t *env);
+
+
+/************************** End of function prototypes ************************/
+
Added: webservices/axis2/trunk/c/tools/codegen/src/wsdl/engine.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/codegen/src/wsdl/engine.c?rev=439295&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/codegen/src/wsdl/engine.c (added)
+++ webservices/axis2/trunk/c/tools/codegen/src/wsdl/engine.c Fri Sep 1 05:45:57 2006
@@ -0,0 +1,402 @@
+/*
+ * 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 <w2c_engine.h>
+#include <axis2_array_list.h>
+#include <axis2_hash.h>
+#include <axis2_string.h>
+#include <w2c_string.h>
+#include <w2c_cmdline_option.h>
+#include <w2c_cmdline_option_consts.h>
+#include <w2c_engine_configuration.h>
+#include <w2c_config_property_loader.h>
+#include <w2c_class_loader.h>
+#include <w2c_extension.h>
+#include <w2c_emitter.h>
+#include <w2c_messages.h>
+#include <stdio.h>
+#include <w2c_class_loader.h>
+#include <axis2_dll_desc.h>
+
+/**
+ * @brief
+ */
+typedef struct w2c_engine_impl
+{
+ w2c_engine_t engine;
+
+ axis2_array_list_t *pre_extensions;
+ axis2_array_list_t *post_extensions;
+ axis2_array_list_t *pre_extensions_dll_desc;
+ axis2_array_list_t *post_extensions_dll_desc;
+ w2c_engine_configuration_t *conf;
+ w2c_config_property_loader_t *prop_loader;
+
+} w2c_engine_impl_t;
+
+#define W2C_INTF_TO_IMPL(engine) \
+ ((w2c_engine_impl_t *) engine)
+
+/************************* Function prototypes ********************************/
+
+axis2_status_t AXIS2_CALL
+w2c_engine_free (w2c_engine_t *engine,
+ const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+w2c_engine_generate(w2c_engine_t *engine,
+ const axis2_env_t *env);
+
+/* private methods */
+static axis2_status_t
+w2c_engine_load_extension (w2c_engine_impl_t *engine_impl,
+ const axis2_env_t *env);
+static axis2_char_t*
+w2c_engine_get_base_uri ( axis2_char_t *current_uri, const axis2_env_t *env);
+
+/************************** End of function prototypes ************************/
+
+AXIS2_EXTERN w2c_engine_t* AXIS2_CALL
+w2c_engine_create_with_parser (const axis2_env_t *env,
+ w2c_cmdline_option_parser_t *parser)
+{
+ w2c_engine_impl_t *engine_impl = NULL;
+ axis2_hash_t *all_options = NULL;
+ axis2_char_t *wsdl_uri = NULL;
+ axis2_char_t *base_uri = NULL;
+ w2c_cmdline_option_t *option = NULL;
+ axis2_char_t *output_lang = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+ engine_impl = (w2c_engine_impl_t *) AXIS2_MALLOC(env->
+ allocator, sizeof(w2c_engine_impl_t));
+
+ if(NULL == engine_impl)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ engine_impl->engine.ops =
+ AXIS2_MALLOC (env->allocator, sizeof(w2c_engine_ops_t));
+ if(NULL == engine_impl->engine.ops)
+ {
+ w2c_engine_free(&(engine_impl->engine), env);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ engine_impl->engine.ops->free = w2c_engine_free;
+ engine_impl->engine.ops->generate = w2c_engine_generate;
+
+ /** initializing variables */
+ engine_impl-> pre_extensions = NULL;
+ engine_impl-> pre_extensions_dll_desc = NULL;
+ engine_impl-> post_extensions = NULL;
+ engine_impl-> post_extensions_dll_desc = NULL;
+
+ engine_impl->prop_loader = w2c_config_property_loader_create ( env);
+
+ all_options = W2C_CMDLINE_OPTION_PARSER_GET_OPTIONS (parser, env );
+ engine_impl-> conf =
+ w2c_engine_configuration_create_with_options ( env, all_options );
+
+ option = axis2_hash_get(all_options,
+ W2C_CMDLINE_OPTION_CONSTS_WSDL_LOCATION_URI,
+ AXIS2_HASH_KEY_STRING );
+
+ wsdl_uri = W2C_CMDLINE_OPTION_GET_VALUE (option, env );
+ W2C_ENGINE_CONFIGURATION_SET_WSDL_URI( engine_impl->conf,
+ env, wsdl_uri );
+
+ base_uri = w2c_engine_get_base_uri( wsdl_uri, env );
+ W2C_ENGINE_CONFIGURATION_SET_BASE_URI( engine_impl->conf,
+ env, base_uri );
+
+ /** engine_configuration can be changed by prop_loader as well*/
+ output_lang = W2C_ENGINE_CONFIGURATION_GET_OUTPUT_LANGUAGE
+ ( engine_impl-> conf, env );
+ if ( output_lang == NULL || *output_lang == '\0' )
+ {
+ output_lang=
+ W2C_CONFIG_PROPERTY_LOADER_GET_DEFAULT_LANGUAGE
+ (engine_impl->prop_loader, env);
+ output_lang = AXIS2_STRDUP( output_lang, env);
+ W2C_ENGINE_CONFIGURATION_SET_OUTPUT_LANGUAGE
+ ( engine_impl-> conf, env, output_lang );
+ if ( NULL == output_lang )
+ {
+ w2c_messages_print_n_log_error( env,
+ "engine.noDefaultLang");
+ return AXIS2_FAILURE;
+ }
+ }
+ w2c_engine_load_extension ( engine_impl, env );
+ return &(engine_impl->engine);
+}
+
+
+
+/***************************Function implementation****************************/
+
+axis2_status_t AXIS2_CALL
+w2c_engine_free (w2c_engine_t *engine,
+ const axis2_env_t *env)
+{
+ w2c_engine_impl_t *engine_impl = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ engine_impl = W2C_INTF_TO_IMPL(engine);
+
+ /* following should be free 1 by 1 after the extension developed */
+ if(engine_impl-> pre_extensions )
+ AXIS2_ARRAY_LIST_FREE (engine_impl-> pre_extensions, env );
+ if(engine_impl-> post_extensions )
+ AXIS2_ARRAY_LIST_FREE (engine_impl-> post_extensions, env );
+ if(engine_impl-> pre_extensions_dll_desc )
+ AXIS2_ARRAY_LIST_FREE (engine_impl-> pre_extensions_dll_desc, env );
+ if(engine_impl-> post_extensions_dll_desc )
+ AXIS2_ARRAY_LIST_FREE (engine_impl-> post_extensions_dll_desc, env );
+
+ if(engine_impl-> conf)
+ W2C_ENGINE_CONFIGURATION_FREE (engine_impl-> conf, env);
+ if(engine_impl-> prop_loader)
+ W2C_CONFIG_PROPERTY_LOADER_FREE( engine_impl-> prop_loader, env );
+
+ if(engine->ops)
+ {
+ AXIS2_FREE(env->allocator, engine->ops);
+ engine->ops = NULL;
+ }
+ if(engine_impl)
+ {
+ AXIS2_FREE(env->allocator, engine_impl);
+ engine_impl = NULL;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+w2c_engine_generate(w2c_engine_t *engine,
+ const axis2_env_t *env)
+{
+ w2c_engine_impl_t *engine_impl = NULL;
+ int size = 0;
+ int i = 0;
+ w2c_extension_t *ext = NULL;
+ w2c_emitter_t *emitter = NULL;
+ axis2_hash_t *emitter_map = NULL;
+ axis2_char_t *emit_name = NULL;
+ axis2_char_t *output_lang = NULL;
+ axis2_bool_t all_flag = AXIS2_FALSE;
+ axis2_bool_t only_flag = AXIS2_FALSE;
+ axis2_dll_desc_t *dll_desc = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ engine_impl = W2C_INTF_TO_IMPL(engine);
+
+ if ( engine_impl-> pre_extensions != NULL )
+ {
+ size = AXIS2_ARRAY_LIST_SIZE( engine_impl-> pre_extensions, env);
+ for (i = 0; i < size ; i++)
+ {
+ ext = (w2c_extension_t*)
+ AXIS2_ARRAY_LIST_GET( engine_impl-> pre_extensions, env, i);
+ W2C_EXTENSION_ENGAGE ( ext, env, engine_impl-> conf);
+ }
+ }
+
+ emitter_map = W2C_CONFIG_PROPERTY_LOADER_GET_LANGUAGE_EMITTER_MAP
+ ( engine_impl-> prop_loader, env );
+ output_lang = W2C_ENGINE_CONFIGURATION_GET_OUTPUT_LANGUAGE
+ ( engine_impl-> conf, env );
+ emit_name = (axis2_char_t*)axis2_hash_get ( emitter_map,
+ output_lang, AXIS2_HASH_KEY_STRING);
+ /* the place where emitter is loading */
+ emitter = w2c_class_loader_get_object_from_class_name
+ ( env, emit_name , W2C_CLASS_LOADER_EMITTER_PATH, &dll_desc );
+ if ( NULL == emitter)
+ {
+ w2c_messages_print_n_log_error( env,
+ "engine.emitterMissing");
+ return AXIS2_FAILURE;
+ }
+ status = W2C_EMITTER_SET_CONFIG( emitter, env, engine_impl-> conf,
+ engine_impl-> prop_loader );
+ if ( AXIS2_FAILURE == status )
+ {
+ w2c_messages_print_n_log_error( env,
+ "engine.errorEmit");
+ return AXIS2_FAILURE;
+ }
+ /* emit skel and stub */
+ all_flag = W2C_ENGINE_CONFIGURATION_GET_GENERATE_ALL
+ (engine_impl-> conf, env );
+ only_flag =
+ W2C_ENGINE_CONFIGURATION_GET_SERVER_SIDE ( engine_impl-> conf, env);
+ if (only_flag )
+ {
+ W2C_EMITTER_EMIT_SKEL( emitter, env );
+ if ( all_flag )
+ {
+ W2C_EMITTER_EMIT_STUB( emitter, env);
+ }
+ }
+ else
+ {
+ W2C_EMITTER_EMIT_STUB( emitter, env);
+ }
+
+ w2c_class_loader_free_loaded_class(env, dll_desc);
+
+ if ( engine_impl-> post_extensions != NULL )
+ {
+ size = AXIS2_ARRAY_LIST_SIZE( engine_impl-> post_extensions, env);
+ for (i = 0; i < size ; i++)
+ {
+ ext = (w2c_extension_t*)
+ AXIS2_ARRAY_LIST_GET( engine_impl-> post_extensions, env, i);
+ W2C_EXTENSION_ENGAGE( ext, env, engine_impl-> conf);
+ }
+ }
+ /** freeing used extension right here */
+ if ( engine_impl-> pre_extensions != NULL )
+ {
+ size = AXIS2_ARRAY_LIST_SIZE( engine_impl-> pre_extensions, env);
+ for (i = 0; i < size ; i++)
+ {
+ dll_desc = (axis2_dll_desc_t*)
+ AXIS2_ARRAY_LIST_GET( engine_impl-> pre_extensions_dll_desc, env, i);
+ /*w2c_class_loader_free_loaded_class(env, dll_desc);*/
+ }
+
+ if ( engine_impl-> post_extensions != NULL )
+ {
+ size = AXIS2_ARRAY_LIST_SIZE( engine_impl-> post_extensions, env);
+ for (i = 0; i < size ; i++)
+ {
+ dll_desc = (axis2_dll_desc_t*)
+ AXIS2_ARRAY_LIST_GET( engine_impl-> post_extensions_dll_desc, env, i);
+ /*w2c_class_loader_free_loaded_class(env, dll_desc);*/
+ }
+ } }
+ return AXIS2_SUCCESS;
+}
+
+/* private methods */
+static axis2_status_t
+w2c_engine_load_extension (w2c_engine_impl_t *engine_impl,
+ const axis2_env_t *env)
+{
+ axis2_array_list_t *extension_names = NULL;
+ w2c_config_property_loader_t *prop_loader = NULL;
+ axis2_char_t *class_name = NULL;
+ w2c_extension_t *ext = NULL;
+ axis2_dll_desc_t *dll_desc = NULL;
+ int size = 0;
+ int i = 0;
+
+ /* load pre extension */
+ prop_loader = engine_impl-> prop_loader;
+ extension_names =
+ W2C_CONFIG_PROPERTY_LOADER_GET_EXTENSION_CLASS_NAMES( prop_loader, env );
+ if ( extension_names != NULL)
+ {
+ engine_impl-> pre_extensions
+ = axis2_array_list_create ( env, 10 );
+ engine_impl-> pre_extensions_dll_desc
+ = axis2_array_list_create ( env, 10 );
+ size = AXIS2_ARRAY_LIST_SIZE ( extension_names ,env);
+ for ( i = 0; i < size; i ++ )
+ {
+ class_name = (axis2_char_t*)AXIS2_ARRAY_LIST_GET
+ ( extension_names, env , i );
+ ext = w2c_class_loader_get_object_from_class_name
+ ( env, class_name, W2C_CLASS_LOADER_EXTENSION_PATH, &dll_desc);
+ if ( NULL!= ext )
+ {
+ AXIS2_ARRAY_LIST_ADD_AT ( engine_impl-> pre_extensions,
+ env, i,(void*)ext);
+ AXIS2_ARRAY_LIST_ADD_AT (engine_impl-> pre_extensions_dll_desc,
+ env, i,(void*)dll_desc);
+ }
+ else
+ {
+ w2c_class_loader_free_loaded_class(env, dll_desc);
+ }
+ }
+ }
+ /* load post extension */
+ extension_names =
+ W2C_CONFIG_PROPERTY_LOADER_GET_POST_EXTENSION_CLASS_NAMES( prop_loader, env );
+
+ if ( extension_names != NULL)
+ {
+ engine_impl-> post_extensions
+ = axis2_array_list_create ( env, 10 );
+ engine_impl-> post_extensions_dll_desc
+ = axis2_array_list_create ( env, 10 );
+ size = AXIS2_ARRAY_LIST_SIZE ( extension_names ,env);
+ for ( i = 0; i < size; i ++ )
+ {
+ class_name = (axis2_char_t*)AXIS2_ARRAY_LIST_GET
+ ( extension_names, env , i );
+ ext = w2c_class_loader_get_object_from_class_name
+ ( env, class_name, W2C_CLASS_LOADER_EXTENSION_PATH, &dll_desc );
+ if ( NULL != ext )
+ {
+ AXIS2_ARRAY_LIST_ADD_AT ( engine_impl-> post_extensions,
+ env, i,ext );
+ AXIS2_ARRAY_LIST_ADD_AT (engine_impl-> post_extensions_dll_desc,
+ env, i,(void*)dll_desc);
+ }
+ else
+ {
+ w2c_class_loader_free_loaded_class(env, dll_desc);
+ }
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+static axis2_char_t*
+w2c_engine_get_base_uri ( axis2_char_t *current_uri, const axis2_env_t *env)
+{
+ axis2_char_t *base_uri = NULL;
+ int index = 0;
+ axis2_char_t *c = NULL;
+ int len = 0;
+
+ index = w2c_string_indexof_cs ( current_uri, "http://" );
+ if (index == 0 )
+ {
+ base_uri = AXIS2_STRDUP("file:", env);
+ base_uri = w2c_string_add_string ( base_uri, current_uri, env );
+ }
+ else
+ {
+ base_uri = AXIS2_STRDUP( current_uri, env );
+ }
+ /* retrieve the base uri */
+ len = AXIS2_STRLEN ( current_uri);
+ for ( c = base_uri + len-1 ; c !=base_uri && *c != '/' ; c -- );
+ *(c+1) = '\0';
+
+ return base_uri;
+}
Added: webservices/axis2/trunk/c/tools/codegen/src/wsdl/engine_config_loader.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/codegen/src/wsdl/engine_config_loader.c?rev=439295&view=auto
==============================================================================
--- webservices/axis2/trunk/c/tools/codegen/src/wsdl/engine_config_loader.c (added)
+++ webservices/axis2/trunk/c/tools/codegen/src/wsdl/engine_config_loader.c Fri Sep 1 05:45:57 2006
@@ -0,0 +1,419 @@
+/*
+ * 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 <w2c_engine_config_loader.h>
+#include <w2c_cmdline_option_consts.h>
+#include <axis2_hash.h>
+#include <axis2_array_list.h>
+#include <w2c_cmdline_option.h>
+#include <w2c_messages.h>
+#include <axis2_string.h>
+#include <w2c_string.h>
+#include <w2c_properties.h>
+
+#define W2C_ENGINE_CONFIG_LOADER_OUTPUT_DEFAULT "src"
+
+static w2c_cmdline_option_t*
+w2c_engine_config_loader_load_option(const axis2_env_t *env,
+ axis2_char_t *short_opt,axis2_char_t *long_opt,
+ axis2_hash_t *options);
+static void
+w2c_engine_config_loader_free_hash(const axis2_env_t *env, axis2_hash_t *h );
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+w2c_engine_config_loader_load_config(
+ const axis2_env_t *env,
+ w2c_engine_configuration_t *conf,
+ axis2_hash_t *option_map )
+{
+ w2c_cmdline_option_t *option = NULL;
+ axis2_char_t *tmp_string= NULL;
+ axis2_bool_t tmp_bool = AXIS2_FALSE;
+
+ /* used in creating map */
+ axis2_char_t *tag = NULL;
+ axis2_char_t *cp = NULL;
+ int loop_state = 0;
+ axis2_char_t *tmp_key = NULL;
+ axis2_hash_t *h = NULL;
+ axis2_hash_index_t *hi = NULL;
+ axis2_array_list_t *tmp_array = NULL;
+ w2c_properties_t *props = NULL;
+ int len = 0;
+
+ /* set output directory */
+ option = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_OUTPUT_LOCATION,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_OUTPUT_LOCATION,
+ option_map);
+
+ if (option != NULL)
+ {
+ tmp_string = W2C_CMDLINE_OPTION_GET_VALUE ( option , env );
+ }
+ else
+ {
+ tmp_string = AXIS2_STRDUP(W2C_ENGINE_CONFIG_LOADER_OUTPUT_DEFAULT, env );
+ }
+ /*TODO: should check for the vaildity of the output location */
+ W2C_ENGINE_CONFIGURATION_SET_OUTPUT_LOCATION( conf, env,
+ tmp_string);
+
+ /* set server side */
+ tmp_bool = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_SERVER_SIDE_CODE,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_SERVER_SIDE_CODE,
+ option_map) != NULL;
+ W2C_ENGINE_CONFIGURATION_SET_SERVER_SIDE ( conf, env,tmp_bool );
+
+ /* set service description*/
+ tmp_bool = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_SERVICE_DESCRIPTION,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_SERVICE_DESCRIPTION,
+ option_map) != NULL;
+ W2C_ENGINE_CONFIGURATION_SET_GENERATE_DEPLOYEMENT_DESCRIPTOR
+ (conf, env,tmp_bool );
+
+ /* by default both sync and asyn are generated */
+ W2C_ENGINE_CONFIGURATION_SET_ASYNC_ON ( conf, env, AXIS2_TRUE);
+ W2C_ENGINE_CONFIGURATION_SET_SYNC_ON ( conf, env, AXIS2_TRUE);
+
+ /* set async only flag */
+ tmp_bool = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_ASYNC_ONLY,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_ASYNC_ONLY,
+ option_map) != NULL;
+ W2C_ENGINE_CONFIGURATION_SET_SYNC_ON ( conf, env, !tmp_bool);
+
+ /* set sync only flag - this would have the priority*/
+ tmp_bool = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_SYNC_ONLY,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_SYNC_ONLY,
+ option_map) != NULL;
+ W2C_ENGINE_CONFIGURATION_SET_ASYNC_ON ( conf, env,!tmp_bool );
+
+ /* package option */
+ option = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_PACKAGE,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_PACKAGE,
+ option_map);
+
+ if (option)
+ {
+ tmp_string = W2C_CMDLINE_OPTION_GET_VALUE ( option, env );
+ W2C_ENGINE_CONFIGURATION_SET_PACKAGE_NAME ( conf, env, tmp_string);
+ }
+
+ /* lang option */
+ option = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_STUB_LANGUAGE,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_STUB_LANGUAGE,
+ option_map);
+
+ if ( option)
+ {
+ tmp_string = W2C_CMDLINE_OPTION_GET_VALUE ( option, env );
+ W2C_ENGINE_CONFIGURATION_SET_OUTPUT_LANGUAGE( conf, env, tmp_string);
+ }
+
+ /* databinding option */
+ option = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_DATA_BINDING_TYPE,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_DATA_BINDING_TYPE,
+ option_map);
+ if ( option)
+ {
+ tmp_string = W2C_CMDLINE_OPTION_GET_VALUE ( option, env );
+ W2C_ENGINE_CONFIGURATION_SET_DATABINDING_TYPE( conf, env, tmp_string);
+ }
+
+ /* set unpack classes */
+ tmp_bool = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_UNPACK_CLASSES,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_UNPACK_CLASSES,
+ option_map) != NULL;
+ W2C_ENGINE_CONFIGURATION_SET_PACK_CLASSES( conf, env, !tmp_bool);
+
+ /* port name option */
+ option = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_PORT_NAME,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_PORT_NAME,
+ option_map);
+ if ( option)
+ {
+ tmp_string = W2C_CMDLINE_OPTION_GET_VALUE ( option, env );
+ W2C_ENGINE_CONFIGURATION_SET_PORT_NAME( conf, env, tmp_string);
+ }
+
+ /* service name option */
+ option = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_SERVICE_NAME,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_SERVICE_NAME,
+ option_map);
+ if ( option)
+ {
+ tmp_string = W2C_CMDLINE_OPTION_GET_VALUE ( option, env );
+ W2C_ENGINE_CONFIGURATION_SET_SERVICE_NAME( conf, env, tmp_string);
+ }
+
+ /* repository path option */
+ option = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_REPOSITORY_PATH,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_REPOSITORY_PATH,
+ option_map);
+ if ( option)
+ {
+ tmp_string = W2C_CMDLINE_OPTION_GET_VALUE ( option, env );
+ W2C_ENGINE_CONFIGURATION_SET_REPOSITORY_PATH( conf, env, tmp_string);
+ }
+
+ /* server side code option*/
+ tmp_bool = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_SERVER_SIDE_CODE,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_SERVER_SIDE_CODE,
+ option_map) != NULL;
+ W2C_ENGINE_CONFIGURATION_SET_SERVERSIDE_INTERFACE
+ ( conf, env, tmp_bool);
+
+ /* generate all option*/
+ tmp_bool = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_GENERATE_ALL,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_GENERATE_ALL,
+ option_map) != NULL;
+ W2C_ENGINE_CONFIGURATION_SET_GENERATE_ALL
+ ( conf, env, tmp_bool);
+
+ /* convert names option*/
+ tmp_bool = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_CONVERT_NAMES,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_CONVERT_NAMES,
+ option_map) != NULL;
+ W2C_ENGINE_CONFIGURATION_SET_CONVERT_NAMES
+ ( conf, env, tmp_bool);
+
+ /* format code option*/
+ tmp_bool = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_INDENT_CODE,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_INDENT_CODE,
+ option_map) != NULL;
+ W2C_ENGINE_CONFIGURATION_SET_INDENT_CODE
+ ( conf, env, tmp_bool);
+
+
+ /* external mapping */
+ option = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_EXTERNAL_MAPPING,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_EXTERNAL_MAPPING,
+ option_map);
+ if ( option)
+ {
+ tmp_string = W2C_CMDLINE_OPTION_GET_VALUE ( option, env );
+ if (tmp_string )
+ {
+ W2C_ENGINE_CONFIGURATION_SET_TYPE_MAPPING_FILE( conf, env, tmp_string);
+ }
+ else
+ {
+ w2c_messages_print_n_log_error(env, "options.nomappingFile");
+ }
+ }
+
+ /* wsdl versioning*/
+ option = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_WSDL_VERSION,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_WSDL_VERSION,
+ option_map);
+ if ( option)
+ {
+ tmp_string = W2C_CMDLINE_OPTION_GET_VALUE ( option, env );
+ if (tmp_string )
+ {
+ W2C_ENGINE_CONFIGURATION_SET_WSDL_VERSION( conf, env, tmp_string);
+ }
+ else
+ {
+ W2C_ENGINE_CONFIGURATION_SET_WSDL_VERSION( conf, env,
+ W2C_CMDLINE_OPTION_CONSTS_WSDL_VERSION_1);
+ }
+ }
+
+ /* flattern files */
+ tmp_bool = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_FLATTEN_FILES,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_FLATTEN_FILES,
+ option_map) != NULL;
+ W2C_ENGINE_CONFIGURATION_SET_FLATTEN_FILES ( conf, env, tmp_bool);
+
+
+ /* namespace to package list*/
+ option = w2c_engine_config_loader_load_option( env,
+ W2C_CMDLINE_OPTION_CONSTS_NAME_SPACE_TO_PACKAGE,
+ W2C_CMDLINE_OPTION_CONSTS_LONG_NAME_SPACE_TO_PACKAGE,
+ option_map);
+ if ( option)
+ {
+ tmp_string = W2C_CMDLINE_OPTION_GET_VALUE ( option, env );
+ if (tmp_string)
+ {
+ h = axis2_hash_make (env );
+ loop_state = -1; /* 1 - started, 1 - '=' found 2- end*/
+ for ( cp = tmp_string; loop_state !=2 ; cp ++ )
+ {
+ if ( loop_state == -1 )
+ {
+ tag = cp;
+ loop_state = 0;
+ }
+ else if (*(cp-1) == '\0' )
+ {
+ tag = cp;
+ }
+ else if ( *cp == '=' )
+ {
+ if ( loop_state != -1 && loop_state != 0 )
+ {
+ w2c_messages_print_n_log_error( env,
+ "options.wrongNamespace2Package");
+ printf("wrong namespace to package"
+ " option-check %daxis2_char_t\n",
+ (int)(cp - tmp_string) );
+ w2c_engine_config_loader_free_hash ( env, h);
+ break;
+ }
+ *cp ='\0';
+ tmp_key = AXIS2_STRDUP ( tag, env );
+ loop_state = 1;
+ }
+ else if ( *cp ==',' || *cp=='\0' )
+ {
+ if ( *cp == '\0' && loop_state == 0 )
+ {
+ loop_state = -1;
+ break;
+ }
+ if ( loop_state != -1 && loop_state != 1)
+ {
+ w2c_messages_print_n_log_error( env,
+ "options.wrongNamespace2Package");
+ printf("wrong namespace to package"
+ " option-check %daxis2_char_t\n",
+ (int)(cp - tmp_string) );
+ w2c_engine_config_loader_free_hash ( env, h);
+ break;
+ }
+ if ( *cp =='\0')
+ loop_state = 2;
+ else
+ loop_state = 0;
+ *cp = '\0';
+ axis2_hash_set( h, tmp_key, AXIS2_HASH_KEY_STRING,
+ AXIS2_STRDUP ( tag, env ) );
+ }
+ }
+ if (loop_state == -1)
+ {
+ axis2_hash_free (h ,env); /*clear created hash*/
+ /* asumes option value is a filename */
+ props = w2c_properties_create( env, tmp_string, '\0');
+ h = W2C_PROPERTIES_GET_HASH( props, env);
+ if ( h == NULL)
+ {
+ w2c_messages_print_n_log_error(env, "options.noFile");
+ }
+ else
+ {
+ /* replace arraylist in each with string */
+ for (hi = axis2_hash_first(h , env) ;
+ hi; hi = axis2_hash_next(env, hi))
+ {
+ axis2_hash_this(hi, (void*)&tmp_key, NULL, (void*)&tmp_string);
+ tmp_key = AXIS2_STRDUP( tmp_key, env);
+ tmp_string = AXIS2_STRDUP ( tmp_string, env );
+ axis2_hash_set( h, tmp_key, AXIS2_HASH_KEY_STRING, tmp_string);
+ }
+ }
+ W2C_PROPERTIES_FREE( props, env);
+ }
+ W2C_ENGINE_CONFIGURATION_SET_URI2PACKAGEMAP( conf, env, h );
+ }
+ }
+
+ /* catch extra parameters */
+ h = NULL;
+ for (hi = axis2_hash_first(option_map , env) ;
+ hi; hi = axis2_hash_next(env, hi))
+ {
+ axis2_hash_this(hi, (void*)&tmp_key,
+ NULL, (void*)&tmp_array);
+ if ( w2c_string_indexof_cs
+ ( tmp_key, W2C_CMDLINE_OPTION_CONSTS_EXTRA_OPTIONTYPE_PREFIX)== 0 && tmp_array)
+ {
+ tmp_string = (char*)AXIS2_ARRAY_LIST_GET (tmp_array, env, 0 );
+ if ( h == NULL )
+ {
+ h = axis2_hash_make ( env );
+ }
+ len = AXIS2_STRLEN (W2C_CMDLINE_OPTION_CONSTS_EXTRA_OPTIONTYPE_PREFIX );
+ tmp_key = axis2_string_substring_starting_at ( tmp_key, len);
+ axis2_hash_set( h, tmp_key, AXIS2_HASH_KEY_STRING, tmp_string );
+ AXIS2_ARRAY_LIST_FREE ( tmp_array, env);
+ }
+ }
+ W2C_ENGINE_CONFIGURATION_SET_CONFIGURATION_PROPERTIES( conf, env, h );
+
+ return AXIS2_SUCCESS;
+}
+
+static w2c_cmdline_option_t*
+w2c_engine_config_loader_load_option(const axis2_env_t *env,
+ axis2_char_t *short_opt,axis2_char_t *long_opt,
+ axis2_hash_t *options_map)
+{
+ w2c_cmdline_option_t *option = NULL;
+ if (long_opt != NULL)
+ {
+ option = (w2c_cmdline_option_t*)axis2_hash_get(options_map,
+ long_opt, AXIS2_HASH_KEY_STRING);
+ if (option != NULL)
+ {
+ return option;
+ }
+ }
+ /* short option gets last precedence */
+ if (short_opt != NULL)
+ {
+ option = (w2c_cmdline_option_t*)axis2_hash_get(options_map,
+ short_opt, AXIS2_HASH_KEY_STRING);
+ }
+
+ return option;
+}
+
+static void
+w2c_engine_config_loader_free_hash(const axis2_env_t *env, axis2_hash_t *h )
+{
+ axis2_hash_index_t *hi = NULL;
+ axis2_char_t *key = NULL;
+ axis2_char_t *value =NULL;
+ for (hi = axis2_hash_first(h, env) ;
+ hi; hi = axis2_hash_next(env, hi))
+ {
+ axis2_hash_this(hi, (void*)&key, NULL, (void*)&value);
+ if ( value )AXIS2_FREE ( env-> allocator, value );
+ if ( key )AXIS2_FREE ( env-> allocator, key);
+ }
+ axis2_hash_free ( h , env);
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org