# service context
[Context Hierarchy]

## Files
file | axis2_svc_ctx.h
## Typedefs
typedef struct axis2_svc_ctx | axis2_svc_ctx_t
## Functions
AXIS2_EXTERN axis2_svc_ctx_t * | axis2_svc_ctx_create (const axutil_env_t *env, struct axis2_svc *svc, struct axis2_svc_grp_ctx *svc_grp_ctx)
AXIS2_EXTERN axis2_ctx_t * | axis2_svc_ctx_get_base (const axis2_svc_ctx_t *svc_ctx, const axutil_env_t *env)
AXIS2_EXTERN struct axis2_svc_grp_ctx * | axis2_svc_ctx_get_parent (const axis2_svc_ctx_t *svc_ctx, const axutil_env_t *env)
AXIS2_EXTERN axis2_status_t | axis2_svc_ctx_set_parent (axis2_svc_ctx_t *svc_ctx, const axutil_env_t *env, struct axis2_svc_grp_ctx *parent)
AXIS2_EXTERN void | axis2_svc_ctx_free (struct axis2_svc_ctx *svc_ctx, const axutil_env_t *env)
AXIS2_EXTERN axis2_status_t | axis2_svc_ctx_init (struct axis2_svc_ctx *svc_ctx, const axutil_env_t *env, struct axis2_conf *conf)
AXIS2_EXTERN const axis2_char_t * | axis2_svc_ctx_get_svc_id (const axis2_svc_ctx_t *svc_ctx, const axutil_env_t *env)
AXIS2_EXTERN struct axis2_svc * | axis2_svc_ctx_get_svc (const axis2_svc_ctx_t *svc_ctx, const axutil_env_t *env)
AXIS2_EXTERN axis2_status_t | axis2_svc_ctx_set_svc (axis2_svc_ctx_t *svc_ctx, const axutil_env_t *env, struct axis2_svc *svc)
AXIS2_EXTERN struct axis2_conf_ctx * | axis2_svc_ctx_get_conf_ctx (const axis2_svc_ctx_t *svc_ctx, const axutil_env_t *env)
AXIS2_EXTERN struct axis2_op_ctx * | axis2_svc_ctx_create_op_ctx (struct axis2_svc_ctx *svc_ctx, const axutil_env_t *env, const axutil_qname_t *qname)

## Detailed Description

service context represents a running "instance" of a service. service context allows instance of operations belonging to a service to be grouped.

## Typedef Documentation

typedef struct axis2_svc_ctx axis2_svc_ctx_t

Type name for struct axis2_svc_ctx

## Function Documentation

AXIS2_EXTERN axis2_svc_ctx_t* axis2_svc_ctx_create | ( | const axutil_env_t * | env,
|  | struct axis2_svc * | svc,
|  | struct axis2_svc_grp_ctx * | svc_grp_ctx |
| ) |  |  |

Creates a service context struct that corresponds to the given service and with the given parent service group context.

Parameters:

  | env | pointer to environment struct
  | svc | pointer to service that this service context represents, service context does not assume the ownership of service
  | svc_grp_ctx | pointer to service group context, the parent of the newly created service context. service context does not assume the ownership of parent

Returns:
  pointer to newly created service context

AXIS2_EXTERN struct axis2_op_ctx* axis2_svc_ctx_create_op_ctx | ( | struct axis2_svc_ctx * | svc_ctx,
|  | const axutil_env_t * | env,
|  | const axutil_qname_t * | qname |
| ) |  |  | `[read]`

Creates an operation context for the named operation. The named operation should be one of the operations in the service related to this service context.

Parameters:

  | svc_ctx | pointer to service context
  | env | pointer to environment struct
  | qname | pointer to qname that represents the operation name.

Returns:
  pointer to operation context

AXIS2_EXTERN void axis2_svc_ctx_free | ( | struct axis2_svc_ctx * | svc_ctx,
|  | const axutil_env_t * | env |
| ) |  |  |

