Connecting PHP and Java-Php/java Bridge [1]_php Tutorial

Source: Internet
Author: User
In the Web development market, Java and PHP are popular technologies that are currently being applied. Java's power is beyond doubt, not only in web development, but in every software application, Java is ubiquitous. PHP is also booming, driven by the power of open source and zend,ibm,oracle. No one will believe that the Internet pioneer Marc Andreessen's Prophecy "PHP will be more popular than Java", but "PHP is targeting the enterprise market, and Java is a positive battle" is indeed in progress, the world's 22 million sites using technology that people have to pay attention to.

Both technologies can compete fiercely, and they can work closely together. From the customer's point of view, the integration of technology is very important, because a large application system, often cannot be done independently by a single language/and technology. The advent of Php/java Bridge will be a bridge between PHP and Java, providing a good choice for companies that need to combine PHP with Java.

Haohappy not deep understanding of the Java EE, if the relevant content to understand the error, welcome criticism advice.

  (a) What is a JSR and what is JSR223?

The JSR (Java specification request) is a formal request to JCP (Java Community Process) to propose a new standardized technical specification. Anyone can submit a JSR (Java spec request) to add new APIs and services to the Java platform. JSR has become an important standard in the Java world.

In the Java servlet specification (servlet 2.4,jsr-154), a series of core abstract concepts (various objects to be considered during Web application processing) are defined to allow Java programmers to write web programs, including Session,request, Response and so on. When programmers are writing programs, it is convenient and safe to communicate with these objects. JSR223 describes how these Java objects are open to Web pages written in other scripting languages, allowing other languages to access those objects as well. The current specification will be used in PHP, but this concept is independent of the scripting language, meaning that it may be used in future scripting languages other than PHP. In a word, the purpose of JSR223 is to integrate the scripting language onto the Java platform.

  (b) What is Php/java Bridge?

Php/java Bridge contains a PHP module (including Java.so,php_java.dll) and a related back-end program (Javabridge.jar,javabridge.war or MonoBridge.exe), The object system used to connect PHP to the Java or ECMA 335 (CLI, an important subset of the Microsoft. NET framework) virtual machines. It fully implements the JSR 223 specification request, allowing PHP scripts to access applications based on the CLR (such as vb.net,c#) or Java (Java,kawa,jruby). Php/java Bridge communicates with a virtual machine via a local socket with an efficient communication protocol. Each PHP process that processes requests for a multi-process HTTP server will have a corresponding virtual machine process.

Requests from multiple HTTP servers are sent centrally to an application server running Php/java Bridge, or each HTTP server has a Php/java bridge and communicates with a Java EE application Server, the required client class library (EJB Client.jar) will be loaded at run time.

If at least one backend program is running within the ECMA virtual machine, such as Novell Mono or Microsoft. NET, then the ECMA 335-based classes can be accessed or supported by VarArgs, reflection,assembly Loading and other features.

If there is a back-end program running in the Java EE Environment, the session sharing between PHP and JSP can be realized and the cluster and load balance will be realized.

Unlike previous attempts (examples of Ext/java or JSR223), Php/java Bridge no longer uses JNI (Java local interface). PHP objects will come from the HTTP (apache/iis) pool, and JAVA/J2EE objects are allocated from the backend program. To communicate between objects through "communication style (continuation passing style)", see Java_closure () below. Once a PHP object crashes, it does not affect the Java application Server and the servlet engine.

Starting with Php/java Bridge version 3.0, we can also use Java as a running environment for PHP scripts. Java code can allocate and invoke PHP scripts through an external or internal Java pool. The script object can come from an external HTTP pool, or an internal PHP fastcgi pool or directly using PHP CGI. This feature requires Java 6 (expected to be available in the first half of 2006) or an external javax.script package.

http://www.bkjia.com/PHPjc/508503.html www.bkjia.com true http://www.bkjia.com/PHPjc/508503.html techarticle in the Web development market, Java and PHP are popular technologies that are currently being applied. Java's power is beyond doubt, not only in web development, but in every software application, Java is ubiquitous. ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.