การติดตั้ง PHP/JavaBridge กับ JavaEE Container
หน้าแรก PHP MySQL เกร็ดความรู้ การติดตั้ง PHP/JavaBridge กับ JavaEE Container
การติดตั้ง PHP/Java Bridge ตัวนีเป็นการติดตั้ง PHP/Java Bridge ที่แตกต่างจา Implementation ของ Zend
เนื่องจากเป็นการใช้ PHP Instance ที่มีอยู่แล้วในการติดต่อไปยัง Java/.Net/Mono Backend ที่มีอยู่แล้ว โดยใช้ PHP/Java Bridge Protocol
website: http://php-java-bridge.sourceforge.net
รายละเอียดจาก Site ที่เป็นผู้ Implement
How it works
The php "Java" class implementation uses the PHP/Java Bridge protocol to connect running PHP instances with already running Java or .NET back ends. The communication works in both directions, the JSR 223 interface can be used to connect to a running PHP server (Apache/IIS, FastCGI, ...) so that Java components can call PHP instances and PHP scripts can invoke CLR (e.g. VB.NET, C#, COM) or Java (e.g. Java, KAWA, JRuby) based applications or transfer control back to the environment where the request came from. The bridge can be set up to automatically start the PHP front-end or the Java/.NET back end, if needed.
Each request-handling PHP process of a multi-process HTTP server communicates with a corresponding thread spawned by the VM. Requests from more than one HTTP server may either be routed to an application server running the PHP/Java Bridge back end or each HTTP server may own a PHP/Java Bridge back end and communicate with a J2EE Java application server by exchanging Java value objects; the necessary client-stub classes (e.g.: SOAP stubs or EJB client .jar files) can be loaded at run-time.
ECMA 335 based classes can be accessed if at least one back end is running inside a ECMA compliant VM, for example Novell's MONO or Microsoft's .NET. Special features such as varargs, reflection or assembly loading are also supported.
When the back end is running in a J2EE environment, session sharing between PHP and JSP is always possible. Clustering and load balancing is available if the J2EE environment supports these features.
The PHP/Java Bridge does not use the Java Native Interface ("JNI"). PHP instances are allocated from the HTTP (Apache/IIS) pool, instances of Java/J2EE components are allocated from the back end. The allocated instances communicate using a "continuation passing style", see java_closure() and the invocable interface. In case a PHP instance crashes, it will not take down the Java application server or servlet engine.[/quote]
ใน Blog นี้ผมจะพูดถึงการติดต่อกับ JavaEE Container เท่านั้นนะครับ
Windows (Win32) Installation
1. ติดตั้ง Apache Tomcat เป็น Windows Service ก่อน แล้วจากนั้นให้ Copy JavaBridge.war ไปยัง autodeploy folder ของ Tomcat
2. หลังจาก Start Tomcat แล้ว ลองเข้าไปใน webapps/JavaBridge แล้ว Copy JavaBridge Folder ไปที่ Web Server แล้วทดลองรัน PHP/Java Example
แค่นี้จริงๆครับ
ถ้าเทียบกันแล้วแตกต่างกันกับ JavaBridge ของ php.net/Zend ค่อนข้างมากทีเดียว ผมเคยใช้ PHP/Java Bridge Implementation มาหลายตัวแล้ว
PEAR/PHP.net/Zend Platform
แต่ข้อเสียคือ Zend Platform ราคาค่อนข้างสูง
PHP.net ขาดความเสถียรบน Windows
PEAR ขาดความเสถียรบน Windows
สุดท้ายจึงมาลงตัวที่ Implementation นี้ครับ
ปล.มี Caucho Resin ที่มี Pure JAVA PHP Implementation กับ WebLogic Liquid ที่มี Pure Java PHP Implementation เหมือนกัน
แต่ยังไม่มีโอกาสได้ทดลองครับ
refer: http://www.narisa.com/blog/zelda/index.php?showentry=1655
ขึ้นไปด้านบน