java_begin_document (line
457)
Enters stream mode (asynchronuous protocol).
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.
void
java_begin_document
()
Converts the java object obj into a PHP value.
Converts the java object obj into a PHP value.
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). 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:
$str = new java("java.lang.String", "12");
echo $str;
=> [o(String):"12"]
$phpString = "$str";
echo $phpString;
=> "12"
$phpNumber = (integer)$str;
echo $phpNumber;
=> 12
echo $phpNumber2;
=> 12
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.
Closes over the php environment and packages it up as a java class.
Closes over the php environment and packages it up as a java class.
Example:
function toString() {return "helloWorld";};
$object = java_get_closure();
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:
function hello() {return "hello";};
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:
class Listener {
function actionPerformed($actionEvent) {
...
}
}
function getListener() {
return java_get_closure(new Listener(), null, array(new Java("java.awt.event.ActionListener")));
}
void
java_closure
()
Returns the jsr223 script context handle.
Returns the jsr223 script context handle.
Example which closes over the current environment and passes it back to java:
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:
java_get_context()->getHttpServletRequest();
void
java_context
()
java_end_document (line
470)
Ends stream mode. stream mode raised an exception.
Ends stream mode. Fires a JavaException if any statement executed during stream mode raised an exception.
void
java_end_document
()
Returns the contents (public fields, public methods, public classes) of object as a string.
Returns the contents (public fields, public methods, public classes) of object as a string.
Example:
void
java_inspect
($object $object)
-
$object
$object: A java object or type.
java_instanceof (line
189)
Tests if object is an instance of clazz.
Tests if object is an instance of clazz.
Example:
void
java_instanceof
($ob $ob, $clazz $clazz)
-
$ob
$ob: A java object
-
$clazz
$clazz: A java object or type.
Set the library path.
Set the library path.
Example:
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:
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.
void
java_require
($arg $arg)
-
$arg
$arg: The list of Java libraries.
Only for internal use.
Only for internal use.
void
java_reset
()
java_server_name (line
357)
Returns the name of the back-end or null, if the back-end is not running.
Returns the name of the back-end or null, if the back-end is not running.O
Example:
$backend = java_get_server_name();
if(!$backend) wakeup_administrator("back-end not running");
echo "Connected to the back-end: $backend\n";
void
java_server_name
()
Return a session handle.
Return a session handle.
When java_session() is called without arguments, the session is shared with java. Example:
java_get_session()->put("key", new Java("java.lang.Object"));
[...]
The java components (jsp, servlets) can retrieve the value, for example with:
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:
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:
java_get_session(null, true)->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.
void
java_session
()
java_set_file_encoding (line
164)
Set the java file encoding, for example UTF-8 or ASCII.
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:
void
java_set_file_encoding
($enc $enc)
-
$enc
$enc: A valid file.encoding string. Please see your Java documentation for a list of valid encodings.
Evaluates the object and fetches its content, if possible.
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:
$str = new java("java.lang.String", "hello");
echo $str;
=> [o(String):"hello"]
=> hello
$chr = $str->toCharArray();
echo $chr;
=> [o(array_of-C):"[C@1b10d42"]
print $ar;
=> Array
print $ar[0];
=> [o(Character):"h"]
=> h
void
java_values
($object $object)
-
$object
$object: A java object or type.