开发者

How do I add a Java backend to an existing PHP site without adding a tomcat server for Java Bridge?

Currently we're using PHP for our websites. Now we're thinking about writing the backend in Java, because of the type safety of the language, and the availability of all kind of tools for Java. I've been reading about Java Bridge and now I'm wondering how to set this up.

We're using PHP already through Apache. I read that to use Java Bridge I need to install Tomcat as well. That means I have two servers (Apache and Tomcat), and I need to add security to the backend, because it is 开发者_如何学Goopen to the whole wide world suddenly... Am I missing something? Is there another way to make the PHP-Java connection without an additional server? How is this usually done?

Any directions or links on how to to do this or any best practices on how to set it up are greatly appreciated. I didn't find the official Java Bridge site very clear. Thanks!


I am currently testing the use of the Zend Java bridge. Two weeks ago, I did test the PHP/Java bridge open source solution. This one does require that you put your java classes into a war deployed in a web server (I did use Tomcat 6). The Zend solution does not require a web server. If you put your business logic in plain java classes, you simply wrap your classes in one (or several) jars. You then start the Zend java bridge daemon into a JVM, passing to the -classpath the Zend Java bridge jar aswell as your own jar's

Ex from a dos windows:

C:\Development\ToolsPHP\ZendServer\bin>java -classpath javamw.jar;mybusinesslogic.jar -Dzend.javamw.port=10002 com.zend.javamw.JavaServer.

Here, I had to specify a port since the 10001 port, which is the default for the bridge, was already in use (use netstat -a to detect port conflicts). Note that the Zend solution only works if your php script is executed on the Apache server managed by the Zend server (community or commercial edition) and that the Zend Java bridge service is running, with its port set to 10002 with the Zend server admin console.

To implement my business logic, I plan using simple Java pojo's, Spring, JPA and Hibernate.


You don't need tomcat. As per instructions you can start Java as

java -Djava.ext.dirs=lib -jar JavaBridge.jar HTTP_LOCAL:8080 2 logfile &

lib contains the Java libraries you want to use.

Peter


Ok, I am not expert on this. Basically, not even one-eyed. But afaik your options are pretty much the following

For the JavaBridge you have to have a TomCat server.
There is also a JavaBridge in Zend Server CE.
And there is Quercus

Well, and the old PHP4 extension


You can look at Gearman. its not exactly, what you are looking for, but it allows Clients and Workers in different languages. As a nice side effect it allows parallel processing with background jobs ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