{
// manager script dispatch
BamPhpServiceManager manager = getServiceManager(env);
if (manager != null) {
AbstractFunction function = null;
if (env.getGlobalValue("_quercus_bam_start_service") != null) {
function = env.findFunction("bam_start_service");
}
else if (env.getGlobalValue("_quercus_bam_stop_service") != null) {
function = env.findFunction("bam_stop_service");
}
if (function == null) {
env.setGlobalValue("_quercus_bam_function_return", BooleanValue.FALSE);
return BooleanValue.FALSE;
}
Value address = env.getGlobalValue("_quercus_bam_service_address");
Value ret = function.call(env, address);
env.setGlobalValue("_quercus_bam_function_return", ret);
return BooleanValue.TRUE;
}
// actor script dispatch
Value eventTypeValue = env.getGlobalValue("_quercus_bam_event_type");
if (eventTypeValue == null)
return BooleanValue.FALSE;
BamEventType eventType = (BamEventType) eventTypeValue.toJavaObject();
Value to = env.getGlobalValue("_quercus_bam_to");
Value from = env.getGlobalValue("_quercus_bam_from");
Value value = env.getGlobalValue("_quercus_bam_value");
AbstractFunction function = findFunction(env, eventType.getPrefix(), value);
if (function == null) {
log.fine(L.l("bam handler function not found for {0}", eventType));
return BooleanValue.FALSE;
}
Value functionReturn = BooleanValue.FALSE;
if (eventType.hasId() && eventType.hasError()) {
Value id = env.getGlobalValue("_quercus_bam_id");
Value error = env.getGlobalValue("_quercus_bam_error");
functionReturn = function.call(env, id, to, from, value, error);
}
else if (! eventType.hasId() && eventType.hasError()) {
Value error = env.getGlobalValue("_quercus_bam_error");
functionReturn = function.call(env, to, from, value, error);
}
else if (eventType.hasId() && ! eventType.hasError()) {
Value id = env.getGlobalValue("_quercus_bam_id");
functionReturn = function.call(env, id, to, from, value);
}
else {
functionReturn = function.call(env, to, from, value);
}
env.setGlobalValue("_quercus_bam_function_return", functionReturn);
return functionReturn;