From: <php...@li...> - 2010-09-22 12:08:39
|
Hello, I'm new to php/java bridge and I'm wondering if I could use this fantastic project in a work of mine. The "problem" is the follow: I have to create a Webservices running on a customized-centos to offer an access to some business operation. My goal is to write the webservices in PHP (as I've already an Apache running on my distro) and write the business operations in java (to avoid my code to be read or edited). Business operations would be a collection of classes rappresenting database entities, classes to manipulate them and some other stuff. I could say I want to create a java-layer between php-webservices and database server. Reading at the installation guide, I've found out one could create a "desktop" java client and call it's methods and classes within php. I don't understand if it's my scenario (webservices + persistence-layer) or it's completely different. So, do I need to write something like the follow: - a java-main class like public class Test { public static final String JAVABRIDGE_PORT="8087"; static final php.java.bridge.JavaBridgeRunner runner = php.java.bridge.JavaBridgeRunner.getInstance(JAVABRIDGE_PORT); public static void main(String args[]) throws Exception { //some initializations go here? runner.waitFor(); System.exit(0); } //and then write a contract for php public Model getModel(String modelName).. public boolean someStuff() } public interface Model{ public boolean save(); } -and within php <?php require_once("http://localhost:8087/JavaBridge/java/Java.inc"); $dbLibrary = new java("Test"); $model = $dbLibrary->getModel("myModel"); //does it return a valid class with a valid db connection(if i setted it in the model)? //do some stuff on model $model->save(); //should it work????? ?> ? Is this the way? Thank you very much Giorgio Maria Santini |