Behind the Site »

Zend - The PHP Company

Zend Platform Java Bridge In-Depth

Additional Products:
Zend Core |
Zend Studio |
Zend Guard

Overview

The Zend Platform Java Bridge is the leading performance and reliability solution for businesses that seek to utilize both PHP and Java/J2EE. Based on a unique design that allows for a single Java Virtual Machine (JVM) instantiation and direct calls from PHP, the Java Bridge delivers unprecedented performance and scalability that make true PHP and Java integration a reality.




Leverage the Power of PHP and Java

The Zend Platform PHP/Java Integration Bridge allows companies who have investments in J2EE application servers to take advantage of PHP, the high-productivity language for Web application development. In addition, the Integration Bridge allows companies using PHP to take advantage of J2EE services that are not present in PHP. The Zend Platform PHP/Java Integration Bridge provides the ability for PHP developers to create applications that interact with any Java object.

  • Single JVM Instantiation - Requires only one JVM to be instantiation for all PHP scripts on the given system, rather than a separate instantiation for each PHP script.
  • Direct Calls from PHP - Access Java methods and properties from PHP (all type conversions are handled automatically).
  • Seamless Integration - Java libraries and classes are seamlessly integrated within your PHP application.


PHP/Java Integration Code Example

<?

// EJB configuration for JBoss. Other servers may need other settings.
// Note that CLASSPATH should contain these classes

$envt = array(
"java.naming.factory.initial" =>
"org.jnp.interfaces.NamingContextFactory",
"java.naming.factory.url.pkgs" =>
"org.jboss.naming:org.jnp.interfaces",
"java.naming.provider.url" => " jnp://yourflowers.com:1099"
);
$ctx = new Java("javax.naming.InitialContext", $envt);

// Try to find the object
$obj = $ctx->lookup("YourflowersBean");

// here we find an object - no error handling in this example
$rmi = new Java("javax.rmi.PortableRemoteObject");
$home = $rmi->narrow($obj, new Java("com.yourflowers.StoreHome"));

// $hw is our bean object
$store = $home->create();

// add an order to the bean
$store->place_order($_GET['client_id'], $_GET['item_id']);
print "Order placed. Current shopping cart: ";

// get shopping cart data from the bean
$cart = $store->get_cart($_GET['client_id']);

foreach($cart as $item)

// release the object
$store->remove();

?>

Return to the Features page