Home >Backend Development >PHP Tutorial >Compare two methods of calling Java objects in PHP_PHP Tutorial

Compare two methods of calling Java objects in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-20 11:04:351384browse

P>The Java language is powerful, so calling Java functions in php will be very useful in many cases. There are two ways to call the Java language in php, one is to use the Java extension module in php, and the other is to use the SJOP protocol implementation provided by the minij2ee application server. Let's compare the characteristics of these two methods below.
Java module of 1.php
The PHP release version contains a Java extension module that can be used to call Java objects, for example:
$system=new Java("java. lang.System");
print "Java version=".$system->getProperty("java.version")."
";
?>
Use this method The advantage is that it is more convenient. As long as you use new Java() to create a Java object, you can call the Java object just like the PHP class. However, this method also has the following obvious shortcomings:
1. Since the Java module of php selects the most suitable Java method according to the data type of php, it cannot call Java overloaded functions.
The Java module of 2.php will load the JVM (Java Virtual Machine) in the current Web Server process, so the system overhead is huge and affects the execution efficiency of the Web Server process.
3. In some operating systems and Web Server environments, the Java module of php will freeze the Web Server process. See http://www.php.net/bugs.php?id=6122.
Due to these reasons, PHP’s Java module has never been able to be applied to actual software systems.
2. Minij2ee application server SJOP protocol implementation
Before introducing the minij2ee application server SJOP protocol implementation, let’s briefly introduce the minij2ee application server. The minij2ee application server is the first J2EE application server product that supports PHP, enabling PHP to be used to develop enterprise-level application systems. The full name of SJOP is Sample Java ORB Protocol (Simple Java Object Request Proxy Protocol), which is a simple and efficient object request proxy protocol. For example:
$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 to implement the SJOP protocol is to enable PHP to access EJB enterprise-level components, so minij2ee provides An EJB-PHP compiler can be used to compile EJB components into PHP classes, so that EJB components can be conveniently called in PHP programs, for example:
require("Cart.php"); file://Cart.php is the php class definition of Cart EJB generated after compiling Cart EJB.
$home=new CartHome(); file://Create the Home interface of EJB.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445193.htmlTechArticleThe PJava language is powerful, so it will be very useful to call Java functions in php in many cases. There are two ways to call Java language in php. One is to use the Java extension module in php,...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn