public function go() { $fopcfg = dirname(__FILE__) . '/fop_config.xml'; $tmppdf = tempnam('/tmp', 'FOP'); if (!extension_loaded('java')) { $tmpxml = tempnam('/tmp', 'FOP'); $tmpxsl = tempnam('/tmp', 'FOP'); file_put_contents($tmpxml, $this->xml); file_put_contents($tmpxsl, $this->xsl); exec("fop -xml {$tmpxml} -xsl {$tmpxsl} -pdf {$tmppdf} 2>&1"); @unlink($tmpxml); @unlink($tmpxsl); } else { $xml = new DOMDocument(); $xml->loadXML($this->xml); $xsl = new DOMDocument(); $xsl->loadXML($this->xsl); $proc = new XSLTProcessor(); $proc->importStyleSheet($xsl); $java_library_path = 'file:/usr/share/fop/lib/fop.jar;file:/usr/share/fop/lib/FOPWrapper.jar'; try { java_require($java_library_path); $j_fwc = new JavaClass("FOPWrapper"); $j_fw = $j_fwc->getInstance($fopcfg); $j_fw->run($proc->transformToXML($xml), $tmppdf); } catch (JavaException $ex) { $trace = new Java("java.io.ByteArrayOutputStream"); $ex->printStackTrace(new Java("java.io.PrintStream", $trace)); print "java stack trace: {$trace}\n"; } } return $tmppdf; }
#!/usr/bin/php <?php include_once "java/Java.inc"; $here = realpath(dirname($_SERVER["SCRIPT_FILENAME"])); if (!$here) { $here = getcwd(); } $Cache = new JavaClass("Cache"); $instance = $Cache->getInstance(); echo $instance->hashCode(); ?>
/** * Choose the Dieselpoint index to use for this query. * * @param mixed (string) Filesystem path to the dieselpoint index to open. * (object) Java Object from ({@link WFDieselSearch::index()}) */ function setIndex($index) { try { if (!defined('DIESELPOINT_JAR_FILES')) { throw new Exception("DIESELPOINT_JAR_FILES must be defined, usually in your webapp.conf file."); } java_require(DIESELPOINT_JAR_FILES); if (is_string($index)) { $Index = new JavaClass("com.dieselpoint.search.Index"); $this->index = $Index->getInstance($index); } else { $this->index = $index; } $this->searcher = new Java("com.dieselpoint.search.Searcher", $this->index); } catch (JavaException $e) { $this->handleJavaException($e); } }