Frees service context instance.

Parameters:

  | svc_ctx | pointer to service context
  | env | pointer to environment struct

Returns:
  void

AXIS2_EXTERN axis2_ctx_t* axis2_svc_ctx_get_base | ( | const axis2_svc_ctx_t * | svc_ctx,
|  | const axutil_env_t * | env |
| ) |  |  |

Gets base which is of type context.

Parameters:

  | svc_ctx | pointer to service context
  | env | pointer to environment struct

Returns:
  pointer to context, returns a reference, not a cloned copy

AXIS2_EXTERN struct axis2_conf_ctx* axis2_svc_ctx_get_conf_ctx | ( | const axis2_svc_ctx_t * | svc_ctx,
|  | const axutil_env_t * | env |
| ) |  |  | `[read]`

Gets configuration context which is the super root (super most parent) of the context hierarchy to which this service context belongs.

Parameters:

  | svc_ctx | pointer to service context
  | env | pointer to environment struct

Returns:
  pointer to configuration context

AXIS2_EXTERN struct axis2_svc_grp_ctx* axis2_svc_ctx_get_parent | ( | const axis2_svc_ctx_t * | svc_ctx,
|  | const axutil_env_t * | env |
| ) |  |  | `[read]`

Gets parent which is of type service group context.

Parameters:

  | svc_ctx | pointer to service context
  | env | pointer to environment struct

Returns:
  pointer to parent service group context

AXIS2_EXTERN struct axis2_svc* axis2_svc_ctx_get_svc | ( | const axis2_svc_ctx_t * | svc_ctx,
|  | const axutil_env_t * | env |
| ) |  |  | `[read]`

Gets the service that this service context represents.

Parameters:

  | svc_ctx | pointer to service context
  | env | pointer to environment struct

Returns:
  pointer to service, returns a reference, not a cloned copy

AXIS2_EXTERN const axis2_char_t* axis2_svc_ctx_get_svc_id | ( | const axis2_svc_ctx_t * | svc_ctx,
|  | const axutil_env_t * | env |
| ) |  |  |

Gets the ID of the service that this service context is an instance of.

Parameters:

  | svc_ctx | pointer to service context
  | env | pointer to environment struct

Returns:
  service ID string.

AXIS2_EXTERN axis2_status_t axis2_svc_ctx_init | ( | struct axis2_svc_ctx * | svc_ctx,
|  | const axutil_env_t * | env,
|  | struct axis2_conf * | conf |
| ) |  |  |

Initializes service context. This method locates the corresponding service that is related to the service context from configuration using service qname and keeps a reference to it for future use.

Parameters:

  | svc_ctx | pointer to service context
  | env | pointer to environment struct
  | conf | pointer to configuration

Returns:
  AXIS2_SUCCESS on success, else AXIS2_FAILURE

AXIS2_EXTERN axis2_status_t axis2_svc_ctx_set_parent | ( | axis2_svc_ctx_t * | svc_ctx,
|  | const axutil_env_t * | env,
|  | struct axis2_svc_grp_ctx * | parent |
| ) |  |  |

Sets parent which is of type service group context.

Parameters:

  | svc_ctx | pointer to service context
  | env | pointer to environment struct
  | parent | parent of service context which is of type service group context

Returns:
  AXIS2_SUCCESS on success, else AXIS2_FAILURE

AXIS2_EXTERN axis2_status_t axis2_svc_ctx_set_svc | ( | axis2_svc_ctx_t * | svc_ctx,
|  | const axutil_env_t * | env,
|  | struct axis2_svc * | svc |
| ) |  |  |

Sets the service that this service context represents.

Parameters:

  | svc_ctx | pointer to service context
  | env | pointer to environment struct
  | svc | pointer to service struct, service context does not assume the ownership of the struct

Returns:
  AXIS2_SUCCESS on success, else AXIS2_FAILURE