Java with 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 an开发者_开发技巧y way that I can write Java and somehow have it work with the PHP?
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.
You're much better off simply biting the bullet and developing any custom modules in PHP. Even if you have to learn a good bit of PHP, it will be much much cleaner, more maintainable, and probably even quicker.
I feel your pain but seriously learn PHP and write modules in PHP for Drupal. You wil be surprised how well the Drupal API is written and documented.
Java can be used if you have another system running and need the two to communicate. Java can be the middle man to compare user tables, update them, etc.
This CAN also be done in PHP but Java is probably more efficient (don't quote me)
In my situation I run PHP on MySQL and another system is on .NET/SQL Server so I intend to use java to export data and manage a middle table between the two so neither PHP or .NET has to run large queries on their respective databases.
There is a chance ill stick to PHP though to keep the languages at a minimin...still thinking about it.
精彩评论