J2EEUtils.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
  3. //
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining
  6. // a copy of this software and associated documentation files (the
  7. // "Software"), to deal in the Software without restriction, including
  8. // without limitation the rights to use, copy, modify, merge, publish,
  9. // distribute, sublicense, and/or sell copies of the Software, and to
  10. // permit persons to whom the Software is furnished to do so, subject to
  11. // the following conditions:
  12. //
  13. // The above copyright notice and this permission notice shall be
  14. // included in all copies or substantial portions of the Software.
  15. //
  16. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  20. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  21. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  22. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. //
  24. using System;
  25. using System.Web.Util;
  26. using System.IO;
  27. using [email protected];
  28. using vmw.common;
  29. namespace System.Web.J2EE
  30. {
  31. internal sealed class J2EEUtils
  32. {
  33. public J2EEUtils()
  34. {
  35. }
  36. public static int RunProc(string[] cmd)
  37. {
  38. java.lang.Runtime rt = java.lang.Runtime.getRuntime();
  39. java.lang.Process proc = rt.exec(cmd);
  40. StreamGobbler errorGobbler = new
  41. StreamGobbler(proc.getErrorStream(), "ERROR");
  42. StreamGobbler outputGobbler = new
  43. StreamGobbler(proc.getInputStream(), "OUTPUT");
  44. errorGobbler.start();
  45. outputGobbler.start();
  46. int exitVal = proc.waitFor();
  47. return exitVal;
  48. }
  49. }
  50. public class StreamGobbler : java.lang.Thread
  51. {
  52. java.io.InputStream _is;
  53. String _type;
  54. public StreamGobbler(java.io.InputStream ins, String type)
  55. {
  56. this._is = ins;
  57. this._type = type;
  58. }
  59. public override void run()
  60. {
  61. try
  62. {
  63. java.io.InputStreamReader isr = new java.io.InputStreamReader(_is);
  64. java.io.BufferedReader br = new java.io.BufferedReader(isr);
  65. String line=null;
  66. while ( (line = br.readLine()) != null)
  67. {
  68. #if DEBUG
  69. Console.WriteLine(_type + ">" + line);
  70. #endif
  71. }
  72. }
  73. catch (Exception ex)
  74. {
  75. #if DEBUG
  76. Console.WriteLine(ex);
  77. #endif
  78. }
  79. }
  80. }
  81. }
  82. #if !CODEDOM_SUPPORT
  83. //stubs for CodeDom symbols
  84. namespace System.CodeDom
  85. {
  86. public class CodeObject
  87. {
  88. protected CodeObject () { }
  89. public System.Collections.IDictionary UserData { get { throw new NotSupportedException (); } }
  90. }
  91. public class CodeExpression : CodeObject
  92. {
  93. protected CodeExpression () { }
  94. }
  95. }
  96. #endif