添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
if (!function_exists(" java_get_base ")) {
1.0E512 ;
function java_get_base ()
{
$ ar = get_required_files();
$ arLen = sizeof( $ ar );
if ( $ arLen > 0 ) {
$ thiz = $ ar [ $ arLen - 1 ];
return dirname( $ thiz );
} else {
return " java ";
}
}
function java_truncate ( $ str )
{
if (strlen( $ str ) > 955 )
return substr( $ str , 0 , 475 ) . '[...]' . substr( $ str , - 475 );
return $ str ;
}
class java_JavaException extends Exception
{
function __toString ()
{
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);}}' ;
eval (" $ i ");
return true ;
}
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);}}' ;
eval (" $ instance ");
return true ;
}
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 ();
return true ;
}
function Java ( $ name )
{
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());
}
function java_wrap ()
{
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 ()
{
return java_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 );
else
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 ");
return true ;
}
}
return false ;
}
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 );
class java_SimpleFactory
{
public $ client ;
function java_SimpleFactory ( $ client )
{
$ this -> client = $ client ;
}
function getProxy ( $ result , $ signature , $ exception , $ wrap )
{
return $ result ;
}
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 );
return $ 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 );
return $ proxy ;
}
}
class java_ThrowExceptionProxyFactory extends java_ExceptionProxyFactory
{
function getProxy ( $ result , $ signature , $ exception , $ wrap )
{
$ proxy = $ this -> create ( $ result , $ signature );
$ proxy = new java_InternalException( $ proxy , $ exception );
return $ proxy ;
}
function checkResult ( $ result )
{
if ( JAVA_PREFER_VALUES || ( $ result -> __hasDeclaredExceptions == 'T' ))
throw $ result ;
else {
trigger_error(" Unchecked exception detected: " . java_truncate( $ result -> __toString ()), E_USER_WARNING );
}
}
}
class java_CacheEntry
{
public $ fmt , $ signature , $ factory , $ java ;
public $ resultVoid ;
function java_CacheEntry ( $ fmt , $ signature , $ factory , $ resultVoid )
{
$ this -> fmt = $ fmt ;
$ this -> signature = $ signature ;
$ this -> factory = $ factory ;
$ this -> resultVoid = $ resultVoid ;
}
}
class java_Arg
{
public $ client ;
public $ exception ;
public $ factory , $ val ;
public $ signature ;
function java_Arg ( $ client )
{
$ this -> client = $ client ;
$ this -> factory = $ client -> simpleFactory ;
}
function linkResult (& $ val )
{
$ this -> val =& $ val ;
}
function setResult ( $ val )
{
$ this -> val =& $ 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 );
return $ 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
{
public $ parentArg ;
public $ idx ;
public $ type ;
public $ counter ;
function java_CompositeArg ( $ client , $ type )
{
parent :: java_Arg ( $ client );
$ this -> type = $ type ;
$ this -> val = array ();
$ this -> counter = 0 ;
}
function setNextIndex ()
{
$ this -> idx = $ this -> counter ++;
}
function setIndex ( $ val )
{
$ this -> idx = $ 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 );
$ this -> m = $ m ;
$ this -> p = $ p ;
$ this -> v = $ v ;
$ this -> n = $ n ;
}
}
class java_Client
{
public $ RUNTIME ;
public $ result , $ exception ;
public $ parser ;
public $ simpleArg , $ compositeArg ;
public $ simpleFactory ,
$ proxyFactory , $ iteratorProxyFacroty ,
$ arrayProxyFactory , $ exceptionProxyFactory , $ throwExceptionProxyFactory ;
public $ arg ;
public $ asyncCtx , $ cancelProxyCreationCounter ;
public $ globalRef ;
public $ stack ;
public $ defaultCache = array (), $ asyncCache = array (), $ methodCache ;
public $ isAsync = 0 ;
public $ currentCacheKey , $ currentArgumentsFormat ;
public $ cachedJavaPrototype ;
public $ sendBuffer , $ preparedToSendBuffer ;
public $ inArgs ;
function java_Client ()
{
$ 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 ;
}
function read ( $ size )
{
return $ this -> protocol -> read ( $ size );
}
function setDefaultHandler ()
{
$ this -> methodCache = $ this -> defaultCache ;
}
function setAsyncHandler ()
{
$ this -> methodCache = $ this -> asyncCache ;
}
function handleRequests ()
{
$ tail_call = false ;
do {
$ this -> stack = array ( $ this -> arg = $ this -> simpleArg );
$ this -> idx = 0 ;
$ this -> parser -> parse ();
if ((count( $ this -> stack )) > 1 ) {
$ arg = array_pop( $ this -> stack );
$ this -> apply ( $ arg );
$ tail_call = true ;
} else {
$ tail_call = false ;
}
$ this -> stack = null ;
} while ( $ tail_call );
return 1 ;
}
function getWrappedResult ( $ wrap )
{
return $ this -> simpleArg -> getResult ( $ wrap );
}
function getInternalResult ()
{
return $ this -> getWrappedResult ( false );
}
function getResult ()
{
return $ this -> getWrappedResult ( true );
}
function getProxyFactory ( $ type )
{
switch ( $ type [ 0 ]) {
case 'E' :
$ factory = $ this -> exceptionProxyFactory ;
break ;
case 'C' :
$ factory = $ this -> iteratorProxyFactory ;
break ;
case 'A' :
$ factory = $ this -> arrayProxyFactory ;
break ;
default :
case 'O' :
$ factory = $ this -> proxyFactory ;
}
return $ factory ;
}
function link (& $ arg , & $ newArg )
{
$ arg -> linkResult ( $ newArg -> val );
$ newArg -> parentArg = $ arg ;
}
function getExact ( $ str )
{
return hexdec( $ str );
}
function getInexact ( $ str )
{
$ val = null ;
sscanf( $ str , " %e ", $ val );
return $ val ;
}
function begin ( $ name , $ st )
{
$ arg = $ this -> arg ;
switch ( $ name [ 0 ]) {
case 'A' :
$ object = $ this -> globalRef -> get ( $ this -> getExact ( $ st [ 'v' ]));
$ newArg = new java_ApplyArg( $ this , 'A' ,
$ this -> parser -> getData ( $ st [ 'm' ]),
$ this -> parser -> getData ( $ st [ 'p' ]),
$ object ,
$ this -> getExact ( $ st [ 'n' ]));
$ this -> link ( $ arg , $ newArg );
array_push( $ this -> stack , $ this -> arg = $ newArg );
break ;
case 'X' :
$ newArg = new java_CompositeArg( $ this , $ st [ 't' ]);
$ this -> link ( $ arg , $ newArg );
array_push( $ this -> stack , $ this -> arg = $ newArg );
break ;
case 'P' :
if ( $ arg -> type == 'H' ) {
$ s = $ st [ 't' ];
if ( $ s [ 0 ] == 'N' ) {
$ arg -> setIndex ( $ this -> getExact ( $ st [ 'v' ]));
} else {
$ arg -> setIndex ( $ this -> parser -> getData ( $ st [ 'v' ]));
}
} else {
$ arg -> setNextIndex ();
}
break ;
case 'S' :
$ arg -> setResult ( $ this -> parser -> getData ( $ st [ 'v' ]));
break ;
case 'B' :
$ s = $ st [ 'v' ];
$ arg -> setResult ( $ s [ 0 ] == 'T' );
break ;
case 'L' :
$ sign = $ st [ 'p' ];
$ val = $ this -> getExact ( $ st [ 'v' ]);
if ( $ sign [ 0 ] == 'A' ) $ val *= - 1 ;
$ arg -> setResult ( $ val );
break ;
case 'D' :
$ arg -> setResult ( $ this -> getInexact ( $ st [ 'v' ]));
break ;
case 'V' :
if ( $ st [ 'n' ] != 'T' ) {
$ arg -> setVoidSignature ();
}
case 'N' :
$ arg -> setResult ( null );
break ;
case 'F' :
break ;
case 'O' :
$ arg -> setFactory ( $ this -> getProxyFactory ( $ st [ 'p' ]));
$ arg -> setResult ( $ this -> asyncCtx = $ this -> getExact ( $ st [ 'v' ]));
if ( $ st [ 'n' ] != 'T' ) $ arg -> setSignature ( $ st [ 'm' ]);
break ;
case 'E' :
$ arg -> setFactory ( $ this -> throwExceptionProxyFactory );
$ arg -> setException ( $ st [ 'm' ]);
$ arg -> setResult ( $ this -> asyncCtx = $ this -> getExact ( $ st [ 'v' ]));
break ;
default :
$ this -> parser -> parserError ();
}
}
function end ( $ name )
{
switch ( $ name [ 0 ]) {
case 'X' :
$ frame = array_pop( $ this -> stack );
$ this -> arg = $ frame -> parentArg ;
break ;
}
}
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 );
} else {
$ 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 )) {
$ wrote_begin = false ;
foreach ( $ arg as $ key => $ val ) {
if (is_string( $ key )) {
if (! $ wrote_begin ) {
$ wrote_begin = 1 ;
$ this -> protocol -> writeCompositeBegin_h ();
}
$ this -> protocol -> writePairBegin_s ( $ key );
$ this -> writeArg ( $ val );
$ this -> protocol -> writePairEnd ();
} else {
if (! $ wrote_begin ) {
$ wrote_begin = 1 ;
$ this -> protocol -> writeCompositeBegin_h ();
}
$ this -> protocol -> writePairBegin_n ( $ key );
$ this -> writeArg ( $ val );
$ this -> protocol -> writePairEnd ();
}
}
if (! $ wrote_begin ) {
$ this -> protocol -> writeCompositeBegin_a ();
}
$ this -> protocol -> writeCompositeEnd ();
}
}
function writeArgs ( $ args )
{
$ this -> inArgs = true ;
$ n = count( $ args );
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 ();
return $ val ;
}
function referenceObject ( $ name , $ args )
{
$ this -> protocol -> referenceBegin ( $ name );
$ this -> writeArgs ( $ args );
$ this -> protocol -> referenceEnd ();
$ val = $ this -> getInternalResult ();
return $ val ;
}
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 ();
$ this -> getResult ();
}
function invokeMethod ( $ object , $ method , $ args )
{
$ this -> protocol -> invokeBegin ( $ object , $ method );
$ this -> writeArgs ( $ args );
$ this -> protocol -> invokeEnd ();
$ val = $ this -> getResult ();
return $ val ;
}
function unref ( $ object )
{
if (isset( $ this -> protocol )) $ this -> protocol -> writeUnref ( $ object );
}
function apply ( $ arg )
{
$ name = $ arg -> p ;
$ object = $ arg -> v ;
$ ob = ( $ object == null ) ? $ name : array (& $ object , $ name );
$ isAsync = $ this -> isAsync ;
$ methodCache = $ this -> methodCache ;
$ currentArgumentsFormat = $ this -> currentArgumentsFormat ;
try {
$ 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 );
die ( 1 );
}
$ this -> isAsync = $ isAsync ;
$ this -> methodCache = $ methodCache ;
$ this -> currentArgumentsFormat = $ currentArgumentsFormat ;
}
function cast ( $ object , $ type )
{
switch ( $ type [ 0 ]) {
case 'S' :
case 's' :
return $ this -> invokeMethod ( 0 , " castToString ", array ( $ object ));
case 'B' :
case 'b' :
return $ this -> invokeMethod ( 0 , " castToBoolean ", array ( $ object ));
case 'L' :
case 'I' :
case 'l' :
case 'i' :
return $ this -> invokeMethod ( 0 , " castToExact ", array ( $ object ));
case 'D' :
case 'd' :
case 'F' :
case 'f' :
return $ this -> invokeMethod ( 0 , " castToInExact ", array ( $ object ));
case 'N' :
case 'n' :
return null ;
case 'A' :
case 'a' :
return $ this -> invokeMethod ( 0 , " castToArray ", array ( $ object ));
case 'O' :
case 'o' :
return $ object ;
default :
throw new java_RuntimeException(" $ type illegal ");
}
}
function getContext ()
{
static $ cache = null ;
if (!is_null( $ cache )) return $ cache ;
return $ cache = $ this -> invokeMethod ( 0 , " getContext ", array ());
}
function getSession ( $ args )
{
return $ this -> invokeMethod ( 0 , " getSession ", $ args );
}
function getServerName ()
{
static $ cache = null ;
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 ");
class java_GlobalRef
{
public $ map ;
function java_GlobalRef ()
{
$ this -> map = array ();
}
function add ( $ object )
{
if (is_null( $ object )) return 0 ;
return array_push( $ this -> map , $ object );
}
function get ( $ id )
{
if (! $ id ) return 0 ;
return $ this -> map [-- $ id ];
}
}
class java_NativeParser
{
public $ parser , $ handler ;
public $ level , $ event ;
public $ buf ;
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> ");
$ this -> level = 0 ;
}
function begin ( $ parser , $ name , $ param )
{
$ this -> event = true ;
switch ( $ name ) {
case 'X' :
case 'A' :
$ this -> level += 1 ;
}
$ this -> handler -> begin ( $ name , $ param );
}
function end ( $ parser , $ name )
{
$ this -> handler -> end ( $ name );
switch ( $ name ) {
case 'X' :
case 'A' :
$ this -> level -= 1 ;
}
}
function getData ( $ str )
{
return base64_decode( $ str );
}
function parse ()
{
do {
$ this -> event = false ;
$ buf = $ this -> buf = $ this -> handler -> read ( JAVA_RECV_SIZE );
$ len = strlen( $ buf );
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. ",
$ buf ,
xml_error_string(xml_get_error_code( $ this -> parser )),
xml_get_current_column_number( $ this -> parser )));
}
} while (! $ this -> event || $ this -> level > 0 );
}
function parserError ()
{
$ this -> handler -> protocol -> handler -> shutdownBrokenConnection (
sprintf(" protocol error: %s. Check the back end log for details. ", $ this -> buf ));
}
}
class java_Parser
{
public $ parser ;
function java_Parser ( $ handler )
{
if (function_exists(" xml_parser_create ")) {
$ this -> parser = new java_NativeParser( $ handler );
$ handler -> RUNTIME [" PARSER "] = " NATIVE ";
} else {
$ this -> parser = new java_SimpleParser( $ handler );
$ handler -> RUNTIME [" PARSER "] = " SIMPLE ";
}
}
function parse ()
{
$ this -> parser -> parse ();
}
function getData ( $ str )