Source for file Options.inc

Documentation is available at Options.inc

  1. <?php /*-*- mode: php; tab-width:4 -*-*/
  2.  
  3. /*
  4.  * Copyright (C) 2003-2007 Jost Boekemeier.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person
  7.  * obtaining a copy of this file (the "Software"), to deal in the
  8.  * Software without restriction, including without limitation the
  9.  * rights to use, copy, modify, merge, publish, distribute,
  10.  * sublicense, and/or sell copies of the Software, and to permit
  11.  * persons to whom the Software is furnished to do so, subject to the
  12.  * following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice shall be included in
  15.  * all copies or substantial portions of the Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  20.  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  22.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23.  * OTHER DEALINGS IN THE SOFTWARE.
  24.  */
  25.  
  26.  
  27. /**
  28.  * Helper function: Extract the URL from base and
  29.  * and set host, port and servlet accordingly.
  30.  * For example when the user has called:
  31.  * require_once("http://localhost:8080/JavaBridge/java/Java.inc");
  32.  * the JAVA_HOSTS is set to localhost:8080 and
  33.  * JAVA_SERVLET to /JavaBridge/JavaBridge.phpjavabridge.
  34.  * @access private
  35.  */
  36. function java_defineHostFromInitialQuery($java_base{
  37.   if($java_base!="java/"{
  38.     $url parse_url($java_base);
  39.     if(isset($url["scheme"]&& ($url["scheme"]=="http")) {
  40.       $host $url["host"];
  41.       $port $url["port"];
  42.       $path $url["path"];
  43.       define ("JAVA_HOSTS""$host:$port");
  44.       $dir dirname($path);
  45.       define ("JAVA_SERVLET""$dir/JavaBridge.phpjavabridge")// On ;; On or User
  46.       return true;
  47.     }
  48.   }
  49.   return false;
  50. }
  51.  
  52. /**
  53.  * The version number of this PHP library.
  54.  */
  55. define ("JAVA_PEAR_VERSION""5.4.1");
  56.  
  57. if(!defined("JAVA_SEND_SIZE")) 
  58.   define("JAVA_SEND_SIZE"8192);
  59.  
  60. if(!defined("JAVA_RECV_SIZE")) 
  61.   define("JAVA_RECV_SIZE"8192);
  62.  
  63. /**
  64.  * The address of the HTTP back end.
  65.  * 
  66.  * For example "127.0.0.1:8080"
  67.  * @see JAVA_SERVLET
  68.  */
  69. if(!defined("JAVA_HOSTS")) {
  70.   if(!java_defineHostFromInitialQuery($JAVA_BASE)) {
  71.     if ($ini=get_cfg_var("java.hosts")) define("JAVA_HOSTS"$ini)
  72.     else                                define("JAVA_HOSTS""127.0.0.1:8080")// host1:port1;host2:port2;...
  73.   }
  74. }
  75.  
  76. /**
  77.  * Rewrite rules for incoming HTTP requests.
  78.  * 
  79.  *Used in conjunction with
  80.  * JAVA_HOSTS and a servlet/J2EE back end
  81.  * <ul>
  82.  * <li>
  83.  * "On" or 1; Hard-codes the context to "JavaBridge":
  84.  * http://foo.com/test.php => http://host1:port1/JavaBridge/test.phpjavabridge
  85.  * cookie path: always "/"
  86.  *<li>
  87.  * "bar/JavaBridge.phpjavabridge"; Hard-codes the context to "bar":
  88.  * http://foo.com/test.php => http://host1:port1/bar/test.phpjavabridge
  89.  * cookie path: always "/"
  90.  *<li>
  91.  * "User"; Separates different web apps:
  92.  * http://foo.com/mApp1/test.php => http://host1:port1/mApp1/test.phpjavabridge
  93.  * cookie path: /mApp1
  94.  * http://foo.com/mApp2/test.php => http://host1:port1/mApp2/test.phpjavabridge
  95.  * cookie path: /mApp2
  96.  *<li>
  97.  * "Off" or 0 doesn't use a web context at all (no cookies are generated, no
  98.  * PHP/Java session sharing). Back-end must have been started with
  99.  * INET:PORT or INET_LOCAL:PORT, no Servlet engine, no J2EE server.
  100.  * </ul>
  101.  */
  102.  if(!defined("JAVA_SERVLET")) {
  103.    if (!(($ini=get_cfg_var("java.servlet"))===false)) define("JAVA_SERVLET"$ini)
  104.    else                                               define("JAVA_SERVLET"1)// "Off"|0, "On"|1 or "User"
  105. }
  106.  
  107. /** The request log level between 0 (log off) and 4 (log debug).
  108.  * 
  109.  * The
  110.  * default request log level is initialized with the value from to the
  111.  * Java system property "php.java.bridge.default_log_level".  The
  112.  * servlet's init-param: servlet_log_level (see WEB-INF/web.xml)
  113.  * overrides this value. The default level is 2.
  114.  */
  115. if(!defined("JAVA_LOG_LEVEL"))
  116.   if (!(($ini=get_cfg_var("java.log_level"))===false)) define("JAVA_LOG_LEVEL"(int)$ini)
  117.   else                                                 define("JAVA_LOG_LEVEL"null)// integer between 0 and 4
  118.  
  119.  
  120. /** Use named pipes instead of local TCP sockets.
  121.  * 
  122.  * Set this to
  123.  * the directory in which the named pipes should be created.
  124.  * Note that pipes are a little bit slower than persistent TCP
  125.  * sockets. But they are more secure.
  126.  * Example: define("JAVA_PIPE_DIR", "/tmp");
  127.  * Default is to use /dev/shm on Linux, false otherwise.
  128.  */
  129. if(!defined("JAVA_PIPE_DIR")) {
  130.   if ($ini=get_cfg_var("java.pipe_dir"))  define("JAVA_PIPE_DIR"$ini)
  131.   else
  132.     if (file_exists ("/dev/shm"))         define("JAVA_PIPE_DIR""/dev/shm" );
  133.     else                                  define("JAVA_PIPE_DIR"null);
  134. }
  135.  
  136. /** Set to 1 for compatibility with earlier versions.
  137.  * 
  138.  * 
  139.  * When this flag is set, a value (null, int, ...) is returned immediately. Otherwise
  140.  * a proxy (Request$PHPNULL, Integer, ...) is returned and PHP must fetch its content
  141.  * using java_values($proxy);
  142.  */
  143. if (!defined("JAVA_PREFER_VALUES"))
  144.   if ($ini=get_cfg_var("java.prefer_values")) define("JAVA_PREFER_VALUES"$ini)
  145.   else                                        define("JAVA_PREFER_VALUES"0);
  146.   
  147. /**
  148.  * Debug mode for the client.
  149.  * 
  150.  * This debug flag is for PHP only. To enable the VMBridge log restart
  151.  * Java with the -Dphp.java.bridge.default_log_level=... option.
  152.  */
  153. if(!defined("JAVA_DEBUG")) 
  154.   if ($ini=get_cfg_var("java.debug")) define("JAVA_DEBUG"$ini)
  155.   else                                define("JAVA_DEBUG"false);
  156.  
  157. /** Whether or not the PHP should keep persistent connections to the servlet.
  158.  * 
  159.  * Set this to true if you can guarantee that IE or Apache's "maxClients" is less than
  160.  * or equal to the SERVLET's thread pool size (usually named "maxThreads").
  161.  **/
  162.  
  163. if(!defined("JAVA_PERSISTENT_SERVLET_CONNECTIONS")) 
  164.   if ($ini=get_cfg_var("java.persistent_servlet_connections")) define("JAVA_PERSISTENT_SERVLET_CONNECTIONS"$ini)
  165.   else                                                         define("JAVA_PERSISTENT_SERVLET_CONNECTIONS"false);

Documentation generated on Mon, 05 Jan 2009 21:11:01 +0100 by phpDocumentor 1.4.2