You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(6) |
Nov
(8) |
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(19) |
Feb
(15) |
Mar
(10) |
Apr
(8) |
May
(7) |
Jun
(9) |
Jul
(13) |
Aug
(31) |
Sep
(111) |
Oct
(52) |
Nov
(72) |
Dec
(42) |
2006 |
Jan
(21) |
Feb
(32) |
Mar
(33) |
Apr
(24) |
May
(15) |
Jun
(40) |
Jul
(32) |
Aug
(19) |
Sep
(38) |
Oct
(37) |
Nov
(63) |
Dec
(37) |
2007 |
Jan
(18) |
Feb
(39) |
Mar
(69) |
Apr
(49) |
May
(71) |
Jun
(59) |
Jul
(71) |
Aug
(85) |
Sep
(46) |
Oct
(14) |
Nov
(25) |
Dec
(56) |
2008 |
Jan
(24) |
Feb
(77) |
Mar
(104) |
Apr
(44) |
May
(41) |
Jun
(11) |
Jul
(31) |
Aug
(59) |
Sep
(44) |
Oct
(86) |
Nov
(66) |
Dec
(93) |
2009 |
Jan
(88) |
Feb
(41) |
Mar
(49) |
Apr
(135) |
May
(22) |
Jun
(31) |
Jul
(60) |
Aug
(71) |
Sep
(76) |
Oct
(18) |
Nov
(52) |
Dec
(20) |
2010 |
Jan
(8) |
Feb
(50) |
Mar
(35) |
Apr
(48) |
May
(46) |
Jun
(84) |
Jul
(38) |
Aug
(61) |
Sep
(51) |
Oct
(31) |
Nov
(17) |
Dec
(18) |
2011 |
Jan
(51) |
Feb
(14) |
Mar
(17) |
Apr
(23) |
May
(15) |
Jun
(11) |
Jul
(5) |
Aug
(5) |
Sep
(15) |
Oct
(8) |
Nov
(5) |
Dec
(25) |
2012 |
Jan
(2) |
Feb
(4) |
Mar
(6) |
Apr
(9) |
May
(27) |
Jun
(32) |
Jul
(36) |
Aug
(10) |
Sep
(16) |
Oct
(3) |
Nov
(13) |
Dec
(7) |
2013 |
Jan
(1) |
Feb
(4) |
Mar
|
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(4) |
Oct
(2) |
Nov
(1) |
Dec
|
2014 |
Jan
|
Feb
|
Mar
(2) |
Apr
(1) |
May
(2) |
Jun
(9) |
Jul
(5) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
2015 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(3) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(2) |
Sep
(5) |
Oct
(1) |
Nov
|
Dec
|
2016 |
Jan
|
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
(3) |
Oct
|
Nov
|
Dec
|
2017 |
Jan
(6) |
Feb
|
Mar
|
Apr
(10) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
2018 |
Jan
(2) |
Feb
(5) |
Mar
|
Apr
|
May
(1) |
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2021 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <php...@li...> - 2006-11-29 05:43:19
|
java bridge is ok when i use php <5.2 now i use 5.2, java birdge is error. 2006/11/29, php...@li... < php...@li...>: > > I have installed: > Apache HTTP Server 2.0.59 > PHP 5.2.0 > JDK 1.5.0_09 > > and trying to install PHP-JAVA bridge v3.1.8 - with no success :( > > Here is exactly what I did (what I think should make the Bridge work): > > 1) Extracted the JavaBridge archive, and then extracted JavaBridge.war. > 2) Copied WEB-INF/lib to my PHP extensions directory (e.g. c:\php5\ext) > and > then copied WEB-INF/cgi/java-x86-windows.dll to my PHP extensions > directory. > 3) Renamed the dll to php_java.dll > 4) Added the following lines to php.ini : > > extension_dir = "C:/php5/ext" > extension=php_java.dll > > [java] > java.java = "C:/Program Files/Java/jdk1.5.0_09/jre/bin/javaw" > java.java_home = "C:/Program Files/Java/jdk1.5.0_09" > java.log_level = 2 > java.log_file = "C:/php5/log/java-bridge.log" > > 5) Then, I restarted Apache, and executed a php-info file from my > web-servable directory ( phpinfo();). > In the page, I can not see the Java table (no Java table at all). When > I tried to run some java > classes from php, I got nothing. (There is an error logged in apache's > error-log, saying that the > PHP was unable to load/find specified module [I dont remember the > exact form of the error-log, I am > not sitting at the concerned machine]). > > > Can someone help me please? Im running desperate now... :(( > Thank you. > > John > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > > > -- regards jl |
From: <php...@li...> - 2006-11-28 23:52:39
|
Currently my company is running the Zend Java Bridge that comes with the Zend Platform on our production webservers, I was just wondering if anyone out there could give me some pros and cons to using the php-java-bridge instead of the Zend Java Bridge? With the recent price increase in their platform we have started looking into other solutions. Any comments would be very appreciated. Thanks -- Jeff |
From: <php...@li...> - 2006-11-28 19:03:40
|
I have installed: Apache HTTP Server 2.0.59 PHP 5.2.0 JDK 1.5.0_09 and trying to install PHP-JAVA bridge v3.1.8 - with no success :( Here is exactly what I did (what I think should make the Bridge work): 1) Extracted the JavaBridge archive, and then extracted JavaBridge.war. 2) Copied WEB-INF/lib to my PHP extensions directory (e.g. c:\php5\ext) and then copied WEB-INF/cgi/java-x86-windows.dll to my PHP extensions directory. 3) Renamed the dll to php_java.dll 4) Added the following lines to php.ini : extension_dir = "C:/php5/ext" extension=php_java.dll [java] java.java = "C:/Program Files/Java/jdk1.5.0_09/jre/bin/javaw" java.java_home = "C:/Program Files/Java/jdk1.5.0_09" java.log_level = 2 java.log_file = "C:/php5/log/java-bridge.log" 5) Then, I restarted Apache, and executed a php-info file from my web-servable directory ( phpinfo();). In the page, I can not see the Java table (no Java table at all). When I tried to run some java classes from php, I got nothing. (There is an error logged in apache's error-log, saying that the PHP was unable to load/find specified module [I dont remember the exact form of the error-log, I am not sitting at the concerned machine]). Can someone help me please? Im running desperate now... :(( Thank you. John |
From: <php...@li...> - 2006-11-28 18:46:41
|
Hi, > Fatal error: Uncaught > [o(Exception):"java.lang.Exception: Invoke failed: > [o(PHP2JavaBridge5)]->getEcDatenForOnlineEc2((Ekunden)o(Ekunden)). > Cause: > java.lang.NoSuchMethodError: DAL.rmi.PHP2JavaBridge5.getEcDatenForOnlineEc2(PHP2JavaBridge5.java:338) the above message means that your class PHP2JavaBridge5 has called a method which existed when it was compiled against an external library, but the current runtime environment doesn't contain this method. You're probably using an old version of the library but you have compiled against a newer one. Regards, Jost Boekemeier ___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de |
From: <php...@li...> - 2006-11-28 12:53:12
|
Hello, I am calling successfully several java functions from php, but I have one function which produces the following error message: Fatal error: Uncaught [o(Exception):"java.lang.Exception: Invoke failed: [o(PHP2JavaBridge5)]->getEcDatenForOnlineEc2((Ekunden)o(Ekunden)). Cause: java.lang.NoSuchMethodError: DAL.rmi.SecureTransporter.getEcDatenForOnlineEc(LDAL/PersistentObjects/Ekunden;)DAL/PersistentObjects/EcDaten; Responsible VM: 1.5.0_06@http://java.sun.com/" at: #-10 DAL.rmi.PHP2JavaBridge5.getEcDatenForOnlineEc2(PHP2JavaBridge5.java:338) #-9 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) #-8 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) The strange thing is that the method is existing and If I comment out the internals of the JAVA-function no error appears and the function can be called. It seems that the Java function getEcDatenForOnlineEc2(..) can only be called from PHP, when the JAVA function doesn't contain a specific line or if it's empty. (see below) My PHP call looks like this and is working (or not working) in dependency of the JAVA code: $this->EcDatenObject = $this->jbridge->getEcDatenForOnlineEc2($this->ekunde); The not working JAVA function looks like: public EcDaten getEcDatenForOnlineEc2(Ekunden ekunde) { EcDaten ec=null; try { ec=m_obj.getEcDatenForOnlineEc(ekunde); } catch (RemoteException e) { } return ec; } the working one looks like: public EcDaten getEcDatenForOnlineEc2(Ekunden ekunde) { EcDaten ec=null; /*try { ec=m_obj.getEcDatenForOnlineEc(ekunde); } catch (RemoteException e) { }*/ return ec; } The function call "m_obj.getEcDatenForOnlineEc(..);" which is called inside the JAVA function makes an RMI Call to a server. This is working well for other RMI functions, don't know if that matters it's only for completeness. Of course I tried also the JAVA function alone without calling it from PHP and it works perfect. I can not imagine why the function call from PHP works only when I comment out my Java code. I am already working for days to solve this problem... Any help is appreciated. scara _________________________________________________________________ Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu! http://desktop.msn.de/ Jetzt gratis downloaden! |
From: <php...@li...> - 2006-11-23 17:37:03
|
Hi, > Hello, would like an example using Session Bean > Stateful with JBOSS. Beyond > as to configure php-java-bridge from http://php-java-bridge.sourceforge.net/examples/J2EE/RMI-IIOP/README "The enterprise bean is a stateful session bean which accepts pages which are added to the document during the session. The document should be created when the PHP session starts and destroyed when the PHP session terminates. See ../php+jsp/documentClient.php." > using these tools in Windows XP You can use the standard deployment tools which came with your J2EE server. Regards, Jost Boekemeier ___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de |
From: <php...@li...> - 2006-11-23 17:33:56
|
Hi, > Olá, would like an example Wello World using EJB and > JBOSS. Beyond as to > configure php-java-bridge using these tools. please see http://php-java-bridge.sourceforge.net/examples/J2EE/RMI-IIOP/README and the FAQ. Regards, Jost Boekemeier ___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de |
From: <php...@li...> - 2006-11-22 21:15:18
|
Hello, would like an example using Session Bean Stateful with JBOSS. Beyond as to configure php-java-bridge using these tools in Windows XP |
From: <php...@li...> - 2006-11-22 21:13:13
|
Ol=E1, would like an example Wello World using EJB and JBOSS. Beyond as to configure php-java-bridge using these tools. |
From: <php...@li...> - 2006-11-22 18:52:40
|
> To set the instance (only once): > java_get_session()->put("DbEnv", $dbenv); > > To read it from every PHP request: > $dbenv = java_get_session()->get("DbEnv"); Better: java_get_session("DbEnv")->put(...); $dbenv=java_get_session("DbEnv")->get(...); this avoids surprises when you switch to the J2EE back end. Regards, Jost Boekemeier ___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de |
From: <php...@li...> - 2006-11-22 18:43:35
|
Hi, [about java_reset()] > One thing though I had to use the @ suppressor to > prenvent the PHP > warning. Is this the proper way or is there another? I don't think there's an official way to clean the JVM class loaders. The above java_reset() only works when running within a J2SE or GNU environment. It doesn't work when you use the recommended J2EE back end, because J2EE uses its own class loading mechanism. Regards, Jost Boekemeier ___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de |
From: <php...@li...> - 2006-11-22 09:22:08
|
Hi. Thanks for the answer. It looks like it's working now. To set the instance (only once): java_get_session()->put("DbEnv", $dbenv); To read it from every PHP request: $dbenv = java_get_session()->get("DbEnv"); Thanks, Ovidiu Dan On 11/21/06, Smarty <zm...@gm...> wrote: > Hi. > > I'm trying to implement the following: Berkeley DB <-> JNI <-> Java > <-> php-java-bridge <-> PHP. > > I would like to have only _one_ persistent Berkeley DB "Environment" > (a class instance) available to every PHP request (so this is not > something session-specific). The idea would be to somehow create an > instance of an object when the Java VM starts up, and then access it > from all PHP requests. > > I need to have this common instance for caching, resource utilization > and concurrency purposes. > > Is there any way to do this with php java bridge? > > Thank you for your time, > Ovidiu Dan, > Amsterdam > |
From: <php...@li...> - 2006-11-21 22:42:49
|
php...@li... wrote: > Hi tesla, > > the JVM caches class files. Please see documentation > for java_reset() for details. > > http://php-java-bridge.sourceforge.net/documentation/PHP-API/html/java_= 8c.html#doc32 > > > Regards, > Jost Boekemeier > > > > > > =09 > =09 > ___________________________________________________________=20 > Der fr=FChe Vogel f=E4ngt den Wurm. Hier gelangen Sie zum neuen Yahoo! = Mail: http://mail.yahoo.de > > -----------------------------------------------------------------------= -- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share= your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > > =20 Thanks Jost that did the trick! One thing though I had to use the @ suppressor to prenvent the PHP=20 warning. Is this the proper way or is there another? -Tesla |
From: <php...@li...> - 2006-11-21 18:51:54
|
Hi Ovidiu, > (a class instance) available to every PHP request > (so this is not > something session-specific). if you control the environment in which the bridge runs, there are certainly ways to do it. You could store the singleton in the application store (see http://php-java-bridge.sourceforge.net/documentation/PHP-API/html/java_8c.html#doc25). Please also see the FAQ entry which describes how to start a persistent JVM. Since Java 6 RC on Linux, Solaris and Windows, users can simply double-click on the JavaBridge.war file to start a persistent JVM once. Regards, Jost Boekemeier ___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de |
From: <php...@li...> - 2006-11-21 18:45:15
|
Hi tesla, the JVM caches class files. Please see documentation for java_reset() for details. http://php-java-bridge.sourceforge.net/documentation/PHP-API/html/java_8c.html#doc32 Regards, Jost Boekemeier ___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de |
From: <php...@li...> - 2006-11-21 14:44:15
|
Hi, I ran a php file that just prints out some text to test the bridge. I then created a new class file with different text. The old text still shows! So I just deleted the class file altogether. But running the PHP file not give an error it just runs as though the file still exists. So I am thinking that it is cached somewhere. I tried the browser cache and the temp directories but found nothing. Any ideas? thanks -tesla |
From: <php...@li...> - 2006-11-21 01:38:03
|
Hi. I'm trying to implement the following: Berkeley DB <-> JNI <-> Java <-> php-java-bridge <-> PHP. I would like to have only _one_ persistent Berkeley DB "Environment" (a class instance) available to every PHP request (so this is not something session-specific). The idea would be to somehow create an instance of an object when the Java VM starts up, and then access it from all PHP requests. I need to have this common instance for caching, resource utilization and concurrency purposes. Is there any way to do this with php java bridge? Thank you for your time, Ovidiu Dan, Amsterdam |
From: <php...@li...> - 2006-11-20 18:42:33
|
Hi Verena, > Why did I capture the top-level environment? java_closure() without any arguments captures the top-level environment, creates and returns a Java proxy for it. Of cause you could use invocable.invokeMethod(engine.get(objectBinding),...) to call a method[1]. But if you don't have more than one PHP class per php file, this shouldn't be necessary; you can capture the object directly, which has the advantage that you don't need to keep a dictionary of additional symbol->object bindings. > thought with engine.get("obj") > I get the PHP object returned Yes. (you'll get a Java proxy for the PHP object). > and so the method > saySomething is invoked on > that object? Yes. > What is the correct syntax to invoke a method on > MyClass()? > > I tried this: > PhpScriptEngine engine = new PhpScriptEngine(); > String s = "<?php \n"; > s += "require_once 'MyClass.php'; \n"; > s += "java_context()->setAttribute( 'obj', > java_closure(new MyClass()), > 100 ); \n"; > s += "?>"; > engine.eval( new StringReader(s) ); > Invocable inv = (Invocable) engine; > inv.invokeMethod( engine.get("obj"), "saySomething", > new Object() ); The above script is not invocable. The last line of a invocable PHP script must contain: java_context()->call(java_closure()); > java.io.IOException: Bad file descriptor > at java.io.FileOutputStream.writeBytes(Native Well, PHP simply terminates after a PHP script is executed. To keep it, you must suspend it and pass control back to the Java continuation. The java_context()->call(kont) calls the Java continuation with the PHP continuation as its argument, so that the Java continuation can call back into the PHP continuation kont whenever necessary: kont.call(scriptEngine.getContinuation()); Of course the above PHP<->Java continuation passing style is hidden behind the JSR223 interfaces. But on the PHP side the java_context()->call() must exist, otherwise the PHP script cannot be called from a (potentially) remote Java script engine interface. > Yes, it sounds like, but actually I'm not sure how > to do it. This faces things > are about the web framework, aren't they? In practice, yes. > So how do > I transform this to a > J2SE app? Just create one public PHP class per PHP file. Example file my/foo.php, my/bar.php foo.php: class my_Foo { function toString() {return "foo";} } java_context()->call(java_closure(new myFoo()); bar.php: class my_Bar { function toString() {return "bar";} } java_context()->call(java_closure(new myBar()); Now you need a XML file which describes your PHP "beans", or simply hard-code the names in your code: ScriptEngineManager m = new ScriptEngineManager(); ScriptEngine foo = m.getEngineByName("php"); foo.eval(new FileReader("my/foo.php")); ScriptEngine bar = m.getEngineByName("php"); bar.eval(new FileReader("my/bar.php")); // now you can call methods from the foo and bar // PHP classes > No, it instanciates a JavaSript object which has one > method called hello. Interesting. I thought that unlike PHP, the JavaScript object hierarchy is not orthogonal to the Java object hierarchy. Regards, Jost Boekemeier [1] In the old JSR223 proposal the invokeMethod() and invokeProcedure() methods where called "invoke()". ___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de |
From: <php...@li...> - 2006-11-20 15:36:44
|
Am Freitag, 17. November 2006 19:40 schrieb php...@li...: > However, you'll get a warning that the instance of > MyClass is not a Java object. Use > > java_closure(new MyClass()) > > instead. OK, this is working now without the warning. > > > Invocable inv = (Invocable) engine; > > inv.invokeMethod( engine.get("obj"), "saySomething", > > new Object() ); > > You will get a null pointer exception because obj is > bound to null, see the warning above. Furthermore you > have captured the top-level environment, but you > probably want to invoke methods from MyClass(). Why did I capture the top-level environment? I thought with engine.get("obj") I get the PHP object returned and so the method saySomething is invoked on that object? What is the correct syntax to invoke a method on MyClass()? I tried this: PhpScriptEngine engine = new PhpScriptEngine(); String s = "<?php \n"; s += "require_once 'MyClass.php'; \n"; s += "java_context()->setAttribute( 'obj', java_closure(new MyClass()), 100 ); \n"; s += "?>"; engine.eval( new StringReader(s) ); Invocable inv = (Invocable) engine; inv.invokeMethod( engine.get("obj"), "saySomething", new Object() ); and it results in this error message: Nov 20 10:55:20 JavaBridge ERROR: An exception occured: java.io.IOException: Bad file descriptor java.io.IOException: Bad file descriptor at java.io.FileOutputStream.writeBytes(Native Method) at java.io.FileOutputStream.write(FileOutputStream.java:260) at java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:109) at php.java.bridge.Response$Writer.flush(Response.java:125) at php.java.bridge.Response.flush(Response.java:671) at php.java.bridge.ClassicResponse.copyResponse(ClassicResponse.java:82) at php.java.bridge.Request.handleSubRequests(Request.java:607) at php.java.bridge.PhpProcedure.invoke(PhpProcedure.java:77) at php.java.bridge.PhpProcedure.invoke(PhpProcedure.java:95) at php.java.script.PhpScriptEngine.invokeMethod(PhpScriptEngine.java:204) at Bootstrap.main(Bootstrap.java:39) Bootstrap.java, line 39 is the last one showed above. > [...] > > return > ((Invocable)((PhpFacesContext)FacesContext.getCurrentInstance()).getScriptE >ngine(this, new URL(script))).invoke(name, args); > > I think this is exactly what you want. The only > difference is that the above method calls out to a URL > instead of a local script file. Yes, it sounds like, but actually I'm not sure how to do it. This faces things are about the web framework, aren't they? So how do I transform this to a J2SE app? In the code example I can't see how to call a method on a previously instanciated PHP object. It only uses the invoke Method with 2 parameters (invokeFunction). > > String script = "var obj = new Object(); > > obj.hello = function(name) > > { print('Hello, ' + name); }"; > > > > Any chance todo something similar with PHP? > > It is certainly possible to automatically call > java_closure(), when a php object is passed to a Java > procedure. But for several reasons we've decided to > require java_closure(php_object). Furthermore, if I > understand the above code correctly, the "new > Object()" above instanciates a Java object, not an > object from the js script interpreter. No, it instanciates a JavaSript object which has one method called hello. But if the only difference to this snippet and the possibiblities of the php-java bridge is the automatic call to java_close(), it is similar enough for my project. Regards, Verena |
From: <php...@li...> - 2006-11-17 18:40:34
|
Hi Verena, > PhpScriptEngine engine = new PhpScriptEngine(); > String s = "<?php \n"; > s += "java_context()->setAttribute( 'obj', new > MyClass(), 100 ); \n"; > s += "java_context()->call(java_closure()); \n"; > s += "?>"; > engine.eval( new StringReader(s) ); the above code should work, it evaluates the php script stored in the Java string s. However, you'll get a warning that the instance of MyClass is not a Java object. Use java_closure(new MyClass()) instead. > Invocable inv = (Invocable) engine; > inv.invokeMethod( engine.get("obj"), "saySomething", > new Object() ); You will get a null pointer exception because obj is bound to null, see the warning above. Furthermore you have captured the top-level environment, but you probably want to invoke methods from MyClass(). Frameworks such as Java Server Faces allow you to define PHP beans and to inject these beans into the framework: http://php-java-bridge.cvs.sourceforge.net/php-java-bridge/php-java-bridge/examples/java-server-faces/helloWorld.php?revision=1.6&view=markup java_context()->call(java_closure(new helloWorld())) ||include("index.php"); The above code creates an instance of the PHP helloWorld() class, creates a Java proxy for it and then calls the framework (the java_context()->call magic does this). When the call() failed (which means that the first request came in from the web server, and not from the framework), we redirect to index.php, which forwards the browser to the framework, which in turn evaluates the PHP script. The script creates the PHP bean and injects it into the framework. After that the framework holds a reference to the PHP bean and can call its methods: http://php-java-bridge.cvs.sourceforge.net/php-java-bridge/php-java-bridge/server/php/java/faces/Script.java?revision=1.6&view=markup return ((Invocable)((PhpFacesContext)FacesContext.getCurrentInstance()).getScriptEngine(this, new URL(script))).invoke(name, args); I think this is exactly what you want. The only difference is that the above method calls out to a URL instead of a local script file. > String script = "var obj = new Object(); > obj.hello = function(name) > { print('Hello, ' + name); }"; > Any chance todo something similar with PHP? It is certainly possible to automatically call java_closure(), when a php object is passed to a Java procedure. But for several reasons we've decided to require java_closure(php_object). Furthermore, if I understand the above code correctly, the "new Object()" above instanciates a Java object, not an object from the js script interpreter. Regards, Jost Boekemeier ___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de |
From: <php...@li...> - 2006-11-17 15:54:16
|
Sorry, once again ;-) I wrote this little part of a Java method for testing: PhpScriptEngine engine = new PhpScriptEngine(); String s = "<?php \n"; s += "require_once 'MyClass.php'; \n"; s += "java_context()->setAttribute( 'obj', new MyClass(), 100 ); \n"; s += "java_context()->call(java_closure()); \n"; s += "?>"; engine.eval( new StringReader(s) ); Invocable inv = (Invocable) engine; inv.invokeMethod( engine.get("obj"), "saySomething", new Object() ); The resulting errors are: java.lang.NullPointerException at java.lang.reflect.Proxy.getInvocationHandler(Proxy.java:636) at php.java.script.PhpScriptEngine.invokeMethod(PhpScriptEngine.java:202) at Bootstrap.main(Bootstrap.java:30) Nov 17 16:30:28 JavaBridge ERROR: PHP Warning: Argument is not (or does not contain) Java object(s). in - on line 3 The NullPointerException happens in the line where invokeMethod is called. Line 3 of the PHP script is the one where setAttribute() is called. As I understand the error message text, it is not possible to set a PHP object as an attribute to the java context, but only Java objects? Another thing I tried was: String s = "<?php \n"; s += "require_once 'MyClass.php'; \n"; s += "$obj = new MyClass(); \n"; s += "java_context()->call(java_closure()); \n"; s += "?>"; but there was the same NullPointerException. This was inspired from the Javascript example provided by SUN here: https://java.sun.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html#invoke ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("JavaScript"); String script = "var obj = new Object(); obj.hello = function(name) { print('Hello, ' + name); }"; engine.eval(script); Invocable inv = (Invocable) engine; Object obj = engine.get("obj"); inv.invokeMethod(obj, "hello", "Script Method !!" ); Any chance todo something similar with PHP? Regards, Verena |
From: <php...@li...> - 2006-11-17 14:14:51
|
php...@li... schrieb: > http://php-java-bridge.cvs.sourceforge.net/php-java-bridge/php-java-bridge/server/test/SwingTest.php?view=markup > thanks for the link. Verena |
From: <php...@li...> - 2006-11-16 18:52:52
|
Hi Verena, > The file SwingTest.php can't be downloaded, because > the webserver always > interprets the php code. Maybe you could rename it > to SwingTest.phps? The SwingTest.php can also be found in the server/test folder from the source download or here: http://php-java-bridge.cvs.sourceforge.net/php-java-bridge/php-java-bridge/server/test/SwingTest.php?view=markup Regards, Jost Boekemeier ___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de |
From: <php...@li...> - 2006-11-16 18:48:53
|
Hi, [setting base directory for java libraries] please set extension_dir=/path/to/php/extension/dir java_require("foo.jar;bar.jar") searches for the foo.jar and bar.jar libraries in extension_dir/lib. Regards, Jost Boekemeier ___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de |
From: <php...@li...> - 2006-11-16 11:58:41
|
> http://sourceforge.net/tracker/index.php?func=detail&aid=1597124&group_id=1 >17793&atid=679233 I added a comment with a simple way to solve this problem. Now I can compile the bridge with JDK1.6 RC and run the interactive shell as well as the HelloWorld test. Thanks again for all your help! Regards, Verena |