summaryrefslogtreecommitdiffstats
path: root/include/axis2_callback.h
blob: 84d09061fbdb301fad403360d643419eb7a65622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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_CALLBACK_H
#define AXIS2_CALLBACK_H

/**
 * @defgroup axis2_callback callback
 * @ingroup axis2_client_api
 * callback represents the callback mechanisms to be used in case of asynchronous
 * invocations. It holds the complete status of the invocation, the resulting
 * SOAP envelope and also callback specific data. One can define a function
 * to be called on complete of the callback as well as a function to be called
 * on error.
 * @{
 */

/**
 * @file axis2_callback.h
 */

#include <axis2_defines.h>
#include <axutil_env.h>
#include <axis2_async_result.h>
#include <axiom_soap_envelope.h>

#ifdef __cplusplus
extern "C"
{
#endif

    /** Type name for axis2_callback */
    typedef struct axis2_callback axis2_callback_t;

    /** Type name for function pointer to be called on complete of callback  */
    typedef axis2_status_t AXIS2_CALL
    axis2_on_complete_func_ptr(
        axis2_callback_t *,
        const axutil_env_t *);

    /** Type name for function pointer to be called on error of callback  */
    typedef axis2_status_t AXIS2_CALL
    axis2_on_error_func_ptr(
        axis2_callback_t *,
        const axutil_env_t *,
        int);

    /**
     * This function is called once the asynchronous operation is successfully 
     * completed and the result is available.
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @param result pointer to async result
     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE 
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axis2_callback_invoke_on_complete(
        axis2_callback_t * callback,
        const axutil_env_t * env,
        axis2_async_result_t * result);

    /**
     * This function is called once the asynchronous operation fails and 
     * the failure code returns. 
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @param exception error code representing the error
     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axis2_callback_report_error(
        axis2_callback_t * callback,
        const axutil_env_t * env,
        const int exception);

    /**
     * Gets the complete status for the callback. This method is useful 
     * for polling (busy waiting).
     * e.g.
     * <code>
     *      <pre>
     *          while(!axis2_callback_get_complete(callback, env)
     *          {
     *             sleep(10);
     *          }
     * do whatever you need here 
     *      </pre>
     * </code>
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @return AXIS2_TRUE if callback is complete, else AXIS2_FALSE
     */
    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
    axis2_callback_get_complete(
        const axis2_callback_t * callback,
        const axutil_env_t * env);

    /**
     * Sets the complete status.
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @param complete bool value representing the status
     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axis2_callback_set_complete(
        axis2_callback_t * callback,
        const axutil_env_t * env,
        const axis2_bool_t complete);

    /**
     * Gets the resulting SOAP envelope.
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @return result SOAP envelope if present, else NULL
     */
    AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL
    axis2_callback_get_envelope(
        const axis2_callback_t * callback,
        const axutil_env_t * env);

    /**
     * Sets the SOAP envelope.
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @param envelope pointer to SOAP envelope
     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axis2_callback_set_envelope(
        axis2_callback_t * callback,
        const axutil_env_t * env,
        axiom_soap_envelope_t * envelope);

    /**
     * Gets the resulting message context.
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @return result message context if present, else NULL
     */
    AXIS2_EXTERN axis2_msg_ctx_t *AXIS2_CALL
    axis2_callback_get_msg_ctx(
        const axis2_callback_t * callback,
        const axutil_env_t * env);

    /**
     * Sets the message context.
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @param msg_ctx pointer to message context
     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axis2_callback_set_msg_ctx(
        axis2_callback_t * callback,
        const axutil_env_t * env,
        axis2_msg_ctx_t * msg_ctx);

    /**
     * Gets error code representing the error.
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @return error code representing the error
     */
    AXIS2_EXTERN int AXIS2_CALL
    axis2_callback_get_error(
        const axis2_callback_t * callback,
        const axutil_env_t * env);

    /**
     * Sets the error code.
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @param error error code representing the error
     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axis2_callback_set_error(
        axis2_callback_t * callback,
        const axutil_env_t * env,
        const int error);

    /**
     * Sets the callback data.
     * @param callback pointer to callback struct
     * @param data pointer to data
     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axis2_callback_set_data(
        axis2_callback_t * callback,
        void *data);

    /**
     * Gets the callback data.
     * @param callback pointer to callback struct
     * @return pointer to callback data
     */
    AXIS2_EXTERN void *AXIS2_CALL
    axis2_callback_get_data(
        const axis2_callback_t * callback);

    /**
     * Sets the on complete callback function.
     * @param callback pointer to callback struct
     * @param f on complete callback function pointer
     */
    AXIS2_EXTERN void AXIS2_CALL
    axis2_callback_set_on_complete(
        axis2_callback_t * callback,
        axis2_on_complete_func_ptr f);

    /**
     * Sets the on error callback function.
     * @param callback pointer to callback struct
     * @param f on error callback function pointer
     */
    AXIS2_EXTERN void AXIS2_CALL
    axis2_callback_set_on_error(
        axis2_callback_t * callback,
        axis2_on_error_func_ptr f);

    /**
     * Frees callback struct.
     * @param callback pointer to callback struct
     * @param env pointer to environment struct
     * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
     */
    AXIS2_EXTERN void AXIS2_CALL
    axis2_callback_free(
        axis2_callback_t * callback,
        const axutil_env_t * env);

    /**
     * Creates a callback struct.
     * @param env pointer to environment struct
     * @return pointer to newly created callback struct
     */
    AXIS2_EXTERN axis2_callback_t *AXIS2_CALL
    axis2_callback_create(
        const axutil_env_t * env);

    /** @} */
#ifdef __cplusplus
}
#endif

#endif                          /* AXIS2_CALL_BACK_H */