Esempio n. 1
0
 function java_PageContext($java_session)
 {
     if (java_is_null($java_session)) {
         throw new Exception("session is null");
     }
     $ctx = java_context();
     $this->servlet = $ctx->getAttribute("php.java.servlet.Servlet");
     $this->response = $ctx->getAttribute("php.java.servlet.HttpServletResponse");
     $this->request = $ctx->getAttribute("php.java.servlet.HttpServletRequest");
     $factory = java("javax.servlet.jsp.JspFactory")->getDefaultFactory();
     $this->pc = $factory->getPageContext($this->servlet, $this->request, $this->response, null, true, 8192, false);
     $this->out = $this->pc->out;
 }
 /**
  * Returns subreference node for this model (or null if it doesn't exist).
  *
  * @access private
  * @return object - org.neo4j.graphdb.Node
  */
 public function getSubrefNode()
 {
     if ($this->_subrefNode == null) {
         $tx = $this->getGateway()->factoryTransaction();
         try {
             $relType = $this->getGateway()->factoryRelationshipType($this->getSubrefNodeName());
             $rel = $this->getNeo()->getReferenceNode()->getSingleRelationship($relType, $this->DIRECTION->OUTGOING);
             if (!java_is_null($rel)) {
                 $this->_subrefNode = $rel->getEndNode();
             }
             $tx->finish();
         } catch (Exception $e) {
             java_last_exception_get()->printStackTrace();
             $tx->failure();
         }
         $tx->finish();
     }
     return $this->_subrefNode;
 }
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;
}
Esempio n. 4
0
            $rep=$client->queryAccountBalance();

            if (java_is_null($rep))
                {
                $err=$client->getLastErr();
                //为正确显示中文对返回java变量进行转换,如果用java_set_file_encoding进行过转换则不用再次转换
                //$err = java_values($err->getBytes("GBK")); 
                $err=java_values($err);
                print "交易错误信息:" . $err . "<br>";
                exit(1);
                }

            $code=java_values($rep->getRetCode());
            $msg=java_values($rep->getErrorMessage());

            if (!java_is_null($msg)) {
            //为正确显示中文对返回java变量进行转换,如果用java_set_file_encoding进行过转换则不用再次转换
                $msg=java_values($msg->getBytes("GBK")); }

            print "交易返回码:" . $code . "<br>";
            print "交易错误信息:" . $msg . "<br>";

            if ($code == "0") //交易成功
                {
                print "<br>------------------------------<br>";
                $opr=$rep->getOpResult();
                $accountNo=java_values($opr->getValueByName("settAccount"));
                //$accountName = java_values($opr->getValueByName("accountName")->getBytes("GBK")); //为正确显示中文对返回java变量进行转换
                $accountName=java_values($opr->getValueByName("accountName"));
                $currType=java_values($opr->getValueByName("currType"));
                $currBalance=java_values($opr->getValueByName("currBalance"));
<?php

require_once "java/Java.inc";
$session = java_session();
?>

<HTML>
<TITLE>PHP and JSP session sharing</title>
<BODY>
<?php 
if (java_is_null($session->get("counter"))) {
    $session->put("counter", 1);
}
$counter = java_values($session->get("counter"));
print "HttpSession variable \"counter\": {$counter}<br>\n";
$session->put("counter", $counter + 1);
?>
<a href="sessionSharing.jsp">JSP page</a>
</BODY>
</HTML>
Esempio n. 6
0
<?php

require_once "java/Java.inc";
/* PHP version of numberguess.jsp */
$session = java_session();
if (java_is_null($numguess = $session->get("bean"))) {
    $session->put("bean", $numguess = new Java("num.NumberGuessBean"));
}
if ($_POST['guess']) {
    $numguess->setGuess($_POST['guess']);
}
?>

<html>
<head><title>Number Guess</title></head>
<body bgcolor="white">
<font size=4>

<?php 
if (java_values($numguess->getSuccess())) {
    ?>
  Congratulations!  You got it.
  And after just <?php 
    echo java_values($numguess->getNumGuesses());
    ?>
 tries.<p>

  <?php 
    $session->destroy();
    ?>
Esempio n. 7
0
 /**
  * @param $path
  * @return Java
  * @throws Exception
  */
 public function loadDocx($path)
 {
     $fileInputStream = new Java("java.io.FileInputStream", $path);
     $OPCPackage = new Java("org.apache.poi.openxml4j.opc.OPCPackage");
     if (java_is_null($fileInputStream)) {
         throw new Exception('[XWPFToHTMLConverter::loadDocx] Null Input Stream');
     }
     $input = java_values($OPCPackage->open($fileInputStream));
     if (java_is_null($input)) {
         throw new Exception('[XWPFToHTMLConverter::loadDocx] Java Input Stream Error');
     }
     $document = new Java("org.apache.poi.xwpf.usermodel.XWPFDocument", $input);
     //        $this->documentXml = $this->getXMLDocument($document);
     //        $valueTest = $this->documentXml->xpath("wbody/wsdt");
     //        var_dump($valueTest);
     //        var_dump(java_values($document->getDocument()->toString()));
     //            w:sdt
     //        var_dump(java_values($document->getDocument()->getBody()->getSectPr()->getPgSz()->getW()->doubleValue()->toString()));
     //        $pageSize = java_values($-document->getDocument()->getBody()->getSectPr()->getPgSz());
     //        $pageHeight = java_values($pageSize->getH()->doubleValue()->toString());
     //        $pageWidht =  java_values($pageSize->getW()->doubleValue()->toString());
     //        var_dump((int) $pageHeight / 20);
     //        var_dump((int) $pageWidht / 20);
     if (is_null($document)) {
         throw new Exception('[XWPFToHTMLConverter::loadDocx] POI XWPFDocument Internal Error');
     }
     return $document;
 }
Esempio n. 8
0
 function print_report_data()
 {
     // global $inetreportsfiles;
     // let the user modify the properties
     if ($this->must_send_html_page()) {
         $this->checkHtmlPageProperties($this->props);
     } else {
         $this->checkProperties($this->props);
         if (strlen($this->props->getProperty("reportname", "")) > 0) {
             $reportname = $this->props->getProperty("reportname");
             $script = $_SERVER['SCRIPT_FILENAME'];
             if (strlen($this->props->getProperty("report", "")) > 0) {
                 error_log("Both properties reportname and report are set.  I will use the reportname property instead.");
             }
             // $report = "file:" . dirname($script) . $reportname;
             $report = "file:" . $reportname;
             $props . put("report", $report);
         }
     }
     // echo $this->props; exit;
     // Give the properties object to the report bridge so that
     // it can decide what to do
     $report = new Java("com.inet.report.ReportBridge", $this->props);
     // Try to get the report engine from the bridge -- will return
     // null if an error occurred, if must_send_html_page() returns true
     // or if the report matching the above properties is already in
     // the cache server
     $engine = $report->getEngine();
     if (!java_is_null($engine)) {
         // We've obtained the report!  Let the user modify it and
         // execute it to move the page data into the
         // i-net Clear Reports cache server.
         $this->checkEngine($engine, $this->props);
         $report->execute();
     }
     // Send back the page data -- either binary data for the java viewer,
     // a HTML- or error page, or a page in the specified init= format (PDF,
     // RTF, PS, XML, XLS etc.)
     $this->_send_response($report);
 }
include_once "java/Java.inc";
java_autoload("lucene.jar");
use java\lang\System as SYS;
use java\io as IO;
use java\util as Util;
use org\apache\lucene as Lucene;
try {
    echo "indexing ... ";
    /* create the index files in the tmp dir */
    $tmp = create_index_dir();
    $analyzer = new Lucene\analysis\standard\StandardAnalyzer();
    $writer = new Lucene\index\IndexWriter($tmp, $analyzer, true);
    $file = new IO\File(getcwd());
    $files = $file->listFiles();
    assert(!java_is_null($files));
    foreach ($files as $f) {
        $doc = new Lucene\document\Document();
        $doc->add(new Lucene\document\Field("name", $f->getName(), Lucene\document\Field::type("Store")->YES, Lucene\document\Field::type("Index")->UN_TOKENIZED));
        $writer->addDocument($doc);
    }
    $writer->optimize();
    $writer->close();
    echo "done\n";
    echo "searching... ";
    /* Search */
    $searcher = new Lucene\search\IndexSearcher($tmp);
    $phrase = new Lucene\search\MatchAllDocsQuery();
    $hits = $searcher->search($phrase);
    /* Print result */
    $iter = $hits->iterator();