douxue4395 2010-01-06 07:26
浏览 103
已采纳

Java与Drupal-6 / PHP

I really dislike PHP, but am pretty comfortable in Java. I have a stable Drupal installation that has been deployed to an Apache/Linux server. I don't know if the server currently supports Java. (What does it take to do that? I have programming in desktop apps for Java but never online before.)

For developing new modules for my site, is there any way that I can write Java and somehow have it work with the PHP?

  • 写回答

3条回答 默认 最新

  • duanhan5388 2010-01-06 07:52
    关注

    To use Java on a (web) server, you'll probably need:

    • an installed Java VM,
    • a servlet container or a full application server if you'll use some advanced techs like EJBs.

    Theoretically you could run a web application without an installed servlet container, but that needs an embedded servlet container or some hacking, though. Most servlet containers or app servers can be used as frontend web servers, but if you decide to move them one step backwards behind the Apache httpd, then with the mod_jk connector plugin, you'll be able to load balance or proxy requests from the Apache web server to your servlet container (note, not just Tomcat: Glassfish and JBoss can be used as well) and hide the Java container from direct web access and provide an additional layer of security and load handling.

    If somehow you'd like to run PHP and Java together, that is possible with some mild hacking: use Quercus (which is a Java implementation of the PHP language) on a suitable server (I'd prefer Glassfish v3), pack your app as a war file and you'll be able to run most PHP applications on a Java app server (and no, this doesn't mean any kind of sluggishness).

    And, of course, if you push back the original Drupal application from the frontend Apache to a backend Java servlet container, then you'll be able to run Java and PHP apps side by side and the only job left for Apache is to load balance. If you are interested, check the Quercus and Drupal howto.

    One more thing I forgot: if you'd like to create new Drupal plugins/modules in Java, that would only work with Quercus or if the Java and PHP apps are connected via web services or a cross-language framework like Protobuf or Thrift (so the view part could be Drupal plugin written in PHP, and business logic in Java running on a remote server). Note that I'm not an experienced Drupal plugin developer.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?