tags:

views:

120

answers:

2

G'day,

I have a project where I need to build a "live" java application (server) to hold state about domain objects (it's a private auction system). The java server will be communicating to and from PHP classes that hold the main back-end business functionality. The PHP classes will be stateless.

I need to communicate domain objects up to the java server (from PHP) so their state can be managed over time. Changes to the domain objects need to be saved back to the data store via calls to PHP classes on a web server.

I was thinking of wrapping my PHP classes using a XML-RPC class (e.g. Zend_Xmlrpc_Server) as they will be stateless. If/when the java application needs to write to the data store (by calling the correct PHP class method) it's a matter of using a XML-RPC client library class.

However, I'm not sure how I expose functionality in the java application so it can be reached by PHP method calls. Can anyone tell me the easiest way to do this in java ... do I just write a multi-threaded application and expose a socket? I'm after the right library classes to use to structure the java application with.

Cheers, Paul

+3  A: 

Expose your server-side Java code as a webservice.

There's countless ways to do this in Java but two that spring to mind are the EJB3 WS Annotations and Apache Axis.

As an aside, whichever technology you choose make sure you see it as a transport and keep the actual processing logic separate from it.

Nick Holt
I second this approach. You don't want to tightly couple these 2 parts of the system and a web services approach (or message-based, REST, ... - the list is endless) allows you to have a clear contract between these 2 parts. Apache also have CXF as an alternative to Axis.
hbunny
Thanks, but my back-end java application needs to store state - so needs to be running in memory at all times. Are these approaches compatible with that?Cheers, Paul.
Paul Hanssen
Like I said with the transport concept, make sure to keep that separate and then what you're left with is a Java server that will certainly allow you to maintain state one way or another the most robust and straight forward way being to store it in a database.
Nick Holt
@stevendick: +1 for messaging or REST, so much easier than SOAP WS.
Nick Holt
A: 

Have you already experiment the PHP Java Bridge tool ?

mere-teresa
Thanks, I'll have a look.
Paul Hanssen