|
From: <php...@li...> - 2010-04-12 15:12:39
|
Hi,
you can use the JSR 223 API to invoke the PHP web container methods from Java.
>From a Java desktop application (JavaBridge.jar and php-script.jar in
the classpath) you can use:
ScriptEngineManager m = new ScriptEngineManager();
ScriptEngine e = m.getEngineByName("php-invocable");
e.eval(new URLReader(new URL("http://localhost:80/JavaProxy.php"));
System.out.println(((Invocable)e).invoke("java_get_server_name", new
Object[]{}));
...
((Closeable)e).close();
>From a Java web application (JavaBridge.jar and php-script.jar in the
WEB-INF/lib, ContextLoaderListener declaration in the WEB-INF/web.xml)
you can use:
ScriptEngine e = EngineFactory.getInvocablePhpScriptEngine(this,
application, request, response, new
URI("http://127.0.0.1:80/JavaBridge/java/JavaProxy.php"));
((Invocable)e).invokeFunction("phpinfo", new Object[]{});
...
((Closeable)e).close();
Please see the Java API documentation at
http://php-java-bridge.sourceforge.net/pjb/server/documentation/API/index.html
and the PHP method
java_call_with_current_continuation ()
for details: http://php-java-bridge.sourceforge.net/pjb/docs/php-api/index.html
Regards,
Jost Bökemeier
|