function createDocument($jndiname, $serverArgs) { // find initial context $initial = new java("javax.naming.InitialContext", $serverArgs); try { // find the service $objref = $initial->lookup("{$jndiname}"); // access the home interface $home = java("javax.rmi.PortableRemoteObject")->narrow($objref, java("DocumentHome")); if (java_is_null($home)) { throw new Exception("home"); } // create a new remote document and return it $doc = $home->create(); } catch (JavaException $ex) { $cause = $ex->getCause(); echo "Could not create remote document. Have you deployed documentBean.jar?<br>\n"; echo "{$cause} <br>\nin file: {$ex->getFile()}<br>\nline:{$ex->getLine()}\n"; exit(1); } return $doc; }
function createDocument($jndiname, $serverArgs) { // find initial context $initial = new java("javax.naming.InitialContext", $serverArgs); // find the service $objref = $initial->lookup("{$jndiname}"); // access the home interface $DocumentHome = new JavaClass("DocumentHome"); $PortableRemoteObject = new JavaClass("javax.rmi.PortableRemoteObject"); $home = $PortableRemoteObject->narrow($objref, $DocumentHome); // create a new remote document and return it $doc = $home->create(); return $doc; }