/JavaProxy.inc

Description
Classes
Class Description
java_JavaType implemented by JavaException and Java
Java The Java proxy class.
java_exception A decorator pattern which overrides all magic methods.
JavaException The java exception proxy
Includes
require_once ("${JAVA_BASE}/Client.inc") (line 41)
Functions
java_begin_document (line 423)

Enters stream mode (asynchronuous protocol). The statements are sent to the back-end in one XML stream.

Use this protocol mode when you have a large number of set operations and you don't expect an exception. Any exception raised during stream mode is reported when java_end_document() is called.

  • access: public
void java_begin_document ()
java_cast (line 230)

Converts the java object obj into a PHP object. The second argument

must be [s]tring, [b]oolean, [i]nteger, [f]loat or [d]ouble, [a]rray, [n]ull or [o]bject (which does nothing).<p> This procedure is for compatibility with the pure PHP implementation, in the C implementation this procedure is called automatically for each type cast or when settype() is called.


Example:

  1.  $str new java("java.lang.String""12");
  2.  echo $str;
  3.  => [o(String):"12"]
  4.  $phpString "$str";
  5.  echo $phpString;
  6.  => "12"
  7.  $phpNumber = (integer)$str;
  8.  echo $phpNumber;
  9.  => 12
  10.  $phpNumber2 java_cast($str"integer");
  11.  echo $phpNumber2;
  12.  => 12

  • access: public
void java_cast ($object $object, $type $type)
  • $object $object: A java object
  • $type $type: A PHP type description, either [Ss]tring, [Bb]oolean, [Ll]ong or [Ii]nteger, [Dd]ouble or [Ff]loat, [Nn]ull, [Aa]rray, [Oo]bject.
java_closure (line 409)

Closes over the php environment and packages it up as a java

class. Example:

  1.  function toString({return "helloWorld";};
  2.  $object java_get_closure();
  3.  echo "Java says that PHP says$object\n";

When a php instance is supplied as an argument, the environment will be used instead. When a string or key/value map is supplied as a second argument, the java procedure names are mapped to the php procedure names. Example:

  1.  function hello({return "hello";};
  2.  echo (string)java_get_closure(null"hello");

When an array of java interfaces is supplied as a third argument, the environment must implement these interfaces. Example:

  1.  class Listener {
  2.    function actionPerformed($actionEvent{
  3.        ...
  4.      }
  5.  }
  6.  function getListener({
  7.      return java_get_closure(new Listener()nullarray(new Java("java.awt.event.ActionListener")));
  8.  }

  • access: public
void java_closure ()
java_context (line 349)

Returns the jsr223 script context handle.

Example which closes over the current environment and passes it back to java:

  1.  java_get_context()->call(java_closure()) || die "Script should be called from java";

It is possible to access implicit web objects (the session, the application store etc.) from the context. Please see the JSR223 documentation for details. Example:

  1.  java_get_context()->getHttpServletRequest();

  • see: #java_session()
  • access: public
void java_context ()
java_end_document (line 437)

Ends stream mode. Fires a JavaException if any statement executed during stream mode raised an exception.

  • access: public
void java_end_document ()
java_inspect (line 151)

Returns the contents (public fields, public methods, public classes) of object as a string.

Example:

  1.  echo java_inspect(java_get_context());

  • access: public
void java_inspect ($object $object)
  • $object $object: A java object or type.
java_instanceof (line 191)

Tests if object is an instance of clazz.

Example:

  1.  return($o instanceof Java && $c instanceof Java && java_instanceof($o$c));

  • access: public
void java_instanceof ($ob $ob, $clazz $clazz)
  • $ob $ob: A java object
  • $clazz $clazz: A java object or type.
java_require (line 258)

Set the library path. Example:

  1.  java_require("foo.jar;bar.jar");

The .jar files should be stored in /usr/share/java or extension_dir/lib one of its sub-directories or under the PHP include_path/LIBNAME/LIBNAME.jar. However, it is also possible to fetch .jar files from a remote server, for example:

  1.  java_require("http://php-java-bridge.sf.net/kawa.jar;...");

Note that the classloader isolates the loaded libraries: When you call java_require("foo.jar"); java_require("bar.jar"), the classes from foo cannot see the classes loaded from bar. If you get a NoClassDefFound error saying that one of your classes cannot access the library you have loaded, you must reset the back-end to clear the loader cache and load your classes and the library in one java_require() call.

  • access: public
void java_require ($arg $arg)
  • $arg $arg: The list of Java libraries.
java_reset (line 127)

Only for internal use.

  • access: public
void java_reset ()
java_server_name (line 327)

Returns the name of the back-end or null, if the back-end is not running. Example:

  1.  $backend java_get_server_name();
  2.  if(!$backendwakeup_administrator("back-end not running");
  3.  echo "Connected to the back-end$backend\n";

  • access: public
void java_server_name ()
java_session (line 314)

Return a session handle. When java_session() is called without arguments, the session is shared with java.

Example:

  1.  java_get_session()->put("key"new Java("java.lang.Object"));
  2.  [...]
The java components (jsp, servlets) can retrieve the value, for example with:
  1.  getSession().getAttribute("key");

When java_get_session() is called with a session name, the session is not shared with java and no cookies are set. Example:

  1.  java_get_session("myPublicApplicationStore")->put("key""value");

When java_get_session() is called with a second argument set to true, a new session is allocated, the old session is destroyed if necessary. Example:

  1.  java_get_session(nulltrue)->put("key""val");

The optional third argument specifies the default lifetime of the session, it defaults to \code session.gc_maxlifetime \endcode. The value 0 means that the session never times out.

  • see: #java_context()
  • access: public
void java_session ()
java_set_file_encoding (line 167)

Set the java file encoding, for example UTF-8 or ASCII. Needed

because php does not support unicode. All string to byte array conversions use this encoding. Example:

  1.  java_set_file_encoding("ISO-8859-1");

  • access: public
void java_set_file_encoding ($enc $enc)
  • $enc $enc: A valid file.encoding string. Please see your Java
    1. file.encoding
    documentation for a list of valid encodings.
java_values (line 120)

Evaluates the object and fetches its content, if possible.

A java array, Map or Collection object is returned as a php array. An array, Map or Collection proxy is returned as a java array, Map or Collection object, and a null proxy is returned as null. All values of java types for which a primitive php type exists are returned as php values. Everything else is returned unevaluated. Please make sure that the values do not not exceed php's memory limit. Example:

  1.  $str new java("java.lang.String""hello");
  2.  echo $str;
  3.  => [o(String):"hello"]
  4.  echo java_values($str);
  5.  => hello
  6.  $chr $str->toCharArray();
  7.  echo $chr;
  8.  => [o(array_of-C):"[C@1b10d42"]
  9.  $ar java_values($chr);
  10.  print $ar;
  11.  => Array
  12.  print $ar[0];
  13.  => [o(Character):"h"]
  14.  print java_values($ar[0]);
  15.  => h

  • access: public
void java_values ($object $object)
  • $object $object: A java object or type.

Documentation generated on Sun, 30 Sep 2007 10:33:26 +0200 by phpDocumentor 1.4.0a2