if
(!function_exists("
java_get_base
")) {
function
java_get_base
()
$
ar
= get_required_files();
$
arLen
= sizeof(
$
ar
);
$
thiz
=
$
ar
[
$
arLen
-
1
];
return
dirname(
$
thiz
);
function
java_truncate
(
$
str
)
if
(strlen(
$
str
) >
955
)
return
substr(
$
str
,
0
,
475
) .
'[...]'
. substr(
$
str
, -
475
);
class
java_JavaException
extends
Exception
return
$
this
->
getMessage
();
class
java_RuntimeException
extends
java_JavaException
class
java_IOException
extends
java_JavaException
class
java_ConnectException
extends
java_IOException
class
java_IllegalStateException
extends
java_RuntimeException
class
java_IllegalArgumentException
extends
java_RuntimeException
function
__construct
(
$
ob
)
parent
::
__construct
("
illegal argument:
" . gettype(
$
ob
));
function
java_autoload_function5
(
$
x
)
$
s
= str_replace("
_
", "
.
",
$
x
);
$
c
= __javaproxy_Client_getClient();
if
(!(
$
c
->
invokeMethod
(
0
, "
typeExists
",
array
(
$
s
))))
return
false
;
$
i
= "
class
$
{x}
extends Java {
" .
"
static function type(
\$
sub=null){if(
\$
sub)
\$
sub='
\$
'.
\$
sub; return java('
$
{s}
'.
\"\$
sub
\"
);}
" .
'function __construct() {$args=func_get_args();'
.
'array_unshift($args,'
. "
'
$
s
'
" .
'); parent::__construct($args);}}'
;
function
java_autoload_function
(
$
x
)
$
idx
= strrpos(
$
x
, "\\");
if
(!
$
idx
)
return
java_autoload_function5(
$
x
);
$
str
= str_replace("\\", "
.
",
$
x
);
$
client
= __javaproxy_Client_getClient();
if
(!(
$
client
->
invokeMethod
(
0
, "
typeExists
",
array
(
$
str
))))
return
false
;
$
package
= substr(
$
x
,
0
,
$
idx
);
$
name
= substr(
$
x
,
1
+
$
idx
);
$
instance
= "
namespace
$
package
; class
$
{name}
extends
\\
Java {
" .
"
static function type(
\$
sub=null){if(
\$
sub)
\$
sub='
\$
'.
\$
sub;return
\\
java('
$
{str}
'.
\"\$
sub
\"
);}
" .
"
static function __callStatic(
\$
procedure,
\$
args) {return
\\
java_invoke(
\\
java('
$
{str}
'),
\$
procedure,
\$
args);}
" .
'function __construct() {$args=func_get_args();'
.
'array_unshift($args,'
. "
'
$
str
'
" .
'); parent::__construct($args);}}'
;
if
(!defined("
JAVA_DISABLE_AUTOLOAD
") && function_exists("
spl_autoload_register
")) spl_autoload_register("
java_autoload_function
");
function
java_autoload
(
$
libs
=
null
)
trigger_error(
'Please use <a href="http://php-java-bridge.sourceforge.net/pjb/webapp.php>tomcat or jee hot deployment</a> instead'
,
E_USER_WARNING
);
function
java_virtual
(
$
path
,
$
return
=
false
)
$
req
= java_context()->
getHttpServletRequest
();
$
req
=
new
java("
php.java.servlet.VoidInputHttpServletRequest
",
$
req
);
$
res
= java_context()->
getHttpServletResponse
();
$
res
=
new
java("
php.java.servlet.RemoteHttpServletResponse
",
$
res
);
$
req
->
getRequestDispatcher
(
$
path
)->
include
(
$
req
,
$
res
);
if
(
$
return
)
return
$
res
->
getBufferContents
();
echo
$
res
->
getBufferContents
();
static
$
classMap
=
array
();
if
(array_key_exists(
$
name
,
$
classMap
))
return
$
classMap
[
$
name
];
return
$
classMap
[
$
name
] =
new
JavaClass
(
$
name
);
function
java_get_closure
()
return
java_closure_array(func_get_args());
return
java_closure_array(func_get_args());
function
java_get_values
(
$
arg
)
return
java_values(
$
arg
);
function
java_get_session
()
return
java_session_array(func_get_args());
function
java_get_context
()
function
java_get_server_name
()
return
java_server_name();
function
java_isnull
(
$
value
)
return
is_null(java_values(
$
value
));
function
java_is_null
(
$
value
)
return
is_null(java_values(
$
value
));
function
java_istrue
(
$
value
)
return
(
boolean
)(java_values(
$
value
));
function
java_is_true
(
$
value
)
return
(
boolean
)(java_values(
$
value
));
function
java_isfalse
(
$
value
)
return
!(java_values(
$
value
));
function
java_is_false
(
$
value
)
return
!(java_values(
$
value
));
function
java_set_encoding
(
$
enc
)
return
java_set_file_encoding(
$
enc
);
function
java_call_with_continuation
(
$
kontinuation
=
null
)
if
(java_getHeader("
X_JAVABRIDGE_INCLUDE
",
$
_SERVER
) && !java_getHeader("
X_JAVABRIDGE_INCLUDE_ONLY
",
$
_SERVER
)) {
if
(is_null(
$
kontinuation
))
java_context()->
call
(java_closure());
elseif
(is_string(
$
kontinuation
))
java_context()->
call
(call_user_func(
$
kontinuation
));
elseif
(
$
kontinuation
instanceof java_JavaType)
java_context()->
call
(
$
kontinuation
);
java_context()->
call
(java_closure(
$
kontinuation
));
function
java_defineHostFromInitialQuery
(
$
java_base
)
if
(
$
java_base
!= "
java
") {
$
url
= parse_url(
$
java_base
);
if
(isset(
$
url
["
scheme
"]) && (
$
url
["
scheme
"] == "
http
" ||
$
url
["
scheme
"] == "
https
")) {
$
scheme
=
$
url
["
scheme
"] == "
https
" ? "
ssl://
" : "";
$
host
=
$
url
["
host
"];
$
port
=
$
url
["
port
"];
$
path
=
$
url
["
path
"];
define ("
JAVA_HOSTS
", "
$
{scheme}
$
{host}
:
$
{port}");
$
dir
= dirname(
$
path
);
define ("
JAVA_SERVLET
", "
$
dir
/servlet.phpjavabridge
");
define("
JAVA_PEAR_VERSION
", "
6.2.1
");
if
(!defined("
JAVA_SEND_SIZE
"))
define("
JAVA_SEND_SIZE
",
8192
);
if
(!defined("
JAVA_RECV_SIZE
"))
define("
JAVA_RECV_SIZE
",
8192
);
if
(!defined("
JAVA_HOSTS
")) {
if
(!java_defineHostFromInitialQuery(java_get_base())) {
if
(
$
java_ini
= get_cfg_var("
java.hosts
")) define("
JAVA_HOSTS
",
$
java_ini
);
else
define("
JAVA_HOSTS
", "
127.0.0.1:8080
");
if
(!defined("
JAVA_SERVLET
")) {
if
(!((
$
java_ini
= get_cfg_var("
java.servlet
")) ===
false
)) define("
JAVA_SERVLET
",
$
java_ini
);
else
define("
JAVA_SERVLET
",
1
);
if
(!defined("
JAVA_LOG_LEVEL
"))
if
(!((
$
java_ini
= get_cfg_var("
java.log_level
")) ===
false
)) define("
JAVA_LOG_LEVEL
", (
int
)
$
java_ini
);
else
define("
JAVA_LOG_LEVEL
",
null
);
if
(!defined("
JAVA_PREFER_VALUES
"))
if
(
$
java_ini
= get_cfg_var("
java.prefer_values
")) define("
JAVA_PREFER_VALUES
",
$
java_ini
);
else
define("
JAVA_PREFER_VALUES
",
0
);
function
java_SimpleFactory
(
$
client
)
$
this
->
client
=
$
client
;
function
getProxy
(
$
result
,
$
signature
,
$
exception
,
$
wrap
)
function
checkResult
(
$
result
)
class
java_ProxyFactory
extends
java_SimpleFactory
function
create
(
$
result
,
$
signature
)
return
new
java_JavaProxy(
$
result
,
$
signature
);
function
createInternal
(
$
proxy
)
return
new
java_InternalJava(
$
proxy
);
function
getProxy
(
$
result
,
$
signature
,
$
exception
,
$
wrap
)
$
proxy
=
$
this
->
create
(
$
result
,
$
signature
);
if
(
$
wrap
)
$
proxy
=
$
this
->
createInternal
(
$
proxy
);
class
java_ArrayProxyFactory
extends
java_ProxyFactory
function
create
(
$
result
,
$
signature
)
return
new
java_ArrayProxy(
$
result
,
$
signature
);
class
java_IteratorProxyFactory
extends
java_ProxyFactory
function
create
(
$
result
,
$
signature
)
return
new
java_IteratorProxy(
$
result
,
$
signature
);
class
java_ExceptionProxyFactory
extends
java_SimpleFactory
function
create
(
$
result
,
$
signature
)
return
new
java_ExceptionProxy(
$
result
,
$
signature
);
function
getProxy
(
$
result
,
$
signature
,
$
exception
,
$
wrap
)
$
proxy
=
$
this
->
create
(
$
result
,
$
signature
);
if
(
$
wrap
)
$
proxy
=
new
java_InternalException(
$
proxy
,
$
exception
);
class
java_ThrowExceptionProxyFactory
extends
java_ExceptionProxyFactory
function
getProxy
(
$
result
,
$
signature
,
$
exception
,
$
wrap
)
$
proxy
=
$
this
->
create
(
$
result
,
$
signature
);
$
proxy
=
new
java_InternalException(
$
proxy
,
$
exception
);
function
checkResult
(
$
result
)
if
(
JAVA_PREFER_VALUES
|| (
$
result
->
__hasDeclaredExceptions
==
'T'
))
trigger_error("
Unchecked exception detected:
" . java_truncate(
$
result
->
__toString
()),
E_USER_WARNING
);
public
$
fmt
,
$
signature
,
$
factory
,
$
java
;
function
java_CacheEntry
(
$
fmt
,
$
signature
,
$
factory
,
$
resultVoid
)
$
this
->
signature
=
$
signature
;
$
this
->
factory
=
$
factory
;
$
this
->
resultVoid
=
$
resultVoid
;
public
$
factory
,
$
val
;
function
java_Arg
(
$
client
)
$
this
->
client
=
$
client
;
$
this
->
factory
=
$
client
->
simpleFactory
;
function
linkResult
(&
$
val
)
function
setResult
(
$
val
)
function
getResult
(
$
wrap
)
$
rc
=
$
this
->
factory
->
getProxy
(
$
this
->
val
,
$
this
->
signature
,
$
this
->
exception
,
$
wrap
);
$
factory
=
$
this
->
factory
;
$
this
->
factory
=
$
this
->
client
->
simpleFactory
;
$
factory
->
checkResult
(
$
rc
);
function
setFactory
(
$
factory
)
$
this
->
factory
=
$
factory
;
function
setException
(
$
string
)
$
this
->
exception
=
$
string
;
function
setVoidSignature
()
$
this
->
signature
= "
@V
";
$
key
=
$
this
->
client
->
currentCacheKey
;
if
(
$
key
&&
$
key
[
0
] !=
'~'
) {
$
this
->
client
->
currentArgumentsFormat
[
6
] = "
3
";
$
cacheEntry
=
new
java_CacheEntry(
$
this
->
client
->
currentArgumentsFormat
,
$
this
->
signature
,
$
this
->
factory
,
true
);
$
this
->
client
->
methodCache
[
$
key
] =
$
cacheEntry
;
function
setSignature
(
$
signature
)
$
this
->
signature
=
$
signature
;
$
key
=
$
this
->
client
->
currentCacheKey
;
if
(
$
key
&&
$
key
[
0
] !=
'~'
) {
$
cacheEntry
=
new
java_CacheEntry(
$
this
->
client
->
currentArgumentsFormat
,
$
this
->
signature
,
$
this
->
factory
,
false
);
$
this
->
client
->
methodCache
[
$
key
] =
$
cacheEntry
;
class
java_CompositeArg
extends
java_Arg
function
java_CompositeArg
(
$
client
,
$
type
)
parent
::
java_Arg
(
$
client
);
$
this
->
type
=
$
type
;
$
this
->
val
=
array
();
$
this
->
idx
=
$
this
->
counter
++;
function
setIndex
(
$
val
)
function
linkResult
(&
$
val
)
$
this
->
val
[
$
this
->
idx
] =&
$
val
;
function
setResult
(
$
val
)
$
this
->
val
[
$
this
->
idx
] =
$
this
->
factory
->
getProxy
(
$
val
,
$
this
->
signature
,
$
this
->
exception
,
true
);
$
this
->
factory
=
$
this
->
client
->
simpleFactory
;
class
java_ApplyArg
extends
java_CompositeArg
public
$
m
,
$
p
,
$
v
,
$
n
;
function
java_ApplyArg
(
$
client
,
$
type
,
$
m
,
$
p
,
$
v
,
$
n
)
parent
::
java_CompositeArg
(
$
client
,
$
type
);
public
$
result
,
$
exception
;
public
$
simpleArg
,
$
compositeArg
;
$
proxyFactory
,
$
iteratorProxyFacroty
,
$
arrayProxyFactory
,
$
exceptionProxyFactory
,
$
throwExceptionProxyFactory
;
public
$
asyncCtx
,
$
cancelProxyCreationCounter
;
public
$
defaultCache
=
array
(),
$
asyncCache
=
array
(),
$
methodCache
;
public
$
currentCacheKey
,
$
currentArgumentsFormat
;
public
$
cachedJavaPrototype
;
public
$
sendBuffer
,
$
preparedToSendBuffer
;
$
this
->
RUNTIME
=
array
();
$
this
->
RUNTIME
["
NOTICE
"] =
'***USE echo java_inspect(jVal) OR print_r(java_values(jVal)) TO SEE THE CONTENTS OF THIS JAVA OBJECT!***'
;
$
this
->
parser
=
new
java_Parser(
$
this
);
$
this
->
protocol
=
new
java_Protocol(
$
this
);
$
this
->
simpleFactory
=
new
java_SimpleFactory(
$
this
);
$
this
->
proxyFactory
=
new
java_ProxyFactory(
$
this
);
$
this
->
arrayProxyFactory
=
new
java_ArrayProxyFactory(
$
this
);
$
this
->
iteratorProxyFactory
=
new
java_IteratorProxyFactory(
$
this
);
$
this
->
exceptionProxyFactory
=
new
java_ExceptionProxyFactory(
$
this
);
$
this
->
throwExceptionProxyFactory
=
new
java_ThrowExceptionProxyFactory(
$
this
);
$
this
->
cachedJavaPrototype
=
new
java_JavaProxyProxy(
$
this
);
$
this
->
simpleArg
=
new
java_Arg(
$
this
);
$
this
->
globalRef
=
new
java_GlobalRef();
$
this
->
asyncCtx
=
$
this
->
cancelProxyCreationCounter
=
0
;
$
this
->
methodCache
=
$
this
->
defaultCache
;
$
this
->
inArgs
=
false
;
return
$
this
->
protocol
->
read
(
$
size
);
function
setDefaultHandler
()
$
this
->
methodCache
=
$
this
->
defaultCache
;
function
setAsyncHandler
()
$
this
->
methodCache
=
$
this
->
asyncCache
;
function
handleRequests
()
$
this
->
stack
=
array
(
$
this
->
arg
=
$
this
->
simpleArg
);
$
this
->
parser
->
parse
();
if
((count(
$
this
->
stack
)) >
1
) {
$
arg
= array_pop(
$
this
->
stack
);
$
this
->
apply
(
$
arg
);
function
getWrappedResult
(
$
wrap
)
return
$
this
->
simpleArg
->
getResult
(
$
wrap
);
function
getInternalResult
()
return
$
this
->
getWrappedResult
(
false
);
return
$
this
->
getWrappedResult
(
true
);
function
getProxyFactory
(
$
type
)
$
factory
=
$
this
->
exceptionProxyFactory
;
$
factory
=
$
this
->
iteratorProxyFactory
;
$
factory
=
$
this
->
arrayProxyFactory
;
$
factory
=
$
this
->
proxyFactory
;
function
link
(&
$
arg
, &
$
newArg
)
$
arg
->
linkResult
(
$
newArg
->
val
);
$
newArg
->
parentArg
=
$
arg
;
function
getExact
(
$
str
)
function
getInexact
(
$
str
)
sscanf(
$
str
, "
%e
",
$
val
);
function
begin
(
$
name
,
$
st
)
$
object
=
$
this
->
globalRef
->
get
(
$
this
->
getExact
(
$
st
[
'v'
]));
$
newArg
=
new
java_ApplyArg(
$
this
,
'A'
,
$
this
->
parser
->
getData
(
$
st
[
'm'
]),
$
this
->
parser
->
getData
(
$
st
[
'p'
]),
$
this
->
getExact
(
$
st
[
'n'
]));
$
this
->
link
(
$
arg
,
$
newArg
);
array_push(
$
this
->
stack
,
$
this
->
arg
=
$
newArg
);
$
newArg
=
new
java_CompositeArg(
$
this
,
$
st
[
't'
]);
$
this
->
link
(
$
arg
,
$
newArg
);
array_push(
$
this
->
stack
,
$
this
->
arg
=
$
newArg
);
if
(
$
arg
->
type
==
'H'
) {
if
(
$
s
[
0
] ==
'N'
) {
$
arg
->
setIndex
(
$
this
->
getExact
(
$
st
[
'v'
]));
$
arg
->
setIndex
(
$
this
->
parser
->
getData
(
$
st
[
'v'
]));
$
arg
->
setNextIndex
();
$
arg
->
setResult
(
$
this
->
parser
->
getData
(
$
st
[
'v'
]));
$
arg
->
setResult
(
$
s
[
0
] ==
'T'
);
$
val
=
$
this
->
getExact
(
$
st
[
'v'
]);
if
(
$
sign
[
0
] ==
'A'
)
$
val
*= -
1
;
$
arg
->
setResult
(
$
val
);
$
arg
->
setResult
(
$
this
->
getInexact
(
$
st
[
'v'
]));
if
(
$
st
[
'n'
] !=
'T'
) {
$
arg
->
setVoidSignature
();
$
arg
->
setResult
(
null
);
$
arg
->
setFactory
(
$
this
->
getProxyFactory
(
$
st
[
'p'
]));
$
arg
->
setResult
(
$
this
->
asyncCtx
=
$
this
->
getExact
(
$
st
[
'v'
]));
if
(
$
st
[
'n'
] !=
'T'
)
$
arg
->
setSignature
(
$
st
[
'm'
]);
$
arg
->
setFactory
(
$
this
->
throwExceptionProxyFactory
);
$
arg
->
setException
(
$
st
[
'm'
]);
$
arg
->
setResult
(
$
this
->
asyncCtx
=
$
this
->
getExact
(
$
st
[
'v'
]));
$
this
->
parser
->
parserError
();
$
frame
= array_pop(
$
this
->
stack
);
$
this
->
arg
=
$
frame
->
parentArg
;
function
createParserString
()
return
new
java_ParserString();
function
writeArg
(
$
arg
)
if
(is_string(
$
arg
)) {
$
this
->
protocol
->
writeString
(
$
arg
);
}
else
if
(is_object(
$
arg
)) {
if
((!
$
arg
instanceof java_JavaType)) {
error_log((
string
)
new
java_IllegalArgumentException(
$
arg
));
trigger_error("
argument '
" . get_class(
$
arg
) . "
' is not a Java object,using NULL instead
",
E_USER_WARNING
);
$
this
->
protocol
->
writeObject
(
null
);
$
this
->
protocol
->
writeObject
(
$
arg
->
__java
);
}
else
if
(is_null(
$
arg
)) {
$
this
->
protocol
->
writeObject
(
null
);
}
else
if
(is_bool(
$
arg
)) {
$
this
->
protocol
->
writeBoolean
(
$
arg
);
}
else
if
(is_integer(
$
arg
)) {
$
this
->
protocol
->
writeLong
(
$
arg
);
}
else
if
(is_float(
$
arg
)) {
$
this
->
protocol
->
writeDouble
(
$
arg
);
}
else
if
(is_array(
$
arg
)) {
foreach
(
$
arg
as
$
key
=>
$
val
) {
if
(is_string(
$
key
)) {
$
this
->
protocol
->
writeCompositeBegin_h
();
$
this
->
protocol
->
writePairBegin_s
(
$
key
);
$
this
->
writeArg
(
$
val
);
$
this
->
protocol
->
writePairEnd
();
$
this
->
protocol
->
writeCompositeBegin_h
();
$
this
->
protocol
->
writePairBegin_n
(
$
key
);
$
this
->
writeArg
(
$
val
);
$
this
->
protocol
->
writePairEnd
();
$
this
->
protocol
->
writeCompositeBegin_a
();
$
this
->
protocol
->
writeCompositeEnd
();
function
writeArgs
(
$
args
)
$
this
->
inArgs
=
true
;
for (
$
i
=
0
;
$
i
<
$
n
;
$
i
++) {
$
this
->
writeArg
(
$
args
[
$
i
]);
$
this
->
inArgs
=
false
;
function
createObject
(
$
name
,
$
args
)
$
this
->
protocol
->
createObjectBegin
(
$
name
);
$
this
->
writeArgs
(
$
args
);
$
this
->
protocol
->
createObjectEnd
();
$
val
=
$
this
->
getInternalResult
();
function
referenceObject
(
$
name
,
$
args
)
$
this
->
protocol
->
referenceBegin
(
$
name
);
$
this
->
writeArgs
(
$
args
);
$
this
->
protocol
->
referenceEnd
();
$
val
=
$
this
->
getInternalResult
();
function
getProperty
(
$
object
,
$
property
)
$
this
->
protocol
->
propertyAccessBegin
(
$
object
,
$
property
);
$
this
->
protocol
->
propertyAccessEnd
();
return
$
this
->
getResult
();
function
setProperty
(
$
object
,
$
property
,
$
arg
)
$
this
->
protocol
->
propertyAccessBegin
(
$
object
,
$
property
);
$
this
->
writeArg
(
$
arg
);
$
this
->
protocol
->
propertyAccessEnd
();
function
invokeMethod
(
$
object
,
$
method
,
$
args
)
$
this
->
protocol
->
invokeBegin
(
$
object
,
$
method
);
$
this
->
writeArgs
(
$
args
);
$
this
->
protocol
->
invokeEnd
();
$
val
=
$
this
->
getResult
();
function
unref
(
$
object
)
if
(isset(
$
this
->
protocol
))
$
this
->
protocol
->
writeUnref
(
$
object
);
$
ob
= (
$
object
==
null
) ?
$
name
:
array
(&
$
object
,
$
name
);
$
isAsync
=
$
this
->
isAsync
;
$
methodCache
=
$
this
->
methodCache
;
$
currentArgumentsFormat
=
$
this
->
currentArgumentsFormat
;
$
res
=
$
arg
->
getResult
(
true
);
if
(((
$
object
==
null
) && !function_exists(
$
name
)) || (!(
$
object
==
null
) && !method_exists(
$
object
,
$
name
)))
throw
new
JavaException
("
java.lang.NoSuchMethodError
", "
$
name
");
$
res
= call_user_func_array(
$
ob
,
$
res
);
if
(is_object(
$
res
) && (!(
$
res
instanceof java_JavaType))) {
trigger_error("
object returned from
$
name
() is not a Java object
",
E_USER_WARNING
);
$
this
->
protocol
->
invokeBegin
(
0
, "
makeClosure
");
$
this
->
protocol
->
writeULong
(
$
this
->
globalRef
->
add
(
$
res
));
$
this
->
protocol
->
invokeEnd
();
$
res
=
$
this
->
getResult
();
$
this
->
protocol
->
resultBegin
();
$
this
->
writeArg
(
$
res
);
$
this
->
protocol
->
resultEnd
();
}
catch
(
JavaException
$
e
) {
$
trace
=
$
e
->
getTraceAsString
();
$
this
->
protocol
->
resultBegin
();
$
this
->
protocol
->
writeException
(
$
e
->
__java
,
$
trace
);
$
this
->
protocol
->
resultEnd
();
}
catch
(
Exception
$
ex
) {
error_log(
$
ex
->
__toString
());
trigger_error("
Unchecked exception detected in callback
",
E_USER_ERROR
);
$
this
->
isAsync
=
$
isAsync
;
$
this
->
methodCache
=
$
methodCache
;
$
this
->
currentArgumentsFormat
=
$
currentArgumentsFormat
;
function
cast
(
$
object
,
$
type
)
return
$
this
->
invokeMethod
(
0
, "
castToString
",
array
(
$
object
));
return
$
this
->
invokeMethod
(
0
, "
castToBoolean
",
array
(
$
object
));
return
$
this
->
invokeMethod
(
0
, "
castToExact
",
array
(
$
object
));
return
$
this
->
invokeMethod
(
0
, "
castToInExact
",
array
(
$
object
));
return
$
this
->
invokeMethod
(
0
, "
castToArray
",
array
(
$
object
));
throw
new
java_RuntimeException("
$
type
illegal
");
if
(!is_null(
$
cache
))
return
$
cache
;
return
$
cache
=
$
this
->
invokeMethod
(
0
, "
getContext
",
array
());
function
getSession
(
$
args
)
return
$
this
->
invokeMethod
(
0
, "
getSession
",
$
args
);
function
getServerName
()
if
(!is_null(
$
cache
))
return
$
cache
;
return
$
cache
=
$
this
->
protocol
->
getServerName
();
function
java_shutdown
()
global
$
java_initialized
;
if
(!
$
java_initialized
)
return
;
if
(session_id()) session_write_close();
$
client
= __javaproxy_Client_getClient();
if
(!isset(
$
client
->
protocol
) ||
$
client
->
inArgs
)
return
;
if
(
$
client
->
preparedToSendBuffer
)
$
client
->
sendBuffer
.=
$
client
->
preparedToSendBuffer
;
$
client
->
sendBuffer
.=
$
client
->
protocol
->
getKeepAlive
();
$
client
->
protocol
->
flush
();
$
client
->
protocol
->
keepAlive
();
register_shutdown_function("
java_shutdown
");
function
java_GlobalRef
()
$
this
->
map
=
array
();
function
add
(
$
object
)
if
(is_null(
$
object
))
return
0
;
return
array_push(
$
this
->
map
,
$
object
);
return
$
this
->
map
[--
$
id
];
public
$
parser
,
$
handler
;
public
$
level
,
$
event
;
function
java_NativeParser
(
$
handler
)
$
this
->
handler
=
$
handler
;
$
this
->
parser
= xml_parser_create();
xml_parser_set_option(
$
this
->
parser
,
XML_OPTION_CASE_FOLDING
,
0
);
xml_set_object(
$
this
->
parser
,
$
this
);
xml_set_element_handler(
$
this
->
parser
, "
begin
", "
end
");
xml_parse(
$
this
->
parser
, "
<F>
");
function
begin
(
$
parser
,
$
name
,
$
param
)
$
this
->
handler
->
begin
(
$
name
,
$
param
);
function
end
(
$
parser
,
$
name
)
$
this
->
handler
->
end
(
$
name
);
function
getData
(
$
str
)
return
base64_decode(
$
str
);
$
this
->
event
=
false
;
$
buf
=
$
this
->
buf
=
$
this
->
handler
->
read
(
JAVA_RECV_SIZE
);
if
(!xml_parse(
$
this
->
parser
,
$
buf
,
$
len
==
0
)) {
$
this
->
handler
->
protocol
->
handler
->
shutdownBrokenConnection
(
sprintf("
protocol error: %s,%s at col %d. Check the back end log for OutOfMemoryErrors.
",
xml_error_string(xml_get_error_code(
$
this
->
parser
)),
xml_get_current_column_number(
$
this
->
parser
)));
}
while
(!
$
this
->
event
||
$
this
->
level
>
0
);
$
this
->
handler
->
protocol
->
handler
->
shutdownBrokenConnection
(
sprintf("
protocol error: %s. Check the back end log for details.
",
$
this
->
buf
));
function
java_Parser
(
$
handler
)
if
(function_exists("
xml_parser_create
")) {
$
this
->
parser
=
new
java_NativeParser(
$
handler
);
$
handler
->
RUNTIME
["
PARSER
"] = "
NATIVE
";
$
this
->
parser
=
new
java_SimpleParser(
$
handler
);
$
handler
->
RUNTIME
["
PARSER
"] = "
SIMPLE
";
$
this
->
parser
->
parse
();
function
getData
(
$
str
)