--- Marc Richards <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am looking for any info or documentation on using PHP in a servlet
> environment. I read what I could find on php.net, and found a couple things
> using google, but not enough to answer my questions. If someone could tell
> me where to look that would be great. I am very interested in seing PHP
> more tightly integrated with J2EE as I think that it would add the
> reliabilty and scalability of the J2EE platform to the ease of use of PHP,
> and allow a smooth transition for the existing PHP user base, who need to do
> things with Java.
>
> These are the type of questions I have right now:
>
> 1) Is this a pure Java version of PHP?
No. And why would there be ;)
> 2) What functionality is available? (only core functions? Some extention
> libraries)
There are 2 things you can do with ext/java
1) create instances of java objects thru the php's java class, You should have
access of all the methods available for that object
ex.
$java = new Java("java.util.Hashtable");
$java->put("Key", "Value");
echo $java->toString();
2) php will run as a servlet engine, meaning you can run php scripts inside
Tomcat. This is done all thru native methods.
> 3) How does it all work? (pass thru mechanism? are pages compiled as
> classes?)
Pages are not compiled as classes they still exists as php scripts.
> 4) Does this make it eiasier to access Java servlets or EJBs? Does it
> increse performance?
Well not sure exactly what you mean by accessing java servlets, You can
"access" a java servlet by simply
file("http://someserver.com/servlet/SomeJava.jsp?param=go"); That would make
the servelet execute but I might not know what you mean by access. I guess if
you wanted to you could use the Java() class to create an instance of a servlet
class and invoke its methods directly.
Accessing a EJB from a php script should be fine, (this is purely theory never
tried it or even fully thought it thru). If you take the steps that you would
to create a refrence of an EJB from java and replicate it using ext/java it
should work.
Here is a quick example from OpenEJB HelloWorld example
http://openejb.sourceforge.net/hello-world.html
<?
$p = new Java("java.utils.Properties");
//The JNDI properties you set depend
//on which server you are using.
$p->put("java.naming.factory.initial", "org.openejb.client.JNDIContext");
$p->put("java.naming.provide.url", "127.0.0.1:4201");
$p->put("java.naming.security.principal", "myuser");
$p->put("java.naming.security.credentials", "mypass");
//Now use those properties to create
//a JNDI InitialContext with the server.
$ctx = new Java("javax.naming.InitialContext", $p );
//Lookup the bean using it's deployment id
$obj = $ctx->lookup("/Hello");
//Be good and use RMI remote object narrowing
//as required by the EJB specification.
//********** This may not work with ext/java extension ***************
$pro = new Java("javax.rmi.PortableRemoteObject");
$helloHome = new Java("HelloHome");
$ejbHome = $pro->narrow( $obj, $helloHome->class);
//********** This may not work with ext/java extension ***************
//Use the HelloHome to create a HelloObject
$ejbObject = $ejbHome->create();
//The part we've all been wainting for...
$message = $ejbObject->sayHello();
//A drum roll please.
echo $message;
?>
So except for the static access to "class" from helloHome It should work.
Maybe if I get borred some time i'll try it.
> 5) Who is responsible for development of this extension?
Sam Ruby was the orig developer. I've played with it. I don't think anyone has
done any new development in awhile.
> 6) When do you expect a non experimental version will be available
When more intrest becomes of it and someone wants to claim any new
development.
- Brad
__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php