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 da...@apache.org on 2006/01/23 03:18:23 UTC
svn commit: r371443 - in /webservices/axis2/trunk/c: include/axis2_stub.h
modules/core/clientapi/stub.c
Author: damitha
Date: Sun Jan 22 18:18:17 2006
New Revision: 371443
URL: http://svn.apache.org/viewcvs?rev=371443&view=rev
Log:
Added stub.* files
Added:
webservices/axis2/trunk/c/include/axis2_stub.h
webservices/axis2/trunk/c/modules/core/clientapi/stub.c
Added: webservices/axis2/trunk/c/include/axis2_stub.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_stub.h?rev=371443&view=auto
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_stub.h (added)
+++ webservices/axis2/trunk/c/include/axis2_stub.h Sun Jan 22 18:18:17 2006
@@ -0,0 +1,120 @@
+/*
+ * 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 AXIS2_STUB_H
+#define AXIS2_STUB_H
+
+#include <axis2_endpoint_ref.h>
+#include <axis2_call.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @file axis2_stub.h
+ * @brief Axis2c service skeleton that should be implemented by actual service
+ * wrappers
+ */
+
+/** @defgroup axis2_stub Axis2 Stub
+ * @ingroup axis2_core_clientapi
+ * @{
+ */
+
+typedef struct axis2_stub_ops axis2_stub_ops_t;
+typedef struct axis2_stub axis2_stub_t;
+
+AXIS2_DECLARE_DATA struct axis2_stub_ops
+{
+ axis2_status_t (AXIS2_CALL *
+ free)(axis2_stub_t *stub,
+ axis2_env_t **env);
+
+ axis2_status_t (AXIS2_CALL *
+ set_endpoint_ref) (axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_endpoint_ref_t *endpoint_ref);
+
+ axis2_status_t (AXIS2_CALL *
+ set_endpoint_uri) (axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_char_t *endpoint_uri);
+
+ axis2_status_t (AXIS2_CALL *
+ invoke_blocking) (axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_msg_ctx_t *msg_ctx);
+
+ axis2_status_t (AXIS2_CALL *
+ invoke_non_blocking) (axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_msg_ctx_t *msg_ctx,
+ axis2_callback_t *callback);
+
+
+} ;
+
+AXIS2_DECLARE_DATA struct axis2_stub
+{
+ axis2_stub_ops_t *ops;
+ axis2_array_list_t *func_array;
+};
+
+/**
+ * Creates axis2_stub struct
+ * @param endpoint reference
+ * @return pointer to newly created axis2_stub struct
+ */
+AXIS2_DECLARE(axis2_stub_t *)
+axis2_stub_create_with_endpoint_ref(axis2_env_t **env,
+ axis2_endpoint_ref_t *endpoint_ref);
+
+/**
+ * Creates axis2_stub struct
+ * @param endpoint uri
+ * @return pointer to newly created axis2_stub struct
+ */
+AXIS2_DECLARE(axis2_stub_t *)
+axis2_stub_create_with_endpoint_uri(axis2_env_t **env,
+ axis2_char_t *endpoint_uri);
+
+/*************************** Function macros **********************************/
+
+#define AXIS2_STUB_FREE(stub, env) \
+ ((stub)->ops->free (stub, env))
+
+#define AXIS2_STUB_SET_ENDPOINT_REF(stub, env, endpoint_ref) \
+ ((stub)->ops->set_endpoint_ref (stub, env, endpoint_ref))
+
+#define AXIS2_STUB_SET_ENDPOINT_URI(stub, env, endpoint_uri) \
+ ((stub)->ops->set_endpoint_uri (stub, env, endpoint_uri))
+
+#define AXIS2_STUB_INVOKE_BLOCKING(stub, env, msg_ctx) \
+ ((stub)->ops->invoke_blocking (stub, env, msg_ctx))
+
+#define AXIS2_STUB_INVOKE_NON_BLOCKING(stub, env, msg_ctx, callback) \
+ ((stub)->ops->invoke_non_blocking (stub, env, msg_ctx, callback))
+
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIS2_STUB_H */
Added: webservices/axis2/trunk/c/modules/core/clientapi/stub.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/clientapi/stub.c?rev=371443&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/clientapi/stub.c (added)
+++ webservices/axis2/trunk/c/modules/core/clientapi/stub.c Sun Jan 22 18:18:17 2006
@@ -0,0 +1,210 @@
+/*
+ * 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 <axis2_stub.h>
+#include <string.h>
+
+/**
+ * @brief
+ */
+typedef struct axis2_stub_impl
+{
+ axis2_stub_t stub;
+
+ axis2_call_t *call;
+
+} axis2_stub_impl_t;
+
+#define AXIS2_INTF_TO_IMPL(stub) \
+ ((axis2_stub_impl_t *) stub)
+
+/************************* Function prototypes ********************************/
+
+axis2_status_t AXIS2_CALL
+axis2_stub_free (axis2_stub_t *stub,
+ axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL
+axis2_stub_set_endpoint_ref (axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_endpoint_ref_t *endpoint_ref);
+
+axis2_status_t AXIS2_CALL
+axis2_stub_set_endpoint_uri (axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_char_t *endpoint_uri);
+
+
+/************************** End of function prototypes ************************/
+
+axis2_stub_t *AXIS2_CALL
+axis2_stub_create (axis2_env_t **env)
+{
+ axis2_stub_impl_t *stub_impl = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ stub_impl = (axis2_stub_impl_t *) AXIS2_MALLOC((*env)->
+ allocator, sizeof(axis2_stub_impl_t));
+
+ if(NULL == stub_impl)
+ {
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ stub_impl->call = NULL;
+ stub_impl->stub.ops = NULL;
+
+ stub_impl->stub.ops =
+ AXIS2_MALLOC ((*env)->allocator, sizeof(axis2_stub_ops_t));
+ if(NULL == stub_impl->stub.ops)
+ {
+ axis2_stub_free(&(stub_impl->stub), env);
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ stub_impl->stub.ops->free = axis2_stub_free;
+ stub_impl->stub.ops->set_endpoint_ref = axis2_stub_set_endpoint_ref;
+ stub_impl->stub.ops->set_endpoint_uri = axis2_stub_set_endpoint_uri;
+
+ return &(stub_impl->stub);
+}
+
+axis2_stub_t * AXIS2_CALL
+axis2_stub_create_with_endpoint_ref (axis2_env_t **env,
+ axis2_endpoint_ref_t *endpoint_ref)
+{
+ axis2_stub_impl_t *stub_impl = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+ AXIS2_PARAM_CHECK((*env)->error, endpoint_ref, NULL);
+
+ stub_impl = (axis2_stub_impl_t *) axis2_stub_create(env);
+ if(!stub_impl)
+ {
+ axis2_stub_free(&(stub_impl->stub), env);
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ /* create call without passing svc_ctx_t struct */
+ stub_impl->call = axis2_call_create(env, NULL);
+ if(!stub_impl->call)
+ {
+ axis2_stub_free(&(stub_impl->stub), env);
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ AXIS2_CALL_SET_TO(stub_impl->call, env, endpoint_ref);
+
+ return &(stub_impl->stub);
+}
+
+axis2_stub_t * AXIS2_CALL
+axis2_stub_create_with_end_point_uri (axis2_env_t **env,
+ axis2_char_t *endpoint_uri)
+{
+ axis2_stub_impl_t *stub_impl = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+ AXIS2_PARAM_CHECK((*env)->error, endpoint_uri, NULL);
+
+ endpoint_ref = axis2_endpoint_ref_create(env, endpoint_uri);
+ if(!endpoint_ref)
+ {
+ return NULL;
+ }
+ stub_impl = (axis2_stub_impl_t *) axis2_stub_create_with_endpoint_ref(env,
+ endpoint_ref);
+
+ if(!stub_impl)
+ {
+ axis2_stub_free(&(stub_impl->stub), env);
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ return &(stub_impl->stub);
+}
+
+/***************************Function implementation****************************/
+
+axis2_status_t AXIS2_CALL
+axis2_stub_free (axis2_stub_t *stub,
+ axis2_env_t **env)
+{
+ axis2_stub_impl_t *stub_impl = NULL;
+
+ AXIS2_FUNC_PARAM_CHECK(stub, env, AXIS2_FAILURE);
+
+ stub_impl = AXIS2_INTF_TO_IMPL(stub);
+
+ if(NULL != stub->ops)
+ {
+ AXIS2_FREE((*env)->allocator, stub->ops);
+ stub->ops = NULL;
+ }
+
+ if(NULL != stub_impl->call)
+ {
+ AXIS2_CALL_FREE(stub_impl->call, env);
+ stub_impl->call = NULL;
+ }
+
+ if(stub_impl)
+ {
+ AXIS2_FREE((*env)->allocator, stub_impl);
+ stub_impl = NULL;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_stub_set_endpoint_ref (axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_endpoint_ref_t *endpoint_ref)
+{
+ axis2_stub_impl_t *stub_impl = NULL;
+
+ AXIS2_FUNC_PARAM_CHECK(stub,env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK((*env)->error, endpoint_ref, AXIS2_FAILURE);
+ stub_impl = AXIS2_INTF_TO_IMPL(stub);
+
+ return AXIS2_CALL_SET_TO(stub_impl->call, env, endpoint_ref);
+}
+
+axis2_status_t AXIS2_CALL
+axis2_stub_set_endpoint_uri (axis2_stub_t *stub,
+ axis2_env_t **env,
+ axis2_char_t *endpoint_uri)
+{
+ axis2_stub_impl_t *stub_impl = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+
+ AXIS2_FUNC_PARAM_CHECK(stub,env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK((*env)->error, endpoint_uri, AXIS2_FAILURE);
+ stub_impl = AXIS2_INTF_TO_IMPL(stub);
+
+ endpoint_ref = axis2_endpoint_ref_create(env, endpoint_uri);
+ if(!endpoint_ref)
+ {
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_CALL_SET_TO(stub_impl->call, env, endpoint_ref);
+}