lilantha    2003/07/17 06:11:19

  Modified:    c/src/server/catalina AxisCppContentHandler.java
                        libAxiscpp.cpp libAxiscpp.dsp
  Log:
  updated
  
  Revision  Changes    Path
  1.2       +16 -1     xml-axis/c/src/server/catalina/AxisCppContentHandler.java
  
  Index: AxisCppContentHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/server/catalina/AxisCppContentHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AxisCppContentHandler.java        8 Jul 2003 13:31:40 -0000       1.1
  +++ AxisCppContentHandler.java        17 Jul 2003 13:11:19 -0000      1.2
  @@ -80,7 +80,22 @@
        }
   
        public static native void Delegate(char [] body, int bodySize, Vector headers, 
int headerCount);
  -     
  +
  +     public static void main(String [] args)
  +     {
  +             String str = "Hello World";
  +             char [] pch = str.toCharArray();
  +             Vector v = new Vector();
  +             v.add("Name1");
  +             v.add("Value1");
  +             v.add("Name2");
  +             v.add("Value2");
  +             try{
  +             System.in.read();
  +             }catch(IOException ex){
  +             }
  +             AxisCppContentHandler.Delegate(pch, pch.length, v, 2);
  +     }
   }
   
   
  
  
  
  1.2       +97 -1     xml-axis/c/src/server/catalina/libAxiscpp.cpp
  
  Index: libAxiscpp.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/server/catalina/libAxiscpp.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- libAxiscpp.cpp    8 Jul 2003 13:48:16 -0000       1.1
  +++ libAxiscpp.cpp    17 Jul 2003 13:11:19 -0000      1.2
  @@ -65,14 +65,110 @@
   #include "libAxiscpp.h"
   #include "AxisCppContentHandler.h"
   #include "../../common/Packet.h"
  +#include <new>
   
   
  +static void
  +jni_throw(JNIEnv* env, const char* exception, const char* msg)
  +{
  +    if (env->ExceptionOccurred())
  +        return;
  +    jclass jexception = env->FindClass(exception);
  +    if (env->ExceptionOccurred())
  +      return;
  +    if (jexception == NULL)
  +        env->FatalError(exception);
  +    env->ThrowNew(jexception, msg);
  +}
  +
  +
  +#define JNI_ASSERT(assert, name, msg) \
  +    do \
  +    { \
  +        if (p_Env->ExceptionOccurred()) \
  +            return; \
  +        if (! assert) \
  +        { \
  +            jni_throw(p_Env, name, msg); \
  +            return; \
  +        } \
  +    } while (0)
  +
  +
  +class JNIVector
  +{
  +public:
  +    JNIVector(JNIEnv* p_Env, jobject p_jVector)
  +        : m_pEnv(p_Env), m_jVector(p_jVector)
  +    {
  +             jclass clazz = p_Env->FindClass("java/util/Vector");
  +             JNI_ASSERT(clazz != NULL, "java/lang/NoClassDefFoundError", 
"java.util.Vector");
  +    
  +             JNI_ASSERT(p_Env->IsInstanceOf(p_jVector, clazz),
  +                                              "java/lang/IllegalArgumentException",
  +                                              "p_jVector not a java.util.Vector 
object!");
  +
  +             m_jmGet = p_Env->GetMethodID(clazz, "get", "(I)Ljava/lang/Object");
  +
  +             JNI_ASSERT(m_jmGet != NULL,
  +                     "java/lang/NoSuchMethodError",
  +                     "method 'public Object get(int index)' not found!");
  +    }
  +     ///Destructor
  +    ~JNIVector()
  +    {
  +
  +    }
  +
  +    char* operator [] (int i) const
  +    {
  +             jboolean isCopy;
  +             jobject obj = m_pEnv->CallObjectMethod(m_jVector, m_jmGet, i);
  +             jstring str = (jstring) obj;
  +             const char *pch = m_pEnv->GetStringUTFChars(str, &isCopy);
  +             if (m_pEnv->ExceptionOccurred())
  +            throw std::bad_alloc();
  +        return (char*)pch;
  +    }
  +
  +     void push_back(const char* str) 
  +     {
  +     
  +     }
  +
  +private:
  +
  +    JNIEnv* m_pEnv;
  +    jobject m_jVector;
  +     jmethodID m_jmGet;
  +};
   
   JNIEXPORT void JNICALL Java_AxisCppContentHandler_Delegate
  -  (JNIEnv *, jclass, jcharArray p_jBody, jint p_nBodySize, jobject p_jvHeaders, 
jint p_nHeaderCount)
  +  (JNIEnv *p_Env, jclass, jcharArray p_jBody, jint p_nBodySize, jobject 
p_jvHeaders, 
  +  jint p_nHeaderCount)
   {
        //TODO: populate soapstream with the headers & the body;
        // invoke to process the contents
  +     soapstream* str = new soapstream;
  +     str->trtype = APTHTTP;
  +     str->so.http.ip_soap = new char[p_nBodySize*sizeof(jchar)];
  +     p_Env->GetCharArrayRegion(p_jBody, 0, p_nBodySize, 
(jchar*)str->so.http.ip_soap);
  +     str->so.http.ip_soapcount = p_nBodySize;
  +     //set method name as a http header.
  +     str->so.http.ip_headers = new header[p_nHeaderCount*2];
  +
  +     JNIVector jvHeader(p_Env, p_jvHeaders);
  +     for(int i=0;i < p_nHeaderCount; i++)
  +     {
  +             str->so.http.ip_headers[i].headername  = jvHeader[i];
  +             str->so.http.ip_headers[i].headervalue = jvHeader[i+1];
  +     }
  +     str->so.http.ip_headercount = p_nHeaderCount;
  +
  +
  +     delete [] str->so.http.ip_headers;
  +     delete str;
   }
  +
   
   
  
  
  
  1.2       +38 -10    xml-axis/c/src/server/catalina/libAxiscpp.dsp
  
  Index: libAxiscpp.dsp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/server/catalina/libAxiscpp.dsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- libAxiscpp.dsp    8 Jul 2003 13:48:16 -0000       1.1
  +++ libAxiscpp.dsp    17 Jul 2003 13:11:19 -0000      1.2
  @@ -66,8 +66,8 @@
   # PROP Output_Dir "Debug"
   # PROP Intermediate_Dir "Debug"
   # PROP Target_Dir ""
  -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D 
"_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBAXISCPP_EXPORTS" /YX /FD /GZ  /c
  -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../common" /D "WIN32" /D "_DEBUG" 
/D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBAXISCPP_EXPORTS" /YX /FD /GZ  /c
  +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D 
"_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBAXISCPP_EXPORTS" /YX /FD /GZ /c
  +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../common" /D "WIN32" /D "_DEBUG" 
/D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBAXISCPP_EXPORTS" /YX /FD /GZ /c
   # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
   # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
   # ADD BASE RSC /l 0x409 /d "_DEBUG"
  @@ -90,10 +90,6 @@
   # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
   # Begin Source File
   
  -SOURCE=.\JNIHttpServletHandler.cpp
  -# End Source File
  -# Begin Source File
  -
   SOURCE=.\libAxiscpp.cpp
   # End Source File
   # End Group
  @@ -106,10 +102,6 @@
   # End Source File
   # Begin Source File
   
  -SOURCE=.\JNIHttpServletHandler.h
  -# End Source File
  -# Begin Source File
  -
   SOURCE=.\libAxiscpp.h
   # End Source File
   # End Group
  @@ -119,10 +111,46 @@
   # Begin Source File
   
   SOURCE=.\AxisCppContentHandler.java
  +
  +!IF  "$(CFG)" == "libAxiscpp - Win32 Release"
  +
  +!ELSEIF  "$(CFG)" == "libAxiscpp - Win32 Debug"
  +
  +# Begin Custom Build
  +ProjDir=.
  +InputPath=.\AxisCppContentHandler.java
  +InputName=AxisCppContentHandler
  +
  +"$(ProjDir)/$(InputName).class" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
  +     echo javac -d axiscpp\WEB-INF\classes $(InputPath) 
  +     javac -d axiscpp\WEB-INF\classes $(InputPath) 
  +     
  +# End Custom Build
  +
  +!ENDIF 
  +
   # End Source File
   # Begin Source File
   
   SOURCE=.\AxisCppServlet.java
  +
  +!IF  "$(CFG)" == "libAxiscpp - Win32 Release"
  +
  +!ELSEIF  "$(CFG)" == "libAxiscpp - Win32 Debug"
  +
  +# Begin Custom Build
  +ProjDir=.
  +InputPath=.\AxisCppServlet.java
  +InputName=AxisCppServlet
  +
  +"$(ProjDir)/$(InputName).class" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
  +     echo javac -d axiscpp\WEB-INF\classes $(InputPath) 
  +     javac -d axiscpp\WEB-INF\classes $(InputPath) 
  +     
  +# End Custom Build
  +
  +!ENDIF 
  +
   # End Source File
   # End Group
   # End Target
  
  
  

Reply via email to