/JavaBridge.inc

Description
Includes
require_once (java_get_base()."/Options.inc") (line 66)
require_once (java_get_base()."/JavaProxy.inc") (line 67)
Functions
Java (line 198)

Access the java type with the given name.

Access the java type with the given name. This procedure can be used to access constants or procedures within a class.
To access class features, use the java constructor instead.
Example:

  1.  java("java.lang.Long")->MAX_VALUE

Any declared exception can be caught by PHP code.
Exceptions derived from java.lang.RuntimeException or Error must not be caught unless declared in the methods throws clause -- OutOfMemoryErrors cannot be caught at all, even if declared.

  • see: Java
  • access: public
void Java (string $name)
  • string $name: The type name
java_call_with_continuation (line 375)

Call the Java continuation with the closed-over PHP environment $kontinuation as its argument.

Call the Java continuation with the closed-over PHP environment $kontinuation as its argument. This procedure can be used to transfer control back to a Java continuation so that Java can call PHP procedures defined within the passed environment. If the script has not been requested by Java, the procedure does nothing. Example PHP script:

  1.  <?php require_once("java/Java.inc");
  2.  
  3.  class my_SalesCalculator function calculateSales($month{return ((int)(string)$month)+1;... }
  4.  
  5.  // ... calculate sales for a given month ...
  6.  
  7.  write_response($response);
  8.  
  9.  // prepare for out-of-band data: make our top-level environment
  10.  // available to Java. But only if it has been requested by Java:
  11.  java_call_with_continuation(new mySalesCalculator());
  12.  ?>
If the above PHP script is named "calculateSales.php", the JSR 223 API can be used to invoke its functions or methods, to debug or test certain functionality from Java while keeping the script running in a production environment. The Java code follows:
  1.  import javax.script.*;
  2.  import java.net.*;
  3.  import java.io.*;
  4.  class SalesTest {
  5.      public static void test(Integer monththrows Exception {
  6.          ScriptEngine e new ScriptEngineManager().getEngineByName("php-invocable");
  7.          ByteArrayOutputStream out;
  8.          OutputStreamWriter writer;
  9.          e.getContext().setWriter(writer=new OutputStreamWriter(out=new ByteArrayOutputStream()));
  10.          Object res=e.eval(new php.java.script.URLReader(new URL("http://localhost/calculateSales.php")));
  11.          System.err.println(((Invocable)e).invokeFunction("calculateSales"new Object[]{month}));
  12.          ((Closeable)e).close();
  13.          System.err.println("PHP exit() code:" String.valueOf(res));
  14.          System.err.println("PHP output:" String.valueOf(out));
  15.       }
  16.       public static void main(String s[]throws Exception {
  17.          test(new Integer(12));
  18.       }
  19.  }
The above Java program opens a URL connection to the PHP script, invokes the calculateSales() function from the passed PHP environment and then outputs the exit code and the HTML response of the PHP script.

  • access: public
void java_call_with_continuation ([mixed $kontinuation = null])
  • mixed $kontinuation: If a PHP object is provided, the object is passed to Java. Otherwise the current environment is used.
java_is_false (line 298)

Checks whether a value is false or not.

Checks whether a value is false or not. Example:

  1.  java_is_false(java("java.lang.System")->getProperty("foo"))

  • return: if the PHP or Java value is false.
  • access: public
true java_is_false (mixed $value)
  • mixed $value: A Java object or a PHP value
java_is_null (line 262)

Checks whether a value is null or not.

Checks whether a value is null or not. Example:

  1.  java_is_null(java("java.lang.System")->getProperty("foo"))

  • return: if $value is the PHP or Java null value.
  • access: public
true java_is_null (mixed $value)
  • mixed $value: A Java object or a PHP value
java_is_true (line 280)

Checks whether a value is true or not.

Checks whether a value is true or not. Example:

  1.  java_is_true(java("java.lang.System")->getProperty("foo"))

  • return: if the PHP or Java value is true.
  • access: public
true java_is_true (mixed $value)
  • mixed $value: A Java object or a PHP value

Documentation generated on Sun, 06 Dec 2009 17:38:17 +0100 by phpDocumentor 1.4.2