You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by na...@apache.org on 2006/03/07 01:27:41 UTC
svn commit: r383724 - in /webservices/axis/trunk/c: include/axis/Axis.h
src/cbindings/AxisC.cpp
Author: nadiramra
Date: Mon Mar 6 16:27:41 2006
New Revision: 383724
URL: http://svn.apache.org/viewcvs?rev=383724&view=rev
Log:
C support fixes/enhancements.
Modified:
webservices/axis/trunk/c/include/axis/Axis.h
webservices/axis/trunk/c/src/cbindings/AxisC.cpp
Modified: webservices/axis/trunk/c/include/axis/Axis.h
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/include/axis/Axis.h?rev=383724&r1=383723&r2=383724&view=diff
==============================================================================
--- webservices/axis/trunk/c/include/axis/Axis.h (original)
+++ webservices/axis/trunk/c/include/axis/Axis.h Mon Mar 6 16:27:41 2006
@@ -54,14 +54,14 @@
* @return AXISC_SUCCESS or AXISC_FAIL to indicate success or fail
*/
AXISC_STORAGE_CLASS_INFO
-void axiscInitializeAxis(AxiscBool bIsServer);
+int axiscInitializeAxis(AxiscBool bIsServer);
/**
* Terminates the Axis runtime.
* @return AXISC_SUCCESS or AXISC_FAIL to indicate success or fail
*/
AXISC_STORAGE_CLASS_INFO
-void axiscTerminate();
+int axiscTerminate();
/**
* Deletes storage allocated by the Axis engine, that is no longer required
@@ -72,7 +72,28 @@
* @return AXISC_SUCCESS or AXISC_FAIL to indicate success or fail
*/
AXISC_STORAGE_CLASS_INFO
-void axiscAxisDelete(void * pValue, AXISC_XSDTYPE type);
+int axiscAxisDelete(void * pValue, AXISC_XSDTYPE type);
+
+/**
+ * Registers a function that will be invoked to handle Axis engine
+ * exceptions. The function will be called with two parameters,
+ * the error code and the error message, if any.
+ *
+ * @param fp - pointer to exception handler function.
+ */
+AXISC_STORAGE_CLASS_INFO
+void axiscRegisterExceptionHandler(void (*fp)(int errorCode, const char *errorString));
+
+/**
+ * Invokes the registered exception handler. If an exception handler was not
+ * registered, the errorCode and errorString are printed to stderr.
+ *
+ * @param errorCode - error code.
+ * @param errorString - error string.
+ */
+
+AXISC_STORAGE_CLASS_INFO
+void axiscInvokeExceptionHandler(int errorCode, const char *errorString);
#ifdef __cplusplus
}
Modified: webservices/axis/trunk/c/src/cbindings/AxisC.cpp
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/c/src/cbindings/AxisC.cpp?rev=383724&r1=383723&r2=383724&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/cbindings/AxisC.cpp (original)
+++ webservices/axis/trunk/c/src/cbindings/AxisC.cpp Mon Mar 6 16:27:41 2006
@@ -14,8 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#include <iostream>
#include <axis/Axis.hpp>
+#include <axis/AxisException.hpp>
+
AXIS_CPP_NAMESPACE_USE
extern "C" {
@@ -24,16 +28,89 @@
#include <axis/TypeMapping.h>
#include <axis/Axis.h>
-STORAGE_CLASS_INFO void axiscInitializeAxis(AxiscBool bIsServer) {
- Axis::initialize(0==bIsServer);
+static void (*global_exceptionHandler)(int errorCode, const char *errorString) = NULL;
+
+STORAGE_CLASS_INFO
+int axiscInitializeAxis(AxiscBool bIsServer)
+{
+ int rc = AXISC_SUCCESS;
+
+ try
+ {
+ Axis::initialize(0==bIsServer);
+ }
+ catch ( AxisException& e )
+ {
+ axiscInvokeExceptionHandler(e.getExceptionCode(), e.what());
+ rc = AXISC_FAIL;
+ }
+ catch ( ... )
+ {
+ rc = AXISC_FAIL;
+ }
+
+ return rc;
}
-STORAGE_CLASS_INFO void axiscTerminate() {
- Axis::terminate();
+STORAGE_CLASS_INFO
+int axiscTerminate()
+{
+ int rc = AXISC_SUCCESS;
+
+ try
+ {
+ Axis::terminate();
+ }
+ catch ( AxisException& e )
+ {
+ axiscInvokeExceptionHandler(e.getExceptionCode(), e.what());
+ rc = AXISC_FAIL;
+ }
+ catch ( ... )
+ {
+ rc = AXISC_FAIL;
+ }
+
+ return rc;
}
+
+AXISC_STORAGE_CLASS_INFO
+int axiscAxisDelete(void * pValue,
+ AXISC_XSDTYPE type)
+{
+ int rc = AXISC_SUCCESS;
+
+ try
+ {
+ Axis::AxisDelete(pValue, (XSDTYPE) type);
+ }
+ catch ( AxisException& e )
+ {
+ axiscInvokeExceptionHandler(e.getExceptionCode(), e.what());
+ rc = AXISC_FAIL;
+ }
+ catch ( ... )
+ {
+ rc = AXISC_FAIL;
+ }
+
+ return rc;
}
-AXISC_STORAGE_CLASS_INFO void axiscAxisDelete(void * pValue, AXISC_XSDTYPE type)
+AXISC_STORAGE_CLASS_INFO
+void axiscRegisterExceptionHandler(void (*fp)(int errorCode, const char *errorString))
{
- Axis::AxisDelete(pValue, (XSDTYPE) type);
+ global_exceptionHandler = fp;
}
+
+
+AXISC_STORAGE_CLASS_INFO
+void axiscInvokeExceptionHandler(int errorCode, const char *errorString)
+{
+ if (global_exceptionHandler)
+ global_exceptionHandler(errorCode, errorString);
+ else
+ cerr << "AXIS EXCEPTION: (" << errorCode << ") " << errorString << endl;
+}
+
+}
\ No newline at end of file