You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by sn...@apache.org on 2002/08/16 21:17:38 UTC
cvs commit: xml-soap/java/src/org/apache/soap/providers/com RPCProvider.cpp COMProvider.dll
snichol 2002/08/16 12:17:38
Modified: java/src/org/apache/soap/providers/com RPCProvider.cpp
COMProvider.dll
Log:
Reviewed by: Scott Nichol
Submitted by: Leif Nilsson TACMa <le...@tac.se>
Further testing has shown that the added ::SysFreeString was no success.
The attached file has removed the ::SysFreeString call but kept the
::VariantClear calls.
Revision Changes Path
1.3 +50 -53 xml-soap/java/src/org/apache/soap/providers/com/RPCProvider.cpp
Index: RPCProvider.cpp
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/providers/com/RPCProvider.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RPCProvider.cpp 3 Jul 2002 20:01:09 -0000 1.2
+++ RPCProvider.cpp 16 Aug 2002 19:17:38 -0000 1.3
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,7 +10,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -18,7 +18,7 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
+ * if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
@@ -26,7 +26,7 @@
*
* 4. The names "SOAP" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
- * software without prior written permission. For written
+ * software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
@@ -53,8 +53,6 @@
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
- *
- * Includes a patch contributed by Leif Nilsson TACMa (leni@tac.se)
*/
#pragma warning(disable:4786) /*Very annoying warning that symbol exceeds debug info size*/
#include <cstdlib>
@@ -85,7 +83,7 @@
BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD fdwReason, LPVOID fImpLoad)
{
if(fdwReason == DLL_PROCESS_ATTACH)
- {
+ {
thisModule= hinstDll;
GetModuleFileName( hinstDll, ModuleName, sizeof ModuleName);
}
@@ -115,8 +113,8 @@
int msgComInitfailed= (int) L"COM Initialize failed hr= 0x%1!lx!";
int msgCLSIDnMethod= (int) L"CLSID is:%1, method to execute is:%2";
int msgPROGIDnMethod=(int) L"Progid is:%1, method to execute is:%2";
-int msgPROGID2CLSID=(int) L"Failed to convert progid to clsid hr= 0x%1!lx!";
-int msgFailedCoCreate=(int) L"Failed to create instance and interface IID_Dispatch hr=0x%1!lx!";
+int msgPROGID2CLSID=(int) L"Failed to convert progid to clsid hr= 0x%1!lx!";
+int msgFailedCoCreate=(int) L"Failed to create instance and interface IID_Dispatch hr=0x%1!lx!";
int msgFailedGetdipid=(int) L"Failed to get dispid for method %1";
int msgFailedDIInvoke=(int) L"Invoke of method %1 failed. hr=0x%2!lx!";
int msgSuccess=(int) L"Success! Return back to java.";
@@ -140,7 +138,7 @@
void (__stdcall*coinit )(void);
IDispatch *idisp;
VARIANT *vp;
-
+
~Undoit()
{
if (NULL != idisp ) { idisp->Release(); idisp= NULL;}
@@ -149,7 +147,7 @@
}
};
-class COMProvider
+class COMProvider
{
jobject jPP; //the java pluggable provider
JNIEnv *env;
@@ -171,16 +169,16 @@
wchar_t progid[256];
Undoit undoit;
ZeroIt(undoit);
- jsize noParmsBytes= NULL == parms_in ? 0 : env->GetArrayLength( parms_in);
+ jsize noParmsBytes= NULL == parms_in ? 0 : env->GetArrayLength( parms_in);
unsigned noParms= noParmsBytes/ sizeof VARIANT;
eventlog(LOG_SUCCESS, msgNoParms, noParms );
char *x= NULL;
if(noParms)
{
- x= (char*)CoTaskMemAlloc( noParmsBytes );
+ x= (char*)CoTaskMemAlloc( noParmsBytes );
if( NULL == x)
{
- throwSoapException( msgCoTaskMemAllocFail );
+ throwSoapException( msgCoTaskMemAllocFail );
return NULL;
}
memset(x, 0, noParmsBytes);
@@ -202,7 +200,7 @@
jboolean isCopy;
wchar_t *cstr= (wchar_t *)env->GetStringChars(jthreadingModel, &isCopy);
if(0== wcscmp(cstr, L"MULTITHREADED"))
- { //just
+ { //just
coInit= COINIT_MULTITHREADED; //Just recognize it.
}
else if(0== wcscmp(cstr, L"APARTMENTTHREADED"))
@@ -222,7 +220,7 @@
if (ASSERT_FAILED(hr))
{
eventlog(LOG_WARNING, msgComInitfailed, hr);
- throwSoapException( msgComInitfailed, hr );
+ throwSoapException( msgComInitfailed, hr );
return NULL;
}
undoit.coinit= OleUninitialize; //Ensure we uninitialize.
@@ -233,7 +231,7 @@
if (ASSERT_FAILED(hr))
{
eventlog(LOG_WARNING, msgComInitfailed, hr);
- throwSoapException( msgComInitfailed, hr );
+ throwSoapException( msgComInitfailed, hr );
return NULL;
}
undoit.coinit= CoUninitialize; //Ensure we uninitialize.
@@ -245,7 +243,7 @@
if(!methodName)
{
eventlog(LOG_ERROR, msgFailedMemory);
- throwSoapException( msgFailedMemory);
+ throwSoapException( msgFailedMemory);
return NULL;
}
@@ -256,22 +254,22 @@
hr= CLSIDFromString(cstr, &clsid );
if (ASSERT_FAILED(hr))
{
- throwSoapException( msgCLSID2stringfailed, hr );
+ throwSoapException( msgCLSID2stringfailed, hr );
if(isCopy == JNI_TRUE) env->ReleaseStringChars(jprogid, cstr);
if(methodName) free(methodName);
return NULL;
}
- eventlog(LOG_INFORMATION, msgCLSIDnMethod , cstr, methodName);
+ eventlog(LOG_INFORMATION, msgCLSIDnMethod , cstr, methodName);
}
else
{
- eventlog(LOG_INFORMATION, msgPROGIDnMethod , cstr, methodName);
- hr= CLSIDFromProgID( cstr, &clsid);
+ eventlog(LOG_INFORMATION, msgPROGIDnMethod , cstr, methodName);
+ hr= CLSIDFromProgID( cstr, &clsid);
if (ASSERT_FAILED(hr))
{
eventlog(LOG_WARNING, msgPROGID2CLSID, hr );
if(isCopy == JNI_TRUE) env->ReleaseStringChars(jprogid, cstr);
- throwSoapException( msgPROGID2CLSID, hr );
+ throwSoapException( msgPROGID2CLSID, hr );
if(methodName) free(methodName);
return NULL;
}
@@ -283,11 +281,11 @@
//Start doing COM stuff
hr= CoCreateInstance( clsid, NULL, CLSCTX_ALL, IID_IDispatch, (void **)&undoit.idisp );
-
+
if (ASSERT_FAILED(hr))
{
eventlog(LOG_WARNING, msgFailedCoCreate, hr );
- throwSoapException( msgFailedCoCreate, hr);
+ throwSoapException( msgFailedCoCreate, hr);
if(methodName) free(methodName);
return NULL;
}
@@ -305,7 +303,7 @@
if (ASSERT_FAILED(hr))
{
- eventlog(LOG_WARNING, msgFailedGetdipid, methodName );
+ eventlog(LOG_WARNING, msgFailedGetdipid, methodName );
throwSoapException(msgFailedGetdipid, methodName );
if(methodName) free(methodName);
return NULL;
@@ -349,7 +347,7 @@
if(methodName) free(methodName);
return NULL;
}
- eventlog(LOG_WARNING, msgFailedDIInvoke, methodName,hr );
+ eventlog(LOG_WARNING, msgFailedDIInvoke, methodName,hr );
throwSoapException(msgInvokeFailed , methodName, hr);
if(methodName) free(methodName);
return NULL;
@@ -359,27 +357,27 @@
hr= variant2object (env, result, jresult);
if (ASSERT_FAILED(hr))
{
- eventlog(LOG_ERROR, msgFailedConvertReturn, V_VT (&result), progid, methodName);
+ eventlog(LOG_ERROR, msgFailedConvertReturn, V_VT (&result), progid, methodName);
throwSoapException(msgFailedConvertReturn, V_VT (&result), progid, methodName);
if(methodName) free(methodName);
- ::VariantClear(&result);
+ ::VariantClear(&result);
return NULL;
}
-
+
if(methodName) free(methodName);
- eventlog(LOG_SUCCESS, msgSuccess );
- ::VariantClear(&result);
+ eventlog(LOG_SUCCESS, msgSuccess );
+ ::VariantClear(&result);
return jresult;
}
//Throw a Java SOAP Exception.
BOOL throwSoapException( const wchar_t *msg)
{
if(NULL== msg) msg= L"Exception thrown by COMProvider";
- jstring jmsg= env->NewStringUTF(ws2mbs(msg));
+ jstring jmsg= env->NewStringUTF(ws2mbs(msg));
jclass jcASE= env->FindClass(javaClass);
jmethodID mid= env->GetStaticMethodID(jcASE,"getSOAPException","(Ljava/lang/String;)Lorg/apache/soap/SOAPException;");
jthrowable jt= (jthrowable) env->CallStaticObjectMethod(jcASE,mid, jmsg);
- env->Throw(jt);
+ env->Throw(jt);
return true;
}
@@ -391,15 +389,15 @@
wchar_t *msgbuf= NULL;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_STRING ,
(wchar_t *)id, 0, 3, (wchar_t *) &msgbuf, 10000, &a);
-
+
if(NULL== msgbuf || *msgbuf == L'\0') msgbuf= L"Exception thrown by COMProvider";
- jstring jmsg= env->NewStringUTF(ws2mbs(msgbuf));
+ jstring jmsg= env->NewStringUTF(ws2mbs(msgbuf));
LocalFree( msgbuf );
jclass jcASE= env->FindClass(javaClass);
jmethodID mid= env->GetStaticMethodID(jcASE,"getSOAPException","(Ljava/lang/String;)Lorg/apache/soap/SOAPException;");
jthrowable jt= (jthrowable) env->CallStaticObjectMethod(jcASE,mid, jmsg);
- env->Throw(jt);
+ env->Throw(jt);
env->DeleteLocalRef(jmsg);
return true;
@@ -414,10 +412,10 @@
wchar_t *msgbuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_STRING,
(wchar_t *)id, 0, 3, (wchar_t *) &msgbuf, 10000, &a);
-
- // fwprintf( stderr, L"%s\n", msgbuf);
+
+ // fwprintf( stderr, L"%s\n", msgbuf);
jclass spClass= env->GetObjectClass(jPP);
- jstring jmsg= env->NewStringUTF(ws2mbs(msgbuf));
+ jstring jmsg= env->NewStringUTF(ws2mbs(msgbuf));
jmethodID mid= env->GetMethodID(spClass, "logit", "(ILjava/lang/String;)V");
env->CallVoidMethod(jPP, mid, (jint)eventtype, jmsg);
env->DeleteLocalRef(jmsg);
@@ -425,7 +423,7 @@
return true;
}
-};//class COMProvider
+};//class COMProvider
const char* COMProvider::javaClass= "org/apache/soap/providers/com/RPCProvider";
extern "C" JNIEXPORT jobject JNICALL Java_org_apache_soap_providers_com_RPCProvider_invoke
@@ -436,7 +434,7 @@
#ifdef NDEBUG //This also will to debug on demand so if we are debugging don't do the catch.
try
{
-#endif
+#endif
env->ExceptionClear(); //Ignore all previous errors.
return cp.invoke(threadingModel, jprogid, jmethodName, parms_in);
#ifdef NDEBUG
@@ -447,7 +445,7 @@
cp.throwSoapException( msgUnknowCPPException);
return NULL;
}
-#endif
+#endif
}
extern "C" JNIEXPORT void JNICALL Java_org_apache_soap_providers_com_RPCProvider_initlog(JNIEnv *env, jclass jc, jshort jlvl)
{
@@ -465,7 +463,6 @@
void *x =bstrS;
memcpy(jr, &x, sizeof x);
if(isCopy == JNI_TRUE) env->ReleaseByteArrayElements(jByteArray,jr,0);
- ::SysFreeString(bstrS);
return jByteArray;
}
@@ -473,49 +470,49 @@
jobject bsf_makeBoolean (JNIEnv *jenv, int val) {
jclass classobj = jenv->FindClass ( "java/lang/Boolean");
- jmethodID constructor =
+ jmethodID constructor =
jenv->GetMethodID (classobj, "<init>", "(Z)V");
return jenv->NewObject (classobj, constructor, (jboolean) val);
}
jobject bsf_makeByte (JNIEnv *jenv, int val) {
jclass classobj = jenv->FindClass ( "java/lang/Byte");
- jmethodID constructor =
+ jmethodID constructor =
jenv->GetMethodID ( classobj, "<init>", "(B)V");
return jenv->NewObject ( classobj, constructor, (jbyte) val);
}
jobject bsf_makeShort (JNIEnv *jenv, int val) {
jclass classobj = jenv->FindClass ( "java/lang/Short");
- jmethodID constructor =
+ jmethodID constructor =
jenv->GetMethodID ( classobj, "<init>", "(S)V");
return jenv->NewObject ( classobj, constructor, (jshort) val);
}
jobject bsf_makeInteger (JNIEnv *jenv, int val) {
jclass classobj = jenv->FindClass ( "java/lang/Integer");
- jmethodID constructor =
+ jmethodID constructor =
jenv->GetMethodID ( classobj, "<init>", "(I)V");
return jenv->NewObject ( classobj, constructor, (jint) val);
}
jobject bsf_makeLong (JNIEnv *jenv, long val) {
jclass classobj = jenv->FindClass ( "java/lang/Long");
- jmethodID constructor =
+ jmethodID constructor =
jenv->GetMethodID ( classobj, "<init>", "(J)V");
return jenv->NewObject ( classobj, constructor, (jlong) val);
}
jobject bsf_makeFloat (JNIEnv *jenv, float val) {
jclass classobj = jenv->FindClass ( "java/lang/Float");
- jmethodID constructor =
+ jmethodID constructor =
jenv->GetMethodID ( classobj, "<init>", "(F)V");
return jenv->NewObject ( classobj, constructor, (jfloat) val);
}
jobject bsf_makeDouble (JNIEnv *jenv, double val) {
jclass classobj = jenv->FindClass ( "java/lang/Double");
- jmethodID constructor =
+ jmethodID constructor =
jenv->GetMethodID ( classobj, "<init>", "(D)V");
return jenv->NewObject ( classobj, constructor, (jdouble) val);
}
@@ -526,10 +523,10 @@
char *buf= NULL;
if(localRefCreated) *localRefCreated= true; //this is mostly the case.
switch (V_VT (&var)) {
- case VT_ERROR:
+ case VT_ERROR:
case VT_EMPTY:
case VT_NULL:
- if(localRefCreated) *localRefCreated= false;
+ if(localRefCreated) *localRefCreated= false;
jresult = NULL;
break;
case VT_I1:
1.4 +9 -9 xml-soap/java/src/org/apache/soap/providers/com/COMProvider.dll
<<Binary file>>