|
From: <php...@li...> - 2009-01-17 10:11:21
|
Hi Jost,
in one of your previous responses you wrote:
> cca.invokeA(ccb);
> is equivalent to:
> ((PhpProcedure)Proxy.getInvocationHandler($cca))).invoke($cca, "invokeA", new Object[]{ccb});
> Note the ccb, it has been resolved using the interface IB.
> If you want to invoke it dynamically, too, use the same procedure as above.
So, because of your last statement I passed ccb instead of $ccb.
If I pass $ccb, however, I also get a new object to PHP (again v="4" instead of v="3") which is the $Proxy0 now,
and this one does also not understand method invokeB() (resulting in a java.lang.NoSuchMethodException).
So, what did you mean with "use the same procedure as above"?
(I believe that if I'd resolve ccb using the interface IB - as you did in your example - then it might work.
But this is exactly what I want to avoid:
Java should be agnostic of whatever method I want to invoke in PHP.
The method name should just be passed onto Java and the method be invoked dynamically.
Otherwise I would always have to provide all these methods as Java interfaces before I could call them.
And this would shoot down all the dynamics of PHP here.)
But I think I start to understand where the general contradiction is,
so let me try to draw a sequence diagram in pseudo code in order to explain
what I believe you expect it to behave and what I actually expected.
You probably see it like this:
PHP Java
--------------------------------------------
0 (before here closures have been created already)
1 $c->call($a, $b)
2 call($cca, $ccb)
3 => cca = getInvocationHandler($cca)
4 => cca.invoke( $cca, "invokeA", $ccb )
5 $a.invokeA($b)
6 => $b.invokeB()
7 $ccb.invokeB()
8 $b.invokeB()
9 => echo '::B'
(and that is the same whether I replace $ccb by ccb or not)
Whereas what I'd expect is:
....
5 $a.invokeA($b)
6 => $b.invokeB() // no Java call here!
9 => echo '::B'
To put that into prosa:
I want $a to call invokeB() on $b WITHOUT going back to Java (that's why I expect v="3" to get passed to PHP).
But it seems to me that you expect that invokeB() is always invoked through Java.
Is this correct?
Is this by intention?
Is there any way for me to achieve what I want?
(Because when I know that invokeB() is just to be invoked on $b on the PHP-side why should I take the overhead of going back through Java again?)
Regards Jürgen
-----Ursprüngliche Nachricht-----
Von: php...@li... [mailto:php...@li...]
Gesendet: Montag, 12. Januar 2009 14:38
An: php...@li...
Betreff: Re: [Php-java-bridge-users] How to wrap two PHP objects as javaclosures,and in Java call a method on the first closure with the secondclosure as parameter?
Hi Juergen,
> public void call(Object $cca, Object $ccb) {
> cca.invoke( $cca, "invokeA", new Object[]{ ccb
> So, the PhpProcedure passed to invokeA() is a new one.
yes, obviously. ccb != $ccb. However, why is this a problem?
> (which in turn causes invokeB() to fail...) Did I find a bug here?
What do you mean with causes invokeB() to fail? The test case I've attached in my previous mail runs correctly, invokeB() correctly returned the string ::B, so I don't see the problem.
Regards,
Jost Boekemeier
|