This repository has been archived by the owner on Jan 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
NEWS
1855 lines (1345 loc) · 65.5 KB
/
NEWS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
php-java-bridge NEWS -- history of user-visible changes.
Please send bug reports, questions and suggestions to
Version 6.2.1
* java_session(null, false) now returns false if a session does not exist.
* Added new BIRT version 2.6
* Incompatible change for those who use $_SERVER["REQUEST_URI"] as a cache key.
Please either use PHP_SELF or please set
<init-param>
<param-name>php_request_uri_is_unique</param-name>
<param-value>true</param-value>
</init-param>
* A (string) cast no longer converts a byte[] array to a
java.lang.String. Example:
$s = new java("java.lang.String", "hello");
$b = $s->getBytes("ASCII");
echo (string)$b;
* To support both x64 and 386 windows dll's, the layout has been changed:
WEB-INF --- cgi
|
--- x86-windows --- conf.d --- mysql.ini [extension="php_mysql.dll"]
| |
| --- ext --- php_mysql.dll
| --- php-cgi.exe <-- moved here
|
|
|
--- i386-linux --- conf.d --- mysql.ini [extension="mysql.so"]
|
--- ext --- mysql.so
--- php-cgi <-- moved here
* The FastCGI configuration has been moved from the FastCGIServlet servlet config to the ContextLoaderListener context.
Please use <context-param parameter ... instead of <init-param servlet-parameter ...
* The PHP JSR 223 ScriptEngine API now supports the Compilable interface. Please see the php/java/tests JUnit tests.
* The EngineFactory has been removed. Scripts running within a servlet context (see ContextLoaderListener) can
now use a ScriptContext decorator to access the FastCGI runner associated with the ContextLoaderListener.
A sample decorator can be found in php.java.script.servlet.PhpCompiledHttpScriptContext
Version 6.1.2.1
* Security fix: Even if the PHP option allow_url_include it set, it is
no longer possible to load arbitrary resources using the JSR 223
script interface. The following eval() will fail if the "remote"
interface is not 127.0.0.1:
<%!
private static final Reader R = EngineFactory.createPhpScriptReader("<?php function f($a) {return 'hello '.$a;}; ?>");
%>
<%
Reader r = EngineFactory.createPhpScriptFileReader(getClass().getName()+"._cache_.inc", R);
ScriptEngine e =
EngineFactory.getInvocablePhpScriptEngine (this,
application, request, response,
new URI("http:https://127.0.0.1/java/JavaProxy.php"););
try {
// inject the above PHP code into the PHP app server and execute it
// will fail if the URI is not http:https://127.0.0.1/...
e.eval(r); r.close();
// call the injected code
Object result = ((Invocable)e).invokeFunction("f", new Object[]{"you"});
out.println ("result: " + result);
} catch (Exception ex) {
out.println(ex);
} finally {
((Closeable)e).close()
}
%>
Version 6.1.2
* The bridge now sets the config dir to cgi/OS-ARCH/conf.d. It makes
it easier to add custom PHP extensions to the Java web
application. Please see the phpinfo() output.
Example for the PHP mysql extension for Linux and Windows (i386/x86):
WEB-INF --- cgi --- php-cgi-x86-windows.exe
|
--- x86-windows --- conf.d --- mysql.ini [extension="php_mysql.dll"]
| |
| --- ext --- php_mysql.dll
|
|
--- php-cgi-i386-linux
|
--- i386-linux --- conf.d --- mysql.ini [extension="mysql.so"]
|
--- ext --- mysql.so
Please see the FAQ entry "I want to ship my own PHP web
application. Where do I put PHP and PHP extensions?" for details.
* The "servlet engine" built into JavaBridge.jar now handles PHP/Java
Bridge protocol requests as efficient as a real servlet engine back
end;
java -jar JavaBridge.jar SERVLET_LOCAL:8080
now uses HTTP/1.1 Transfer-Encoding: chunked. Example:
telnet localhost 8080
PUT /JavaBridge/servlet.phpjavabridge HTTP/1.1
Host: localhost:8080
Transfer-Encoding: chunked
22
<H p="1" v="java.lang.String"></H>
b
<F p="E" />
0
* It is now easy to use the bridge back-end in an existing
servlet. Example code:
public class MyServlet extends HttpServlet {
...
public String hello() { return "hello from MyServlet"; }
...
protected void doPut (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
IContextFactory ctx = new RemoteHttpServletContextFactory(this, getServletContext(), req, req, res);
res.setHeader("X_JAVABRIDGE_CONTEXT", ctx.getId());
res.setHeader("Pragma", "no-cache");
res.setHeader("Cache-Control", "no-cache");
try { ctx.handleRequests(req.getInputStream(), res.getOutputStream()); } finally { ctx.destroy(); }
}
}
If MyServlet listens on localhost:8080/MyWebApp/MyServlet, PHP scripts can call it:
<?php
define("JAVA_HOSTS", "localhost:8080");
define("JAVA_SERVLET", "/MyWebApp/MyServlet");
require_once("java/Java.inc");
echo java_context()->getServlet()->hello();
?>
Version 6.1.1
* The bridge now supports all available PHP stream transports. Example:
<?php require_once("https://secure-host.com:8443/JavaBridge/java/Java.inc");
echo java_context()->getHttpServletRequest()->getScheme();
echo ", ";
echo java_server_name();
?>
The above is equivalent to:
<?php
define("JAVA_HOSTS", "ssl:https://secure-host.com:8443");
define("JAVA_SERVLET", "/JavaBridge/servlet.phpjavabridge");
require_once("java/Java.inc");
echo java_context()->getHttpServletRequest()->getScheme();
echo ", ";
echo java_server_name();
?>
=> https, ssl:https://my-secure-host.com:8443
Please see the PHP documentation stream_get_transports() for
details.
Version 6.1.0
* Some Windows PHP install procedures destroy a local PHP executable
by setting a "PHPRC" environment variable. This environment variable
may have been useful in the past, but it disturbs modern PHP executables.
Environment entries passed to PHP are now filtered through a blacklist,
see PHP_ENV_BLACKLIST in global.properties in JavaBridge.jar.
The list can be changed as usual. Example global.properties file:
PHP_ENV_BLACKLIST = KEY1 KEY2 KEYN
Example command line:
java -Dphp.java.bridge.php_env_blacklist="key1 key2 keyN" -jar JavaBridge.jar ...
Version 6.0.0
* Apache or IIS PHP scripts can now use "java_virtual()" to include
the output of JSP scripts, Java servlets or Java frameworks into PHP
pages.
* MS .NET support has been removed: The "MonoBridge.exe" is not
available anymore.
* Support for GNU "Java", GNU Autoconf/Makefile has been removed: The
only remaining targets "JavaBridgeTemplate.war" and "JavaBridge.war"
can now be build by a java "ant" build script.
* FreeBSD support has been removed: The "unix domain" socket channel
(implemented by a JNI "libnatcJavaBridge.so") cannot be used
anymore, therefore the bridge will be very slow on this operating
system kernel. FreeBSD users must use local TCP sockets and switch
off the Nagle algorithm or fix their kernel or add a TCP_NDELAY
option to the PHP streams implementation.
* Dynamic class loading has been removed: The java_require() procedure
is not available anymore. Please use standard JEE or servlet
autodeployment instead.
* Support for the Tomcat "CGIServlet.java" has been removed: PHP must
support the FastCGI SAPI. PHP >= 5.2.0 support the FastCGI SAPI by
default. If you have a php-cgi binary < version 5.2.0, recompile it
with the --enable-fastcgi option. The FastCGI servlet has been
rewritten to support HTTP/1.1 chunked connections and the
"WebSockets" protocol used by google "Chrome".
* The named pipe communication channel has been removed: On Security
Enhanced Linux please use HTTP/1.1 chunked connections instead.
* The servlet or JEE back end must support HTTP/1.1 chunked
connections or the communication will fail. This has been tested on
the following AS: Glassfish, Jetty 7, Tomcat, Oracle/BEA WebLogic, Sun
AS 9.
* The low-level protocol has not been changed. But due to the above
changes an old "Java.inc" might not work with a new JavaBridge.war
back end anymore. Please make sure to upgrade your "Java.inc" PHP
library.
Version 5.5.5
* PHP scripts running within a JEE server can now use PHP paths like:
.../MOODLE/dir/do.php/something?with=what
This feature can be switched off by removing the <filter> and
<filter-mapping> from the web application web.xml.
* PHP scripts running within a JEE server now use java.io.tmpdir as
their the session.save_path. This can be changed as usual, see
php.java.bridge.global.properties PHP_EXEC_ARGS. Use
Util.DEFAULT_PHP_ARGS as a template.
* A beta test version of the PHPDebugger is now part of the PHP/Java
Bridge.
* The build system doesn't create RunJavaBridge and RunMonoBridge
executables anymore. java.so, libnatcJavaBridge.so and a "java"
binary are still created for compatibility with GNU "gcj"
"Java". Please ignore or delete them if you're using Java instead of
GNU "gcj" "Java".
Version 5.5.4.1
* The "JBoss" application server abuses the log4j port 4445 for its
internal purposes. The bridge now switches off log4j "chainsaw" if
getServletContext().getServerInfo().startsWith("JBoss").
* The namespace separator "_" (e.g.: new org_foo_bar_baz(...) syntax),
which has been used by some projects, is available again. However,
new projects should use the official namespace separator, which
defaults to "\".
* If the option -Dphp.java.bridge.default_log_file= is set, the bridge
switches off log4j chainsaw completely.
* The default value of php_include_java has been set to Off.
* A configuration option has been added to the JavaBridgeTemplate.war
which sets php_include_java to On.
* Bugfix: If php_include_java is set, global PHP variables are no
longer discarded; the PHP scripts are required from the top-level
environment.
Version 5.5.4
* Bugfix: Throwing JavaException w/o messages is possible again.
* A bug has been fixed in the JSR 223 handling which could cause the
JSR 223 script engine to crash. See the ChangeLog for details.
* If the Java environment doesn't allow java.lang.Threads, Sockets, or
if the back end doesn't run on localhost
("127.0.0.1".equals(req.getRemoteAddr()), or if the promiscuous
option is set, the bridge now uses a HTTP tunnel to communicate with
the back end. Example:
--
telnet YOURHOST.com 8080
PUT /JavaBridge/foo.phpjavabridge HTTP/1.1
Host: YOURHOST.com:8080
Transfer-Encoding: chunked
22
<H p="1" v="java.lang.String"></H>
b
<F p="E" />
0
--
* Due to the new communication channel, version 5.5.4 may not be
compatible with earlier versions. Please make sure to upgrade both,
the "Java.inc" PHP library and the "JavaBridge.jar" Java library.
* An option "java.persistent_servlet_connections" has been added to
the java.ini. Due to a bug in some Tomcat versions,
JAVA_PERSISTENT_SERVLET_CONNECTIONS cannot be used with
Transfer-Encoding: chunked. Tomcat 6.0.14 sends back a valid body
without Content-Length and Transfer-Encoding: chunked if it wants to
close a persistent chunked connection via Connection: close (see
tomcats connectionTimeout setting). An attempt to use the new
communication channel with JAVA_PERSISTENT_SERVLET_CONNECTIONS
raises a fatal error immediately. Either enable the Pipe- or
SocketContextServer or disable JAVA_PERSISTENT_SERVLET_CONNECTIONS
in your PHP script or in the java.ini
* The promiscuous option is not required anymore. If set as a context
parameter, it switches off the Pipe- and SocketContextServer.
Example web.xml:
...
</listener>
<!-- force the bridge to use the HTTP tunnel -->
<context-param>
<param-name>promiscuous</param-name>
<param-value>On</param-value>
</context-param>
<context-param>
<param-name>override_hosts</param-name>
...
* The option -Dphp.java.bridge.default_log_file=FILE redirects all log
output to FILE. The following example sends all log output to
standard out: JAVA_OPTS="-Dphp.java.bridge.default_log_file="
bin/catalina.sh run
* The JAVA_DEBUG option has been removed from Java.inc, so that
Java.inc fits into 64K. Use JavaBridge.inc from the src.zip or a
PHP source level debugger (for example the Zend Debugger) if you
want to debug the PHP bridge code.
Version 5.5.3
* The bridge can now handle java.lang.RuntimeException/Errors: If the
option JAVA_PREFER_VALUES is set, each RuntimeException/Error is
thrown as a PHP JavaException. Otherwise java_last_exception_get()
can be used to fetch the last RuntimeException/Error. Example:
define ("JAVA_PREFER_VALUES", false);
require ("http:https://localhost:8080/JavaBridge/java/Java.inc");
try {
@new java("java.lang.String", null);
if ($ex = java_last_exception_get()) {
echo "OOPS, ";
java_last_exception_clear();
throw $ex;
}
} catch (JavaException $e) {
echo "Received Exception or Error:" . $e->getMessage();
}
* java_begin_document()/java_end_document() are now dummy calls and
have been removed from the documentation.
* java_last_exception_get()/java_last_exception_clear() are no longer
deprecated.
Version 5.5.1
* Improved unix-domain socket handling: If
java.socketname=/path/to/some/unix.socket
is set in the php ini file, the bridge starts a Java process
listening on that socket.
* Improved local tcp socket handling: If
define ("JAVA_SERVLET", false);
define ("JAVA_HOSTS", PORT); // e.g.: PORT = 9090
is set before including Java.inc, the bridge starts a Java process
listening on that port.
* Improved JSR 223 standalone invocable script engine: When running in
standalone mode, the InvocablePhpScriptEngine can now connect to a
remote PHP application server, too. Example:
PHP script "hello.php":
<?php require_once("java/Java.inc");
function f() {return java_server_name();};
java_call_with_continuation(java_closure());
?>
The Java code:
ScriptEngine e = (new ScriptEngineManager()).getEngineByName("php-invocable");
e.eval(new php.java.script.URLReader(new URL("http:https://localhost/hello.php")));
System.out.println(((Invocable)e).invokeMethod(e.get("php.java.bridge.PhpProcedure"), "f", new Object[]{}));
((Closeable)e).close();
Version 5.5
* mono_closure() and java_closure no longer try to determine the type
automatically, pass the type as the third argument. Instead of:
$win->add_DeleteEvent (new Mono("Gtk.DeleteEventHandler",
mono_closure($this, "delete")));
use:
$win->add_DeleteEvent (new Mono("Gtk.DeleteEventHandler",
mono_closure($this, "delete", mono('Gtk.DeleteEventHandler$Method'))));
instead.
* The current PHP continuation is now available from the engine scope,
key "php.java.bridge.PhpProcedure".
* The bridge tries to autoload Java classes by default. For example
use java\lang\String as Str; echo new Str("hello");
will autoload the class JString. This can be switched off with
define("JAVA_DISABLE_AUTOLOAD", true); before including Java.inc.
* PHP 5.3 classes can now extend Java classes easily. For example:
<?php
use java\lang\String as JString;
class String extends JString {
function toString() { return "I am" . parent::toString(); }
}
$str = new String(" a php/java string");
echo $str->toString ();
?>
* Since PHP 5.3 TYPE::procedure() can be used instead of
TYPE::type()->procedure().
<?php
use java\lang\System as Sys;
echo Sys::getProperties();
// equivalent to echo Sys::type()->getProperties()
?>
However, to access a static procedure with the name "type" or a
sub-type of a type, you still have to use the TYPE::type(SUBTYPE)
syntax.
* Improved array handling:
$l = new java("java.util.ArrayList", array(1,2,3));
echo isset($l[3])?"t":"f";
=> f
$l[] = 4;
echo isset($l[3])?"t":"f";
=> t
unset($l[3]);
echo isset($l[3])?"t":"f";
=> f
print_r(java_cast($l, "array"));
=> array((object)1, (object)2, (object)3);
print_r(java_values($l));
=> array( (int)1, (int)2, (int)3);
* The bridge no longer throws java.lang.RuntimeException or
java.lang.Error unless these exceptions are declared in the
procedure or method definition.
Version 5.4.4.2
* A fast path has been added so that scripts running within a java
servlet engine or J2EE server can access their Java back end. This
can be switched off by setting the PhpCgiServlet init-param
php_include_java to Off.
* A fast path has been added so that scripts running within a java
servlet engine or J2EE server consume only one continuation. This
means that the bridge can now run on engines which have a limited
thread pool without having to check for a potential dead-lock
(e.g. thread pool is full of servlets waiting for another servlet to
start). This short path can be switched off by setting the system
property php.java.bridge.no_short_path=true.
* java_invoke is now an official API method
* java_require() documentation has been removed. It is and will be
supported, but new users should use tomcat/jee hot deployment
instead.
* It is now much easier to install the bridge for all Java web
applications or to add it to existing Java web application. Only the
JavaBridge, php-servlet and php-script jar files and 9 lines of
standard XML configuration are needed, see our
FAQ.html#global-servlet for details.
* RequestDispatcher.include() can now be used with the PHP
servlet. The servlet now checks if javax.servlet.include.* exists
and uses these arguments instead of the original arguments obtained
via reqest.getRequestURL() etc.
* The php.java.script.servlet.EngineFactory API has been revised.
Version 5.4.4.1
* Remote PHP scripts can now be accessed as usual. The code:
<%@page import="java.io.*" %>
<%@page import="javax.script.*" %>
<%@page import="php.java.script.servlet.EngineFactory" %>
<%
ScriptEngine e =
EngineFactory.getInvocablePhpScriptEngine (this,
application, request, response,
new java.net.URI("http:https://foo:80/myApp/JavaProxy.php"));
String result = (String)((Invocable)e).invokeFunction("phpversion",
new Object[]{});
((Closeable)e).close();
out.println("yourApp running PHP version:" + result);
%>
Will eval "phpversion()" on the server foo and return the result.
There must not be a firewall in between and both components should be
behind a firewall.
Version 5.4.4
* The handling of J2EE JSR 223 script engines (and scripts executed
within a J2EE server) has been changed. They are no longer reclaimed
automatically when they are idle for more than 15 seconds. Please see
the ChangeLog file for details.
* A system FastCGI server executable is now executed from the PATH.
Version 5.4.3.3
* The binary download has been split into a JavaBridgeTemplate5433.war
and a php-java-bridge_5.4.3.3_documentation.zip.
Version 5.4.3.2
* A shutdown hook can now be used to automatically shut down libraries
when the (servlet-) context is destroyed.
* Invocable script engines are automatically destroyed when the
(servlet-) context is destroyed.
* Invocable script engines are no longer automatically destroyed at
the end of the request, as users may want to store them in the
application store for example. Use ((Closeable)engine).close() to
destroy a script engine explicitly.
* The convenience procedures getHttpServletResponse(),
getHttpServletRequest(), getServlet(), getServletConfig(),
getServletContext(), getRealPath() have been added to the the
java_context().
* On Solaris the directory /tmp is used instead of /dev/shm to create
the named pipes.
* An Eclipse BIRT report example is included.
* Users who want to run php from Java, can pass arguments via
-Dphp.java.bridge.php_exec_args=ARGS. ARGS must be a list of
java.net.URLEncoded arguments, separated by a space. User-provided
PHP_EXEC_ARGS replace the standard args, which are: "-d
allow_url_include=On -d display_errors=Off -d log_errors=On -d
java.persistent_servlet_connections=On".
Version 5.4.3.1
* java_unwrap($closure) can now used to retrieve the PHP object
associated with a java_closure(). Example:
class f{function __toString(){return "p";}function toString(){return "j"}};
$cl = java_closure(new f());
echo $cl;
=> j
$cl = java_unwrap($cl)
echo $cl;
=> p
Version 5.4.2
* JavaBridge.jar now supports a -Dphp.java.bridge.daemon=true option.
When this option is set, the bridge ignores all other options,
closes the in-, out- and error streams immediately and runs
as a daemon. Example
<html>
<head/>
<body>
<form method="POST" action="<?php $_SERVER['PHP_SELF']?>">
<input type="submit" value="java_start" name="java_start">
<input type="submit" value="java_stop" name="java_stop">
<input type="submit" value="java_properties" name="java_properties">
</form>
<?php require_once("java/Java.inc");
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$JAVA="javaw";
} else {
$JAVA="nohup java";
}
if (isset($_POST["java_start"])) {
echo
system("$JAVA -Dphp.java.bridge.daemon='true' -jar java/JavaBridge.jar SERVLET_LOCAL:8080");
exit (0);
}
if (isset($_POST["java_stop"])) {
$file = fsockopen("127.0.0.1", 8080) or die ("java not running");
fwrite($file, "PUT /JavaBridge/JavaBridge.phpjavabridge HTTP/1.0\r\nHost: localhost\r\nContent-Length: 71\r\n\r\n<C v=\"java.lang.System\" p=\"C\" /><I v=\"1\" m=\"exit\" p=\"I\"><S v=\"0\" /></I>");
fclose ($file);
exit (0);
}
try {
echo java("java.lang.System")->getProperties();
} catch (Exception $e) {
echo $e;
}
?>
</body>
</html>
Version 5.4.1
* If PHP is used within a J2EE server or servlet engine the option
JAVA_PERSISTENT_SERVLET_CONNECTIONS is set. This means that the
servlet option fcgi_children (see WEB-INF/web.xml) must be less than
or equal to the servlet engine's thread pool size. It defaults to
5. The smallest thread pool we've seen is the thread pool of the Sun
J2EE server version 9, with 5 entries.
* If PHP is used within Apache or IIS via the java.so or
php_java.dll the option JAVA_PERSISTENT_SERVLET_CONNECTIONS is
set. This means that Apache/IIS "maxChilds" must be less than or
equal to the servlet engine or J2EE server's "maxThreads" value,
otherwise the additional PHP executables will hang. On Fedora and
RedHat Linux we have verified that Tomcat's maxThreads == Apache
maxChilds. If you're unsure, do not use the php_java.dll/java.so.
* Due to a bug in PHP versions < 5.3 persistent connections cannot be
used on Windows. Please make sure to switch them off.
* All options can now be set on the command line. Example:
php-cgi -djava.persistent_servlet_connections=On test.php
Version 5.3.4
* To be compatible with all operating systems, the bridge now uses
a dummy round-trip during context switches, effectively reverting
the change from version 5.3.3.
Version 5.3.3
* For context switches the bridge now uses write-write-read on
protocol level.
* The PhpServlet* JSR 223 script engines have been rewritten to make
it easier to call Apache or IIS PHP modules or libraries from
servlets. Example:
<%!
/* Create a PHP script with a function f() */
private static java.io.File script;
private static java.io.File getScript(String path) {
if(script!=null) return script;
return script=EngineFactory.getPhpScript(path, new StringReader(
"<?php function f($arg) {return 1 + java_values($arg); }; ?>"));
}
%>
<%
/* Create a standard script engine and invoke function f on http port 80 */
ScriptEngine e = EngineFactory.getInvocablePhpScriptEngine (this,
application, request, response, "http", 80);
File script = getScript(application.getRealPath(request.getServletPath()));
FileReader reader = EngineFactory.createPhpScriptFileReader(script);
e.eval (reader); reader.close();
Object result=((Invocable)i).invokeFunction("f",new Object[]{new Integer(2)});
((Closeable)e).close(); // flush the output generated by invokeXXX
out.println("result from php::f(), printed from the servlet: " + result);
%>
Version 5.3.0
* The bridge now uses real PHP 6 namespaces. Example:
java_autoload("lucene.jar");
use org::apache::lucene;
use org::apache::lucene::index;
use org::apache::lucene::search;
use org::apache::lucene::search::IndexSearcher as LuceneSearcher;
$searcher = new LuceneSearcher(...);
$term = new index::Term("name", "someTerm");
$phrase = new search::PhraseQuery();
$phrase->add($term);
$hits = $searcher->search($phrase);
Version 5.2.3
* Java boolean values now display as 0/1:
echo ((bool)(string)new java("java.lang.Boolean", false)) ? "#t":"#f";
=> #f
echo ((bool)(string)new java("java.lang.Boolean", true )) ? "#t":"#f";
=> #t
Version 5.2.2.4
* The mono.so does not interfere with the pure Java PHP/Java Bridge
implementation anymore.
Version 5.2.2.3
* The deprecated php_java.dll and java.so may trash the pure Java
PHP/Java Bridge implementation. Revert all changes made by the
java.so or php_java.dll and use our own settings.
Version 5.2.2.2
* The JSR223 scripts can now be cached. See jsp+php.jsp and jsr223.jsp
for details.
* The standalone component now uses a very restrictive security
setting by default. It can be switched off in java.ini.
Version 5.2.2
* This version contains bug fixes only.
Version 5.2.1
* java_isnull() or java_is_null() can be used to test for a Java NULL value.
It is equivalent to is_null (java_values ($javaObject)));
Version 5.2.0
* The Java type has been removed from java.so and php_java.dll. To
access Java, use
require_once ("java/Java.inc");
* java_require("foo.jar;...") and java_autoload("foo.jar;...")
override the libraries from the global class path.
Version 5.1.0
* This release contains only bugfixes.
* The procedure which calculates the weight of the potential method
candidates has been rewritten. It is compatible with Sam Ruby's code
written for PHP 4 except that arrays with a non matching component
type have a much larger weight.
* The bridge now uses the same code as zend_eval_string() to load
the PHP code into the zend engine. If your debugger or some other
component "xxx" crashes in xxx_execute(), check if it honors the
EG(no_extensions)==1 flag.
* The bridge no longer tries to load libraries from
php.java.bridge.base/lib. Use java.ext.dirs instead.
Version 5.0.0
This version is no longer backward compatible with earlier versions:
* Undeclared exceptions thrown by Java procedures can no longer be
caught by PHP code. This change may cause confusion, but it is
consistent with other container implementations, for example EJB.
* No automatic Java -> PHP value conversion. Use java_values($javaValue)
to retrieve the value from a Java proxy.[1]
* Java NULL values are represented as PhpNull proxies. Use java_values()
to retrieve the value.[1]
[1] Note that in PHP versions <= 5.3
class Clazz { function __toString() {return "42"; } }
var_dump((int)(string)new Clazz());
works correctly but
var_dump((int)new Clazz());
does not. This means that if you want to convert an object into
a value, you must convert it into a string first.
Version 4.3.3
This release contains bug fixes only. The following "bugs" have
been fixed:
* The asynchronous protocol can now be used everywhere. Please see
examples/bench/bench.php for details.
* The Apache/IIS front end and the tomcat back end can be restarted
independently. Tomcat doesn't keep references to old classes when
the context is reloaded.
* When gcj is used, dynamic proxies are created by the default
classloader. This is necessary because gcj doesn't have a class GC.
* The JSR223 script engines now wait for the SimpleContextFactory to
finish. In previous versions the script engines were recycled at the
end of the PHP script, not at the end of the PHP to Java
communication.
* The old C implementation has been removed. PHP 4 is not supported
anymore.
Version 4.3.1
* JSP or servlets can now access PHP as follows:
<% out.println ("I AM A SERVLET ... ");
javax.script.ScriptEngine e =
php.java.script.EngineFactory.getPhpScriptEngine
(this, application, request, response);
e.getContext().setWriter (out);
e.eval ("<?php echo '... AND I AM AN EMBEDDED PHP SCRIPT';?>");
e.eval ("<?php echo java_inspect (java_closure()); ?>");
%>
The InvocablePhpScriptEngine can be retrieved with
EngineFactory.getInvocablePhpScriptEngine(...);
Version 4.3.0
* A php-java-bridge-mono RPM is now available.
* Renamed JavaBridge to VMBridge.
* It is now possible to access PHP (HTTP- or FastCGI) pool instances
from servlets or frameworks such as Spring or JSF using the JSR 223
API. See script/EngineFactory.java and servlet/ContextLoaderListener.java.
* New high-level API:
java_autoload() or java_autoload("foo.jar;bar.jar;...");
echo new java_lang_String("hello");
=> hello
echo java_lang_String::type();
=> type: java.lang.String
echo java_lang_Boolean::type()->TYPE;
=> primitive type: boolean
echo php_java_bridge_Util::type("Logger");
=> type: php.java.bridge.Util$Logger
echo php_java_bridge_Util::type('ProcessWithErrorHandler$PhpException');
=> type: php.java.bridge.Util$ProcessWithErrorHandler$PhpException
Version 4.2.0
* This is an experimental release.
* A cache has been added to the pure PHP PHP/Java Bridge
implementation. If enabled, scripts which call a java routine more
than once will execute up to 7 times faster.
Version 4.1.8
* The old C extension doesn't exist anymore.
* For backward compatibility the file "java.c" loads "Java.inc",
compiles and caches it. Although this temporarily makes the C
implementation up to 10 times slower (due to a slow XML parser/writer
on PHP level), it allows us to use certain optimizations on opcode
level. Furthermore the C-based XML parser and XML writer is still
there and will be used by the pure PHP/Java Bridge implementation in
the future.
* Since the C extension doesn't use any object-level API's anymore (at
the moment it uses only zend_compile() and zend_execute()), it will
compile against all future versions of the zend engine. Furthermore it
should now be easy to compile it on operating systems which don't
support autoconf.
* The user option java.persistent_connections has been
removed. Persistent connections are always switched on in PHP >= 5.
* The pure PHP/Java Bridge implementation looks for a function
"java_get_default_channel()". If it exists and returns a string or
integer, the bridge will use this port number. It is used by Apache or
IIS to communicate the port number of the Java sub component (if any)
to PHP. Outside of Apache/IIS this can be used as follows:
# start java from a service script
java -jar JavaBridge.jar INET_LOCAL:9876
# In each PHP script define the default channel# before
# loading Java.inc
if(!function_exists("java_get_default_channel")) {
function java_get_default_channel() { return 9876; }
require_once("java/Java.inc");
}
echo java("java.lang.System")->getProperties();
Version 4.1.7
* Forcibly switched off java.persistent connections when the C front
end is used with a J2EE back end. The persistent connection handling
in java.c was a hack which assumed ownership of the back end. Now that
we support a J2EE cluster and the Apache load balancer, the C code
must be rewritten so that it uses the same algorithm as the pure
PHP/Java Bridge implementation: connect to the servlet to obtain the
session and the local channel#, then switch to the (persistent-)
channel.
* Removed all deprecated code from the back end. The back end
now throws an exception if it is used with an old C front end.
Version 4.1.6
* Fixed a bug in the pure PHP/Java Bridge implementation, which did
not handle urls like http:https://foo.org//bar/baz.php correctly (the apache
load balancer emits such URL's).
* Apache load balancer supported. See the FAQ entry "How to I enable
load balancing for the PHP/Java Bridge cluster".
Version 4.1.5
* The simple web server built into the JavaBridge.jar can now handle
JSR223 scripts, directories and plain (html- and text-) files. This is
convenient for testing server-side script implementations such as PHP,
bean shell, ecma script, etc.
* The JavaBridge.war file is now marked as "distributable" and can be
used in a cluster environment. We have tested a Tomcat 6 cluster with