|
From: <php...@li...> - 2009-09-24 09:53:39
|
Hi,
> This seems to work.
Not really.
If you want to catch unchecked exceptions, you need php/java bridge version
5.4.4.2 and set the JAVA_PREFER_VALUES option.
We will add a parameter to java_begin_document()/java_end_document() in
version 5.5 so that execution of the compiled document stops after the first
exception.
Regards,
Jost Boekemeier
On Sep 24, 2009 12:00 AM, <php...@li...>
wrote:
> Would it be feasible to create a generic callback interface in Java > and
then use java_closure() ...
Sorry to followup to my own post here, but I tried this out and it does
work. The code I have on the Java side is roughly equivalent to the
following:
public static void runInTransaction(Callback callback) throws
CallbackException {
SessionFactory factory = getSessionFactory();
try {
factory.getCurrentSession().beginTransaction();
callback.execute();
factory.getCurrentSession().getTransaction().commit();
} catch (RuntimeException e) {
factory.getCurrentSession().getTransaction().rollback();
throw new CallbackException(e);
}
}
>From the PHP side:
class MyCallback {
function execute() {
//arbitrary code
}
}
$callback = java_closure(new MyCallback(), null, new Java("Callback"));
try {
java(...)->runInTransaction($callback);
} catch (JavaException $ex) {
//handle exception
}
This seems to work. Does this sidestep the exception handling issue? Does
it significantly impact performance versus ensuring that all methods in the
arbitrary code declare all exceptions that they throw?
Thanks in advance...
Michael
------------------------------------------------------------------------------
Come build with us!...
|