From: <php...@li...> - 2011-01-17 18:09:05
|
Hi there, A couple of quick questions with regards to coding techniques using PHP, the JavaBridge and third-party classes...I have tried to keep my examples brief, generic and concise! 1) When using Java, an example line of code could be "ExampleClass.TestSomething().Item(this);" which when translated into PHP would be the same as "ExampleClass->TestSomething()->Item(???);" but what should I be using for the Java keyword "this" in PHP script? Obviously the PHP equivalent "$this" is not right for this requirement when needing to refer to the current Java object's context. 2) Is it possible to create user defined callback interfaces to Java in PHP script when using the JavaBridge? Using third-party classes, I'm successfully instantiating a class called "Problem" which has a method called "Optimise". This all runs fine, in effect in a black box, and comes back with a successful result. However, as part of the processing this class does when Optimise is invoked is to call a public Java interface called "IEvaluator" after each iteration of calculations being done under the covers. In Java, IEvaluator has one method called "Evaluate" and is referred to as a user defined callback interface. Now if I wanted to hook into this interface to get results after each iteration and was coding this in Java, I would simply ensure my own class implements IEvaluator and create a public class implementing "Evaluate", which would then get called after each round of calculations. E.g.: public class Example1 implements IEvaluator { public int Evaluate(Evaluator evaluator) { Do something here like print iteration number to the screen; return something like a carry on processing flag; } ...more Java code where Problem.Optimise() is invoked etc; } But how would I in PHP provide the same user defined interface for the same Java class to use? I have looked at loads of examples but they do not seem to point me in the right direction. Is this possible? Thanks in advance for any help. Cheers, Marc The information contained in this E-mail is confidential. It is intended only for the stated addressee(s) and access to it by any other person is unauthorised. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this E-mail. Such unauthorised use may be unlawful. If you have received this E-mail in error, please inform us immediately and delete it and all copies from your system. |
From: <php...@li...> - 2011-01-17 20:42:43
|
Hi, please see our API documentation at: http://php-java-bridge.sourceforge.net/pjb/docs/php-api/java/_JavaProxy.inc.html#functionjava_closure Regards, Jost Bökemeier |
From: <php...@li...> - 2011-01-18 09:27:29
|
Hi, Thanks for that, I'll read through the java_closure documentation. I'm still at a loss with regards to the equivalent "this" Java keyword - what should I be using as I have tried everything and still cannot find the correct reference to pass into the method. Thanks, Marc On 17 Jan 2011, at 20:42, php...@li... wrote: > Hi, > > please see our API documentation at: > > http://php-java-bridge.sourceforge.net/pjb/docs/php-api/java/_JavaProxy.inc.html#functionjava_closure > > Regards, > Jost Bökemeier > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users Mob: +44 797 329 5617 The information contained in this E-mail is confidential. It is intended only for the stated addressee(s) and access to it by any other person is unauthorised. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this E-mail. Such unauthorised use may be unlawful. If you have received this E-mail in error, please inform us immediately and delete it and all copies from your system. |
From: <php...@li...> - 2011-01-18 13:19:43
|
Hi again, I've looked at the java_closure example and others on the web and I'm still having problems - I would be grateful if in addition to the outstanding "this" keyword problem, could you quickly tell me what I am doing wrong with the below simple code: // Simple test method class IEValuator { public function Evaluate(){return 2;} } $tmpIEValuator = new IEValuator; $javaObject = java_closure(new $tmpIEValuator()); The script runs fine with no errors but the third-party Java object "Problem" which looks for a public user defined interface called "IEvaluator" never finds or runs the call-back "Evaluate" method I'm trying to define above - what have I got incorrect? I appreciate you cannot go into coding specifics with third-party classes etc but I think I am not setting up the user defined interface correctly via the JavaBridge/PHP. Thanks again for your help, Marc On 18 Jan 2011, at 09:27, php...@li... wrote: > Hi, > > Thanks for that, I'll read through the java_closure documentation. I'm still at a loss with regards to the equivalent "this" Java keyword - what should I be using as I have tried everything and still cannot find the correct reference to pass into the method. > > Thanks, > > Marc > > On 17 Jan 2011, at 20:42, php...@li... wrote: > >> Hi, >> >> please see our API documentation at: >> >> http://php-java-bridge.sourceforge.net/pjb/docs/php-api/java/_JavaProxy.inc.html#functionjava_closure >> >> Regards, >> Jost Bökemeier >> ------------------------------------------------------------------------------ >> Protect Your Site and Customers from Malware Attacks >> Learn about various malware tactics and how to avoid them. Understand >> malware threats, the impact they can have on your business, and how you >> can protect your company and customers by using code signing. >> http://p.sf.net/sfu/oracle-sfdevnl >> _______________________________________________ >> php-java-bridge-users mailing list >> php...@li... >> https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > > > Mob: +44 797 329 5617 > > The information contained in this E-mail is confidential. It is intended only for the stated addressee(s) and access to it by any other person is unauthorised. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this E-mail. Such unauthorised use may be unlawful. If you have received this E-mail in error, please inform us immediately and delete it and all copies from your system. > > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users Mob: +44 797 329 5617 The information contained in this E-mail is confidential. It is intended only for the stated addressee(s) and access to it by any other person is unauthorised. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this E-mail. Such unauthorised use may be unlawful. If you have received this E-mail in error, please inform us immediately and delete it and all copies from your system. |
From: <php...@li...> - 2011-01-18 18:23:26
|
Hi, in PHP "this" is written as $this. If you want to extend Java classes (rather than implementing interfaces) please see our FAQ entry "How do I extend Java classes" for more information. Regarding your other question; the interface is missing. Please carefully read our "java_closure" API documentation. Regards, Jost Bökemeier |
From: <php...@li...> - 2011-01-18 23:18:43
|
Hi there, Thanks for the reply. Unfortunately, my first question was not very clear - passing $this to the java method, as per my example, will not pass a reference to the current java object as the same "this" keyword does in java itself. Hence, my question was about what to use instead of "this" in my php code when trying to reference the current java object in a call to a java method, as per my example. I understand the usage of $this in pure php code but I think it acts differently to the java keyword of the same name doesn't it, unless I'm mistaken? I have gone carefully through the docs and examples and was still not having any success, hence the follow-up query. I'll keep looking. Thanks, Marc On 18 Jan 2011, at 18:23, php...@li... wrote: > Hi, > > in PHP "this" is written as $this. > > If you want to extend Java classes (rather than implementing interfaces) > please see our FAQ entry "How do I extend Java classes" for more > information. > > Regarding your other question; the interface is missing. Please carefully > read our "java_closure" API documentation. > > Regards, > Jost Bökemeier > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users |
From: <php...@li...> - 2011-01-19 19:23:46
|
Hi, so it is difficult for you to fetch the current object from the current java continuation? get_context()->getThis() might be a useful addition. But I don't think I will add it. You can easily write it yourself. Regards, Jost Bökemeier |