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 sa...@apache.org on 2005/11/28 06:11:11 UTC
svn commit: r349373 - in /webservices/axis2/trunk/c: include/axis2_svc_ctx.h
modules/core/context/src/Makefile.am modules/core/context/src/svc_ctx.c
Author: samisa
Date: Sun Nov 27 21:10:59 2005
New Revision: 349373
URL: http://svn.apache.org/viewcvs?rev=349373&view=rev
Log:
Added initial compiling version of service context
Added:
webservices/axis2/trunk/c/include/axis2_svc_ctx.h
webservices/axis2/trunk/c/modules/core/context/src/svc_ctx.c
Modified:
webservices/axis2/trunk/c/modules/core/context/src/Makefile.am
Added: webservices/axis2/trunk/c/include/axis2_svc_ctx.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_svc_ctx.h?rev=349373&view=auto
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_svc_ctx.h (added)
+++ webservices/axis2/trunk/c/include/axis2_svc_ctx.h Sun Nov 27 21:10:59 2005
@@ -0,0 +1,106 @@
+/*
+ * 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_SVC_CTX_H
+#define AXIS2_SVC_CTX_H
+
+
+/**
+ * @file axis2_svc_ctx.h
+ * @brief axis2 Message Context interface
+ */
+
+#include <axis2_defines.h>
+#include <axis2_env.h>
+#include <axis2_operation_ctx.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** @defgroup axis2_svc_ctx Message Context
+ * @ingroup axis2_core_context
+ * @{
+ */
+
+typedef struct axis2_svc_ctx_ops axis2_svc_ctx_ops_t;
+typedef struct axis2_svc_ctx axis2_svc_ctx_t;
+
+
+/**
+ * @brief Message Context operations struct
+ * Encapsulator struct for operations of axis2_svc_ctx
+ */
+struct axis2_svc_ctx_ops
+{
+ axis2_ctx_t* (AXIS2_CALL *get_base)(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+ struct axis2_svc_grp_ctx* (AXIS2_CALL *get_parent)(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+ axis2_status_t (AXIS2_CALL *free)(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+ /**
+ * The method is used to do the intialization of the EngineContext
+ */
+ axis2_status_t (AXIS2_CALL *init)(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env,
+ axis2_engine_config_t *engine_config);
+ /**
+ * @return Returns the svc_id.
+ */
+ axis2_char_t* (AXIS2_CALL *get_svc_id)(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+ axis2_svc_t* (AXIS2_CALL *get_svc)(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+ struct axis2_conf_ctx* (AXIS2_CALL *get_conf_ctx)(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+ axis2_operation_ctx_t* (AXIS2_CALL *create_operation_ctx)(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env, axis2_qname_t *qname);
+};
+
+/**
+ * @brief Message Context struct
+ * Axis2 Message Context
+ */
+struct axis2_svc_ctx
+{
+ axis2_svc_ctx_ops_t *ops;
+};
+
+AXIS2_DECLARE(axis2_svc_ctx_t*) axis2_svc_ctx_create(axis2_env_t **env,
+ axis2_svc_t *svc,
+ struct axis2_svc_grp_ctx *svc_grp_ctx);
+
+/************************** Start of function macros **************************/
+
+#define AXIS2_SVC_CTX_GET_BASE(svc_ctx, env) ((svc_ctx)->ops->get_base(svc_ctx, env))
+#define AXIS2_SVC_CTX_GET_PARENT(svc_ctx, env) ((svc_ctx)->ops->get_parent(svc_ctx, env))
+#define AXIS2_SVC_CTX_FREE(svc_ctx, env) ((svc_ctx)->ops->free(svc_ctx, env))
+#define AXIS2_SVC_CTX_INIT(svc_ctx, env, engine_config) ((svc_ctx)->ops->init(svc_ctx, env, engine_config))
+#define AXIS2_SVC_CTX_GET_SVC_ID(svc_ctx, env) ((svc_ctx)->ops->get_svc_id(svc_ctx, env))
+#define AXIS2_SVC_CTX_GET_SVC(svc_ctx, env) ((svc_ctx)->ops->get_svc(svc_ctx, env))
+#define AXIS2_SVC_CTX_GET_CONF_CTX(svc_ctx, env) ((svc_ctx)->ops->get_conf_ctx(svc_ctx, env))
+#define AXIS2_SVC_CTX_CREATE_OPERATION_CTX(svc_ctx, env, qname) ((svc_ctx)->ops->create_operation_ctx(svc_ctx, env, qname))
+
+/************************** End of function macros ****************************/
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIS2_SVC_CTX_H */
Modified: webservices/axis2/trunk/c/modules/core/context/src/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/context/src/Makefile.am?rev=349373&r1=349372&r2=349373&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/context/src/Makefile.am (original)
+++ webservices/axis2/trunk/c/modules/core/context/src/Makefile.am Sun Nov 27 21:10:59 2005
@@ -1,6 +1,6 @@
lib_LTLIBRARIES = libaxis2_context.la
AM_CPPFLAGS = $(CPPFLAGS)
-libaxis2_context_la_SOURCES = ctx.c msg_ctx.c
+libaxis2_context_la_SOURCES = ctx.c msg_ctx.c operation_ctx.c svc_ctx.c
libaxis2_context_la_LIBADD = $(LDFLAGS)
INCLUDES = -I${CUTEST_HOME}/include \
Added: webservices/axis2/trunk/c/modules/core/context/src/svc_ctx.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/context/src/svc_ctx.c?rev=349373&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/context/src/svc_ctx.c (added)
+++ webservices/axis2/trunk/c/modules/core/context/src/svc_ctx.c Sun Nov 27 21:10:59 2005
@@ -0,0 +1,232 @@
+/*
+ * 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_svc_ctx.h>
+#include <axis2.h>
+#include <axis2_hash.h>
+
+typedef struct axis2_svc_ctx_impl
+{
+ /** context base struct */
+ axis2_svc_ctx_t svc_ctx;
+ /** base context struct */
+ axis2_ctx_t *base;
+ /** parent of operation context is a service context instance */
+ struct axis2_svc_grp_ctx *parent;
+ /** service associated with this service context */
+ axis2_svc_t *svc;
+ /** id of the service associated with this context */
+ axis2_char_t *svc_id;
+ /** service qname */
+ axis2_qname_t *svc_qname;
+} axis2_svc_ctx_impl_t;
+
+/** Interface to implementation conversion macro */
+#define AXIS2_INTF_TO_IMPL(svc_ctx) ((axis2_svc_ctx_impl_t *)svc_ctx)
+
+axis2_ctx_t* AXIS2_CALL axis2_svc_ctx_get_base(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+struct axis2_svc_grp_ctx * AXIS2_CALL axis2_svc_ctx_get_parent(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+axis2_status_t AXIS2_CALL axis2_svc_ctx_free(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+axis2_status_t AXIS2_CALL axis2_svc_ctx_init(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env,
+ axis2_engine_config_t *engine_config);
+axis2_char_t* AXIS2_CALL axis2_svc_ctx_get_svc_id(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+axis2_svc_t* AXIS2_CALL axis2_svc_ctx_get_svc(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+struct axis2_conf_ctx* AXIS2_CALL axis2_svc_ctx_get_conf_ctx(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env);
+axis2_operation_ctx_t* AXIS2_CALL axis2_svc_ctx_create_operation_ctx(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env, axis2_qname_t *qname);
+
+axis2_svc_ctx_t* AXIS2_CALL axis2_svc_ctx_create(axis2_env_t **env,
+ axis2_svc_t *svc,
+ struct axis2_svc_grp_ctx *svc_grp_ctx)
+{
+ axis2_svc_ctx_impl_t *svc_ctx_impl = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ svc_ctx_impl = AXIS2_MALLOC( (*env)->allocator, sizeof(axis2_svc_ctx_impl_t) );
+ if (!svc_ctx_impl)
+ {
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ svc_ctx_impl->svc_ctx.ops = NULL;
+ svc_ctx_impl->base = NULL;
+ svc_ctx_impl->parent = NULL;
+ svc_ctx_impl->svc = NULL;
+ svc_ctx_impl->svc_id = NULL;
+ svc_ctx_impl->svc_qname = NULL;
+
+ svc_ctx_impl->base = axis2_ctx_create(env);
+ if (!(svc_ctx_impl->base))
+ {
+ axis2_svc_ctx_free(&(svc_ctx_impl->svc_ctx), env);
+ return NULL;
+ }
+
+ if (svc)
+ {
+ svc_ctx_impl->svc = svc;
+ svc_ctx_impl->svc_qname = AXIS2_SVC_GET_NAME(svc, env);
+ if (svc_ctx_impl->svc_qname)
+ {
+ svc_ctx_impl->svc_id = AXIS2_QNAME_GET_LOCALPART(svc_ctx_impl->svc_qname, env);
+ }
+ }
+
+ if (svc_grp_ctx)
+ {
+ svc_ctx_impl->parent = svc_grp_ctx;
+ }
+
+ /* initialize operations */
+
+ svc_ctx_impl->svc_ctx.ops = AXIS2_MALLOC( (*env)->allocator, sizeof(axis2_svc_ctx_ops_t) );
+ if (!svc_ctx_impl->svc_ctx.ops)
+ {
+ AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ axis2_svc_ctx_free(&(svc_ctx_impl->svc_ctx), env);
+ return NULL;
+ }
+
+ svc_ctx_impl->svc_ctx.ops->get_base = axis2_svc_ctx_get_base;
+ svc_ctx_impl->svc_ctx.ops->get_parent = axis2_svc_ctx_get_parent;
+ svc_ctx_impl->svc_ctx.ops->free = axis2_svc_ctx_free;
+ svc_ctx_impl->svc_ctx.ops->init = axis2_svc_ctx_init;
+ svc_ctx_impl->svc_ctx.ops->get_svc_id = axis2_svc_ctx_get_svc_id;
+ svc_ctx_impl->svc_ctx.ops->get_svc = axis2_svc_ctx_get_svc;
+ svc_ctx_impl->svc_ctx.ops->get_conf_ctx = axis2_svc_ctx_get_conf_ctx;
+ svc_ctx_impl->svc_ctx.ops->create_operation_ctx = axis2_svc_ctx_create_operation_ctx;
+
+ return &(svc_ctx_impl->svc_ctx);
+}
+
+axis2_ctx_t* AXIS2_CALL axis2_svc_ctx_get_base(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env)
+{
+ AXIS2_FUNC_PARAM_CHECK(svc_ctx, env, NULL);
+ return AXIS2_INTF_TO_IMPL(svc_ctx)->base;
+}
+
+
+struct axis2_svc_grp_ctx * AXIS2_CALL axis2_svc_ctx_get_parent(struct axis2_svc_ctx *svc_ctx, axis2_env_t **env)
+{
+ AXIS2_FUNC_PARAM_CHECK(svc_ctx, env, NULL);
+ return AXIS2_INTF_TO_IMPL(svc_ctx)->parent;
+}
+
+
+
+axis2_status_t AXIS2_CALL axis2_svc_ctx_free (struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env)
+{
+ axis2_svc_ctx_impl_t *svc_ctx_impl = NULL;
+
+ AXIS2_FUNC_PARAM_CHECK(svc_ctx, env, AXIS2_FAILURE);
+
+ svc_ctx_impl = AXIS2_INTF_TO_IMPL(svc_ctx);
+
+ if (svc_ctx_impl->svc_ctx.ops)
+ {
+ AXIS2_FREE((*env)->allocator, svc_ctx_impl->svc_ctx.ops);
+ svc_ctx_impl->svc_ctx.ops = NULL;
+ }
+
+ if (svc_ctx_impl->base)
+ {
+ AXIS2_CTX_FREE(svc_ctx_impl->base, env);
+ svc_ctx_impl->base = NULL;
+ }
+
+ AXIS2_FREE((*env)->allocator, svc_ctx_impl);
+ svc_ctx_impl = NULL;
+
+ return AXIS2_SUCCESS;
+}
+
+
+/**
+ * The method is used to do the intialization of the EngineContext
+ */
+axis2_status_t AXIS2_CALL init(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env,
+ axis2_engine_config_t *engine_config)
+{
+ axis2_svc_ctx_impl_t *svc_ctx_impl = NULL;
+
+ AXIS2_FUNC_PARAM_CHECK(svc_ctx, env, AXIS2_FAILURE);
+
+ svc_ctx_impl = AXIS2_INTF_TO_IMPL(svc_ctx);
+
+ if (svc_ctx_impl->svc_qname)
+ {
+ axis2_char_t *svc_name = AXIS2_QNAME_GET_LOCALPART(svc_ctx_impl->svc_qname, env);
+ svc_ctx_impl->svc = AXIS2_ENGINE_CONFIG_GET_SVC(engine_config, env, svc_name);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+/**
+ * @return Returns the svc_id.
+ */
+axis2_char_t* AXIS2_CALL get_svc_id(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env)
+{
+ AXIS2_FUNC_PARAM_CHECK(svc_ctx, env, NULL);
+ return AXIS2_INTF_TO_IMPL(svc_ctx)->svc_id;
+}
+
+
+axis2_svc_t* AXIS2_CALL get_svc(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env)
+{
+ AXIS2_FUNC_PARAM_CHECK(svc_ctx, env, NULL);
+ return AXIS2_INTF_TO_IMPL(svc_ctx)->svc;
+}
+
+struct axis2_conf_ctx* AXIS2_CALL get_conf_ctx(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env)
+{
+ AXIS2_FUNC_PARAM_CHECK(svc_ctx, env, NULL);
+ return NULL; /*(struct axis2_conf_ctx *) AXIS2_SVC_GRP_CTX_GET_PARENT(AXIS2_INTF_TO_IMPL(svc_ctx)->parent, env);*/
+}
+
+axis2_operation_ctx_t* AXIS2_CALL create_operation_ctx(struct axis2_svc_ctx *svc_ctx,
+ axis2_env_t **env, axis2_qname_t *qname)
+{
+ axis2_svc_ctx_impl_t *svc_ctx_impl = NULL;
+ axis2_operation_t *operation = NULL;
+
+ AXIS2_FUNC_PARAM_CHECK(svc_ctx, env, NULL);
+
+ svc_ctx_impl = AXIS2_INTF_TO_IMPL(svc_ctx);
+
+ if (svc_ctx_impl->svc)
+ {
+ /*operation = AXIS2_SVC_GET_OPERATION_WITH_QNAME(svc_ctx_impl->svc, env, qname);
+ return axis2_operation_ctx_create(env, operation, svc_ctx);*/
+ }
+
+ return NULL;
+}