Compare two ways to call Java objects in PHP _php tutorial

Source: Internet
Author: User
Tags php compiler
The P>java language is powerful, so it can be useful to invoke Java functionality in PHP in many cases. There are two ways to invoke the Java language in PHP, one is to use the Java extension in PHP, and the other is to use the SJOP protocol provided by the MINIJ2EE application server. Let's compare the characteristics of each of these two methods.
Java Module for 1.php
The PHP release contains a Java extension module that can be used to invoke Java objects, such as:
$system =new Java ("Java.lang.System");
Print "Java version=". $system->getproperty ("Java.version"). "
";
?>
The advantage of using this method is that it is convenient to use new Java () to create a Java object, and you can invoke the Java object just like the PHP class. But this approach also has the following obvious drawbacks:
1. Because PHP's Java module chooses the most appropriate Java method based on the PHP data type, it is not possible to invoke Java overloaded functions.
The 2.php Java module will load the JVM (Java Virtual machine) in the current Web server's process, so the overhead of the Web server process is greatly affected by the execution efficiency.
3. In some operating systems and Web server environments, PHP's Java modules will make the Web server process zombie. See http://www.php.net/bugs.php?id=6122.
For these reasons, PHP's Java module has not been applied to the actual software system.
2.MINIJ2EE Application Server SJOP protocol implementation
Before introducing MINIJ2EE Application Server SJOP protocol implementation, let's briefly introduce the MINIJ2EE application server. The MINIJ2EE application server is the first Java EE Application Server product that supports PHP, enabling PHP to be used to develop enterprise application systems. SJOP Full name is the sample Java ORB Protocol (simple Java Object Request Proxy protocol), is a simple and efficient object request proxy protocol. Like what:
$conn =minij2ee_fetch_connection ();
Print "Java version=". Minij2ee_callstatic_javaobj ($conn, "Java.lang.System", "GetProperty", "java.lang.String", " Java.version ").
";
?>
The main purpose of the MINIJ2EE application server implementation of the SJOP protocol is to enable access to EJB Enterprise components in PHP, so MINIJ2EE provides a ejb-php compiler that can compile EJB components into PHP classes, making it easy to invoke EJB components in PHP programs. For example:
Require ("cart.php"); File://Cart.php is the PHP class definition for the cart EJB generated after compiling the cart EJB.
$home =new carthome (); FILE://Create the home interface of the EJB.

http://www.bkjia.com/PHPjc/445193.html www.bkjia.com true http://www.bkjia.com/PHPjc/445193.html techarticle The Pjava language is powerful, so it can be useful to invoke Java functionality in PHP in many cases. There are two ways to call the Java language in PHP, one is to use the Java Extension Module in PHP, ...

  • 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.