jsmooth-cvs Mailing List for JSmooth (Page 5)
Status: Beta
Brought to you by:
reyes
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(64) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(44) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
|
Feb
|
Mar
|
Apr
(23) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
(35) |
Mar
(75) |
Apr
(105) |
May
(89) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(12) |
Nov
|
Dec
|
2014 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2016 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
(2) |
May
(1) |
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Rodrigo R. <re...@us...> - 2007-05-01 19:40:21
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/util-core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv9102/util-core Modified Files: Process.cpp Process.h Log Message: adds exit code propagation when exe-run Index: Process.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-core/Process.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Process.h 28 Apr 2007 08:47:57 -0000 1.1 --- Process.h 1 May 2007 19:40:16 -0000 1.2 *************** *** 44,47 **** --- 44,48 ---- bool m_redirectstderr; HANDLE m_redirectHandle; + DWORD m_exitCode; public: *************** *** 53,56 **** --- 54,58 ---- void join(); + int getExitCode(); }; Index: Process.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-core/Process.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Process.cpp 28 Apr 2007 08:47:57 -0000 1.1 --- Process.cpp 1 May 2007 19:40:16 -0000 1.2 *************** *** 83,87 **** NULL, NULL, inheritsHandle, creationFlags, NULL, NULL, &info, &m_procinfo); ! if (res != 0) { --- 83,87 ---- NULL, NULL, inheritsHandle, creationFlags, NULL, NULL, &info, &m_procinfo); ! if (res != 0) { *************** *** 106,107 **** --- 106,115 ---- } + + int Process::getExitCode() + { + GetExitCodeProcess(m_procinfo.hProcess, + &m_exitCode); + return (int)m_exitCode; + } + |
From: Rodrigo R. <re...@us...> - 2007-04-30 21:01:17
|
Update of /cvsroot/jsmooth/jsmooth In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv13492 Modified Files: build.number Log Message: Index: build.number =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/build.number,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** build.number 12 Apr 2007 20:01:49 -0000 1.33 --- build.number 30 Apr 2007 21:00:43 -0000 1.34 *************** *** 1,3 **** #Build Number for ANT. Do not edit! ! #Thu Apr 12 21:58:32 CEST 2007 ! build.number=202 --- 1,3 ---- #Build Number for ANT. Do not edit! ! #Sun Apr 29 22:58:14 CEST 2007 ! build.number=213 |
From: Rodrigo R. <re...@us...> - 2007-04-30 20:58:14
|
Update of /cvsroot/jsmooth/jsmooth/sample In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv12456/sample Modified Files: sample.jsmooth Log Message: Index: sample.jsmooth =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/sample/sample.jsmooth,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** sample.jsmooth 12 Apr 2007 20:01:50 -0000 1.10 --- sample.jsmooth 30 Apr 2007 20:58:11 -0000 1.11 *************** *** 7,10 **** --- 7,11 ---- <JVMSearchPath>exepath</JVMSearchPath> <JVMSearchPath>jview</JVMSearchPath> + <arguments>${EXECUTABLEPATH}</arguments> <embeddedJar>true</embeddedJar> <executableName>Sample.exe</executableName> *************** *** 38,43 **** <maximumMemoryHeap>67108864</maximumMemoryHeap> <maximumVersion></maximumVersion> ! <minimumVersion>1.1</minimumVersion> ! <skeletonName>Autodownload Wrapper</skeletonName> <skeletonProperties> <key>Message</key> --- 39,44 ---- <maximumMemoryHeap>67108864</maximumMemoryHeap> <maximumVersion></maximumVersion> ! <minimumVersion>1.3</minimumVersion> ! <skeletonName>Console Wrapper</skeletonName> <skeletonProperties> <key>Message</key> *************** *** 46,54 **** </skeletonProperties> <skeletonProperties> ! <key>DownloadURL</key> ! <value>http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab</value> ! </skeletonProperties> ! <skeletonProperties> ! <key>SingleProcess</key> <value>0</value> </skeletonProperties> --- 47,51 ---- </skeletonProperties> <skeletonProperties> ! <key>PressKey</key> <value>0</value> </skeletonProperties> |
From: Rodrigo R. <re...@us...> - 2007-04-30 20:57:28
|
Update of /cvsroot/jsmooth/jsmooth/src/locale In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv11880/src/locale Modified Files: Texts.properties Texts_fr.properties Log Message: Index: Texts.properties =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/src/locale/Texts.properties,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Texts.properties 28 Apr 2007 09:03:51 -0000 1.13 --- Texts.properties 30 Apr 2007 20:57:08 -0000 1.14 *************** *** 23,28 **** CURRENTDIR_LABEL=Current Directory CURRENTDIR_HELP=Define here the directory to be set as the working directory of the the application, when launched. <p>Just leave it empty if you don't need any modification of this value at startup.<p>Typical use of this option is to go up one level when the executable is in a <tt>bin</tt> subdirectory of the program root.<p><b>WARNING</b>: Unlike the other files or directory options, which are all relative to the project file, this value is always relative to the generated executable location. That is, if you set <tt>".."</tt> or "an\\other\\dir" here, the generated wrapper will change to this directory from <u>its</u> own current directory.<p> You can also use the ${EXECUTABLEPATH} keyword, which will be replaced at runtime by the directory of the executable. ! CURRENTDIR_FORCEEXEPATH=Sets the executable folder as current directory of the application. This is equivalent to setting the "current dir" as "${EXECUTABLEPATH}". ! CURRENTDIR_FORCEEXEPATH_HELP=If this option is selected, the current directory of your application is forced to be the directory where the executable is installed. SKELETONPROPERTIES_LABEL=Skeleton Properties SKELETONPROPERTIES_HELP=The table above shows the properties associated to the selected skeleton. Change the values of the properties to customize the behaviour of the native executable wrapper generated. --- 23,28 ---- CURRENTDIR_LABEL=Current Directory CURRENTDIR_HELP=Define here the directory to be set as the working directory of the the application, when launched. <p>Just leave it empty if you don't need any modification of this value at startup.<p>Typical use of this option is to go up one level when the executable is in a <tt>bin</tt> subdirectory of the program root.<p><b>WARNING</b>: Unlike the other files or directory options, which are all relative to the project file, this value is always relative to the generated executable location. That is, if you set <tt>".."</tt> or "an\\other\\dir" here, the generated wrapper will change to this directory from <u>its</u> own current directory.<p> You can also use the ${EXECUTABLEPATH} keyword, which will be replaced at runtime by the directory of the executable. ! CURRENTDIR_FORCEEXEPATH=Sets the executable folder as current directory of the application. ! CURRENTDIR_FORCEEXEPATH_HELP=If this option is selected, the current directory of your application is forced to be the directory where the executable is installed. <p> This is equivalent to setting the "current dir" to "${EXECUTABLEPATH}". SKELETONPROPERTIES_LABEL=Skeleton Properties SKELETONPROPERTIES_HELP=The table above shows the properties associated to the selected skeleton. Change the values of the properties to customize the behaviour of the native executable wrapper generated. Index: Texts_fr.properties =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/src/locale/Texts_fr.properties,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Texts_fr.properties 28 Apr 2007 09:03:51 -0000 1.8 --- Texts_fr.properties 30 Apr 2007 20:57:08 -0000 1.9 *************** *** 23,29 **** CURRENTDIR_LABEL=Répertoire de travail CURRENTDIR_HELP=Sélectionnez le répertoire qui sera considéré comme le répertoire de travail (également appelé "répertoire courant") par votre application. <p>Vous pouvez laisser ce champ vide si votre application n'en a pas besoin ou si la valeur par défaut vous convient (celle-ci étant le répertoire d'où l'exécutable a été lancé). <p> Un exemple courant d'utilisation de ce paramètre est de remonter d'un niveau à la racine du répertoire d'installation de votre application, lorsque l'exécutable se trouve dans un sous-répertoire <tt>bin/</tt>. <p> <b>ATTENTION</b>: Contrairement aux autres fichiers et répertoires d'un projet JSmooth, qui sont tous relatifs au fichier projet (.jsmooth), celui-ci est relatif au répertoire courant de l'application. <br> Par exemple, si vous mettez la valeur <tt>..</tt> ou <tt>un/autre/repertoire</tt>, le lanceur changera le répertoire de travail de votre application relativement au chemin courant. <p> Vous pouvez également utiliser le mot clé ${EXECUTABLEPATH}, qui sera remplacé au lancement par le répertoire où se situe l'exécutable. ! CURRENTDIR_FORCEEXEPATH=Définit le répertoire de l'exécutable comme répertoire courant. Ceci est équivalent au mot clé ${EXECUTABLEPATH} positionné dans le champ texte. ! CURRENTDIR_FORCEEXEPATH_HELP=Si cette option est cochée, JSmooth définit le répertoire où se trouve l'exécutable comme répertoire courant au démarrage. ! If this option is selected, the current directory of your application is forced to be the directory where the executable is installed. SKELETONPROPERTIES_LABEL=Propriétés du squelette SKELETONPROPERTIES_HELP=Les champs ci-contre vous permettent de spécialiser le comportement du squelette de lancement utilisé. --- 23,28 ---- CURRENTDIR_LABEL=Répertoire de travail CURRENTDIR_HELP=Sélectionnez le répertoire qui sera considéré comme le répertoire de travail (également appelé "répertoire courant") par votre application. <p>Vous pouvez laisser ce champ vide si votre application n'en a pas besoin ou si la valeur par défaut vous convient (celle-ci étant le répertoire d'où l'exécutable a été lancé). <p> Un exemple courant d'utilisation de ce paramètre est de remonter d'un niveau à la racine du répertoire d'installation de votre application, lorsque l'exécutable se trouve dans un sous-répertoire <tt>bin/</tt>. <p> <b>ATTENTION</b>: Contrairement aux autres fichiers et répertoires d'un projet JSmooth, qui sont tous relatifs au fichier projet (.jsmooth), celui-ci est relatif au répertoire courant de l'application. <br> Par exemple, si vous mettez la valeur <tt>..</tt> ou <tt>un/autre/repertoire</tt>, le lanceur changera le répertoire de travail de votre application relativement au chemin courant. <p> Vous pouvez également utiliser le mot clé ${EXECUTABLEPATH}, qui sera remplacé au lancement par le répertoire où se situe l'exécutable. ! CURRENTDIR_FORCEEXEPATH=Force le répertoire de l'exécutable comme répertoire courant. ! CURRENTDIR_FORCEEXEPATH_HELP=Si cette option est cochée, JSmooth définit le répertoire où se trouve l'exécutable comme répertoire courant au démarrage. <p> Ceci est équivalent au mot clé ${EXECUTABLEPATH} positionné dans le champ texte. SKELETONPROPERTIES_LABEL=Propriétés du squelette SKELETONPROPERTIES_HELP=Les champs ci-contre vous permettent de spécialiser le comportement du squelette de lancement utilisé. |
From: Rodrigo R. <re...@us...> - 2007-04-30 20:54:39
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/winservice/sample In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10646/winservice/sample Modified Files: sample.props Log Message: Winservice DLL instanciation fix Index: sample.props =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/winservice/sample/sample.props,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sample.props 9 Apr 2007 17:15:50 -0000 1.1 --- sample.props 30 Apr 2007 20:54:32 -0000 1.2 *************** *** 7,13 **** currentdir= bundledvm=jre ! skel_Message=Java has not been found on your computer. Do you want to download it? skel_URL=http://www.java.com skel_DownloadURL=http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab javapropertiescount=1 javaproperty_name_0=nom1 --- 7,19 ---- currentdir= bundledvm=jre ! skel_ServiceName=jsmooth test winservice ! skel_ServiceDisplayName=testing a winservice ! skel_Message=This program needs Java to run.\nPlease download it at http://www.java.com skel_URL=http://www.java.com + skel_Autostart=1 skel_DownloadURL=http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab + skel_Logfile=mytest.log + skel_Interactive=1 + skel_Debug=1 javapropertiescount=1 javaproperty_name_0=nom1 |
From: Rodrigo R. <re...@us...> - 2007-04-30 20:54:38
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/winservice In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10646/winservice Modified Files: Makefile.win WinService.cpp Log Message: Winservice DLL instanciation fix Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/winservice/Makefile.win,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.win 9 Apr 2007 22:21:23 -0000 1.2 --- Makefile.win 30 Apr 2007 20:54:32 -0000 1.3 *************** *** 11,15 **** LIBS = -L"/lib" -L"../commonjava" -L"../util-core" ../commonjava/CommonJava.a ../util-core/util-core.a INCS = -I"/include" -I"../util-core" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -g -I"/include/c++" -I"/include/c++/mingw32" -I"/include/c++/backward" -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I../util-core BIN = winservice.exe CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" --- 11,15 ---- LIBS = -L"/lib" -L"../commonjava" -L"../util-core" ../commonjava/CommonJava.a ../util-core/util-core.a INCS = -I"/include" -I"../util-core" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -I"/include/c++" -I"/include/c++/mingw32" -I"/include/c++/backward" -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I../util-core BIN = winservice.exe CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" Index: WinService.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/winservice/WinService.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WinService.cpp 12 Apr 2007 20:01:50 -0000 1.4 --- WinService.cpp 30 Apr 2007 20:54:32 -0000 1.5 *************** *** 30,33 **** --- 30,35 ---- #include "JVMRegistryLookup.h" #include "JavaMachineManager.h" + #include "JClassProxy.h" + #include "JArgs.h" WinService* winservice_ref; *************** *** 83,87 **** { if (m_jvm != 0) ! m_jvm->callDLLStaticMethodInt("java.lang.System", "exit", "(I)V", 0); } --- 85,98 ---- { if (m_jvm != 0) ! { ! SunJVMDLL* runner = m_jvm->getDLL(); ! log("Calling java.lang.System.exit(0)..."); ! ! JClassProxy disp(runner, "java.lang.System"); ! disp.invokeStatic("void exit(int)", JArgs(0)); ! log("exit(0) returned successfully"); ! ! // m_jvm->callDLLStaticMethodInt("java.lang.System", "exit", "(I)V", 0); ! } } *************** *** 161,165 **** { SERVICE_STATUS status; ! log("set status " + StringUtils::toString(currentState)); status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; --- 172,202 ---- { SERVICE_STATUS status; ! std::string meaning = ""; ! switch(currentState) ! { ! case SERVICE_STOPPED: ! meaning = "SERVICE_STOPPED"; ! break; ! case SERVICE_START_PENDING: ! meaning = "SERVICE_START_PENDING"; ! break; ! case SERVICE_STOP_PENDING: ! meaning = "SERVICE_STOP_PENDING"; ! break; ! case SERVICE_RUNNING: ! meaning = "SERVICE_RUNNING"; ! break; ! case SERVICE_CONTINUE_PENDING: ! meaning = "SERVICE_CONTINUE_PENDING"; ! break; ! case SERVICE_PAUSE_PENDING: ! meaning = "SERVICE_PAUSE_PENDING"; ! break; ! case SERVICE_PAUSED: ! meaning = "SERVICE_PAUSED"; ! break; ! } ! ! log("set status " + StringUtils::toString(currentState) + " (" + meaning + ")"); status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; *************** *** 250,254 **** --- 287,293 ---- JavaMachineManager man(*globalResMan); + setStatus(SERVICE_RUNNING); SunJVMLauncher* launcher = man.runDLLFromRegistry(true); + if (launcher != 0) { *************** *** 257,266 **** setStatus(SERVICE_RUNNING); ! if ( ! launcher->dllInstanciate(*globalResMan, "wsreg") ) { ! log("Failed to launch the service: can't instanciate the JVM DLL"); } else ! log("Launched successfully the DLL (" + launcher->toString() + ")"); } else --- 296,308 ---- setStatus(SERVICE_RUNNING); ! ! SunJVMDLL* jdll = m_jvm->getDLL(); ! if (jdll != 0) { ! jdll->run( globalResMan->getProperty(ResourceManager::KEY_MAINCLASSNAME), false); } else ! log("ERROR: JVM is launched, but can get a DLL... ?"); ! } else *************** *** 274,278 **** setStatus(SERVICE_STOPPED); - log("stopped!"); return; } --- 316,319 ---- |
From: Rodrigo R. <re...@us...> - 2007-04-30 20:54:38
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/commonjava In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10646/commonjava Modified Files: Makefile.win SunJVMDLL.cpp SunJVMDLL.h SunJVMLauncher.cpp SunJVMLauncher.h Log Message: Winservice DLL instanciation fix Index: SunJVMLauncher.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/SunJVMLauncher.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** SunJVMLauncher.cpp 28 Apr 2007 08:43:43 -0000 1.26 --- SunJVMLauncher.cpp 30 Apr 2007 20:54:32 -0000 1.27 *************** *** 108,141 **** if (FileUtils::fileExists(this->RuntimeLibPath)) { ! SunJVMDLL runner(this->RuntimeLibPath, this->VmVersion); // set up the vm parameters... ! setupVM(resource, &runner); ! return runner.run(resource.getProperty(ResourceManager::KEY_MAINCLASSNAME)); ! // then call the main class... ! ! ! // vector<string> args = StringUtils::split(resource.getProperty(ResourceManager::KEY_ARGUMENTS), " \t\n\r", "\"\'"); ! // JClassProxy mainclass(&runner, resource.getProperty(string(ResourceManager::KEY_MAINCLASSNAME)) ); ! // jstring empty = runner.newUTFString(""); ! // jclass strclss = runner.findClass( resource.getProperty(string(ResourceManager::KEY_MAINCLASSNAME) )); ! // if (strclss) ! // { ! // jobjectArray jargumentsval = runner.newObjectArray(args.size(), strclss, empty); ! // mainclass.invokeStatic( "void main(java.lang.String[]args)", JArgs(jargumentsval)); ! // return true; ! ! // } ! // return false; ! // jclass strclss = runner.findClass( resource.getProperty(string(ResourceManager::KEY_MAINCLASSNAME) )); ! // JMethodCaller maincaller(resource.getProperty(string(ResourceManager::KEY_MAINCLASSNAME)), ! // "void static main(String[]args)"); ! // JArgs maa(jargumentsval); ! // jvalue* jarguments = maa.allocArray(); ! // maincaller.invokeStatic(runner, jarguments); ! // delete jarguments; } - return false; } --- 108,122 ---- if (FileUtils::fileExists(this->RuntimeLibPath)) { ! m_dllrunner = new SunJVMDLL(this->RuntimeLibPath, this->VmVersion); // set up the vm parameters... ! setupVM(resource, m_dllrunner); ! if (justInstanciate) ! return m_dllrunner->instanciate(); ! else ! return m_dllrunner->run(resource.getProperty(ResourceManager::KEY_MAINCLASSNAME), ! true); } return false; } *************** *** 213,216 **** --- 194,201 ---- } + SunJVMDLL* SunJVMLauncher::getDLL() + { + return m_dllrunner; + } bool operator < (const SunJVMLauncher& v1, const SunJVMLauncher& v2) Index: SunJVMLauncher.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/SunJVMLauncher.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SunJVMLauncher.h 28 Apr 2007 08:43:43 -0000 1.12 --- SunJVMLauncher.h 30 Apr 2007 20:54:32 -0000 1.13 *************** *** 78,81 **** --- 78,84 ---- */ Version VmVersion; + + SunJVMExe* m_exerunner; + SunJVMDLL* m_dllrunner; /** *************** *** 112,115 **** --- 115,119 ---- virtual bool setupVM(ResourceManager& resource, JVMBase* vm); + SunJVMDLL* getDLL(); std::string toString() const; *************** *** 128,138 **** JavaVM* getJavaVM(); ! jclass findClass(const std::string& clazz); ! jmethodID findMethod(jclass& cls, const std::string& methodname, const std::string& signature, bool isStatic); ! void invokeVoidStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); ! // jvaluea invokeIntStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); ! jint invokeIntStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); ! jlong invokeLongStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); private: --- 132,142 ---- JavaVM* getJavaVM(); ! // jclass findClass(const std::string& clazz); ! // jmethodID findMethod(jclass& cls, const std::string& methodname, const std::string& signature, bool isStatic); ! // void invokeVoidStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); ! // // jvaluea invokeIntStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); ! // jint invokeIntStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); ! // jlong invokeLongStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); private: Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/Makefile.win,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile.win 28 Apr 2007 08:43:43 -0000 1.7 --- Makefile.win 30 Apr 2007 20:54:32 -0000 1.8 *************** *** 12,16 **** LIBS = -L"$(MINGW)/lib" INCS = -I"../util-core" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -g -I"../util-core" -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" BIN = CommonJava.a CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" --- 12,16 ---- LIBS = -L"$(MINGW)/lib" INCS = -I"../util-core" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -Os -I"../util-core" -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" BIN = CommonJava.a CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" Index: SunJVMDLL.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/SunJVMDLL.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SunJVMDLL.cpp 28 Apr 2007 08:43:43 -0000 1.1 --- SunJVMDLL.cpp 30 Apr 2007 20:54:32 -0000 1.2 *************** *** 40,44 **** } ! bool SunJVMDLL::run(const std::string& mainclass) { if (m_statusCode == SunJVMDLL::JVM_NOT_STARTED) --- 40,44 ---- } ! bool SunJVMDLL::run(const std::string& mainclass, bool waitDeath) { if (m_statusCode == SunJVMDLL::JVM_NOT_STARTED) *************** *** 58,63 **** ma[0].l = mainargs; disp.invokeStatic(std::string("void main(java.lang.String[] args)"), ma); return true; - } --- 58,64 ---- ma[0].l = mainargs; disp.invokeStatic(std::string("void main(java.lang.String[] args)"), ma); + if (waitDeath == true) + m_javavm->DestroyJavaVM(); return true; } *************** *** 65,68 **** --- 66,76 ---- } + void SunJVMDLL::join() + { + if (m_statusCode == SunJVMDLL::JVM_LOADED) + { + m_javavm->DestroyJavaVM(); + } + } bool SunJVMDLL::instanciate() *************** *** 100,103 **** --- 108,112 ---- } + m_statusCode = SunJVMDLL::JVM_CANT_USE_VM; return false; } Index: SunJVMDLL.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/SunJVMDLL.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SunJVMDLL.h 28 Apr 2007 08:43:43 -0000 1.1 --- SunJVMDLL.h 30 Apr 2007 20:54:32 -0000 1.2 *************** *** 85,90 **** } ! bool run(const std::string& mainclass); ! jclass findClass(const std::string& clazz); jmethodID findMethod(jclass& cls, const std::string& methodname, const std::string& signature, bool isStatic); --- 85,91 ---- } ! bool run(const std::string& mainclass, bool waitDeath = true); ! void join(); ! jclass findClass(const std::string& clazz); jmethodID findMethod(jclass& cls, const std::string& methodname, const std::string& signature, bool isStatic); |
From: Rodrigo R. <re...@us...> - 2007-04-30 20:54:37
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/util-net In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10646/util-net Modified Files: Makefile.win Log Message: Winservice DLL instanciation fix Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-net/Makefile.win,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.win 28 Apr 2007 08:49:33 -0000 1.3 --- Makefile.win 30 Apr 2007 20:54:32 -0000 1.4 *************** *** 12,16 **** OBJ = HttpClient.o URL.o downloadgui.o httpdownload.o $(RES) LIBS = -L"$(MINGW)/lib" -L"/lib" -lws2_32 $(FLTK-LDFLAGS) ! CXXINCS = -I"../util-core" -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" $(FLTK-CXXFLAGS) BIN = $(PROJECTNAME).a CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" --- 12,16 ---- OBJ = HttpClient.o URL.o downloadgui.o httpdownload.o $(RES) LIBS = -L"$(MINGW)/lib" -L"/lib" -lws2_32 $(FLTK-LDFLAGS) ! CXXINCS = -Os -I"../util-core" -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" $(FLTK-CXXFLAGS) BIN = $(PROJECTNAME).a CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" |
From: Rodrigo R. <re...@us...> - 2007-04-30 20:54:37
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/consolewrapper In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10646/consolewrapper Modified Files: Makefile.win main.cpp Log Message: Winservice DLL instanciation fix Index: main.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/consolewrapper/main.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** main.cpp 28 Apr 2007 08:51:05 -0000 1.17 --- main.cpp 30 Apr 2007 20:54:32 -0000 1.18 *************** *** 46,91 **** int main(int argc, char *argv[]) { ! ResourceManager* globalResMan = new ResourceManager("JAVA", PROPID, JARID); ! for (int i=0; i<argc; i++) ! { ! DEBUG("ARGUMENT[" + StringUtils::toString(i) + "]=" + std::string(argv[i])); ! } ! // sets up the arguments ! // ! if (argc > 1) ! globalResMan->setProperty(string(ResourceManager::KEY_ARGUMENTS), ""); ! for (int i=1; i<argc; i++) ! globalResMan->addUserArgument(argv[i]); ! ! // ! // sets up the debug mode, if requested ! std::string dodebug = globalResMan->getProperty("skel_Debug"); ! if (StringUtils::parseInt(dodebug) != 0) ! { ! enableDebug = true; ! globalResMan->printDebug(); ! } ! char curdir[256]; ! GetCurrentDirectory(256, curdir); ! string newcurdir = globalResMan->getCurrentDirectory(); ! SetCurrentDirectory(newcurdir.c_str()); ! JavaMachineManager man(*globalResMan); ! if (man.run(false, false) == false) { ! std::string errmsg = globalResMan->getProperty("skel_Message"); ! cerr << errmsg.c_str(); ! cerr << "\r\n"; } int waitkey = atoi(globalResMan->getProperty("skel_PressKey").c_str()); if (waitkey != 0) ! { ! system("PAUSE"); ! } delete globalResMan; --- 46,88 ---- int main(int argc, char *argv[]) { ! ResourceManager* globalResMan = new ResourceManager("JAVA", PROPID, JARID); ! // for (int i=0; i<argc; i++) ! // { ! // printf("CMD-ARGUMENTx[%d]=%s\n",i ,argv[i]); ! // } ! // sets up the arguments ! // ! if (argc > 1) ! globalResMan->setProperty(string(ResourceManager::KEY_ARGUMENTS), ""); ! for (int i=1; i<argc; i++) ! globalResMan->addUserArgument(argv[i]); ! // ! // sets up the debug mode, if requested ! std::string dodebug = globalResMan->getProperty("skel_Debug"); ! if (StringUtils::parseInt(dodebug) != 0) ! { ! enableDebug = true; ! globalResMan->printDebug(); ! } ! string newcurdir = globalResMan->getCurrentDirectory(); ! SetCurrentDirectory(newcurdir.c_str()); ! JavaMachineManager man(*globalResMan); ! if (man.run(false, false) == false) { ! std::string errmsg = globalResMan->getProperty("skel_Message"); ! cerr << errmsg.c_str(); ! cerr << "\r\n"; } int waitkey = atoi(globalResMan->getProperty("skel_PressKey").c_str()); if (waitkey != 0) ! { ! system("PAUSE"); ! } delete globalResMan; Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/consolewrapper/Makefile.win,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.win 28 Apr 2007 08:51:05 -0000 1.5 --- Makefile.win 30 Apr 2007 20:54:32 -0000 1.6 *************** *** 11,15 **** LIBS = -L"/lib" -L"../commonjava" -L"../util-core" ../commonjava/CommonJava.a ../util-core/util-core.a INCS = -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -g -I"/include/c++" -I"/include/c++/mingw32" -I"/include/c++/backward" -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I../util-core BIN = ConsoleWrapper.exe CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" --- 11,15 ---- LIBS = -L"/lib" -L"../commonjava" -L"../util-core" ../commonjava/CommonJava.a ../util-core/util-core.a INCS = -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -I"/include/c++" -I"/include/c++/mingw32" -I"/include/c++/backward" -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I../util-core BIN = ConsoleWrapper.exe CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" |
From: Rodrigo R. <re...@us...> - 2007-04-30 20:54:37
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/winservice/sample/src In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10646/winservice/sample/src Modified Files: AlertServer.java Log Message: Winservice DLL instanciation fix Index: AlertServer.java =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/winservice/sample/src/AlertServer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AlertServer.java 12 Apr 2007 20:01:50 -0000 1.3 --- AlertServer.java 30 Apr 2007 20:54:32 -0000 1.4 *************** *** 25,28 **** --- 25,30 ---- InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); + OutputStream outs = m_sock.getOutputStream(); + Writer out = new OutputStreamWriter(outs); String line; *************** *** 30,33 **** --- 32,36 ---- { FileWriter fw = new FileWriter("c:/alertserver.log", true); + out.write("PRINTING <" + line + ">"); System.out.println("Received: " + line); fw.write(line + "\n"); |
From: Rodrigo R. <re...@us...> - 2007-04-30 20:54:37
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/util-core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10646/util-core Modified Files: Makefile.win Log Message: Winservice DLL instanciation fix Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-core/Makefile.win,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.win 28 Apr 2007 08:47:57 -0000 1.3 --- Makefile.win 30 Apr 2007 20:54:32 -0000 1.4 *************** *** 11,15 **** LIBS = -L"$(MINGW)/lib" -L"/lib" -lws2_32 INCS = -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" BIN = $(PROJECTNAME).a CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" --- 11,15 ---- LIBS = -L"$(MINGW)/lib" -L"/lib" -lws2_32 INCS = -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -Os -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" BIN = $(PROJECTNAME).a CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" |
From: Rodrigo R. <re...@us...> - 2007-04-30 20:54:36
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/simplewrap In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10646/simplewrap Modified Files: main.cpp Log Message: Winservice DLL instanciation fix Index: main.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/simplewrap/main.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** main.cpp 28 Apr 2007 08:51:24 -0000 1.26 --- main.cpp 30 Apr 2007 20:54:32 -0000 1.27 *************** *** 68,72 **** } - std::string dodebug = globalResMan->getProperty("skel_Debug"); if ((StringUtils::parseInt(dodebug) != 0) && (DEBUGCONSOLE==0)) --- 68,71 ---- *************** *** 75,79 **** } - if (DEBUGCONSOLE!=0) globalResMan->printDebug(); --- 74,77 ---- |
From: Rodrigo R. <re...@us...> - 2007-04-28 09:07:34
|
Update of /cvsroot/jsmooth/jsmooth In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25283 Modified Files: Changelog build.xml Log Message: Index: build.xml =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/build.xml,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** build.xml 12 Apr 2007 20:01:49 -0000 1.36 --- build.xml 28 Apr 2007 09:07:31 -0000 1.37 *************** *** 4,8 **** <!-- see the README.txt file for additional information --> <!-- DO NOT SKIP THIS PART! REALLY! IT WON'T WORK OTHERWISE --> ! <property name="JDKDIR" value="c:\Program Files\Java\jdk1.5.0_06"/> <property name="RM" value="CMD /C DEL"/> --- 4,8 ---- <!-- see the README.txt file for additional information --> <!-- DO NOT SKIP THIS PART! REALLY! IT WON'T WORK OTHERWISE --> ! <property name="JDKDIR" value="c:\Program Files\Java\jdk1.5.0_11"/> <property name="RM" value="CMD /C DEL"/> *************** *** 28,36 **** <property name="DOCBOOKBASE" value="c:\programs\docbook-xsl-1.72.0"/> ! <!-- set here the properties specific the release --> <property name="VERSION" value="0.9.9-5"/> ! <!-- You should need to modify the properties below --> <property environment="env"/> --- 28,36 ---- <property name="DOCBOOKBASE" value="c:\programs\docbook-xsl-1.72.0"/> ! <!-- set here the properties specific to the release --> <property name="VERSION" value="0.9.9-5"/> ! <!-- You don't need to modify the properties below --> <property environment="env"/> Index: Changelog =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/Changelog,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Changelog 12 Apr 2007 20:01:49 -0000 1.35 --- Changelog 28 Apr 2007 09:07:31 -0000 1.36 *************** *** 1,4 **** --- 1,6 ---- 0.9.9-5 - Adds new wrapper for windows services + - Refactored the Sun JVM launcher, now 3 specialized class are + available: JVMBase, SunJVMExe, SunJVMDLL 0.9.9-4 (2007-04-07) |
From: Rodrigo R. <re...@us...> - 2007-04-28 09:03:55
|
Update of /cvsroot/jsmooth/jsmooth/src/locale In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv23365/src/locale Modified Files: Texts.properties Texts_fr.properties Log Message: augmented the "single process" help in english and french Index: Texts.properties =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/src/locale/Texts.properties,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Texts.properties 12 Apr 2007 20:01:50 -0000 1.12 --- Texts.properties 28 Apr 2007 09:03:51 -0000 1.13 *************** *** 87,91 **** SKEL_AUTODOWNLOAD_PROPERTY_DLURL_LABEL=Java VM to download # ! SKEL_GENERIC_PROPERTY_SINGLEPROCESS_DESCRIPTION=The default behaviour is to launch the java application in a different (detached) process. If you want to force the wrapper to launch the Java application in the same process than the exe, than select this option. SKEL_GENERIC_PROPERTY_SINGLEPROCESS_LABEL=Launch java app in the exe process SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION=Enable the jsmooth debug console. --- 87,91 ---- SKEL_AUTODOWNLOAD_PROPERTY_DLURL_LABEL=Java VM to download # ! SKEL_GENERIC_PROPERTY_SINGLEPROCESS_DESCRIPTION=The default behaviour is to launch the java application in a different (detached) process by invoking java[w].exe (or jre[w].exe, according to the version of the JVM). If you want to force the wrapper to launch the Java application in the same process than the exe, than select this option. <p> When this option is enabled, JSmooth locates the JVM.dll and instanciates it, resulting in the VM running in the same process than the jsmooth wrapper (only the wrapper appears in the process list of the computer). SKEL_GENERIC_PROPERTY_SINGLEPROCESS_LABEL=Launch java app in the exe process SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION=Enable the jsmooth debug console. Index: Texts_fr.properties =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/src/locale/Texts_fr.properties,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Texts_fr.properties 12 Apr 2007 20:01:50 -0000 1.7 --- Texts_fr.properties 28 Apr 2007 09:03:51 -0000 1.8 *************** *** 87,91 **** SKEL_AUTODOWNLOAD_PROPERTY_DLURL_LABEL=JVM à télécharger # ! SKEL_GENERIC_PROPERTY_SINGLEPROCESS_DESCRIPTION=Le comportement par défaut du squelette est de lancer l'application java dans un processus différent (détaché). Si vous souhaitez forcer le lanceur à utiliser le même processus que l'exécutable, activez cette option. <p> Lorsque cette option est activée, JSmooth tentera toujours d'instancier une machine virtuelle java en utilisant la DLL (généralement jvm.dll) fournie par la JVM de Sun. SKEL_GENERIC_PROPERTY_SINGLEPROCESS_LABEL=Lancer java dans le même processus SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION=Activer la console de débogage JSmooth --- 87,91 ---- SKEL_AUTODOWNLOAD_PROPERTY_DLURL_LABEL=JVM à télécharger # ! SKEL_GENERIC_PROPERTY_SINGLEPROCESS_DESCRIPTION=Le comportement par défaut du squelette est de lancer l'application java dans un processus différent (détaché). Si vous souhaitez forcer le lanceur à utiliser le même processus que l'exécutable, activez cette option. <p> Lorsque cette option est activée, JSmooth tentera toujours d'instancier une machine virtuelle java en utilisant la DLL (généralement jvm.dll) fournie par la JVM de Sun. Dans ce cas, un seul processus apparaitra pour votre application dans la liste des processus de l'ordinateur. SKEL_GENERIC_PROPERTY_SINGLEPROCESS_LABEL=Lancer java dans le même processus SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION=Activer la console de débogage JSmooth |
From: Rodrigo R. <re...@us...> - 2007-04-28 08:51:28
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/simplewrap In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19089 Modified Files: main.cpp Log Message: Changed the command line arguments for the ResourceManager refactoring Index: main.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/simplewrap/main.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** main.cpp 4 Apr 2007 19:47:09 -0000 1.25 --- main.cpp 28 Apr 2007 08:51:24 -0000 1.26 *************** *** 58,63 **** atexit(lastExit); - DEBUGCONSOLE = new DebugConsole("JSmooth Debug"); - globalResMan = new ResourceManager("JAVA", PROPID, JARID); --- 58,61 ---- *************** *** 66,79 **** if ((lpszArgument!=NULL) && (strlen(lpszArgument)>0)) { - DEBUG(string("Setting arguments: ") + lpszArgument); - // std::vector<std::string> args = StringUtils::split(lpszArgument, " \t\n\r", "\"'", true); - // globalResMan->setUserArguments( args ); - std::vector<std::string> args = StringUtils::split(lpszArgument, " \t\n\r", "\"'", false); - for (int i=0; i<args.size(); i++) - args[i] = StringUtils::fixArgumentString(args[i]); globalResMan->setUserArguments( args ); } std::string dodebug = globalResMan->getProperty("skel_Debug"); if ((StringUtils::parseInt(dodebug) != 0) && (DEBUGCONSOLE==0)) --- 64,72 ---- if ((lpszArgument!=NULL) && (strlen(lpszArgument)>0)) { std::vector<std::string> args = StringUtils::split(lpszArgument, " \t\n\r", "\"'", false); globalResMan->setUserArguments( args ); } + std::string dodebug = globalResMan->getProperty("skel_Debug"); if ((StringUtils::parseInt(dodebug) != 0) && (DEBUGCONSOLE==0)) *************** *** 82,85 **** --- 75,79 ---- } + if (DEBUGCONSOLE!=0) globalResMan->printDebug(); |
From: Rodrigo R. <re...@us...> - 2007-04-28 08:51:09
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/consolewrapper In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18709 Modified Files: Makefile.win main.cpp Log Message: Changed the command line arguments for the ResourceManager refactoring Index: main.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/consolewrapper/main.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** main.cpp 4 Apr 2007 19:47:09 -0000 1.16 --- main.cpp 28 Apr 2007 08:51:05 -0000 1.17 *************** *** 44,82 **** } - // std::string fixArgumentString(const std::string& arg) - // { - // string res; - // for (int i=0; i<arg.length(); i++) - // { - // char c = arg[i]; - // if (c == '\\') - // { - // if ((i + 1) < arg.length()) - // { - // if (arg[i+1] == '"') - // { - // res += "\\§§"; - // } - // } - // else - // { - // res += '\\'; - // } - // } - - // res += c; - // } - // return res; - // } - int main(int argc, char *argv[]) { - // for (int i=0; i<argc; i++) - // { - // printf("ARG ORIGINAL: [$%s]\n", argv[i]); - // } - ResourceManager* globalResMan = new ResourceManager("JAVA", PROPID, JARID); // sets up the arguments // --- 44,56 ---- } int main(int argc, char *argv[]) { ResourceManager* globalResMan = new ResourceManager("JAVA", PROPID, JARID); + for (int i=0; i<argc; i++) + { + DEBUG("ARGUMENT[" + StringUtils::toString(i) + "]=" + std::string(argv[i])); + } + // sets up the arguments // *************** *** 84,88 **** globalResMan->setProperty(string(ResourceManager::KEY_ARGUMENTS), ""); for (int i=1; i<argc; i++) ! globalResMan->addUserArgument(StringUtils::fixArgumentString(argv[i])); // --- 58,62 ---- globalResMan->setProperty(string(ResourceManager::KEY_ARGUMENTS), ""); for (int i=1; i<argc; i++) ! globalResMan->addUserArgument(argv[i]); // Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/consolewrapper/Makefile.win,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.win 1 Mar 2007 22:03:19 -0000 1.4 --- Makefile.win 28 Apr 2007 08:51:05 -0000 1.5 *************** *** 11,15 **** LIBS = -L"/lib" -L"../commonjava" -L"../util-core" ../commonjava/CommonJava.a ../util-core/util-core.a INCS = -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -I"/include/c++" -I"/include/c++/mingw32" -I"/include/c++/backward" -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I../util-core BIN = ConsoleWrapper.exe CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" --- 11,15 ---- LIBS = -L"/lib" -L"../commonjava" -L"../util-core" ../commonjava/CommonJava.a ../util-core/util-core.a INCS = -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -g -I"/include/c++" -I"/include/c++/mingw32" -I"/include/c++/backward" -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I../util-core BIN = ConsoleWrapper.exe CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" |
From: Rodrigo R. <re...@us...> - 2007-04-28 08:51:08
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/consolewrapper/samplejar In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18709/samplejar Modified Files: sample.props Log Message: Changed the command line arguments for the ResourceManager refactoring Index: sample.props =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/consolewrapper/samplejar/sample.props,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sample.props 1 Mar 2007 22:03:19 -0000 1.4 --- sample.props 28 Apr 2007 08:51:05 -0000 1.5 *************** *** 1,5 **** arguments=arg1 arg2 arg3 mainclassname=Sample ! classpath=sample.jar;..\\jsmoothgen.jar jvmsearch=javahome;registry;jrepath;jdkpath;exepath;jview minversion=1.1 --- 1,5 ---- arguments=arg1 arg2 arg3 mainclassname=Sample ! classpath=samplejar/sample.jar jvmsearch=javahome;registry;jrepath;jdkpath;exepath;jview minversion=1.1 |
From: Rodrigo R. <re...@us...> - 2007-04-28 08:50:48
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/autodownload In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18649 Modified Files: Makefile.win main.cpp Log Message: Changed the command line arguments for the ResourceManager refactoring Index: main.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/autodownload/main.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** main.cpp 4 Apr 2007 19:47:08 -0000 1.6 --- main.cpp 28 Apr 2007 08:50:44 -0000 1.7 *************** *** 75,80 **** // Note that this overwrites an existing KEY_ARGUMENTS std::vector<std::string> args = StringUtils::split(lpszArgument, " \t\n\r", "\"'", false); - for (int i=0; i<args.size(); i++) - args[i] = StringUtils::fixArgumentString(args[i]); globalResMan->setUserArguments( args ); } --- 75,78 ---- Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/autodownload/Makefile.win,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.win 1 Apr 2007 22:18:05 -0000 1.3 --- Makefile.win 28 Apr 2007 08:50:44 -0000 1.4 *************** *** 17,22 **** FLTK-CXXFLAGS = $(shell fltk-config --cxxflags) ##LINKLIBS = ../commonjava/CommonJava.a ../util-core/util-core.a mspack.a ../util-net/util-net.a ! LINKLIBS = ../commonjava/CommonJava.a ../util-core/util-core.a ../util-net/util-net.a ! LIBS = -L"$(MINGW)/lib" -L"/lib" -lws2_32 -L"/lib" -L"../commonjava" -mwindows -L"../util-core" $(LINKLIBS) $(FLTK-LDFLAGS) -lsetupapi INCS = -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS) --- 17,22 ---- FLTK-CXXFLAGS = $(shell fltk-config --cxxflags) ##LINKLIBS = ../commonjava/CommonJava.a ../util-core/util-core.a mspack.a ../util-net/util-net.a ! LINKLIBS = ../commonjava/CommonJava.a ../util-net/util-net.a ../util-core/util-core.a ! LIBS = -L. -L"$(MINGW)/lib" -L"/lib" -lws2_32 -L"/lib" -L"../commonjava" -mwindows -L"../util-core" -L"../util-net" $(LINKLIBS) $(FLTK-LDFLAGS) -lsetupapi INCS = -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS) *************** *** 33,37 **** $(BIN): $(LINKOBJ) $(LINKLIBS) ! $(CPP) $(LINKOBJ) -o $(BIN) $(LIBS) #mspack.a: $(libmscabd_la_SOURCES) --- 33,37 ---- $(BIN): $(LINKOBJ) $(LINKLIBS) ! $(CPP) $(CXXFLAGS) $(LINKOBJ) $(LIBS) -o $(BIN) #mspack.a: $(libmscabd_la_SOURCES) |
From: Rodrigo R. <re...@us...> - 2007-04-28 08:49:36
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/util-net In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18230 Modified Files: Makefile.win httpdownload.cpp Log Message: New uses the util-core/Thread class for threading Index: httpdownload.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-net/httpdownload.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** httpdownload.cpp 4 Mar 2007 23:21:44 -0000 1.2 --- httpdownload.cpp 28 Apr 2007 08:49:33 -0000 1.3 *************** *** 21,24 **** --- 21,26 ---- #include "httpdownload.h" + #include "Thread.h" + #include <stdlib.h> *************** *** 68,72 **** // the requests. // ! bool downloadHttpThread(void* param) { downloadThreadParams* dparam = (downloadThreadParams*)param; --- 70,74 ---- // the requests. // ! void downloadHttpThread(void* param) { downloadThreadParams* dparam = (downloadThreadParams*)param; *************** *** 117,121 **** params.downloadResult = false; ! downloadThread = _beginthread((void( __cdecl * )( void * ))downloadHttpThread, 0, (void*) ¶ms); Fl::add_timeout(1.0, updateProgressBar); Fl::run(); --- 119,125 ---- params.downloadResult = false; ! Thread th; ! th.start(downloadHttpThread, ¶ms); ! Fl::add_timeout(1.0, updateProgressBar); Fl::run(); Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-net/Makefile.win,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.win 5 Mar 2007 07:00:54 -0000 1.2 --- Makefile.win 28 Apr 2007 08:49:33 -0000 1.3 *************** *** 26,30 **** ar r $(BIN) $(OBJ) ranlib $(BIN) ! $(CPP) -g $(OBJ) testmain.o -o test.exe $(LIBS) ../util-core/util-core.a $(PROJECTNAME).a: $(OBJ) testmain.o --- 26,30 ---- ar r $(BIN) $(OBJ) ranlib $(BIN) ! $(CPP) -g $(OBJ) ../util-core/util-core.a testmain.o -o test.exe $(LIBS) $(PROJECTNAME).a: $(OBJ) testmain.o |
From: Rodrigo R. <re...@us...> - 2007-04-28 08:48:02
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/util-core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17460 Modified Files: Makefile.win testmain.cpp Added Files: Process.cpp Process.h Log Message: added Process class --- NEW FILE: Process.h --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __JSMOOTHCOREPROCESS_H_ #define __JSMOOTHCOREPROCESS_H_ #include <process.h> #include <windows.h> #include <winbase.h> #include <string> #include <stdio.h> /** * Provides basic string operations. * * @author Rodrigo Reyes <re...@ch...> */ class Process { PROCESS_INFORMATION m_procinfo; bool m_useconsole; std::string m_commandline; bool m_started; std::string m_redirection; bool m_redirectstderr; HANDLE m_redirectHandle; public: Process(const std::string& commandline, bool useconsole); void setRedirect(const std::string& filename); bool run(); void join(); }; #endif --- NEW FILE: Process.cpp --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "Process.h" #include "StringUtils.h" Process::Process(const std::string& commandline, bool useconsole) { m_commandline = commandline; m_useconsole = useconsole; m_started = false; m_redirectHandle = INVALID_HANDLE_VALUE; } void Process::setRedirect(const std::string& filename) { m_redirection = filename; m_useconsole = true; } bool Process::run() { STARTUPINFO info; GetStartupInfo(&info); int creationFlags = 0; int inheritsHandle; if (m_useconsole == true) { info.dwFlags = STARTF_USESHOWWINDOW|STARTF_USESTDHANDLES; info.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); info.hStdError = GetStdHandle(STD_ERROR_HANDLE); info.hStdInput = GetStdHandle(STD_INPUT_HANDLE); creationFlags = NORMAL_PRIORITY_CLASS; inheritsHandle = TRUE; } else { info.dwFlags = STARTF_USESHOWWINDOW; creationFlags = NORMAL_PRIORITY_CLASS | DETACHED_PROCESS; inheritsHandle = FALSE; } if (m_redirection.size() > 0) { SECURITY_ATTRIBUTES secattrs; secattrs.nLength = sizeof(SECURITY_ATTRIBUTES); secattrs.lpSecurityDescriptor = NULL; secattrs.bInheritHandle = TRUE; m_redirectHandle = CreateFile(m_redirection.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, &secattrs, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (m_redirectHandle == INVALID_HANDLE_VALUE) { return false; } info.hStdOutput = m_redirectHandle; info.hStdError = m_redirectHandle; info.dwFlags = STARTF_USESTDHANDLES; } // string exeline = StringUtils::fixQuotes(exepath) + " " + arguments; int res = CreateProcess(NULL, (char*)m_commandline.c_str(), NULL, NULL, inheritsHandle, creationFlags, NULL, NULL, &info, &m_procinfo); if (res != 0) { m_started = true; return true; } return false; } void Process::join() { if (!m_started) return; WaitForSingleObject(m_procinfo.hProcess, INFINITE); if (m_redirectHandle != INVALID_HANDLE_VALUE) { CloseHandle(m_redirectHandle); } } Index: testmain.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-core/testmain.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testmain.cpp 17 Mar 2007 08:50:38 -0000 1.2 --- testmain.cpp 28 Apr 2007 08:47:57 -0000 1.3 *************** *** 24,27 **** --- 24,37 ---- #include "StringUtils.h" #include <winnls.h> + #include "FileUtils.h" + + void _debugOutput(const std::string& text) + { + printf("%s\n", text.c_str()); + } + + void _debugWaitKey() + { + } int main(int argc, char *argv[]) *************** *** 34,37 **** --- 44,66 ---- if (res > 0) printf("result: %s\n", buffer); + + + std::string cmdlinetest = " \"this is my\ test\\\" \"here and then\""; + cmdlinetest = " \"this is my\ test here\\\" \"and\" \"then\""; + printf("splitting line <%s>\n", cmdlinetest.c_str()); + std::vector<std::string> args = StringUtils::split(cmdlinetest, " \t\n\r", "\"'", false, false); + for (int i=0; i<args.size(); i++) + { + printf("ARG[%d]=%s\n", i, args[i].c_str(), false, false); + } + + // std::string fqmethod = "void mytest1(java.lang.String test[ ] ) "; + // std::vector<std::string> t1 = StringUtils::split(fqmethod, " \t(,);][", "", false, true); + + // for (std::vector<std::string>::iterator i=t1.begin(); i != t1.end(); i++) + // printf("TOK: %s\n" , i->c_str()); + + // std::string readf = FileUtils::readFile("Log.h"); + // printf("READ: <<%s>>", readf.c_str()); } Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-core/Makefile.win,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.win 9 Apr 2007 17:19:14 -0000 1.2 --- Makefile.win 28 Apr 2007 08:47:57 -0000 1.3 *************** *** 8,12 **** MINGW = RES = ! OBJ = Log.o Thread.o FileUtils.o StringUtils.o DebugConsole.o $(RES) LIBS = -L"$(MINGW)/lib" -L"/lib" -lws2_32 INCS = -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" --- 8,12 ---- MINGW = RES = ! OBJ = Process.o Log.o Thread.o FileUtils.o StringUtils.o DebugConsole.o $(RES) LIBS = -L"$(MINGW)/lib" -L"/lib" -lws2_32 INCS = -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" |
From: Rodrigo R. <re...@us...> - 2007-04-28 08:47:30
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/util-core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17420 Modified Files: FileUtils.cpp FileUtils.h Log Message: added fileExists(string,string), getParent() and readFile() methods Index: FileUtils.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-core/FileUtils.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FileUtils.cpp 2 Apr 2007 22:11:44 -0000 1.3 --- FileUtils.cpp 28 Apr 2007 08:47:27 -0000 1.4 *************** *** 49,52 **** --- 49,58 ---- } + bool FileUtils::fileExists(const std::string& path, const std::string& filename) + { + std::string f = FileUtils::concFile(path, filename); + return fileExists(f); + } + vector<string> FileUtils::recursiveSearch(const string& pathdir, const string& pattern) { *************** *** 117,120 **** --- 123,138 ---- } + std::string FileUtils::getParent(const std::string &path) + { + if (path[path.length()-1] == '\\') + return getParent( path.substr(0, path.size() - 1) ); + + int pos = path.rfind('\\', path.npos); + if (pos != path.npos) + return path.substr(0, pos+1); + else + return path; + } + std::string FileUtils::getComputerName() { *************** *** 159,160 **** --- 177,208 ---- MoveFileEx(file.c_str(), 0, MOVEFILE_DELAY_UNTIL_REBOOT); } + + std::string FileUtils::readFile(const std::string& filename) + { + HANDLE f = CreateFile(filename.c_str(), GENERIC_READ, + FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + std::string result; + + if (f != INVALID_HANDLE_VALUE) + { + char buffer[129]; + DWORD hasread; + buffer[127] = 0; + + do { + ReadFile(f, buffer, 127, &hasread, NULL); + buffer[hasread] = 0; + result += buffer; + } while (hasread > 0); + + CloseHandle(f); + } + else + { + // printf("Can't open file %s\n",filename.c_str()); + } + + return result; + } Index: FileUtils.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-core/FileUtils.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FileUtils.h 2 Apr 2007 22:11:44 -0000 1.3 --- FileUtils.h 28 Apr 2007 08:47:27 -0000 1.4 *************** *** 56,59 **** --- 56,61 ---- static bool fileExists(const string& filename); + static bool fileExists(const std::string&path, const string& filename); + /** * Lookup recursively for files matching a given pattern in a given *************** *** 89,92 **** --- 91,97 ---- static std::string getExecutablePath(); + + static std::string getParent(const std::string &path); + /** * Returns the name of the executable binary that was used to start *************** *** 112,115 **** --- 117,122 ---- static bool isAbsolute(const std::string& filename); + static std::string readFile(const std::string& filename); + static void deleteOnReboot(std::string file); |
From: Rodrigo R. <re...@us...> - 2007-04-28 08:46:21
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/util-core In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16649 Modified Files: StringUtils.cpp StringUtils.h Log Message: added (un)escaping and command-line quoting methods Index: StringUtils.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-core/StringUtils.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StringUtils.cpp 4 Apr 2007 19:47:10 -0000 1.2 --- StringUtils.cpp 28 Apr 2007 08:46:17 -0000 1.3 *************** *** 21,25 **** #include "StringUtils.h" ! vector<string> StringUtils::split(const string& str, const string& separators, const string& quotechars, bool handleEscape) { vector<string> result; --- 21,26 ---- #include "StringUtils.h" ! vector<string> StringUtils::split(const string& str, const string& separators, const string& quotechars, ! bool handleEscape, bool returnSeparators) { vector<string> result; *************** *** 28,32 **** for (int i=0; i<str.length(); i++) { ! if ( handleEscape && (str[i] == '\\')) { i++; --- 29,33 ---- for (int i=0; i<str.length(); i++) { ! if ( handleEscape && (str[i] == '\\')) // Found an escaped char { i++; *************** *** 52,56 **** } } ! else if (separators.find(str[i], 0) != separators.npos) { if (buf.length() > 0) --- 53,57 ---- } } ! else if (separators.find(str[i], 0) != separators.npos) // found a separator... { if (buf.length() > 0) *************** *** 59,64 **** buf = ""; } } ! else if (quotechars.find(str[i], 0) != separators.npos) { if (buf.length() > 0) --- 60,73 ---- buf = ""; } + + if (returnSeparators) + { + buf += str[i]; + result.push_back(buf); + buf = ""; + } + } ! else if (quotechars.find(str[i], 0) != quotechars.npos) // Found a quote char... { if (buf.length() > 0) *************** *** 127,130 **** --- 136,146 ---- } + string StringUtils::toHexString(int val) + { + char buf[32]; + sprintf(buf, "%x", val); + return string(buf); + } + string StringUtils::toString(const vector<string>& seq) { *************** *** 241,244 **** --- 257,270 ---- } + string StringUtils::requoteForCommandLine(const string& str) + { + std::string res = StringUtils::replace(str, "\"", ""); + if (res[res.size()-1] == '\\') + res += "\\"; + // res = res.substr(0, res.size()-1); + return StringUtils::fixQuotes(res); + } + + string StringUtils::replace(const string& str, const string& pattern, const string& replacement) { *************** *** 265,268 **** --- 291,328 ---- } + std::string StringUtils::escape(const string& str) + { + std::string result; + for (int i=0; i<str.size(); i++) + { + if (str[i] == '\\') + result += "\\\\"; + else + result += str[i]; + } + return result; + } + + std::string StringUtils::unescape(const string& str) + { + std::string result; + for (int i=0; i<str.size(); i++) + { + if (str[i] == '\\') + { + if ((i+1<str.size()) && (str[i+1]=='\\')) + { + i++; + result += "\\"; + } + else + result += "\\"; + } + else + result += str[i]; + } + return result; + } + string StringUtils::toLowerCase(const string& str) { *************** *** 301,302 **** --- 361,386 ---- return res; } + + + std::string StringUtils::sizeToJavaString(int size) + { + if (size > (1024*1024)) + return StringUtils::toString(size / (1024*1024)) + "m"; + else if (size > 1024) + return StringUtils::toString(size / 1024) + "k"; + else + return StringUtils::toString(size); + } + + std::string StringUtils::sizeToJavaString(std::string size) + { + if ( (size.find('m') != string::npos) + || (size.find('M') != string::npos) + || (size.find('k') != string::npos) + || (size.find('K') != string::npos) ) + { + return size; + } + else + return sizeToJavaString(StringUtils::parseInt(size)); + } Index: StringUtils.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/util-core/StringUtils.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** StringUtils.h 4 Apr 2007 19:47:10 -0000 1.2 --- StringUtils.h 28 Apr 2007 08:46:17 -0000 1.3 *************** *** 71,75 **** * @param quotechars a string that contains all the characters that are used as quote chars. */ ! static vector<string> split(const string& str, const string& separators, const string& quotechars, bool handleEscape = true); /** --- 71,75 ---- * @param quotechars a string that contains all the characters that are used as quote chars. */ ! static vector<string> split(const string& str, const string& separators, const string& quotechars, bool handleEscape = true, bool returnSeparators = false); /** *************** *** 91,94 **** --- 91,95 ---- */ static string toString(int val); + static string toHexString(int val); /** *************** *** 136,141 **** * @return a fixed copy of the string */ ! static string fixQuotes(const string& str); ! /** * Ensures a string is correctly quoted, the quotes are enclosing --- 137,144 ---- * @return a fixed copy of the string */ ! static std::string fixQuotes(const string& str); ! ! static std::string escape(const string& str); ! static std::string unescape(const string& str); /** * Ensures a string is correctly quoted, the quotes are enclosing *************** *** 146,154 **** * @return a fixed copy of the string */ ! static string requote(const string& str); ! ! static string toLowerCase(const string& str); static std::string fixArgumentString(const std::string& arg); }; --- 149,161 ---- * @return a fixed copy of the string */ ! static std::string requote(const string& str); ! static std::string StringUtils::requoteForCommandLine(const string& str); ! static std::string toLowerCase(const string& str); static std::string fixArgumentString(const std::string& arg); + + static std::string sizeToJavaString(int size); + static std::string sizeToJavaString(std::string size); + }; |
Update of /cvsroot/jsmooth/jsmooth/skeletons/commonjava In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv15833 Modified Files: JavaMachineManager.cpp Makefile.win ResourceManager.cpp ResourceManager.h SunJVMLauncher.cpp SunJVMLauncher.h Added Files: JArgs.cpp JArgs.h JClassProxy.cpp JClassProxy.h JMethodCaller.cpp JMethodCaller.h JVMBase.cpp JVMBase.h SunJVMDLL.cpp SunJVMDLL.h SunJVMExe.cpp SunJVMExe.h test.cpp Log Message: Large refactoring of the DLL and EXE launchers --- NEW FILE: JMethodCaller.cpp --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "JMethodCaller.h" JMethodCaller::JMethodCaller(const std::string& clazz, const std::string& method) : m_isValid(false), m_static(false) { m_clazz = clazz; parseSignature(method); } JMethodCaller::JMethodCaller(const std::string& method) { parseSignature(method); } jvalue JMethodCaller::invoke(SunJVMDLL& jvm, jobject& obj, jvalue args[]) { jvalue res; DEBUG("invoking " + m_clazz + ": " + m_methodname + ", " + getJavaSignature()); jclass cl = jvm.findClass(m_clazz); if (cl == 0) { DEBUG("Can't find class " + m_clazz + " !!"); return res; } jmethodID m = jvm.findMethod(cl, m_methodname, getJavaSignature(), false); switch (m_returntype.TYPE) { case JVOID: jvm.invokeVoid(obj, m, args); break; case JBOOLEAN: res.z = jvm.invokeBoolean(obj, m, args); break; case JBYTE: res.b = jvm.invokeByte(obj, m, args); break; case JCHAR: res.c = jvm.invokeChar(obj, m, args); break; case JSHORT: res.s = jvm.invokeShort(obj, m, args); break; case JINT: res.i = jvm.invokeInt(obj, m, args); break; case JLONG: res.j = jvm.invokeLong(obj, m, args); break; case JFLOAT: res.f = jvm.invokeFloat(obj, m, args); break; case JDOUBLE: res.d = jvm.invokeDouble(obj, m, args); break; case JOBJECT: res.l = jvm.invokeObject(obj, m, args); break; } return res; } jvalue JMethodCaller::invokeStatic(SunJVMDLL& launcher, jvalue args[]) { jvalue res; jclass cl = launcher.findClass(m_clazz); jmethodID m = launcher.findMethod(cl, m_methodname, getJavaSignature(), true); DEBUG("Invoke Static " + m_methodname + " " + getJavaSignature()); switch (m_returntype.TYPE) { case JVOID: launcher.invokeVoidStatic(cl, m, args); break; case JBOOLEAN: res.z = launcher.invokeBooleanStatic(cl, m, args); break; case JBYTE: res.b = launcher.invokeByteStatic(cl, m, args); break; case JCHAR: res.c = launcher.invokeCharStatic(cl, m, args); break; case JSHORT: res.s = launcher.invokeShortStatic(cl, m, args); break; case JINT: res.i = launcher.invokeIntStatic(cl, m, args); break; case JLONG: res.j = launcher.invokeLongStatic(cl, m, args); break; case JOBJECT: res.l = launcher.invokeObjectStatic(cl, m, args); break; } return res; } std::string JMethodCaller::getJavaSignature() { std::string res = "("; for (std::vector<JDATATYPE>::iterator i=m_arguments.begin(); i != m_arguments.end(); i++) { res += StringUtils::replace(getDatatypeSignature(*i), ".", "/"); } res += ")"; res += getDatatypeSignature(m_returntype); return res; } std::string JMethodCaller::getDatatypeSignature(const JDATATYPE& d) { std::string res; for (int j=0; j<d.ARRAYLEVEL; j++) res += "["; switch(d.TYPE) { case JBOOLEAN: res += "Z"; break; case JBYTE: res += "B"; break; case JCHAR: res += "C"; break; case JSHORT: res += "S"; break; case JINT: res += "I"; break; case JLONG: res += "J"; break; case JFLOAT: res += "F"; break; case JDOUBLE: res += "D"; break; case JVOID: res += "V"; break; case JOBJECT: res += "L" + d.CLASSNAME + ";"; break; } return res; } std::string JMethodCaller::toString() { if (m_parsingError != "") return m_parsingError; std::string res = ""; res += "Returntype(" + m_returntype.toString() + ") "; res += "methodname(" + m_methodname + ") "; res += "argumentlist("; for (std::vector<JDATATYPE>::iterator i=m_arguments.begin(); i != m_arguments.end(); i++) { res += "::" + i->toString(); } res += ") "; return res; } bool JMethodCaller::parseSignature(const std::string& fqmethod) { JDATATYPE emptyData; emptyData.ARRAYLEVEL = 0; emptyData.CLASSNAME = ""; emptyData.TYPE = -1; emptyData.INTERNALNAME = ""; // // Clear data // m_returntype = emptyData; m_arguments.clear(); m_methodname = ""; m_parsingError = ""; m_isValid = false; std::vector<std::string> tokens = StringUtils::split(fqmethod, " \t(,);[]", "", false, true); // states of the automata: // 0: expecting the return type (goes to 0 or 1) // 1: expecting the method name or a modifier (goes to 1 or 2) // 2: expecting a ( (goes to 3) // 3: expecting a type (goes to 4) // 4: expecting a modifier, a name, a ",", or a ")" (goes to 3 or 4 or 9) // 9: end of the automata (end) int state = 0; JDATATYPE curData; // DEBUG("Start parsing " + fqmethod); for (std::vector<std::string>::iterator i=tokens.begin(); i != tokens.end(); i++) { while ( (i != tokens.end() ) && ((*i == " ") || (*i == "\t"))) i++; if (i == tokens.end()) { if (state == 9) { m_isValid = true; return true; } m_parsingError = "Uncomplete parsing"; return false; } // DEBUG("Current non-space token: " + *i + ", state: " + StringUtils::toString(state)); string tok = *i; switch (state) { // 0: expecting the return type case 0: { int type = parseType(tok); curData = emptyData; if (type == JOBJECT) { curData.TYPE = JOBJECT; curData.CLASSNAME = tok; } else curData.TYPE = type; // DEBUG("Return type found : " + StringUtils::toString(curData.TYPE)); state = 1; } break; case 1: if (tok == "[") { while ( (i != tokens.end()) && (*i != "]") ) i++; if (i == tokens.end()) { m_parsingError = "Unfinished array modifier"; return false; } curData.ARRAYLEVEL++; // DEBUG("Return type modifier: array+1"); } else { m_returntype = curData; curData = emptyData; m_methodname = tok; // DEBUG("Found method name: " + tok); state = 2; } break; case 2: if (tok == "(") state = 3; else { m_parsingError = "Expecting a (, got a " + tok; return false; } // DEBUG("Now parsing arguments..."); break; case 3: { int type = parseType(tok); // DEBUG("Argument type parsed: " + StringUtils::toString(type)); curData = emptyData; if (type == JOBJECT) { curData.TYPE = JOBJECT; curData.CLASSNAME = tok; } else curData.TYPE = type; state = 4; } break; case 4: if (tok == ")") { // DEBUG("End of argument list"); m_arguments.push_back(curData); state = 9; } else if (tok == ",") { m_arguments.push_back(curData); state = 3; // DEBUG("New argument starting"); } else if (tok == "[") { // DEBUG("Array started, looking for end"); while ( (i != tokens.end()) && (*i != "]") ) { // DEBUG("Array-skipping " + *i); i++; } if (i == tokens.end()) { m_parsingError = "Unfinished array modifier"; // DEBUG(m_parsingError); return false; } else i++; curData.ARRAYLEVEL++; // DEBUG("Parsed array modifier"); } else { if (curData.INTERNALNAME == "") curData.INTERNALNAME = tok; else { m_parsingError = "Unexpected token " + tok; return false; } } break; case 9: // DEBUG("Completed successfully"); m_isValid = true; return true; default: DEBUG("ERROR, unknown state " + StringUtils::toString(state)); } // DEBUG("New state: " + StringUtils::toString(state)); } if (state == 9) { // DEBUG("Parsed correctly"); m_isValid = true; return true; } // DEBUG("INCORRECT STATE"); return false; } int JMethodCaller::parseType(const std::string& tok) { if (tok == "boolean") return JBOOLEAN; else if (tok == "byte") return JBYTE; else if (tok == "char") return JCHAR; else if (tok == "short") return JSHORT; else if (tok == "int") return JINT; else if (tok == "long") return JLONG; else if (tok == "double") return JDOUBLE; else if (tok == "void") return JVOID; else return JOBJECT; } --- NEW FILE: SunJVMExe.h --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __SUNJVMEXE_H_ #define __SUNJVMEXE_H_ #include <string> #include "Version.h" #include "StringUtils.h" #include "FileUtils.h" #include "ResourceManager.h" #include "JavaProperty.h" #include "JVMBase.h" /** * Manages a Sun's JVM available on the computer. * @author Rodrigo Reyes <re...@ch...> */ class SunJVMExe : public JVMBase { private: std::string m_jrehome; Version m_version; public: SunJVMExe(const std::string& jrehome); SunJVMExe(const std::string& jrehome, const Version& v); Version guessVersion(); bool run(const std::string& mainclass, bool useconsole); std::string lookUpExecutable(bool useconsole); std::string getClassPath(bool full); private: }; #endif --- NEW FILE: SunJVMDLL.cpp --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "SunJVMDLL.h" #include "JClassProxy.h" SunJVMDLL::SunJVMDLL(const std::string& jvmdll, const Version& v) { m_dllpath = jvmdll; m_version = v; m_statusCode = SunJVMDLL::JVM_NOT_STARTED; m_vmlib = NULL; } SunJVMDLL::~SunJVMDLL() { if (m_vmlib != NULL) { FreeLibrary(m_vmlib); } } bool SunJVMDLL::run(const std::string& mainclass) { if (m_statusCode == SunJVMDLL::JVM_NOT_STARTED) instanciate(); if (m_statusCode == SunJVMDLL::JVM_LOADED) { JClassProxy disp(this, mainclass); jstring emptystr = newUTFString(std::string("")); jobjectArray mainargs = newObjectArray(m_arguments.size(), "java.lang.String", emptystr); for (int i =0; i<m_arguments.size(); i++) { env()->SetObjectArrayElement(mainargs, i, newUTFString(m_arguments[i])); } printf("arguments array = %d\n", mainargs); jvalue ma[1]; ma[0].l = mainargs; disp.invokeStatic(std::string("void main(java.lang.String[] args)"), ma); return true; } return false; } bool SunJVMDLL::instanciate() { m_vmlib = LoadLibrary(m_dllpath.c_str()); if (m_vmlib == NULL) { m_statusCode = SunJVMDLL::JVM_DLL_CANT_LOAD; return false; } CreateJavaVM_t CreateJavaVM = (CreateJavaVM_t)GetProcAddress(m_vmlib, "JNI_CreateJavaVM"); GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs = (GetDefaultJavaVMInitArgs_t)GetProcAddress(m_vmlib, "JNI_GetDefaultJavaVMInitArgs"); if ((CreateJavaVM == NULL) || (GetDefaultJavaVMInitArgs == NULL)) { m_statusCode = SunJVMDLL::JVM_CANT_USE_VM; return false; } DEBUG("VM Created successfully"); m_javavm = new JavaVM(); m_javaenv = new JNIEnv(); bool res; if ((m_version.getMajor() == 1) && (m_version.getMinor() == 1)) res = setupVM11DLL(CreateJavaVM, GetDefaultJavaVMInitArgs); else res = setupVM12DLL(CreateJavaVM, GetDefaultJavaVMInitArgs); if (res) { m_statusCode = SunJVMDLL::JVM_LOADED; return true; } return false; } bool SunJVMDLL::setupVM12DLL(CreateJavaVM_t CreateJavaVM, GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs) { vector<string> jpropstrv; for (int i=0; i<m_properties.size(); i++) jpropstrv.push_back( "-D" + m_properties[i].getName() + "=" + m_properties[i].getValue()); // DEBUG("MAXHEAP: " + StringUtils::toString(m_maxHeap)); // DEBUG("INITIALHEAP: " + StringUtils::toString(m_initialHeap)); if (m_maxHeap > 0) { jpropstrv.push_back("-Xmx" +StringUtils::toString(m_maxHeap)); } if (m_initialHeap > 0) { jpropstrv.push_back("-Xms" + StringUtils::toString(m_initialHeap)); } JavaVMInitArgs vm_args; GetDefaultJavaVMInitArgs(&vm_args); JavaVMOption options[1 + jpropstrv.size()]; std::string cpoption = "-Djava.class.path=" + StringUtils::join(m_pathElements, ";"); DEBUG("Classpath: " + cpoption); options[0].optionString = (char*)cpoption.c_str(); vm_args.version = 0x00010002; vm_args.version = JNI_VERSION_1_2; vm_args.options = options; vm_args.nOptions = 1 + jpropstrv.size(); for (int i=0; i<jpropstrv.size(); i++) { options[1 + i].optionString = (char*)jpropstrv[i].c_str(); DEBUG(string("Option added:") + options[1+i].optionString); } vm_args.ignoreUnrecognized = JNI_TRUE; // // Create the VM if (CreateJavaVM( &m_javavm, &m_javaenv, &vm_args) != 0) { DEBUG("Can't create VM"); m_statusCode = SunJVMDLL::JVM_CANT_CREATE_VM; return false; } DEBUG("VM 1.2+ Created successfully !!"); return true; } bool SunJVMDLL::setupVM11DLL(CreateJavaVM_t CreateJavaVM, GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs) { JDK1_1InitArgs vm_args; vm_args.version = 0x00010001; GetDefaultJavaVMInitArgs(&vm_args); if (m_maxHeap > 0) vm_args.maxHeapSize = m_maxHeap; if (m_initialHeap > 0) vm_args.minHeapSize = m_initialHeap; // // create the properties array // char const * props[m_properties.size()+1]; vector<string> jpropstrv; for (int i=0; i<m_properties.size(); i++) jpropstrv[i] = m_properties[i].getName() + "=" + m_properties[i].getValue(); for (int i=0; i<m_properties.size(); i++) props[i] = jpropstrv[i].c_str(); props[m_properties.size()] = NULL; vm_args.properties = (char**)props; /* Append USER_CLASSPATH to the default system class path */ std::string classpath = vm_args.classpath; classpath += StringUtils::join(m_pathElements, ";"); DEBUG("Classpath = " + classpath); vm_args.classpath = (char*)classpath.c_str(); // // Create the VM if (CreateJavaVM( &m_javavm, &m_javaenv, &vm_args) != 0) { DEBUG("Can't create VM"); m_statusCode = SunJVMDLL::JVM_CANT_CREATE_VM; return false; } DEBUG("VM 1.1 Created successfully !!"); return true; } jclass SunJVMDLL::findClass(const std::string& clazz) { std::string classname = StringUtils::replace(clazz,".", "/"); DEBUG("Looking up for class <" + classname + ">"); jclass cls = env()->FindClass(classname.c_str()); if (cls == 0) DEBUG("Can't find class " + classname + " !"); return cls; } jmethodID SunJVMDLL::findMethod(jclass& cls, const std::string& methodname, const std::string& signature, bool isStatic) { jmethodID mid; if (isStatic) mid = env()->GetStaticMethodID(cls, methodname.c_str(), signature.c_str()); else mid = env()->GetMethodID(cls, methodname.c_str(), signature.c_str()); return mid; } JavaVM* SunJVMDLL::getJavaVM() { return m_javavm; } jstring SunJVMDLL::newUTFString(const std::string& str) { return env()->NewStringUTF(str.c_str()); } jobject SunJVMDLL::newObject(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->NewObjectA(clazz, methodid, arguments); } jobjectArray SunJVMDLL::newObjectArray(int size, jclass clazz, jobject initialValue) { return env()->NewObjectArray((jsize)size, clazz, initialValue); } jobjectArray SunJVMDLL::newObjectArray(int size, const std::string& classname, jobject initialValue) { jclass cls = findClass(classname); return newObjectArray(size, cls, initialValue); } // // Static method invocation // void SunJVMDLL::invokeVoidStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { env()->CallStaticVoidMethodA(clazz, methodid, arguments); } jboolean SunJVMDLL::invokeBooleanStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticBooleanMethodA(clazz, methodid, arguments); } jbyte SunJVMDLL::invokeByteStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticByteMethodA(clazz, methodid, arguments); } jchar SunJVMDLL::invokeCharStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticCharMethodA(clazz, methodid, arguments); } jshort SunJVMDLL::invokeShortStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticShortMethodA(clazz, methodid, arguments); } jint SunJVMDLL::invokeIntStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticIntMethodA(clazz, methodid, arguments); } jlong SunJVMDLL::invokeLongStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticLongMethodA(clazz, methodid, arguments); } jfloat SunJVMDLL::invokeFloatStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticFloatMethodA(clazz, methodid, arguments); } jdouble SunJVMDLL::invokeDoubleStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticDoubleMethodA(clazz, methodid, arguments); } jobject SunJVMDLL::invokeObjectStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) { return env()->CallStaticObjectMethodA(clazz, methodid, arguments); } // // method invocation // void SunJVMDLL::invokeVoid(jobject& obj, jmethodID& methodid, jvalue arguments[]) { env()->CallVoidMethodA(obj, methodid, arguments); } jboolean SunJVMDLL::invokeBoolean(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallBooleanMethodA(obj, methodid, arguments); } jbyte SunJVMDLL::invokeByte(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallByteMethodA(obj, methodid, arguments); } jchar SunJVMDLL::invokeChar(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallCharMethodA(obj, methodid, arguments); } jshort SunJVMDLL::invokeShort(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallShortMethodA(obj, methodid, arguments); } jint SunJVMDLL::invokeInt(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallIntMethodA(obj, methodid, arguments); } jlong SunJVMDLL::invokeLong(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallLongMethodA(obj, methodid, arguments); } jfloat SunJVMDLL::invokeFloat(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallFloatMethodA(obj, methodid, arguments); } jdouble SunJVMDLL::invokeDouble(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallDoubleMethodA(obj, methodid, arguments); } jobject SunJVMDLL::invokeObject(jobject& obj, jmethodID& methodid, jvalue arguments[]) { return env()->CallObjectMethodA(obj, methodid, arguments); } Index: ResourceManager.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/ResourceManager.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ResourceManager.h 12 Apr 2007 20:01:50 -0000 1.13 --- ResourceManager.h 28 Apr 2007 08:43:43 -0000 1.14 *************** *** 60,63 **** --- 60,65 ---- HGLOBAL m_jarHandler; int m_jarSize; + + std::vector<std::string> m_arguments; std::vector<std::string> m_deleteOnFinalize; *************** *** 168,171 **** --- 170,175 ---- void addUserArgument(std::string argument); + std::vector<std::string> getArguments(); + int getResourceSize(int id); HGLOBAL getResource(int id); --- NEW FILE: JArgs.cpp --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "JArgs.h" JArgs::JArgs() { } JArgs::JArgs(SunJVMDLL* vm) { m_vm = vm; } jvalue* JArgs::allocArray() { jvalue* args = new jvalue[m_values.size()]; for (int i=0; i<m_values.size(); i++) { args[i] = m_values[i]; } return args; } JArgs& JArgs::add(int i) { jvalue v; v.i = i; m_values.push_back(v); return *this; } JArgs& JArgs::add(jobject &o) { jvalue v; v.l = o; m_values.push_back(v); return *this; } JArgs& JArgs::add(bool b) { jvalue v; v.z = b; m_values.push_back(v); return *this; } JArgs& JArgs::add(const std::string& str ) { jvalue v; v.l = m_vm->newUTFString(str); m_values.push_back(v); return *this; } --- NEW FILE: SunJVMDLL.h --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __SUNJVMDLL_H_ #define __SUNJVMDLL_H_ #include <string> #include "jni.h" #include "Version.h" #include "StringUtils.h" #include "FileUtils.h" #include "ResourceManager.h" #include "JavaProperty.h" #include "JVMBase.h" typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, JNIEnv **env, void *args); typedef jint (JNICALL *GetDefaultJavaVMInitArgs_t)(void *args); /** * Manages a Sun's JVM available on the computer. * @author Rodrigo Reyes <re...@ch...> */ class SunJVMDLL : public JVMBase { public: enum StatusCode { JVM_NOT_STARTED=0, JVM_DLL_CANT_LOAD , JVM_CANT_CREATE_VM , JVM_CANT_USE_VM, JVM_LOADED } ; /** * The path to the .DLL that can be used to create a JVM * instance. The string may be empty is the information is not * known. */ std::string m_dllpath; Version m_version; HINSTANCE m_vmlib; StatusCode m_statusCode; protected: JavaVM *m_javavm; JNIEnv *m_javaenv; public: SunJVMDLL(const std::string& jvmdll, const Version& v); ~SunJVMDLL(); bool instanciate(); bool setupVM12DLL(CreateJavaVM_t CreateJavaVM, GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs); bool setupVM11DLL(CreateJavaVM_t CreateJavaVM, GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs); JNIEnv* env() { JNIEnv* env; jint result = m_javavm->AttachCurrentThread((void**)&env, 0); return env; } bool run(const std::string& mainclass); jclass findClass(const std::string& clazz); jmethodID findMethod(jclass& cls, const std::string& methodname, const std::string& signature, bool isStatic); JavaVM* getJavaVM(); jstring newUTFString(const std::string& str); jobject newObject(jclass clazz, jmethodID& methodid, jvalue arguments[]); jobjectArray newObjectArray(int size, jclass clazz, jobject initialValue); jobjectArray newObjectArray(int size, const std::string& classname, jobject initialValue); void invokeVoidStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); jboolean invokeBooleanStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); jbyte invokeByteStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); jchar invokeCharStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); jshort invokeShortStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); jint invokeIntStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); jlong invokeLongStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); jfloat invokeFloatStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); jdouble invokeDoubleStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); jobject invokeObjectStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); void invokeVoid(jobject& obj, jmethodID& methodid, jvalue arguments[]); jboolean invokeBoolean(jobject& obj, jmethodID& methodid, jvalue arguments[]); jbyte invokeByte(jobject& obj, jmethodID& methodid, jvalue arguments[]); jchar invokeChar(jobject& obj, jmethodID& methodid, jvalue arguments[]); jshort invokeShort(jobject& obj, jmethodID& methodid, jvalue arguments[]); jint invokeInt(jobject& obj, jmethodID& methodid, jvalue arguments[]); jlong invokeLong(jobject& obj, jmethodID& methodid, jvalue arguments[]); jfloat invokeFloat(jobject& obj, jmethodID& methodid, jvalue arguments[]); jdouble invokeDouble(jobject& obj, jmethodID& methodid, jvalue arguments[]); jobject invokeObject(jobject& obj, jmethodID& methodid, jvalue arguments[]); }; #endif Index: SunJVMLauncher.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/SunJVMLauncher.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SunJVMLauncher.h 12 Apr 2007 20:01:50 -0000 1.11 --- SunJVMLauncher.h 28 Apr 2007 08:43:43 -0000 1.12 *************** *** 23,27 **** #include <string> ! #include <jni.h> #include "Version.h" --- 23,27 ---- #include <string> ! #include "jni.h" #include "Version.h" *************** *** 31,34 **** --- 31,37 ---- #include "JavaProperty.h" + #include "SunJVMDLL.h" + #include "SunJVMExe.h" + typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, JNIEnv **env, void *args); typedef jint (JNICALL *GetDefaultJavaVMInitArgs_t)(void *args); *************** *** 55,60 **** }; ! int Status; ! protected: --- 58,62 ---- }; ! int LaunchingStatus; protected: *************** *** 105,111 **** --- 107,118 ---- * false otherwise. */ + virtual bool runProc(ResourceManager& resource, bool noConsole, const string& origin); + virtual bool setupVM(ResourceManager& resource, JVMBase* vm); + + std::string toString() const; + Version guessVersionByProcess(const string& exepath); *************** *** 119,122 **** --- 126,138 ---- int destroyVM(); + JavaVM* getJavaVM(); + + jclass findClass(const std::string& clazz); + jmethodID findMethod(jclass& cls, const std::string& methodname, const std::string& signature, bool isStatic); + + void invokeVoidStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); + // jvaluea invokeIntStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); + jint invokeIntStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); + jlong invokeLongStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]); private: *************** *** 129,135 **** bool runVM11proc(ResourceManager& resource, bool noConsole, const string& origin); bool runVM12proc(ResourceManager& resource, bool noConsole, const string& origin); ! ! std::string sizeToString(int size); ! std::string sizeToString(std::string size); }; --- 145,149 ---- bool runVM11proc(ResourceManager& resource, bool noConsole, const string& origin); bool runVM12proc(ResourceManager& resource, bool noConsole, const string& origin); ! }; Index: JavaMachineManager.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/JavaMachineManager.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** JavaMachineManager.cpp 9 Apr 2007 17:18:16 -0000 1.16 --- JavaMachineManager.cpp 28 Apr 2007 08:43:43 -0000 1.17 *************** *** 120,136 **** { DEBUG("- Trying to use PATH"); ! string exename = dontUseConsole?"javaw.exe":"java.exe"; SunJVMLauncher launcher; ! launcher.VmVersion = launcher.guessVersionByProcess("java.exe"); ! if (launcher.VmVersion.isValid() ! && (!min.isValid() || (min <= launcher.VmVersion)) ! && (!max.isValid() || (launcher.VmVersion <= max))) ! { ! DEBUG("Found valid java machine " + exename + " on PATH (" + launcher.VmVersion.toString() + ")"); ! Version v12("1.2.0"); ! if (launcher.runExe(exename, false, m_resman, dontUseConsole, (launcher.VmVersion<v12)?"1.1":"1.2", "path")) ! return true; ! } } } --- 120,140 ---- { DEBUG("- Trying to use PATH"); ! SunJVMLauncher launcher; ! return launcher.runProc(m_resman, ! dontUseConsole, "path"); ! ! // string exename = dontUseConsole?"javaw.exe":"java.exe"; ! // SunJVMLauncher launcher; ! // launcher.VmVersion = launcher.guessVersionByProcess("java.exe"); ! // if (launcher.VmVersion.isValid() ! // && (!min.isValid() || (min <= launcher.VmVersion)) ! // && (!max.isValid() || (launcher.VmVersion <= max))) ! // { ! // DEBUG("Found valid java machine " + exename + " on PATH (" + launcher.VmVersion.toString() + ")"); ! // Version v12("1.2.0"); ! // if (launcher.runExe(exename, false, m_resman, dontUseConsole, (launcher.VmVersion<v12)?"1.1":"1.2", "path")) ! // return true; ! // } } } Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/Makefile.win,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile.win 12 Apr 2007 20:01:50 -0000 1.6 --- Makefile.win 28 Apr 2007 08:43:43 -0000 1.7 *************** *** 8,13 **** MINGW = RES = ! OBJ = JavaMachineManager.o JVMEnvVarLookup.o JVMRegistryLookup.o MSJViewLauncher.o Properties.o ResourceManager.o SunJVMLauncher.o Version.o global.o JavaProperty.o $(RES) ! LINKOBJ = JavaMachineManager.o JVMEnvVarLookup.o JVMRegistryLookup.o MSJViewLauncher.o Properties.o ResourceManager.o SunJVMLauncher.o Version.o global.o JavaProperty.o $(RES) LIBS = -L"$(MINGW)/lib" INCS = -I"../util-core" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" --- 8,13 ---- MINGW = RES = ! OBJ = JVMBase.o SunJVMExe.o JArgs.o JClassProxy.o SunJVMDLL.o JavaMachineManager.o JVMEnvVarLookup.o JVMRegistryLookup.o MSJViewLauncher.o Properties.o ResourceManager.o SunJVMLauncher.o Version.o global.o JavaProperty.o JMethodCaller.o $(RES) ! LINKOBJ = JVMBase.o SunJVMExe.o JArgs.o JClassProxy.o SunJVMDLL.o JavaMachineManager.o JVMEnvVarLookup.o JVMRegistryLookup.o MSJViewLauncher.o Properties.o ResourceManager.o SunJVMLauncher.o Version.o global.o JavaProperty.o JMethodCaller.o $(RES) LIBS = -L"$(MINGW)/lib" INCS = -I"../util-core" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" *************** *** 25,31 **** $(RM) $(OBJ) $(BIN) ! $(BIN): $(LINKOBJ) ar r $(BIN) $(LINKOBJ) ranlib $(BIN) JavaMachineManager.o: JavaMachineManager.cpp --- 25,32 ---- $(RM) $(OBJ) $(BIN) ! $(BIN): $(LINKOBJ) test.cpp ar r $(BIN) $(LINKOBJ) ranlib $(BIN) + $(CPP) $(CXXFLAGS) test.cpp $(BIN) ../util-core/util-core.a -o test.exe JavaMachineManager.o: JavaMachineManager.cpp --- NEW FILE: JMethodCaller.h --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __JMETHODCALLER_H_ #define __JMETHODCALLER_H_ #include <string> #include <vector> #include "common.h" #include "StringUtils.h" #include "SunJVMDLL.h" /** * * @author Rodrigo Reyes <re...@ch...> */ class JMethodCaller { enum { JBOOLEAN = 1, JBYTE, JCHAR, JSHORT, JINT, JLONG, JFLOAT, JDOUBLE, JVOID, JOBJECT } ; struct JDATATYPE { int TYPE; std::string CLASSNAME; int ARRAYLEVEL; std::string INTERNALNAME; std::string toString() { std::string modifier = ""; for (int i=0; i<ARRAYLEVEL; i++) modifier += "[]"; switch(TYPE) { case JBOOLEAN: return "boolean " + INTERNALNAME + modifier; case JBYTE: return "byte " + INTERNALNAME + modifier; case JCHAR: return "char " + INTERNALNAME + modifier; case JSHORT: return "short " + INTERNALNAME + modifier; case JINT: return "int " + INTERNALNAME + modifier; case JLONG: return "long " + INTERNALNAME + modifier; case JFLOAT: return "float " + INTERNALNAME + modifier; case JDOUBLE: return "double " + INTERNALNAME + modifier; case JVOID: return "void " + INTERNALNAME + modifier; case JOBJECT: return "Class " + CLASSNAME + " " + INTERNALNAME + modifier; } return "<UnknownJavaType>" + modifier; } }; private: bool m_static; std::string m_clazz; std::string m_methodname; JDATATYPE m_returntype; std::vector<JDATATYPE> m_arguments; std::string m_parsingError; bool m_isValid; public: JMethodCaller(const std::string& clazz, const std::string& method); JMethodCaller(const std::string& method); jvalue invokeStatic(SunJVMDLL& launcher, jvalue args[]); jvalue invoke(SunJVMDLL& jvm, jobject& obj, jvalue args[]); std::string toString(); std::string getJavaSignature(); private: bool parseSignature(const std::string& fqmethod); std::string getDatatypeSignature(const JDATATYPE& d); int parseType(const std::string& tok); }; #endif Index: ResourceManager.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/ResourceManager.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ResourceManager.cpp 12 Apr 2007 20:01:50 -0000 1.21 --- ResourceManager.cpp 28 Apr 2007 08:43:43 -0000 1.22 *************** *** 59,63 **** return; } ! // // loads the jar information --- 59,69 ---- return; } ! ! // ! // Split the arguments ! // ! m_arguments = StringUtils::split(getProperty(KEY_ARGUMENTS, ""), " \t\n\r", "\"\'"); ! ! // // loads the jar information *************** *** 260,264 **** for (map<string, string>::iterator i = props.begin(); i != props.end(); i++) { ! DEBUG(" - Property: " + i->first + "=" + i->second); } } --- 266,270 ---- for (map<string, string>::iterator i = props.begin(); i != props.end(); i++) { ! DEBUG(" - Property: " + i->first + "=<" + i->second+">"); } } *************** *** 266,271 **** void ResourceManager::setUserArguments(std::vector<std::string> arguments) { ! if (arguments.size() > 0) ! setProperty(KEY_ARGUMENTS, ""); for (std::vector<std::string>::iterator i=arguments.begin(); i != arguments.end(); i++) { --- 272,277 ---- void ResourceManager::setUserArguments(std::vector<std::string> arguments) { ! m_arguments.clear(); ! for (std::vector<std::string>::iterator i=arguments.begin(); i != arguments.end(); i++) { *************** *** 291,299 **** else { ! setProperty(KEY_ARGUMENTS, getProperty(KEY_ARGUMENTS) + " " + StringUtils::fixQuotes(argument) ); ! DEBUG("Added user argument " + argument); } } int ResourceManager::getResourceSize(int id) { --- 297,310 ---- else { ! m_arguments.push_back(argument); ! // setProperty(KEY_ARGUMENTS, getProperty(KEY_ARGUMENTS) + " " + StringUtils::requoteForCommandLine(StringUtils::escape(argument)) ); } } + std::vector<std::string> ResourceManager::getArguments() + { + return m_arguments; + } + int ResourceManager::getResourceSize(int id) { Index: SunJVMLauncher.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/SunJVMLauncher.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** SunJVMLauncher.cpp 12 Apr 2007 20:01:50 -0000 1.25 --- SunJVMLauncher.cpp 28 Apr 2007 08:43:43 -0000 1.26 *************** *** 20,23 **** --- 20,28 ---- #include "SunJVMLauncher.h" + #include "Process.h" + + #include "SunJVMDLL.h" + #include "JArgs.h" + #include "JClassProxy.h" extern "C" { [...1654 lines suppressed...] ! ! // jint SunJVMLauncher::invokeIntStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) ! // { ! // JNIEnv *env = new JNIEnv(); ! // jint result = m_javavm->AttachCurrentThread((void**)&env, 0); ! // DEBUG("Attached thread to the VM: " + StringUtils::toString(result)); ! // JNIEnv* jenv = env; ! ! // return jenv->CallStaticIntMethodA(clazz, methodid, arguments); ! // } ! ! // jlong SunJVMLauncher::invokeLongStatic(jclass clazz, jmethodID& methodid, jvalue arguments[]) ! // { ! // JNIEnv *env = new JNIEnv(); ! // jint result = m_javavm->AttachCurrentThread((void**)&env, 0); ! // DEBUG("Attached thread to the VM: " + StringUtils::toString(result)); ! // JNIEnv* jenv = env; ! ! // return jenv->CallStaticLongMethodA(clazz, methodid, arguments); ! // } --- NEW FILE: JClassProxy.cpp --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "JClassProxy.h" JClassProxy::JClassProxy(SunJVMDLL* vm, const std::string& classname) { m_vm = vm; m_class = m_vm->findClass(classname); m_classname = classname; } jobject JClassProxy::newInstance(const std::string& signature, JArgs args) { jvalue* jv = args.allocArray(); jobject res = newInstance(signature, jv); delete jv; return res; } jobject JClassProxy::newInstance(const std::string& signature, jvalue arguments[]) { JMethodCaller caller(signature); jmethodID m = m_vm->findMethod(m_class, "<init>", caller.getJavaSignature(), false); printf("Constructor %s:%s: %d/%d\n", signature.c_str(), caller.getJavaSignature().c_str(), m, m_class); return m_vm->newObject(m_class, m, arguments); } jvalue JClassProxy::invoke(jobject& obj, const std::string& fqmethod, JArgs args) { JMethodCaller jmc(m_classname, fqmethod); jvalue* jv = args.allocArray(); jvalue res = jmc.invoke(*m_vm, obj, jv); delete jv; return res; } jvalue JClassProxy::invoke(jobject& obj, const std::string& fqmethod, jvalue arguments[]) { DEBUG("INVOKING " + m_classname + " :: " + fqmethod); JMethodCaller jmc(m_classname, fqmethod); return jmc.invoke(*m_vm, obj, arguments); } jvalue JClassProxy::invokeStatic(const std::string& fqmethod, JArgs args) { JMethodCaller jmc(m_classname, fqmethod); jvalue* jv = args.allocArray(); jvalue res = jmc.invokeStatic(*m_vm, jv); delete jv; return res; } jvalue JClassProxy::invokeStatic(const std::string& fqmethod, jvalue arguments[]) { JMethodCaller jmc(m_classname, fqmethod); return jmc.invokeStatic(*m_vm, arguments); } --- NEW FILE: JVMBase.cpp --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "JVMBase.h" JVMBase::JVMBase() { m_maxHeap = -1; m_initialHeap = -1; } void JVMBase::addPathElement(const std::string& element) { m_pathElements.push_back(element); } void JVMBase::addProperty(const JavaProperty& prop) { m_properties.push_back(prop); } void JVMBase::setMaxHeap(long size) { m_maxHeap = size; } void JVMBase::setInitialHeap(long size) { m_initialHeap = size; } void JVMBase::addArgument(const std::string& arg) { // m_arguments.push_back(StringUtils::requoteForCommandLine(arg)); m_arguments.push_back(arg); } void JVMBase::setArguments(const std::string& args) { m_arguments.clear(); DEBUG("arguments:<" + args + ">"); // std::string ua = StringUtils::unescape(args); // DEBUG("arguments unescaped:<" + ua + ">"); vector<string> splitted = StringUtils::split(args, " \t\n\r", "\"\'", false); for (int i=0; i<splitted.size(); i++) { DEBUG("SPLITTED-ARG[" + StringUtils::toString(i)+"]="+ splitted[i]); this->addArgument(splitted[i]); } } --- NEW FILE: SunJVMExe.cpp --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "SunJVMExe.h" #include <vector> #include <string> #include "Process.h" #include "FileUtils.h" SunJVMExe::SunJVMExe(const std::string& jrehome) { m_jrehome = jrehome; } SunJVMExe::SunJVMExe(const std::string& jrehome, const Version& v) { m_jrehome = jrehome; m_version = v; } bool SunJVMExe::run(const std::string& mainclass, bool useconsole) { if (!m_version.isValid()) { m_version = guessVersion(); } if (!m_version.isValid()) return false; std::vector<std::string> execv; execv.push_back(StringUtils::requoteForCommandLine(lookUpExecutable(useconsole))); if (m_maxHeap > 0) { if ((m_version.getMajor()==1)&&(m_version.getMinor()==1)) execv.push_back("-mx" + StringUtils::toString(m_maxHeap)); else execv.push_back("-Xmx" + StringUtils::toString(m_maxHeap)); } if (m_initialHeap > 0) { if ((m_version.getMajor()==1)&&(m_version.getMinor()==1)) execv.push_back("-ms" + StringUtils::toString(m_initialHeap)); else execv.push_back("-Xms" + StringUtils::toString(m_initialHeap)); } for (int i=0; i<m_properties.size(); i++) execv.push_back( StringUtils::requoteForCommandLine("-D" + m_properties[i].getName()) + "=" + StringUtils::requoteForCommandLine(m_properties[i].getValue())); std::string classpath; if ((m_version.getMajor()==1)&&(m_version.getMinor()==1)) classpath = getClassPath(true); else classpath = getClassPath(false); if (classpath.size() > 0) execv.push_back("-classpath " + StringUtils::requoteForCommandLine(classpath)); execv.push_back(mainclass); for (int i=0; i<m_arguments.size(); i++) { execv.push_back( StringUtils::requoteForCommandLine(m_arguments[i]) ); } std::string execmd = StringUtils::join(execv, " "); DEBUG("COMMAND: <" + execmd + ">"); Process proc(execmd, useconsole); if (proc.run()) { DEBUG("Started successfully"); proc.join(); return true; } else { DEBUG("Failed running " + execmd); } return false; } std::string SunJVMExe::lookUpExecutable(bool useconsole) { std::string java; if (m_jrehome.size() == 0) { return useconsole?"java.exe":"javaw.exe"; } if (useconsole) { if (FileUtils::fileExists(m_jrehome, "bin\\java.exe")) java = FileUtils::concFile(m_jrehome, "bin\\java.exe"); else if (FileUtils::fileExists(m_jrehome, "bin\\jre.exe")) java = FileUtils::concFile(m_jrehome, "bin\\jre.exe"); else { std::vector<std::string> javas = FileUtils::recursiveSearch(m_jrehome, "java.exe"); DEBUG("REC: " + StringUtils::toString(javas)); if (javas.size() == 0) javas = FileUtils::recursiveSearch(m_jrehome, "jre.exe"); if (javas.size() > 0) java = javas[0]; } } else { if (FileUtils::fileExists(m_jrehome, "bin\\javaw.exe")) java = FileUtils::concFile(m_jrehome, "bin\\javaw.exe"); else if (FileUtils::fileExists(m_jrehome, "bin\\jrew.exe")) java = FileUtils::concFile(m_jrehome, "bin\\jrew.exe"); else { std::vector<std::string> javas = FileUtils::recursiveSearch(m_jrehome, "javaw.exe"); DEBUG("REC: " + StringUtils::toString(javas)); if (javas.size() == 0) javas = FileUtils::recursiveSearch(m_jrehome, "jrew.exe"); if (javas.size() > 0) java = javas[0]; } } return java; } Version SunJVMExe::guessVersion() { std::string exepath = lookUpExecutable(true); string exeline = exepath + " -version"; Version result; // Return immediatly if the exe does not exist if (!FileUtils::fileExists(exepath)) return result; string tmpfilename = FileUtils::createTempFileName(".tmp"); Process proc(exeline, true); proc.setRedirect(tmpfilename); proc.run(); proc.join(); std::string voutput = FileUtils::readFile(tmpfilename); vector<string> split = StringUtils::split(voutput, " \t\n\r", "\""); for (vector<string>::iterator i=split.begin(); i != split.end(); i++) { Version v(*i); if (v.isValid()) { result = v; break; } } FileUtils::deleteOnReboot(tmpfilename); return result; } std::string SunJVMExe::getClassPath(bool full) { std::vector<std::string> cp; for (std::vector<std::string>::const_iterator i=m_pathElements.begin(); i!=m_pathElements.end(); i++) cp.push_back(*i); if (full) { std::string javaexe = lookUpExecutable(true); std::string home = FileUtils::getParent( FileUtils::getParent( javaexe )); if (FileUtils::fileExists(home)) { vector<string> cpzips = FileUtils::recursiveSearch(home, "*.zip"); cp.insert(cp.end(), cpzips.begin(), cpzips.end()); vector<string> cpjars = FileUtils::recursiveSearch(home, "*.jar"); cp.insert(cp.end(), cpjars.begin(), cpjars.end()); } } return StringUtils::join(cp, ";"); } --- NEW FILE: JArgs.h --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __JARGS_H_ #define __JARGS_H_ #include "jni.h" #include "StringUtils.h" #include "SunJVMDLL.h" class JArgs { private: std::vector<jvalue> m_values; SunJVMDLL* m_vm; public: JArgs(); JArgs(SunJVMDLL* vm); JArgs(int i) { add(i); } JArgs(bool i) { add(i); } JArgs(jobject& o) { add(o); } JArgs(const std::string& o) { add(o); } jvalue* allocArray(); JArgs& add(int i); JArgs& add(bool b); JArgs& add(jobject& obj); JArgs& add(jobjectArray& arr) { add((jobject)arr); } JArgs& add(jstring& obj) { return add((jstring)obj); } JArgs& add(const std::string& str ); JArgs& operator+(int i) { return add(i); } JArgs& operator+(bool i) { return add(i); } JArgs& operator+(jobject& i) { return add(i); } JArgs& operator+(const std::string& i) { return add(i); } }; #endif --- NEW FILE: JClassProxy.h --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __JCLASSPROXY_H_ #define __JCLASSPROXY_H_ #include <string> #include <vector> #include "common.h" #include "StringUtils.h" #include "SunJVMDLL.h" /** * * @author Rodrigo Reyes <re...@ch...> */ #include "JMethodCaller.h" #include "SunJVMDLL.h" #include "JArgs.h" class JClassProxy { private: jclass m_class; SunJVMDLL* m_vm; std::string m_classname; public: JClassProxy(SunJVMDLL* vm, const std::string& classname); jobject newInstance(const std::string& signature, JArgs args); jobject newInstance(const std::string& signature, jvalue arguments[]); jvalue invoke(jobject& obj, const std::string& fqmethod, JArgs args); jvalue invoke(jobject& obj, const std::string& fqmethod, jvalue arguments[]); jvalue invokeStatic(const std::string& fqmethod, JArgs args); jvalue invokeStatic(const std::string& fqmethod, jvalue arguments[]); }; #endif --- NEW FILE: test.cpp --- #include "JClassProxy.h" #include "JMethodCaller.h" #include "SunJVMDLL.h" #include "SunJVMExe.h" #include "Thread.h" #include "JVMRegistryLookup.h" void _debugOutput(const std::string& text) { printf("%s\n", text.c_str()); } void _debugWaitKey() { } void thread_test(void* param) { SunJVMDLL* jvm = (SunJVMDLL*)param; jclass c1 = jvm->findClass("java.lang.System"); printf("class java.lang.System = %d\n", c1); jmethodID m1 = jvm->findMethod(c1, "currentTimeMillis", "()J", true); printf("method currentTimeMillis = %d\n", m1); jvalue v[0]; for(int i=0; i<100; i++) { long t = jvm->invokeLongStatic(c1, m1, v); printf("%d... current millis : %ld\n", i, t); Thread::sleep(1000); fflush(stdout); } } int test_dll() { SunJVMDLL jvm("c:\\Program Files\\Java\\jdk1.5.0_11\\jre\\bin\\client\\jvm.dll", Version("1.2")); //SunJVMDLL jvm("c:\\Program Files\\JavaSoft\\JRE\\1.1\\bin\\javai.dll", Version("1.1")); jvm.addPathElement("..\\..\\sample\\sample.jar"); jvm.setMaxHeap(6231616); jvm.setInitialHeap(6231616); jvm.instanciate(); JClassProxy disp(&jvm, "JSmoothPropertiesDisplayer"); jstring emptystr = jvm.newUTFString(std::string("")); jobjectArray mainargs = jvm.newObjectArray(0, "java.lang.String", emptystr); printf("arguments array = %d\n", mainargs); jvalue ma[1]; ma[0].l = mainargs; disp.invokeStatic(std::string("void main(java.lang.String[] args)"), ma); jvalue frameargs[1]; JClassProxy frameproxy(&jvm, "javax.swing.JFrame"); jstring str = jvm.newUTFString(std::string("Ceci est un test!")); jobject frame2 = frameproxy.newInstance("void javax.swing.JFrame(java.lang.String str)", JArgs((jobject)str)); printf("FRAME=%d\n", frame2); frameproxy.invoke(frame2, "void setVisible(boolean b)", JArgs((bool)true)); Thread t1; t1.start(thread_test, &jvm); t1.sleep(6000); Thread t2; t2.start(thread_test,&jvm); t1.join(); t2.join(); } int main() { std::string jrehome = "c:\\Program Files\\JavaSoft\\JRE\\1.1"; // jrehome = "c:\\Program Files\\JavaSoft\\JRE\\1.3.1_02"; SunJVMExe jre(jrehome); jre.addPathElement("."); jre.addPathElement("..\\..\\sample\\sample.jar"); jre.setMaxHeap(6231616); jre.setInitialHeap(6231616); //SunJVMDLL jvm("c:\\Program Files\\JavaSoft\\JRE\\1.1\\bin\\javai.dll", Version("1.1")); DEBUG( "FOUND: " + jre.lookUpExecutable(false) ); DEBUG("Version...: " + jre.guessVersion().toString()); DEBUG("PARENT: " + FileUtils::getParent(jrehome)); DEBUG("CP1= " + jre.getClassPath(false)); DEBUG("CP2= " + jre.getClassPath(true)); jre.run("maclasse", false); vector<SunJVMLauncher> launchers = JVMRegistryLookup::lookupJVM(); for (int i=0; i<launchers.size(); i++) { DEBUG(launchers[i].toString()); } } --- NEW FILE: JVMBase.h --- /* JSmooth: a VM wrapper toolkit for Windows Copyright (C) 2003-2007 Rodrigo Reyes <re...@ch...> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __SUNJVMBASE_H_ #define __SUNJVMBASE_H_ #include <string> #include "jni.h" #include "Version.h" #include "StringUtils.h" #include "FileUtils.h" #include "ResourceManager.h" #include "JavaProperty.h" /** * @author Rodrigo Reyes <re...@ch...> */ class JVMBase { protected: std::vector<std::string> m_pathElements; std::vector<JavaProperty> m_properties; int m_maxHeap; int m_initialHeap; std::vector<std::string> m_arguments; public: JVMBase(); void addPathElement(const std::string& element); void addProperty(const JavaProperty& prop); void setMaxHeap(long size); void setInitialHeap(long size); void addArgument(const std::string& arg); void setArguments(const std::string& args); }; #endif |
Update of /cvsroot/jsmooth/jsmooth/skeletons/commonjava In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv12205/skeletons/commonjava Modified Files: Makefile.win Properties.cpp Properties.h ResourceManager.cpp ResourceManager.h SunJVMLauncher.cpp SunJVMLauncher.h Log Message: Windows service wrapper update Index: Properties.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/Properties.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Properties.h 1 Mar 2007 21:56:03 -0000 1.5 --- Properties.h 12 Apr 2007 20:01:50 -0000 1.6 *************** *** 79,82 **** --- 79,84 ---- string get(const string& key) const; + bool contains(const string& key) const; + /** * Adds a new property. Index: ResourceManager.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/ResourceManager.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ResourceManager.h 1 Mar 2007 21:56:03 -0000 1.12 --- ResourceManager.h 12 Apr 2007 20:01:50 -0000 1.13 *************** *** 137,140 **** --- 137,142 ---- */ std::string getProperty(const std::string& key) const; + std::string getProperty(const std::string& key, const std::string& def) const; + bool getBooleanProperty(const std::string& key) const; /** *************** *** 165,169 **** void setUserArguments(std::vector<std::string> arguments); void addUserArgument(std::string argument); ! private: void saveTemp(std::string tempname); --- 167,174 ---- void setUserArguments(std::vector<std::string> arguments); void addUserArgument(std::string argument); ! ! int getResourceSize(int id); ! HGLOBAL getResource(int id); ! private: void saveTemp(std::string tempname); Index: SunJVMLauncher.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/SunJVMLauncher.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SunJVMLauncher.h 9 Apr 2007 17:18:17 -0000 1.10 --- SunJVMLauncher.h 12 Apr 2007 20:01:50 -0000 1.11 *************** *** 49,52 **** --- 49,61 ---- std::string RuntimeLibPath; + enum { + JVM_NOT_LAUNCHED=0, + JVM_PROCESS_LAUNCHED, + JVM_DLL_INSTANCIATED + }; + + int Status; + + protected: JavaVM *m_javavm; *************** *** 80,84 **** virtual bool run(ResourceManager& resource, const string& origin, bool justInstanciate = false); - /** * Runs the JVM as a process and launches the application. The --- 89,92 ---- *************** *** 100,115 **** std::string toString() const; - Version guessVersionByProcess(const string& exepath); ! // int operator<(const SunJVMLauncher& other) const; ! ! friend bool operator < (const SunJVMLauncher& v1, const SunJVMLauncher& v2); ! bool runExe(const string& exepath, bool forceFullClasspath, ResourceManager& resource, bool noConsole, const std::string& version, const string& origin); - bool dllInstanciate(ResourceManager& resource, const string& origin); bool callDLLStaticMethod(const std::string& classname, const std::string& methodname, const std::string& signature); int destroyVM(); --- 108,120 ---- std::string toString() const; Version guessVersionByProcess(const string& exepath); ! friend bool operator < (const SunJVMLauncher& v1, const SunJVMLauncher& v2); ! bool runExe(const string& exepath, bool forceFullClasspath, ResourceManager& resource, bool noConsole, const std::string& version, const string& origin); bool dllInstanciate(ResourceManager& resource, const string& origin); bool callDLLStaticMethod(const std::string& classname, const std::string& methodname, const std::string& signature); + bool callDLLStaticMethodInt(const std::string& classname, const std::string& methodname, const std::string& signature, int value); int destroyVM(); *************** *** 117,122 **** private: - // bool runVM12DLL(ResourceManager& resource, const string& origin); - // bool runVM11DLL(ResourceManager& resource, const string& origin); bool runVMDLL(ResourceManager& resource, const string& origin, bool justInstanciate=false); --- 122,125 ---- Index: Makefile.win =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/Makefile.win,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.win 1 Mar 2007 21:56:02 -0000 1.5 --- Makefile.win 12 Apr 2007 20:01:50 -0000 1.6 *************** *** 12,16 **** LIBS = -L"$(MINGW)/lib" INCS = -I"../util-core" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -I"../util-core" -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" BIN = CommonJava.a CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" --- 12,16 ---- LIBS = -L"$(MINGW)/lib" INCS = -I"../util-core" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" ! CXXINCS = -g -I"../util-core" -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" BIN = CommonJava.a CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)" Index: ResourceManager.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/ResourceManager.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ResourceManager.cpp 6 Apr 2007 16:27:10 -0000 1.20 --- ResourceManager.cpp 12 Apr 2007 20:01:50 -0000 1.21 *************** *** 162,167 **** // m_deleteOnFinalize.push_back(s); FileUtils::deleteOnReboot(s); ! } ! } --- 162,166 ---- // m_deleteOnFinalize.push_back(s); FileUtils::deleteOnReboot(s); ! } } *************** *** 176,179 **** --- 175,195 ---- } + std::string ResourceManager::getProperty(const std::string& key, const std::string& def) const + { + if (m_props.contains(key)) + return m_props.get(key); + else + return def; + } + + bool ResourceManager::getBooleanProperty(const std::string& key) const + { + std::string prop = getProperty(key); + if (StringUtils::parseInt(prop)==1) + return true; + + return false; + } + std::string ResourceManager::saveJarInTempFile() { *************** *** 279,280 **** --- 295,322 ---- } } + + int ResourceManager::getResourceSize(int id) + { + std::string propid = idToResourceName(id); + HRSRC resprop = FindResource(NULL, propid.c_str(), m_resourceCategory.c_str()); + if (resprop != NULL) + { + return SizeofResource(NULL, resprop); + } + else + return 0; + } + + HGLOBAL ResourceManager::getResource(int id) + { + std::string propid = idToResourceName(id); + HRSRC resprop = FindResource(NULL, propid.c_str(), m_resourceCategory.c_str()); + if (resprop != NULL) + { + int size = SizeofResource(NULL, resprop); + char buffer[size+1]; + return LoadResource(NULL, resprop); + } + else + return 0; + } Index: SunJVMLauncher.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/SunJVMLauncher.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** SunJVMLauncher.cpp 9 Apr 2007 17:18:16 -0000 1.24 --- SunJVMLauncher.cpp 12 Apr 2007 20:01:50 -0000 1.25 *************** *** 470,532 **** } - // bool SunJVMLauncher::runVM11DLL(ResourceManager& resource, const string& origin) - // { - // if (setupVM11DLL(resource, origin) == false) - // { - // DEBUG("CAN'T LOAD DLL "); - // return false; - // } - - // std::string classname = resource.getProperty(string(ResourceManager::KEY_MAINCLASSNAME)); - // classname = StringUtils::replace(classname,".", "/"); - // jclass cls = (m_javaenv)->FindClass(classname.c_str()); - // if (cls == 0) - // { - // char tmpbuf[255]; - // sprintf(tmpbuf, "Cant find <%s> at all!", classname.c_str()); - // DEBUG(tmpbuf); - // DEBUG(std::string("Can't Find CLASS <") + classname + std::string(">")); - // return false; - // } - // else - // DEBUG("CLASS "+ classname +" FOUND"); - - // char strbuf[255]; - // sprintf(strbuf, ""); - // jstring jstr = (m_javaenv)->NewStringUTF(strbuf); - // jmethodID mid = (m_javaenv)->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V"); - - // vector<string> pargs = StringUtils::split(resource.getProperty(ResourceManager::KEY_ARGUMENTS), " \t\n\r", "\"\'"); - // jobjectArray args; - - // if (pargs.size() > 0) - // { - // args = (m_javaenv)->NewObjectArray(pargs.size(), (m_javaenv)->FindClass("java/lang/String"), jstr); - // for (int i=0; i<pargs.size(); i++) - // { - // jstr = (m_javaenv)->NewStringUTF(pargs[i].c_str()); - // (m_javaenv)->SetObjectArrayElement(args, i, jstr); - // } - // } - // else - // { - // args = (m_javaenv)->NewObjectArray(0, (m_javaenv)->FindClass("java/lang/String"), jstr); - // } - - // if ((mid != 0) && (args != 0)) - // { - // m_javaenv->CallStaticVoidMethod(cls, mid, args); - // DEBUG("VM CALLED !!"); - - // m_javavm->DestroyJavaVM(); - // return true; - // } - // else - // { - // DEBUG("Can't find method !"); - // return false; - // } - // } - bool SunJVMLauncher::runVM11proc(ResourceManager& resource, bool noConsole, const string& origin) { --- 470,473 ---- *************** *** 821,828 **** bool SunJVMLauncher::callDLLStaticMethod(const std::string& clazz, const std::string& methodname, const std::string& signature) { std::string classname = StringUtils::replace(clazz,".", "/"); DEBUG("Calling " + classname + "::" + methodname + signature); DEBUG("Check if " + classname + " is available"); ! jclass cls = (m_javaenv)->FindClass(classname.c_str()); if (cls == 0) { --- 762,781 ---- bool SunJVMLauncher::callDLLStaticMethod(const std::string& clazz, const std::string& methodname, const std::string& signature) { + JNIEnv *env = new JNIEnv(); + jint result = m_javavm->AttachCurrentThread((void**)&env, 0); + DEBUG("Attached thread to the VM: " + StringUtils::toString(result)); + + // if (result != 0) + // { + // DEBUG("Can't attach the thread to the VM!"); + // return false; + // } + + JNIEnv* jenv = env; + std::string classname = StringUtils::replace(clazz,".", "/"); DEBUG("Calling " + classname + "::" + methodname + signature); DEBUG("Check if " + classname + " is available"); ! jclass cls = (jenv)->FindClass(classname.c_str()); if (cls == 0) { *************** *** 835,845 **** char strbuf[255]; sprintf(strbuf, ""); ! jstring jstr = (m_javaenv)->NewStringUTF(strbuf); ! jmethodID mid = (m_javaenv)->GetStaticMethodID(cls, methodname.c_str(), signature.c_str()); if (mid != 0) { DEBUG("Calling static method from " + classname); ! m_javaenv->CallStaticVoidMethod(cls, mid); return true; } --- 788,840 ---- char strbuf[255]; sprintf(strbuf, ""); ! jstring jstr = (jenv)->NewStringUTF(strbuf); ! jmethodID mid = (jenv)->GetStaticMethodID(cls, methodname.c_str(), signature.c_str()); if (mid != 0) { DEBUG("Calling static method from " + classname); ! jenv->CallStaticVoidMethod(cls, mid); ! return true; ! } ! else ! { ! DEBUG("Can't find method !"); ! return false; ! } ! ! } ! ! bool SunJVMLauncher::callDLLStaticMethodInt(const std::string& clazz, const std::string& methodname, const std::string& signature, int value) ! { ! JNIEnv *env = new JNIEnv(); ! jint result = m_javavm->AttachCurrentThread((void**)&env, 0); ! DEBUG("Attached thread to the VM: " + StringUtils::toString(result)); ! ! JNIEnv* jenv = env; ! ! std::string classname = StringUtils::replace(clazz,".", "/"); ! DEBUG("Calling " + classname + "::" + methodname + signature); ! DEBUG("Check if " + classname + " is available"); ! jclass cls = (jenv)->FindClass(classname.c_str()); ! if (cls == 0) ! { ! DEBUG(std::string("Can't Find CLASS <") + classname + std::string("> (probably a classpath issue)")); ! return false; ! } ! else ! DEBUG("OK, class " + classname + " is available"); ! ! char strbuf[255]; ! sprintf(strbuf, ""); ! jstring jstr = (jenv)->NewStringUTF(strbuf); ! jmethodID mid = (jenv)->GetStaticMethodID(cls, methodname.c_str(), signature.c_str()); ! ! if (mid != 0) ! { ! DEBUG("Calling static method " + methodname + " from " + classname + " (" + StringUtils::toString((int)cls) + "," + StringUtils::toString((int)mid) +")" ); ! jvalue args[5]; ! args[0].i = value; ! jint val = value; ! jenv->CallStaticVoidMethod(cls, mid, (jint)value); return true; } Index: Properties.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/commonjava/Properties.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Properties.cpp 1 Mar 2007 21:56:03 -0000 1.6 --- Properties.cpp 12 Apr 2007 20:01:50 -0000 1.7 *************** *** 76,79 **** --- 76,87 ---- } + bool Properties::contains(const string& key) const + { + map<string, string>::const_iterator i = m_data.find(key); + if (i == m_data.end()) + return false; + return true; + } + string Properties::unescape(const string& val) { |
From: Rodrigo R. <re...@us...> - 2007-04-12 20:01:58
|
Update of /cvsroot/jsmooth/jsmooth/skeletons/winservice In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv12205/skeletons/winservice Modified Files: WinService.cpp WinService.h description.skel main.cpp Log Message: Windows service wrapper update Index: description.skel =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/winservice/description.skel,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** description.skel 9 Apr 2007 22:21:23 -0000 1.2 --- description.skel 12 Apr 2007 20:01:50 -0000 1.3 *************** *** 23,33 **** </skeletonProperties> <skeletonProperties> - <description>SKEL_WINSERVICE_DESCRIPTION_DESCRIPTION</description> - <idName>ServiceDescription</idName> - <label>SKEL_WINSERVICE_DESCRIPTION_LABEL</label> - <type>textarea</type> - <value>A description of the service</value> - </skeletonProperties> - <skeletonProperties> <description>SKEL_WINSERVICE_PROPERTY_MESSAGE_DESCRIPTION</description> <idName>Message</idName> --- 23,26 ---- *************** *** 51,54 **** --- 44,54 ---- </skeletonProperties> <skeletonProperties> + <description>SKEL_WINSERVICE_INTERACTIVE_DESCRIPTION</description> + <idName>Interactive</idName> + <label>SKEL_WINSERVICE_INTERACTIVE_LABEL</label> + <type>boolean</type> + <value>0</value> + </skeletonProperties> + <skeletonProperties> <description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description> <idName>Debug</idName> Index: main.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/winservice/main.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** main.cpp 9 Apr 2007 22:21:23 -0000 1.3 --- main.cpp 12 Apr 2007 20:01:50 -0000 1.4 *************** *** 35,42 **** extern WinService* winservice_ref; void _debugOutput(const std::string& text) { ! if (winservice_ref != 0) winservice_ref->log(text); } --- 35,43 ---- extern WinService* winservice_ref; + bool global_debug; void _debugOutput(const std::string& text) { ! if ((winservice_ref != 0) && global_debug) winservice_ref->log(text); } *************** *** 46,51 **** --- 47,55 ---- int main(int argc, char *argv[]) { + global_debug = false; winservice_ref = 0; ResourceManager resman("JAVA", PROPID, JARID); + + std::string rootdir = FileUtils::getExecutablePath(); std::string serviceName = resman.getProperty("skel_ServiceName"); *************** *** 55,70 **** serviceDisplayName = serviceName; ! std::string autostart = resman.getProperty("skel_Autostart"); ! std::string logfile = resman.getProperty("skel_Logile"); if (logfile == "") logfile = "service.log"; WinService winserv(serviceName, logfile); winserv.setDisplayName(serviceDisplayName); winserv.setDescription(serviceDescription); ! winserv.setAutostart( (StringUtils::parseInt(autostart)==1)?true:false ); ! ! winserv.setAutostart( true ); if (argc>1) --- 59,76 ---- serviceDisplayName = serviceName; ! global_debug = resman.getBooleanProperty("skel_Debug"); ! std::string logfile = resman.getProperty("skel_Logfile"); if (logfile == "") logfile = "service.log"; + if (!FileUtils::isAbsolute(logfile)) + logfile = FileUtils::concFile(rootdir, logfile); + WinService winserv(serviceName, logfile); winserv.setDisplayName(serviceDisplayName); winserv.setDescription(serviceDescription); ! winserv.setAutostart( resman.getBooleanProperty("skel_Autostart") ); ! winserv.setInteractive( resman.getBooleanProperty("skel_Interactive") ); if (argc>1) Index: WinService.cpp =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/winservice/WinService.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WinService.cpp 9 Apr 2007 22:21:23 -0000 1.3 --- WinService.cpp 12 Apr 2007 20:01:50 -0000 1.4 *************** *** 80,83 **** --- 80,89 ---- } + WinService::~WinService() + { + if (m_jvm != 0) + m_jvm->callDLLStaticMethodInt("java.lang.System", "exit", "(I)V", 0); + } + void WinService::connect() { *************** *** 100,107 **** return false; std::string exepath = FileUtils::concFile(FileUtils::getExecutablePath(), FileUtils::getExecutableFileName()); HANDLE service = (HANDLE)CreateService((SC_HANDLE)scman, m_cname, m_serviceDisplayName.c_str(), // service name to display SERVICE_ALL_ACCESS, // desired access ! SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS, // service type m_autostart?SERVICE_AUTO_START:SERVICE_DEMAND_START, // start type SERVICE_ERROR_NORMAL, // error control type --- 106,114 ---- return false; std::string exepath = FileUtils::concFile(FileUtils::getExecutablePath(), FileUtils::getExecutableFileName()); + HANDLE service = (HANDLE)CreateService((SC_HANDLE)scman, m_cname, m_serviceDisplayName.c_str(), // service name to display SERVICE_ALL_ACCESS, // desired access ! SERVICE_WIN32_OWN_PROCESS | (m_interactive?SERVICE_INTERACTIVE_PROCESS:0), // service type m_autostart?SERVICE_AUTO_START:SERVICE_DEMAND_START, // start type SERVICE_ERROR_NORMAL, // error control type *************** *** 217,221 **** setStatus(SERVICE_STOP_PENDING); m_serviceThread.start(winservice_thread_stop, (void*)this); - setStatus(SERVICE_STOP_PENDING); return; --- 224,227 ---- *************** *** 251,261 **** setStatus(SERVICE_RUNNING); ! launcher->dllInstanciate(*globalResMan, "wsreg"); ! ! log("Launched successfully the DLL (" + launcher->toString() + ")"); } else { ! log("ERROR: could not launch the JVM DLL"); } --- 257,274 ---- setStatus(SERVICE_RUNNING); ! if ( ! launcher->dllInstanciate(*globalResMan, "wsreg") ) ! { ! log("Failed to launch the service: can't instanciate the JVM DLL"); ! } ! else ! log("Launched successfully the DLL (" + launcher->toString() + ")"); } else { ! log("ERROR: could not find any suitable Java Virtual Machine"); ! std::string errmsg = globalResMan->getProperty("skel_Message"); ! MessageBox(NULL, ! errmsg.c_str(), FileUtils::getExecutableFileName().c_str(), ! MB_OK|MB_ICONQUESTION|MB_APPLMODAL); } *************** *** 267,280 **** void WinService::kill() { ! log("requesting stop..."); ! setStatus(SERVICE_STOP_PENDING); if (m_jvm != 0) { setStatus(SERVICE_STOPPED); ! m_jvm->callDLLStaticMethod("java.lang.System", "exit", "()V"); ! log("exit called"); ! m_jvm->destroyVM(); ! log("vm destroyed"); } } --- 280,294 ---- void WinService::kill() { ! log("Stopping the service..."); if (m_jvm != 0) { setStatus(SERVICE_STOPPED); ! // We are never here for a very long time, as the ! // SERVICE_STOPPED signal kills this thread asap. Therefore, we ! // do nothing here, we delay the java.lang.System.exit() call to ! // the destructor of this class } + else + log("no jvm available"); } *************** *** 336,339 **** --- 350,358 ---- } + void WinService::setInteractive(bool b) + { + m_interactive = b; + } + void WinService::setDisplayName(const std::string& displayname) { Index: WinService.h =================================================================== RCS file: /cvsroot/jsmooth/jsmooth/skeletons/winservice/WinService.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WinService.h 9 Apr 2007 22:21:23 -0000 1.3 --- WinService.h 12 Apr 2007 20:01:50 -0000 1.4 *************** *** 40,43 **** --- 40,44 ---- std::string m_serviceDescription; bool m_autostart; + bool m_interactive; SERVICE_TABLE_ENTRY m_dispatchTable[2]; *************** *** 54,57 **** --- 55,59 ---- public: WinService(const std::string& name, const std::string& filename); + ~WinService(); void connect(); *************** *** 80,83 **** --- 82,86 ---- void setDescription(const std::string& description); void setAutostart(bool b); + void setInteractive(bool b); }; |